From 0d2da4a2507a5a8d34bf7f736727917d791df0d2 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期三, 14 五月 2025 14:48:31 +0800
Subject: [PATCH] 1. 添加数据库事务提交,减少频繁执行 SQL 写操作

---
 SourceCode/Bond/Servo/PageRecipe.cpp |   35 ++++++++++++++++++-----------------
 1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/SourceCode/Bond/Servo/PageRecipe.cpp b/SourceCode/Bond/Servo/PageRecipe.cpp
index a741eea..85f369a 100644
--- a/SourceCode/Bond/Servo/PageRecipe.cpp
+++ b/SourceCode/Bond/Servo/PageRecipe.cpp
@@ -32,15 +32,21 @@
 	pListCtrl->DeleteAllItems();
 
 	// 閬嶅巻鏁版嵁骞舵彃鍏ュ埌CListCtrl涓�
-	int nIndex = 0;
-	for (const auto& row : vecData) {
-		int nNewItem = pListCtrl->InsertItem(nIndex, _T(""));
+	for (int i = 0; i < static_cast<int>(vecData.size()); ++i) {
+		// 鎻掑叆琛�
+		pListCtrl->InsertItem(i, _T(""));
 
-		CString str;
-		str.Format(_T("%d"), nIndex++);
-		pListCtrl->SetItemText(nNewItem, 1, str); // Recipe No
-		str.Format(_T("%s"), row.c_str());
-		pListCtrl->SetItemText(nNewItem, 2, str); // PPID
+		// 璁剧疆 Recipe No锛堢1鍒楋級
+		CString strRecipeNo;
+		strRecipeNo.Format(_T("%d"), i);
+		pListCtrl->SetItemText(i, 1, strRecipeNo);
+
+		// 璁剧疆 PPID锛堢2鍒楋級
+		CString strPPID = CA2T(vecData[i].c_str());
+		if (strPPID.CompareNoCase(_T("NULL")) == 0) {
+			strPPID.Empty();
+		}
+		pListCtrl->SetItemText(i, 2, strPPID);
 	}
 
 	// 鑾峰彇鍒楁暟
@@ -147,18 +153,13 @@
 void CPageRecipe::OnBnClickedButtonSave()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	std::vector<std::string> vecPPID;
 	int nCount = m_listPPID.GetItemCount();
 	for (int i = 0; i < nCount; ++i) {
-		std::string strPPID = CT2A(m_listPPID.GetItemText(i, 2));
-		SECSRuntimeManager::getInstance().updatePPIDForRecipe(i, strPPID);
+		CString str = m_listPPID.GetItemText(i, 2);
+		vecPPID.emplace_back(CT2A(str));
 	}
-
-	//if (!SECSRuntimeManager::getInstance().saveAllPPID(vecData)) {
-	//	AfxMessageBox(_T("淇濆瓨澶辫触"));
-	//}
-	//else {
-	//	AfxMessageBox(_T("淇濆瓨鎴愬姛"));
-	//}
+	SECSRuntimeManager::getInstance().setAllPPID(vecPPID);
 }
 
 void CPageRecipe::OnBnClickedButtonRefresh()

--
Gitblit v1.9.3