123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- // 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<int,int> 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<int,int> 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();
- }
|