// DlgCreatAccount.cpp : 实现文件 // #include "stdafx.h" #include "LaiPuLaser.h" #include "DlgCreatAccount.h" #include "afxdialogex.h" #include "AuthorityMgr.h" #include "MsgBox.h" // CDlgCreatAccount 对话框 IMPLEMENT_DYNAMIC(CDlgCreatAccount, CDialogEx) CDlgCreatAccount::CDlgCreatAccount(CWnd* pParent /*=NULL*/) : CDialogEx(CDlgCreatAccount::IDD, pParent) { } CDlgCreatAccount::~CDlgCreatAccount() { } void CDlgCreatAccount::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Text(pDX, IDC_NAME, m_Name); DDX_Text(pDX, IDC_PASSWORD, m_PassWord1); DDX_Text(pDX, IDC_PASSWORD2, m_PassWord2); DDX_Control(pDX, IDC_AUTHORITY_COMB, m_AuthorityComb); } BEGIN_MESSAGE_MAP(CDlgCreatAccount, CDialogEx) ON_BN_CLICKED(IDOK, &CDlgCreatAccount::OnBnClickedOk) END_MESSAGE_MAP() // CDlgCreatAccount 消息处理程序 BOOL CDlgCreatAccount::OnInitDialog() { CDialogEx::OnInitDialog(); IniAuthorityComb(); UpdateData(FALSE); return TRUE; } void CDlgCreatAccount::IniAuthorityComb() { AUTHORITY_TYPE CurAuthority = gAuthorityMgr->GetCurAuthority(); if(CurAuthority== _NO_LOGIN || CurAuthority== _USER) return; int idx = 0; m_AuthorityComb.InsertString(idx++,gAuthorityMgr->GetAccountName(_USER)); m_AuthorityComb.InsertString(idx++,gAuthorityMgr->GetAccountName(_ADMIN)); if(CurAuthority== _FACTORY) { m_AuthorityComb.InsertString(idx++,gAuthorityMgr->GetAccountName(_FACTORY)); } m_AuthorityComb.SetCurSel(_USER); } void CDlgCreatAccount::OnBnClickedOk() { AUTHORITY_TYPE CurAuthority = gAuthorityMgr->GetCurAuthority(); if(CurAuthority== _USER) { CMsgBox MsgBox; MsgBox.Show("当前权限不能创建账号!"); return; } UpdateData(TRUE); if(m_Name=="") { CMsgBox MsgBox; MsgBox.Show("用户名不能为空!"); return; } if(m_PassWord1=="") { CMsgBox MsgBox; MsgBox.Show("密码不能为空!"); return; } if(m_PassWord1 != m_PassWord2) { CMsgBox MsgBox; MsgBox.Show("确认密码不一致!"); return; } CAccount Account; Account.m_Name = m_Name; Account.m_PassWord = m_PassWord1; Account.m_Authority = (AUTHORITY_TYPE)(m_AuthorityComb.GetCurSel()+1);//权限 gAuthorityMgr->AddAccount(Account); CDialogEx::OnOK(); }