You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
2.9 KiB
C++
112 lines
2.9 KiB
C++
|
|
#include "stdafx.h"
|
|
#include "LaiPuLaser.h"
|
|
#include "DlgAuthorityAccount.h"
|
|
#include "afxdialogex.h"
|
|
#include "MsgBox.h"
|
|
#include "AuthorityMgr.h"
|
|
#include "DlgAuthorityCreatAccount.h"
|
|
#include "DlgAuthorityPar.h"
|
|
|
|
IMPLEMENT_DYNAMIC(CDlgAuthorityAccount, CDialogEx)
|
|
CDlgAuthorityAccount::CDlgAuthorityAccount(CWnd* pParent /*=NULL*/)
|
|
: CDialogEx(CDlgAuthorityAccount::IDD, pParent)
|
|
{
|
|
m_CurSelIdx = -1;//当前选中索引
|
|
}
|
|
CDlgAuthorityAccount::~CDlgAuthorityAccount()
|
|
{
|
|
}
|
|
void CDlgAuthorityAccount::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialogEx::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_USER_LIST, m_UserList);
|
|
}
|
|
BEGIN_MESSAGE_MAP(CDlgAuthorityAccount, CDialogEx)
|
|
|
|
ON_NOTIFY(NM_CLICK, IDC_USER_LIST, &CDlgAuthorityAccount::OnNMClickUserList)
|
|
ON_BN_CLICKED(IDC_DEL_SEL, &CDlgAuthorityAccount::OnBnClickedDelSel)
|
|
ON_BN_CLICKED(IDC_CREAT, &CDlgAuthorityAccount::OnBnClickedCreatAccount)
|
|
ON_BN_CLICKED(IDC_OPEN_AUTH_PAR_DLG, &CDlgAuthorityAccount::OnBnClickedOpenAuthorityDlg)
|
|
END_MESSAGE_MAP()
|
|
|
|
//截获一部分键盘输入
|
|
BOOL CDlgAuthorityAccount::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
if(pMsg->message==WM_KEYDOWN)
|
|
{
|
|
char c = pMsg->wParam;
|
|
if(c==VK_RETURN || c==VK_ESCAPE)
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
return CDialogEx::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
BOOL CDlgAuthorityAccount::OnInitDialog()
|
|
{
|
|
CDialogEx::OnInitDialog();
|
|
IniUserList();
|
|
UpdateUserList();
|
|
UpdateData(FALSE);
|
|
return TRUE;
|
|
}
|
|
void CDlgAuthorityAccount::IniUserList()
|
|
{
|
|
//设置风格
|
|
m_UserList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
|
|
//设置列
|
|
int idx = 0;
|
|
m_UserList.InsertColumn(idx,"类型",LVCFMT_CENTER,120,-1);
|
|
idx++;
|
|
m_UserList.InsertColumn(idx,"用户名",LVCFMT_CENTER,150,-1);
|
|
}
|
|
void CDlgAuthorityAccount::UpdateUserList()
|
|
{
|
|
m_UserList.DeleteAllItems();
|
|
gAuthorityMgr->InsertToList(m_UserList);
|
|
UpdateData(FALSE);
|
|
}
|
|
//获取list 当前选择的行号
|
|
int CDlgAuthorityAccount::GetCurListIdx(CListCtrl &list)
|
|
{
|
|
POSITION pos = list.GetFirstSelectedItemPosition();
|
|
if (pos == NULL)
|
|
{
|
|
return -1;
|
|
}
|
|
else
|
|
{
|
|
while (pos)
|
|
{
|
|
int nItem = list.GetNextSelectedItem(pos);
|
|
return nItem;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
void CDlgAuthorityAccount::OnNMClickUserList(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
*pResult = 0;
|
|
m_CurSelIdx=GetCurListIdx(m_UserList);
|
|
}
|
|
void CDlgAuthorityAccount::OnBnClickedDelSel()
|
|
{
|
|
gAuthorityMgr->DelUser(m_CurSelIdx);
|
|
UpdateUserList();
|
|
}
|
|
void CDlgAuthorityAccount::OnBnClickedCreatAccount()
|
|
{
|
|
CDlgAuthorityCreatAccount dlg;
|
|
dlg.DoModal();
|
|
UpdateUserList();
|
|
}
|
|
void CDlgAuthorityAccount::OnBnClickedOpenAuthorityDlg()
|
|
{
|
|
if(!gAuthorityMgr->CheckAuthorityByName("AUTHORITY_AuthorityEdit",true))
|
|
return;
|
|
CDlgAuthorityPar dlg;
|
|
dlg.DoModal();
|
|
} |