From 33f080ddc32f3545b685b2e0a7a5df3c35894270 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期四, 11 十二月 2025 14:43:40 +0800
Subject: [PATCH] 1.Event删除功能的实现;

---
 SourceCode/Bond/Servo/CPageCollectionEvent.cpp |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/Servo/CPageCollectionEvent.cpp b/SourceCode/Bond/Servo/CPageCollectionEvent.cpp
index b7d3322..d28ac2c 100644
--- a/SourceCode/Bond/Servo/CPageCollectionEvent.cpp
+++ b/SourceCode/Bond/Servo/CPageCollectionEvent.cpp
@@ -32,6 +32,7 @@
 	ON_WM_CTLCOLOR()
 	ON_WM_DESTROY()
 	ON_WM_SIZE()
+	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, &CPageCollectionEvent::OnLvnItemchangedList1)
 END_MESSAGE_MAP()
 
 
@@ -123,3 +124,55 @@
 		m_listCtrl.SetItemText(index, 4, item->getReportIdsText().c_str());
 	}
 }
+
+void CPageCollectionEvent::OnCreateBtns()
+{
+	const int BTN_W = 80;
+	const int BTN_H = 28;
+	CreateBtn(_T("鏂板"), BTN_W, BTN_H, 3001);
+	CreateBtn(_T("鍒犻櫎"), BTN_W, BTN_H, 3002)->EnableWindow(FALSE);
+	CreateBtn(_T("缂栬緫"), BTN_W, BTN_H, 3003)->EnableWindow(FALSE);
+}
+
+void CPageCollectionEvent::OnLvnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult)
+{
+	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+	int nSelCount = m_listCtrl.GetSelectedCount();
+	if (CButton* pDel = GetBtnByName("鍒犻櫎")) {
+		pDel->EnableWindow(nSelCount > 0);
+	}
+	if (CButton* pEdit = GetBtnByName("缂栬緫")) {
+		pEdit->EnableWindow(nSelCount > 0);
+	}
+	*pResult = 0;
+}
+
+void CPageCollectionEvent::OnClickedBtn(const char* btnName)
+{
+	ASSERT(btnName);
+	if (_strcmpi(btnName, "鍒犻櫎") == 0) {
+		POSITION pos = m_listCtrl.GetFirstSelectedItemPosition();
+		if (pos == nullptr) return;
+		int nItem = m_listCtrl.GetNextSelectedItem(pos);
+		auto pEvent = reinterpret_cast<SERVO::CCollectionEvent*>(m_listCtrl.GetItemData(nItem));
+		if (pEvent == nullptr) return;
+
+		int rc = UX_CanExecute(L"delEvents");
+		if (rc != 1) {
+			AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+			return;
+		}
+
+		int ret = theApp.m_model.m_hsmsPassive.deleteCollectionEvent((unsigned short)pEvent->getEventId());
+		if (ret == 0) {
+			UX_RecordAction(L"delEvents");
+			m_listCtrl.DeleteAllItems();
+			loadCollectionEvents();
+			if (CButton* pDel = GetBtnByName("鍒犻櫎")) pDel->EnableWindow(FALSE);
+			if (CButton* pEdit = GetBtnByName("缂栬緫")) pEdit->EnableWindow(FALSE);
+		}
+		else {
+			AfxMessageBox(_T("鍒犻櫎浜嬩欢澶辫触"));
+		}
+	}
+}

--
Gitblit v1.9.3