| SourceCode/Bond/BondEq/BondEq.rc | 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/BondEq/BondEq.vcxproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/BondEq/BondEqDlg.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/BondEq/BondEqDlg.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/BondEq/Resource.h | 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/BondEq/UserManagerDlg.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/x64/Debug/Config/BondEq.db | 补丁 | 查看 | 原始文档 | blame | 历史 |
SourceCode/Bond/BondEq/BondEq.rcBinary files differ
SourceCode/Bond/BondEq/BondEq.vcxproj
@@ -223,6 +223,7 @@ <ClInclude Include="HmTab.h" /> <ClInclude Include="HmVerticalTab.h" /> <ClInclude Include="HorizontalLine.h" /> <ClInclude Include="InputDialog.h" /> <ClInclude Include="Intent.h" /> <ClInclude Include="LoadMonitor.h" /> <ClInclude Include="Log.h" /> @@ -279,6 +280,7 @@ <ClCompile Include="HmTab.cpp" /> <ClCompile Include="HmVerticalTab.cpp" /> <ClCompile Include="HorizontalLine.cpp" /> <ClCompile Include="InputDialog.cpp" /> <ClCompile Include="Intent.cpp" /> <ClCompile Include="LoadMonitor.cpp" /> <ClCompile Include="Log.cpp" /> SourceCode/Bond/BondEq/BondEqDlg.cpp
@@ -11,6 +11,8 @@ #include "SettingsDlg.h" #include "UserManager.h" #include "LoginDlg.h" #include "ChangePasswordDlg.h" #include "InputDialog.h" // test #include "AxisSettingsDlg.h" @@ -224,10 +226,8 @@ InitRxWindows(); // 登录管理 if (userManager.isLoggedIn()) { m_pTopToolbar->SetOperatorBtnText(userManager.getCurrentUser().c_str()); } // 更新登录状态 UpdateLoginStatus(); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE @@ -512,6 +512,22 @@ LRESULT CBondEqDlg::OnToolbarBtnClicked(WPARAM wParam, LPARAM lParam) { int id = (int)lParam; if (id == IDC_BUTTON_RUN || id == IDC_BUTTON_STOP || id == IDC_BUTTON_SETTINGS) { CInputDialog inputDialog(_T("验证用户"), _T("请输入用户密码:")); if (inputDialog.DoModal() != IDOK) { AfxMessageBox(_T("取消验证!")); return 0; } CString inputText = inputDialog.GetInputText(); std::string strPass = UserManager::getInstance().getCurrentPass(); if (inputText.Compare(strPass.c_str()) != 0) { AfxMessageBox(_T("密码错误!")); return 0; } } if (id == IDC_BUTTON_RUN) { m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(FALSE); m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(TRUE); @@ -528,24 +544,36 @@ int menuId = (int)wParam; UserManager& userManager = UserManager::getInstance(); if (menuId == 0) { ShowLoginDlg(); CLoginDlg loginDlg; loginDlg.DoModal(); UpdateLoginStatus(); } else if (1 == menuId) { CChangePasswordDlg changePasswordDlg; if (changePasswordDlg.DoModal() == IDOK) { } } else if (2 == menuId) { CUserManagerDlg dlg; dlg.DoModal(); } else if (3 == menuId) { int ret = AfxMessageBox(_T("是否切换用户?切换用户会退出当前账号!"), MB_OK | MB_ICONEXCLAMATION); if (ret != MB_OK) { return 0; } if (userManager.isLoggedIn()) { userManager.logout(); } ShowLoginDlg(); CLoginDlg loginDlg; loginDlg.DoModal(); UpdateLoginStatus(); } else if (2 == menuId) { // test CUserManagerDlg dlg; dlg.DoModal(); //if (userManager.isLoggedIn()) { // userManager.logout(); // m_pTopToolbar->SetOperatorBtnText(_T("未登录")); //} else { userManager.logout(); UpdateLoginStatus(); } } @@ -618,17 +646,33 @@ return pDlg; } void CBondEqDlg::ShowLoginDlg() void CBondEqDlg::UpdateLoginStatus() { CLoginDlg loginDlg; loginDlg.DoModal(); HMENU hMenu = m_pTopToolbar->GetOperatorMenu(); UserManager& userManager = UserManager::getInstance(); if (userManager.isLoggedIn()) { ::EnableMenuItem(hMenu, ID_OPEATOR_LOGIN, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); ::EnableMenuItem(hMenu, ID_OPERATOR_CHANGE_PASSWORD, MF_BYCOMMAND | MF_ENABLED); ::EnableMenuItem(hMenu, ID_OPEATOR_SWITCH, MF_BYCOMMAND | MF_ENABLED); ::EnableMenuItem(hMenu, ID_OPERATOR_LOGOUT, MF_BYCOMMAND | MF_ENABLED); if (userManager.getCurrentUserRole() == UserRole::SuperAdmin) { ::EnableMenuItem(hMenu, ID_OPEATOR_USER_MANAGER, MF_BYCOMMAND | MF_ENABLED); } else { ::EnableMenuItem(hMenu, ID_OPEATOR_USER_MANAGER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } m_pTopToolbar->SetOperatorBtnText(userManager.getCurrentUser().c_str()); } else { ::EnableMenuItem(hMenu, ID_OPEATOR_LOGIN, MF_BYCOMMAND | MF_ENABLED); ::EnableMenuItem(hMenu, ID_OPERATOR_CHANGE_PASSWORD, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); ::EnableMenuItem(hMenu, ID_OPEATOR_USER_MANAGER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); ::EnableMenuItem(hMenu, ID_OPEATOR_SWITCH, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); ::EnableMenuItem(hMenu, ID_OPERATOR_LOGOUT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); m_pTopToolbar->SetOperatorBtnText(_T("未登录")); } } SourceCode/Bond/BondEq/BondEqDlg.h
@@ -24,7 +24,7 @@ void CloseView(CBaseView* pView); CHomeDialog* CreateHomeDlg(); CBaseView* CreateRemoteEqView(BEQ::IRemoteEquipment* pEquipment); void ShowLoginDlg(); void UpdateLoginStatus(); private: COLORREF m_crBkgnd; SourceCode/Bond/BondEq/Resource.hBinary files differ
SourceCode/Bond/BondEq/UserManagerDlg.cpp
@@ -5,9 +5,12 @@ #include "BondEq.h" #include "afxdialogex.h" #include "UserManagerDlg.h" #include "InputDialog.h" #include "UserManager.h" #include "NewCellTypes/GridCellCombo.h" #include "NewCellTypes/GridCellNumeric.h" #include <set> // CUserManagerDlg 对话框 @@ -190,6 +193,22 @@ return; } CInputDialog inputDialog(_T("添加用户"), _T("请输入用户名:")); if (inputDialog.DoModal() != IDOK) { return; } CString inputText = inputDialog.GetInputText(); if (inputText.IsEmpty()) { AfxMessageBox(_T("用户名不能为空!"), MB_OK | MB_ICONEXCLAMATION); return; } if (IsUsernameDuplicate(inputText)) { AfxMessageBox(_T("用户名重复!"), MB_OK | MB_ICONEXCLAMATION); return; } int nRowCount = pGridCtrl->GetRowCount(); pGridCtrl->SetRowCount(nRowCount + 1); int newRowIndex = nRowCount; @@ -197,8 +216,7 @@ CString strText; strText.Format(_T("%d"), newRowIndex); pGridCtrl->SetItemText(newRowIndex, 0, strText); strText.Format(_T("User%d"), newRowIndex); pGridCtrl->SetItemText(newRowIndex, 1, strText); pGridCtrl->SetItemText(newRowIndex, 1, inputText); pGridCtrl->SetItemText(newRowIndex, 2, _T("123456")); pGridCtrl->SetItemText(newRowIndex, 3, _T("操作员")); pGridCtrl->SetItemText(newRowIndex, 4, _T("30")); @@ -540,11 +558,27 @@ { // TODO: 在此添加控件通知处理程序代码 std::vector<std::vector<std::string>> vecData; std::set<std::string> usernameSet; // 用于存储用户名,检查是否重复 for (int i = 1; i < m_gridUserManager.GetRowCount(); ++i) { std::vector<std::string> rowData; CString cellText = m_gridUserManager.GetItemText(i, 1); std::string username = CT2A(cellText.GetString()); if (usernameSet.find(username) != usernameSet.end()) { CString message; message.Format(_T("用户名 [%s] 重复,请修改后保存!"), cellText); AfxMessageBox(message, MB_ICONEXCLAMATION); return; } usernameSet.insert(username); for (int j = 1; j < m_gridUserManager.GetColumnCount() - 1; ++j) { CString cellText = m_gridUserManager.GetItemText(i, j); std::string cellString = CT2A(cellText.GetString()); // 第4列是权限,转换为数字字符串 if (j == 3) { if (cellText == _T("管理员")) cellString = "0"; SourceCode/Bond/x64/Debug/Config/BondEq.dbBinary files differ