// DlgUserManager.cpp : 实现文件 // #include "stdafx.h" #include "IDE.h" #include "DlgUserGroupAlloc.h" #include "StringOperation.h" #include ".\dlgusergroupalloc.h" // CDlgUserGroupAlloc 对话框 IMPLEMENT_DYNAMIC(CDlgUserGroupAlloc, CDialog) CDlgUserGroupAlloc::CDlgUserGroupAlloc(CWnd* pParent /*=NULL*/) : CDialog(CDlgUserGroupAlloc::IDD, pParent) { m_bIsLookStatus = false; } CDlgUserGroupAlloc::~CDlgUserGroupAlloc() { } void CDlgUserGroupAlloc::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST_SRC, m_ctrlListBoxSrc); DDX_Control(pDX, IDC_LIST_DEST, m_ctrlListBoxDest); DDX_Control(pDX, IDC_BTN_SEL_SINGLE, m_btnSetSingle); DDX_Control(pDX, IDC_BTN_SEL_ALL, m_btnSetAll); DDX_Control(pDX, IDC_BTN_REVERSE_SEL_SINGLE, m_btnDelSingle); DDX_Control(pDX, IDC_BTN_REVERSE_SEL_ALL, m_btnDelAll); } BEGIN_MESSAGE_MAP(CDlgUserGroupAlloc, CDialog) ON_BN_CLICKED(IDC_BTN_SEL_SINGLE, OnBnClickedBtnSelSingle) ON_BN_CLICKED(IDC_BTN_SEL_ALL, OnBnClickedBtnSelAll) ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_SINGLE, OnBnClickedBtnReverseSelSingle) ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_ALL, OnBnClickedBtnReverseSelAll) ON_BN_CLICKED(IDOK, OnBnClickedOk) ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel) END_MESSAGE_MAP() // CDlgUserGroupAlloc 消息处理程序 BOOL CDlgUserGroupAlloc::OnInitDialog() { CDialog::OnInitDialog(); // TODO: 在此添加额外的初始化 InitCtrlInfo(); if( -1==PMS_VerifyUserPermit( g_nUserID,PMS_USER_BELONGGROUP_ALLOC,"" ) ) { m_btnSetSingle.ShowWindow( false ); m_btnSetAll.ShowWindow( false ); m_btnDelSingle.ShowWindow( false ); m_btnDelAll.ShowWindow( false ); GetDlgItem(IDOK)->ShowWindow( false ); m_bIsLookStatus = true; } return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CDlgUserGroupAlloc::InitCtrlInfo(void) { CDBInterface::GetInstancePtr()->GetAllGroupByUserID( &m_ctrlListBoxDest,(char *)(LPCTSTR)m_strUserID.Trim() ); CDBInterface::GetInstancePtr()->GetAllGroupByUserID( &m_ctrlListBoxSrc,&m_ctrlListBoxDest ); #if 0 CHAR strAllocGroupIDList[MAX_LIST_LENGTH + 1] = {0}; CHAR strNotAllocGroupIDList[MAX_LIST_LENGTH + 1] = {0}; CHAR strID[MAX_ID + 1] = {0}; CHAR strGroupName[MAX_PURVIEW_NAME + 1] = {0}; m_ctrlListBoxSrc.ResetContent(); m_ctrlListBoxDest.ResetContent(); int i; int nAllocGroupCnt = GetUserGroupAllocList( (char *)(LPCTSTR)m_strUserID, strAllocGroupIDList ); for( i = 0; i < nAllocGroupCnt; i++ ) { SplitStr(strAllocGroupIDList, ',', i, strID); GetUserGroupName( atoi(strID), strGroupName ); m_ctrlListBoxSrc.InsertString(i, strGroupName); } int nNotAllocGroupCnt = GetUserGroupNotAllocList( (char *)(LPCTSTR)m_strUserID, strNotAllocGroupIDList ); for( i = 0; i < nNotAllocGroupCnt; i++ ) { SplitStr(strNotAllocGroupIDList, ',', i, strID); GetUserGroupName( atoi(strID), strGroupName ); m_ctrlListBoxDest.InsertString(i, strGroupName); } #endif } void CDlgUserGroupAlloc::OnBnClickedBtnSelSingle() { // TODO: 在此添加控件通知处理程序代码 CString str; int nCount, i, nIndex = 0; CArray arrayListSel; nCount = m_ctrlListBoxSrc.GetSelCount(); arrayListSel.SetSize( nCount ); m_ctrlListBoxSrc.GetSelItems( nCount, arrayListSel.GetData() ); for( i = 0; i < nCount; i++ ) { m_ctrlListBoxSrc.GetText( arrayListSel[i] - nIndex, str ); m_ctrlListBoxSrc.DeleteString( arrayListSel[i] - nIndex ); m_ctrlListBoxSrc.SetSel( arrayListSel[i] - nIndex, FALSE ); m_ctrlListBoxDest.AddString( str ); nIndex++; } } void CDlgUserGroupAlloc::OnBnClickedBtnSelAll() { // TODO: 在此添加控件通知处理程序代码 CString str; int i, nCount, nIndex = 0; nCount = m_ctrlListBoxSrc.GetCount(); for( i = 0; i < nCount; i++ ) { m_ctrlListBoxSrc.GetText( i - nIndex, str ); m_ctrlListBoxSrc.DeleteString( i - nIndex ); m_ctrlListBoxDest.AddString( str ); nIndex++; } } void CDlgUserGroupAlloc::OnBnClickedBtnReverseSelSingle() { CString str; int nCount, i, nIndex = 0; CArray arrayListSel; nCount = m_ctrlListBoxDest.GetSelCount(); arrayListSel.SetSize( nCount ); m_ctrlListBoxDest.GetSelItems( nCount, arrayListSel.GetData() ); for( i = 0; i < nCount; i++ ) { m_ctrlListBoxDest.GetText( arrayListSel[i] - nIndex, str ); m_ctrlListBoxDest.DeleteString( arrayListSel[i] - nIndex ); m_ctrlListBoxDest.SetSel( arrayListSel[i] - nIndex, FALSE ); m_ctrlListBoxSrc.AddString( str ); nIndex++; } } void CDlgUserGroupAlloc::OnBnClickedBtnReverseSelAll() { CString str; int i, nCount, nIndex = 0; nCount = m_ctrlListBoxDest.GetCount(); for( i = 0; i < nCount; i++ ) { m_ctrlListBoxDest.GetText( i - nIndex, str ); m_ctrlListBoxDest.DeleteString( i - nIndex ); m_ctrlListBoxSrc.AddString( str ); nIndex++; } } void CDlgUserGroupAlloc::OnBnClickedBtnOk() { #if 0 CString str; CHAR chID[MAX_ID + 1] = {0}; int nRet, i, nCount; nCount = m_ctrlListBoxDest.GetCount(); for( i = 0; i < nCount; i++ ) { m_ctrlListBoxDest.GetText( i, str ); nRet = GetUserGroupID( (char *)(LPCTSTR)m_strUserID, chID, (char *)(LPCTSTR)str ); if( nRet == 0 ) { GetUserGroupID( chID, (char *)(LPCTSTR)str ); AddUserPurviewInfo( (char *)(LPCTSTR)m_strUserID, atoi(chID), (char *)(LPCTSTR)str ); } } nCount = m_ctrlListBoxSrc.GetCount(); for( i = 0; i < nCount; i++ ) { m_ctrlListBoxSrc.GetText( i, str ); nRet = GetUserGroupID( (char *)(LPCTSTR)m_strUserID, chID, (char *)(LPCTSTR)str ); if( nRet > 0 ) { DelUserPurviewInfo( (char *)(LPCTSTR)m_strUserID, atoi(chID) ); } } AfxMessageBox(g_strMsgSetSuccess); #endif } void CDlgUserGroupAlloc::OnBnClickedBtnCancel() { OnCancel(); } void CDlgUserGroupAlloc::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 if( !m_bIsLookStatus ) { int nGroupID=0; CString sUserName = m_strUserID.Trim(); CString sGroupName; CDBInterface::GetInstancePtr()->DeleteUserGroup( (char *)(LPCTSTR)sUserName,0 ); int i, nCount; nCount = m_ctrlListBoxDest.GetCount(); for( i = 0; i < nCount; i++ ) { m_ctrlListBoxDest.GetText( i, sGroupName ); CDBInterface::GetInstancePtr()->GetGroupIDByName( sGroupName,nGroupID ); int nID = 0; CHAR szMaxID[MAX_ID] = {0}; CDBInterface::GetInstancePtr()->GetMaxID("t_role_user", "id", szMaxID); nID = atoi( szMaxID ); CDBInterface::GetInstancePtr()->AddUserToGroup( nID+1,(char *)(LPCTSTR)sUserName,nGroupID,"" ); } CString sContent; //sContent.Format("编辑用户< %s >所属组",sUserName ); //CDBInterface::GetInstancePtr()->InsertLogRecord( LOG_USER_GROUP_EDIT,0,"",(char *)(LPCTSTR)sContent ); } OnOK(); } void CDlgUserGroupAlloc::OnBnClickedCancel() { // TODO: 在此添加控件通知处理程序代码 OnCancel(); }