DlgUserGroupAlloc.cpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. // DlgUserManager.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "IDE.h"
  5. #include "DlgUserGroupAlloc.h"
  6. #include "StringOperation.h"
  7. #include ".\dlgusergroupalloc.h"
  8. // CDlgUserGroupAlloc 对话框
  9. IMPLEMENT_DYNAMIC(CDlgUserGroupAlloc, CDialog)
  10. CDlgUserGroupAlloc::CDlgUserGroupAlloc(CWnd* pParent /*=NULL*/)
  11. : CDialog(CDlgUserGroupAlloc::IDD, pParent)
  12. {
  13. m_bIsLookStatus = false;
  14. }
  15. CDlgUserGroupAlloc::~CDlgUserGroupAlloc()
  16. {
  17. }
  18. void CDlgUserGroupAlloc::DoDataExchange(CDataExchange* pDX)
  19. {
  20. CDialog::DoDataExchange(pDX);
  21. DDX_Control(pDX, IDC_LIST_SRC, m_ctrlListBoxSrc);
  22. DDX_Control(pDX, IDC_LIST_DEST, m_ctrlListBoxDest);
  23. DDX_Control(pDX, IDC_BTN_SEL_SINGLE, m_btnSetSingle);
  24. DDX_Control(pDX, IDC_BTN_SEL_ALL, m_btnSetAll);
  25. DDX_Control(pDX, IDC_BTN_REVERSE_SEL_SINGLE, m_btnDelSingle);
  26. DDX_Control(pDX, IDC_BTN_REVERSE_SEL_ALL, m_btnDelAll);
  27. }
  28. BEGIN_MESSAGE_MAP(CDlgUserGroupAlloc, CDialog)
  29. ON_BN_CLICKED(IDC_BTN_SEL_SINGLE, OnBnClickedBtnSelSingle)
  30. ON_BN_CLICKED(IDC_BTN_SEL_ALL, OnBnClickedBtnSelAll)
  31. ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_SINGLE, OnBnClickedBtnReverseSelSingle)
  32. ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_ALL, OnBnClickedBtnReverseSelAll)
  33. ON_BN_CLICKED(IDOK, OnBnClickedOk)
  34. ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
  35. END_MESSAGE_MAP()
  36. // CDlgUserGroupAlloc 消息处理程序
  37. BOOL CDlgUserGroupAlloc::OnInitDialog()
  38. {
  39. CDialog::OnInitDialog();
  40. // TODO: 在此添加额外的初始化
  41. InitCtrlInfo();
  42. if( -1==PMS_VerifyUserPermit( g_nUserID,PMS_USER_BELONGGROUP_ALLOC,"" ) )
  43. {
  44. m_btnSetSingle.ShowWindow( false );
  45. m_btnSetAll.ShowWindow( false );
  46. m_btnDelSingle.ShowWindow( false );
  47. m_btnDelAll.ShowWindow( false );
  48. GetDlgItem(IDOK)->ShowWindow( false );
  49. m_bIsLookStatus = true;
  50. }
  51. return TRUE; // return TRUE unless you set the focus to a control
  52. // 异常: OCX 属性页应返回 FALSE
  53. }
  54. void CDlgUserGroupAlloc::InitCtrlInfo(void)
  55. {
  56. CDBInterface::GetInstancePtr()->GetAllGroupByUserID( &m_ctrlListBoxDest,(char *)(LPCTSTR)m_strUserID.Trim() );
  57. CDBInterface::GetInstancePtr()->GetAllGroupByUserID( &m_ctrlListBoxSrc,&m_ctrlListBoxDest );
  58. #if 0
  59. CHAR strAllocGroupIDList[MAX_LIST_LENGTH + 1] = {0};
  60. CHAR strNotAllocGroupIDList[MAX_LIST_LENGTH + 1] = {0};
  61. CHAR strID[MAX_ID + 1] = {0};
  62. CHAR strGroupName[MAX_PURVIEW_NAME + 1] = {0};
  63. m_ctrlListBoxSrc.ResetContent();
  64. m_ctrlListBoxDest.ResetContent();
  65. int i;
  66. int nAllocGroupCnt = GetUserGroupAllocList( (char *)(LPCTSTR)m_strUserID, strAllocGroupIDList );
  67. for( i = 0; i < nAllocGroupCnt; i++ )
  68. {
  69. SplitStr(strAllocGroupIDList, ',', i, strID);
  70. GetUserGroupName( atoi(strID), strGroupName );
  71. m_ctrlListBoxSrc.InsertString(i, strGroupName);
  72. }
  73. int nNotAllocGroupCnt = GetUserGroupNotAllocList( (char *)(LPCTSTR)m_strUserID, strNotAllocGroupIDList );
  74. for( i = 0; i < nNotAllocGroupCnt; i++ )
  75. {
  76. SplitStr(strNotAllocGroupIDList, ',', i, strID);
  77. GetUserGroupName( atoi(strID), strGroupName );
  78. m_ctrlListBoxDest.InsertString(i, strGroupName);
  79. }
  80. #endif
  81. }
  82. void CDlgUserGroupAlloc::OnBnClickedBtnSelSingle()
  83. {
  84. // TODO: 在此添加控件通知处理程序代码
  85. CString str;
  86. int nCount, i, nIndex = 0;
  87. CArray<int,int> arrayListSel;
  88. nCount = m_ctrlListBoxSrc.GetSelCount();
  89. arrayListSel.SetSize( nCount );
  90. m_ctrlListBoxSrc.GetSelItems( nCount, arrayListSel.GetData() );
  91. for( i = 0; i < nCount; i++ )
  92. {
  93. m_ctrlListBoxSrc.GetText( arrayListSel[i] - nIndex, str );
  94. m_ctrlListBoxSrc.DeleteString( arrayListSel[i] - nIndex );
  95. m_ctrlListBoxSrc.SetSel( arrayListSel[i] - nIndex, FALSE );
  96. m_ctrlListBoxDest.AddString( str );
  97. nIndex++;
  98. }
  99. }
  100. void CDlgUserGroupAlloc::OnBnClickedBtnSelAll()
  101. {
  102. // TODO: 在此添加控件通知处理程序代码
  103. CString str;
  104. int i, nCount, nIndex = 0;
  105. nCount = m_ctrlListBoxSrc.GetCount();
  106. for( i = 0; i < nCount; i++ )
  107. {
  108. m_ctrlListBoxSrc.GetText( i - nIndex, str );
  109. m_ctrlListBoxSrc.DeleteString( i - nIndex );
  110. m_ctrlListBoxDest.AddString( str );
  111. nIndex++;
  112. }
  113. }
  114. void CDlgUserGroupAlloc::OnBnClickedBtnReverseSelSingle()
  115. {
  116. CString str;
  117. int nCount, i, nIndex = 0;
  118. CArray<int,int> arrayListSel;
  119. nCount = m_ctrlListBoxDest.GetSelCount();
  120. arrayListSel.SetSize( nCount );
  121. m_ctrlListBoxDest.GetSelItems( nCount, arrayListSel.GetData() );
  122. for( i = 0; i < nCount; i++ )
  123. {
  124. m_ctrlListBoxDest.GetText( arrayListSel[i] - nIndex, str );
  125. m_ctrlListBoxDest.DeleteString( arrayListSel[i] - nIndex );
  126. m_ctrlListBoxDest.SetSel( arrayListSel[i] - nIndex, FALSE );
  127. m_ctrlListBoxSrc.AddString( str );
  128. nIndex++;
  129. }
  130. }
  131. void CDlgUserGroupAlloc::OnBnClickedBtnReverseSelAll()
  132. {
  133. CString str;
  134. int i, nCount, nIndex = 0;
  135. nCount = m_ctrlListBoxDest.GetCount();
  136. for( i = 0; i < nCount; i++ )
  137. {
  138. m_ctrlListBoxDest.GetText( i - nIndex, str );
  139. m_ctrlListBoxDest.DeleteString( i - nIndex );
  140. m_ctrlListBoxSrc.AddString( str );
  141. nIndex++;
  142. }
  143. }
  144. void CDlgUserGroupAlloc::OnBnClickedBtnOk()
  145. {
  146. #if 0
  147. CString str;
  148. CHAR chID[MAX_ID + 1] = {0};
  149. int nRet, i, nCount;
  150. nCount = m_ctrlListBoxDest.GetCount();
  151. for( i = 0; i < nCount; i++ )
  152. {
  153. m_ctrlListBoxDest.GetText( i, str );
  154. nRet = GetUserGroupID( (char *)(LPCTSTR)m_strUserID, chID, (char *)(LPCTSTR)str );
  155. if( nRet == 0 )
  156. {
  157. GetUserGroupID( chID, (char *)(LPCTSTR)str );
  158. AddUserPurviewInfo( (char *)(LPCTSTR)m_strUserID, atoi(chID), (char *)(LPCTSTR)str );
  159. }
  160. }
  161. nCount = m_ctrlListBoxSrc.GetCount();
  162. for( i = 0; i < nCount; i++ )
  163. {
  164. m_ctrlListBoxSrc.GetText( i, str );
  165. nRet = GetUserGroupID( (char *)(LPCTSTR)m_strUserID, chID, (char *)(LPCTSTR)str );
  166. if( nRet > 0 )
  167. {
  168. DelUserPurviewInfo( (char *)(LPCTSTR)m_strUserID, atoi(chID) );
  169. }
  170. }
  171. AfxMessageBox(g_strMsgSetSuccess);
  172. #endif
  173. }
  174. void CDlgUserGroupAlloc::OnBnClickedBtnCancel()
  175. {
  176. OnCancel();
  177. }
  178. void CDlgUserGroupAlloc::OnBnClickedOk()
  179. {
  180. // TODO: 在此添加控件通知处理程序代码
  181. if( !m_bIsLookStatus )
  182. {
  183. int nGroupID=0;
  184. CString sUserName = m_strUserID.Trim();
  185. CString sGroupName;
  186. CDBInterface::GetInstancePtr()->DeleteUserGroup( (char *)(LPCTSTR)sUserName,0 );
  187. int i, nCount;
  188. nCount = m_ctrlListBoxDest.GetCount();
  189. for( i = 0; i < nCount; i++ )
  190. {
  191. m_ctrlListBoxDest.GetText( i, sGroupName );
  192. CDBInterface::GetInstancePtr()->GetGroupIDByName( sGroupName,nGroupID );
  193. int nID = 0;
  194. CHAR szMaxID[MAX_ID] = {0};
  195. CDBInterface::GetInstancePtr()->GetMaxID("t_role_user", "id", szMaxID);
  196. nID = atoi( szMaxID );
  197. CDBInterface::GetInstancePtr()->AddUserToGroup( nID+1,(char *)(LPCTSTR)sUserName,nGroupID,"" );
  198. }
  199. CString sContent;
  200. //sContent.Format("编辑用户< %s >所属组",sUserName );
  201. //CDBInterface::GetInstancePtr()->InsertLogRecord( LOG_USER_GROUP_EDIT,0,"",(char *)(LPCTSTR)sContent );
  202. }
  203. OnOK();
  204. }
  205. void CDlgUserGroupAlloc::OnBnClickedCancel()
  206. {
  207. // TODO: 在此添加控件通知处理程序代码
  208. OnCancel();
  209. }