From aadeadede11fabacebc5378ac0548794f5f49a74 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期四, 11 十二月 2025 13:51:57 +0800
Subject: [PATCH] 1.实现报告的增加和删除;
---
SourceCode/Bond/Servo/CPageReport.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 58 insertions(+), 1 deletions(-)
diff --git a/SourceCode/Bond/Servo/CPageReport.cpp b/SourceCode/Bond/Servo/CPageReport.cpp
index b537d06..4e3fd2e 100644
--- a/SourceCode/Bond/Servo/CPageReport.cpp
+++ b/SourceCode/Bond/Servo/CPageReport.cpp
@@ -5,6 +5,8 @@
#include "Servo.h"
#include "CPageReport.h"
#include "afxdialogex.h"
+#include "CReportEditDlg.h"
+#include <algorithm>
// CPageReport 瀵硅瘽妗�
@@ -152,7 +154,32 @@
void CPageReport::OnClickedBtn(const char* btnName)
{
ASSERT(btnName);
- if (_strcmpi(btnName, "鍒犻櫎") == 0) {
+ if (_strcmpi(btnName, "鏂板") == 0) {
+ int rc = UX_CanExecute(L"addReports");
+ if (rc != 1) {
+ AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+ return;
+ }
+
+ unsigned int newId = theApp.m_model.m_hsmsPassive.getMaxReportId() + 1;
+ std::vector<unsigned int> initVids;
+ CReportEditDlg dlg(_T("鏂板鎶ュ憡"), static_cast<int>(newId), initVids, this);
+ if (dlg.DoModal() != IDOK) return;
+ const auto& vids = dlg.GetSelectedVids();
+
+ int ret = theApp.m_model.m_hsmsPassive.addReport(static_cast<int>(newId), vids);
+ if (ret == 0) {
+ UX_RecordAction(L"addReports");
+ m_listCtrl.DeleteAllItems();
+ loadReports();
+ if (CButton* pDel = GetBtnByName("鍒犻櫎")) pDel->EnableWindow(FALSE);
+ if (CButton* pEdit = GetBtnByName("缂栬緫")) pEdit->EnableWindow(FALSE);
+ }
+ else {
+ AfxMessageBox(_T("鏂板鎶ュ憡澶辫触锛堝彲鑳絀D閲嶅鎴栨枃浠跺啓鍏ュけ璐ワ級"));
+ }
+ }
+ else if (_strcmpi(btnName, "鍒犻櫎") == 0) {
POSITION pos = m_listCtrl.GetFirstSelectedItemPosition();
if (pos == nullptr) return;
int nItem = m_listCtrl.GetNextSelectedItem(pos);
@@ -177,4 +204,34 @@
AfxMessageBox(_T("鍒犻櫎鎶ュ憡澶辫触"));
}
}
+ else if (_strcmpi(btnName, "缂栬緫") == 0) {
+ POSITION pos = m_listCtrl.GetFirstSelectedItemPosition();
+ if (pos == nullptr) return;
+ int nItem = m_listCtrl.GetNextSelectedItem(pos);
+ auto pRpt = reinterpret_cast<SERVO::CReport*>(m_listCtrl.GetItemData(nItem));
+ if (pRpt == nullptr) return;
+
+ int rc = UX_CanExecute(L"editReports");
+ if (rc != 1) {
+ AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+ return;
+ }
+
+ std::vector<unsigned int> vidsExisting = pRpt->getVids();
+ CReportEditDlg dlg(_T("缂栬緫鎶ュ憡"), (int)pRpt->getReportId(), vidsExisting, this);
+ if (dlg.DoModal() != IDOK) return;
+ const auto& vids = dlg.GetSelectedVids();
+
+ int ret = theApp.m_model.m_hsmsPassive.updateReport((int)pRpt->getReportId(), vids);
+ if (ret == 0) {
+ UX_RecordAction(L"editReports");
+ m_listCtrl.DeleteAllItems();
+ loadReports();
+ if (CButton* pDel = GetBtnByName("鍒犻櫎")) pDel->EnableWindow(FALSE);
+ if (CButton* pEdit = GetBtnByName("缂栬緫")) pEdit->EnableWindow(FALSE);
+ }
+ else {
+ AfxMessageBox(_T("缂栬緫鎶ュ憡澶辫触锛堝彲鑳芥枃浠跺啓鍏ュけ璐ワ級"));
+ }
+ }
}
--
Gitblit v1.9.3