Dlg_GroupManage.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. // Dlg_GroupManage.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "Dlg_GroupManage.h"
  5. #include "Dlg_AddGroup.h"
  6. // CDlg_GroupManage 对话框
  7. IMPLEMENT_DYNAMIC(CDlg_GroupManage, CDialog)
  8. CDlg_GroupManage::CDlg_GroupManage(CWnd* pParent /*=NULL*/)
  9. : CDialog(CDlg_GroupManage::IDD, pParent)
  10. {
  11. m_hRoot = NULL;
  12. m_hCurretItem = NULL;
  13. m_bIsLookStatus = false;
  14. m_nGroupID = -1;
  15. m_nType = 0;
  16. }
  17. CDlg_GroupManage::~CDlg_GroupManage()
  18. {
  19. }
  20. void CDlg_GroupManage::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. DDX_Control(pDX, IDC_TREE_GROUP, m_wndTree);
  24. DDX_Control(pDX, IDC_LIST_SRC, m_ctrlListBoxSrc);
  25. DDX_Control(pDX, IDC_LIST_DEST, m_ctrlListBoxDest);
  26. DDX_Control(pDX, IDC_BTN_SEL_SINGLE, m_btnSetSingle);
  27. DDX_Control(pDX, IDC_BTN_SEL_ALL, m_btnSetAll);
  28. DDX_Control(pDX, IDC_BTN_REVERSE_SEL_SINGLE, m_btnDelSingle);
  29. DDX_Control(pDX, IDC_BTN_REVERSE_SEL_ALL, m_btnDelAll);
  30. DDX_Control(pDX, IDC_LIST_SRC2, m_ctrlListBoxSrc1);
  31. DDX_Control(pDX, IDC_LIST_DEST2, m_ctrlListBoxDest1);
  32. DDX_Control(pDX, IDC_BTN_SEL_SINGLE2, m_btnSetSingle1);
  33. DDX_Control(pDX, IDC_BTN_SEL_ALL2, m_btnSetAll1);
  34. DDX_Control(pDX, IDC_BTN_REVERSE_SEL_SINGLE2, m_btnDelSingle1);
  35. DDX_Control(pDX, IDC_BTN_REVERSE_SEL_ALL2, m_btnDelAll1);
  36. DDX_Control(pDX, IDC_LIST_SRC3, m_ctrlListBoxSrc2);
  37. DDX_Control(pDX, IDC_LIST_DEST3, m_ctrlListBoxDest2);
  38. DDX_Control(pDX, IDC_BTN_SEL_SINGLE3, m_btnSetSingle2);
  39. DDX_Control(pDX, IDC_BTN_SEL_ALL3, m_btnSetAll2);
  40. DDX_Control(pDX, IDC_BTN_REVERSE_SEL_SINGLE3, m_btnDelSingle2);
  41. DDX_Control(pDX, IDC_BTN_REVERSE_SEL_ALL3, m_btnDelAll2);
  42. DDX_Control(pDX, IDC_BTN_ADDGROUP, m_btnAddGroup);
  43. DDX_Control(pDX, IDC_BTN_DELGROUP, m_btnDelGroup);
  44. DDX_Radio(pDX, IDC_RADIO1, m_nType);
  45. }
  46. BEGIN_MESSAGE_MAP(CDlg_GroupManage, CDialog)
  47. ON_BN_CLICKED(IDC_BTN_ADDGROUP, OnBnClickedBtnAddgroup)
  48. ON_BN_CLICKED(IDC_BTN_DELGROUP, OnBnClickedBtnDelgroup)
  49. ON_BN_CLICKED(IDC_BTN_SEL_SINGLE, OnBnClickedBtnSelSingle)
  50. ON_BN_CLICKED(IDC_BTN_SEL_ALL, OnBnClickedBtnSelAll)
  51. ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_SINGLE, OnBnClickedBtnReverseSelSingle)
  52. ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_ALL, OnBnClickedBtnReverseSelAll)
  53. ON_BN_CLICKED(IDC_BTN_SEL_SINGLE2, OnBnClickedBtnSelSingle1)
  54. ON_BN_CLICKED(IDC_BTN_SEL_ALL2, OnBnClickedBtnSelAll1)
  55. ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_SINGLE2, OnBnClickedBtnReverseSelSingle1)
  56. ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_ALL2, OnBnClickedBtnReverseSelAll1)
  57. ON_BN_CLICKED(IDC_BTN_SEL_SINGLE3, OnBnClickedBtnSelSingle2)
  58. ON_BN_CLICKED(IDC_BTN_SEL_ALL3, OnBnClickedBtnSelAll2)
  59. ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_SINGLE3, OnBnClickedBtnReverseSelSingle2)
  60. ON_BN_CLICKED(IDC_BTN_REVERSE_SEL_ALL3, OnBnClickedBtnReverseSelAll2)
  61. ON_BN_CLICKED(IDOK, OnBnClickedOk)
  62. ON_NOTIFY(NM_DBLCLK, IDC_TREE_GROUP, OnNMDblclkTreeGroup)
  63. ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio1)
  64. ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio2)
  65. ON_BN_CLICKED(IDC_RADIO3, OnBnClickedRadio3)
  66. END_MESSAGE_MAP()
  67. // CDlg_GroupManage 消息处理程序
  68. BOOL CDlg_GroupManage::OnInitDialog()
  69. {
  70. CDialog::OnInitDialog();
  71. // TODO: 在此添加额外的初始化
  72. InitTreeInfo();
  73. if( -1==PMS_VerifyUserPermit( g_nUserID,PMS_GROUP_INFO_ALLOC,"" ) )
  74. {
  75. m_btnSetSingle.ShowWindow( false );
  76. m_btnSetAll.ShowWindow( false );
  77. m_btnDelSingle.ShowWindow( false );
  78. m_btnDelAll.ShowWindow( false );
  79. m_btnAddGroup.ShowWindow( false );
  80. m_btnDelGroup.ShowWindow( false );
  81. GetDlgItem(IDOK)->ShowWindow( false );
  82. m_bIsLookStatus = true;
  83. }
  84. HTREEITEM hSelectedItem = m_wndTree.GetSelectedItem();
  85. HTREEITEM hParent = m_wndTree.GetParentItem( hSelectedItem );
  86. //int nGroupID = 0;
  87. //CString str="操作员";
  88. //CDBInterface::GetInstancePtr()->GetGroupIDByName( str,nGroupID );
  89. //m_sCurrentGroupName = str;
  90. //CDBInterface::GetInstancePtr()->GetGroupPermitByID( &m_ctrlListBoxDest,nGroupID );
  91. //CDBInterface::GetInstancePtr()->GetGroupPermitByID( &m_ctrlListBoxSrc,&m_ctrlListBoxDest );
  92. IsVisibleCtrl();
  93. UpdateData( false );
  94. return TRUE; // return TRUE unless you set the focus to a control
  95. // 异常: OCX 属性页应返回 FALSE
  96. }
  97. void CDlg_GroupManage::InitTreeInfo(void)
  98. {
  99. m_wndTree.ModifyStyle(0, TVS_HASBUTTONS | TVS_LINESATROOT
  100. | TVS_HASLINES | TVS_DISABLEDRAGDROP
  101. | TVS_SHOWSELALWAYS);
  102. m_wndTree.DeleteAllItems();
  103. m_wndTree.SetItemHeight(20);
  104. m_wndImageList.DeleteImageList();
  105. m_wndImageList.Create(IDB_LEFT, 16, 1, RGB(255, 0, 255));
  106. m_wndTree.SetImageList(&m_wndImageList, LVSIL_NORMAL);
  107. ////插入串口和设备
  108. m_hRoot = m_wndTree.InsertItem(g_strGroup, 0, 0);
  109. CDBInterface::GetInstancePtr()->GetAllGroupToTree( &m_wndTree, m_hRoot );
  110. //展开树
  111. m_wndTree.Expand(m_wndTree.GetRootItem(),TVE_EXPAND);
  112. HTREEITEM handleTreeItem = m_wndTree.GetRootItem();
  113. while(handleTreeItem)
  114. {
  115. handleTreeItem = m_wndTree.GetChildItem(handleTreeItem);
  116. m_wndTree.Expand(handleTreeItem, TVE_EXPAND);
  117. }
  118. }
  119. void CDlg_GroupManage::OnBnClickedBtnAddgroup()
  120. {
  121. CDlg_AddGroup dlg;
  122. if( dlg.DoModal()==IDOK )
  123. {
  124. int nID = 0;
  125. CHAR szMaxID[MAX_ID] = {0};
  126. CDBInterface::GetInstancePtr()->GetMaxID("t_user_group", "id", szMaxID);
  127. nID = atoi( szMaxID );
  128. CDBInterface::GetInstancePtr()->AddGroup(nID+1, (char *)(LPCTSTR)dlg.m_sEdit_GroupName, "");
  129. m_wndTree.InsertItem(dlg.m_sEdit_GroupName,5,5,m_hRoot);
  130. CString sContent;
  131. sContent.Format("%s %s< %s >",g_strAdd,g_strGroup,m_sCurrentGroupName );
  132. CDBInterface::GetInstancePtr()->InsertLogRecord( LOG_GROUP_ADD,0,"",(char *)(LPCTSTR)sContent );
  133. m_ctrlListBoxDest.ResetContent();
  134. m_ctrlListBoxSrc.ResetContent();
  135. m_ctrlListBoxDest1.ResetContent();
  136. m_ctrlListBoxSrc1.ResetContent();
  137. m_ctrlListBoxDest2.ResetContent();
  138. m_ctrlListBoxSrc2.ResetContent();
  139. CDBInterface::GetInstancePtr()->GetGroupIDByName( dlg.m_sEdit_GroupName,m_nGroupID );
  140. CDBInterface::GetInstancePtr()->GetGroupPermitByID( &m_ctrlListBoxDest,m_nGroupID );
  141. CDBInterface::GetInstancePtr()->GetGroupPermitByID( &m_ctrlListBoxSrc,&m_ctrlListBoxDest );
  142. CDBInterface::GetInstancePtr()->GetGroupUserByID( &m_ctrlListBoxDest2,m_nGroupID );
  143. CDBInterface::GetInstancePtr()->GetGroupUserByID( &m_ctrlListBoxSrc2,&m_ctrlListBoxDest2 );
  144. GetGroupDevice();
  145. }
  146. }
  147. void CDlg_GroupManage::OnBnClickedBtnDelgroup()
  148. {
  149. if( m_hCurretItem==NULL )
  150. {
  151. MessageBox(g_strDClickFirstOperate, g_strTip, MB_ICONWARNING);
  152. return;
  153. }
  154. CString str;
  155. str.Format(g_strDelGroup,m_sCurrentGroupName );
  156. if( MessageBox( str,g_strTip,MB_YESNO )==IDNO )
  157. return;
  158. m_wndTree.DeleteItem( m_hCurretItem );
  159. int nGroupID=0;
  160. CDBInterface::GetInstancePtr()->GetGroupIDByName( m_sCurrentGroupName,nGroupID );
  161. CDBInterface::GetInstancePtr()->DelGroup( nGroupID );
  162. str.Format( "%d",nGroupID );
  163. CDBInterface::GetInstancePtr()->DelTableData( "t_role_equip","group_id",(char *)(LPCTSTR)str,2 );
  164. CDBInterface::GetInstancePtr()->DelTableData( "t_role_user","group_id",(char *)(LPCTSTR)str,2 );
  165. //int nCount=0;
  166. //nCount = m_ctrlListBoxSrc.GetCount();
  167. //for( int i = 0; i < nCount; i++ )
  168. // m_ctrlListBoxSrc.DeleteString( i );
  169. //nCount = m_ctrlListBoxDest.GetCount();
  170. //for( int i = 0; i < nCount; i++ )
  171. // m_ctrlListBoxDest.DeleteString( i );
  172. m_hCurretItem = NULL;
  173. CString sContent;
  174. sContent.Format("%s %s< %s >",g_strDel,g_strGroup,m_sCurrentGroupName );
  175. CDBInterface::GetInstancePtr()->InsertLogRecord( LOG_GROUP_DELETE,0,"",(char *)(LPCTSTR)sContent );
  176. m_ctrlListBoxDest.ResetContent();
  177. m_ctrlListBoxSrc.ResetContent();
  178. m_ctrlListBoxDest1.ResetContent();
  179. m_ctrlListBoxSrc1.ResetContent();
  180. m_ctrlListBoxDest2.ResetContent();
  181. m_ctrlListBoxSrc2.ResetContent();
  182. }
  183. void CDlg_GroupManage::OnBnClickedBtnSelSingle()
  184. {
  185. CString str;
  186. int nCount, i, nIndex = 0;
  187. CArray<int,int> arrayListSel;
  188. nCount = m_ctrlListBoxSrc.GetSelCount();
  189. arrayListSel.SetSize( nCount );
  190. m_ctrlListBoxSrc.GetSelItems( nCount, arrayListSel.GetData() );
  191. for( i = 0; i < nCount; i++ )
  192. {
  193. m_ctrlListBoxSrc.GetText( arrayListSel[i] - nIndex, str );
  194. m_ctrlListBoxSrc.DeleteString( arrayListSel[i] - nIndex );
  195. m_ctrlListBoxSrc.SetSel( arrayListSel[i] - nIndex, FALSE );
  196. m_ctrlListBoxDest.AddString( str );
  197. nIndex++;
  198. }
  199. }
  200. void CDlg_GroupManage::OnBnClickedBtnSelAll()
  201. {
  202. CString str;
  203. int i, nCount, nIndex = 0;
  204. nCount = m_ctrlListBoxSrc.GetCount();
  205. for( i = 0; i < nCount; i++ )
  206. {
  207. m_ctrlListBoxSrc.GetText( i - nIndex, str );
  208. m_ctrlListBoxSrc.DeleteString( i - nIndex );
  209. m_ctrlListBoxDest.AddString( str );
  210. nIndex++;
  211. }
  212. }
  213. void CDlg_GroupManage::OnBnClickedBtnReverseSelSingle()
  214. {
  215. CString str;
  216. int nCount, i, nIndex = 0;
  217. CArray<int,int> arrayListSel;
  218. nCount = m_ctrlListBoxDest.GetSelCount();
  219. arrayListSel.SetSize( nCount );
  220. m_ctrlListBoxDest.GetSelItems( nCount, arrayListSel.GetData() );
  221. for( i = 0; i < nCount; i++ )
  222. {
  223. m_ctrlListBoxDest.GetText( arrayListSel[i] - nIndex, str );
  224. m_ctrlListBoxDest.DeleteString( arrayListSel[i] - nIndex );
  225. m_ctrlListBoxDest.SetSel( arrayListSel[i] - nIndex, FALSE );
  226. m_ctrlListBoxSrc.AddString( str );
  227. nIndex++;
  228. }
  229. }
  230. void CDlg_GroupManage::OnBnClickedBtnReverseSelAll()
  231. {
  232. CString str;
  233. int i, nCount, nIndex = 0;
  234. nCount = m_ctrlListBoxDest.GetCount();
  235. for( i = 0; i < nCount; i++ )
  236. {
  237. m_ctrlListBoxDest.GetText( i - nIndex, str );
  238. m_ctrlListBoxDest.DeleteString( i - nIndex );
  239. m_ctrlListBoxSrc.AddString( str );
  240. nIndex++;
  241. }
  242. }
  243. void CDlg_GroupManage::OnBnClickedOk()
  244. {
  245. if( !m_bIsLookStatus )
  246. {
  247. CString sGroupPermit;
  248. CString str;
  249. int nID=0;
  250. int nCount = m_ctrlListBoxDest.GetCount();
  251. for( int i = 0; i < nCount; i++ )
  252. {
  253. m_ctrlListBoxDest.GetText( i, str );
  254. CDBInterface::GetInstancePtr()->GetPermitIDByName( str,nID );
  255. str.Format("%d-",nID );
  256. sGroupPermit += str;
  257. }
  258. sGroupPermit = sGroupPermit.Left( sGroupPermit.GetLength()-1 );
  259. CDBInterface::GetInstancePtr()->ModifyGroup( m_sCurrentGroupName,sGroupPermit );
  260. CString sContent;
  261. sContent.Format("%s %s< %s >",g_strEdit,g_strGroup,m_sCurrentGroupName );
  262. CDBInterface::GetInstancePtr()->InsertLogRecord( LOG_GROUP_EDIT,0,"",(char *)(LPCTSTR)sContent );
  263. }
  264. if( !m_bIsLookStatus )
  265. {
  266. CString sUserUid;
  267. CDBInterface::GetInstancePtr()->DeleteGroupUser( m_nGroupID );
  268. int i, nCount;
  269. nCount = m_ctrlListBoxDest2.GetCount();
  270. for( i = 0; i < nCount; i++ )
  271. {
  272. m_ctrlListBoxDest2.GetText( i, sUserUid );
  273. //CDBInterface::GetInstancePtr()->GetGroupIDByName( sGroupName,nGroupID );
  274. int nID = 0;
  275. CHAR szMaxID[MAX_ID] = {0};
  276. CDBInterface::GetInstancePtr()->GetMaxID("t_role_user", "id", szMaxID);
  277. nID = atoi( szMaxID );
  278. CDBInterface::GetInstancePtr()->AddUserToGroup( nID+1,(char *)(LPCTSTR)sUserUid,m_nGroupID,"" );
  279. }
  280. }
  281. if( !m_bIsLookStatus )
  282. {
  283. CString str;
  284. int i, nCount, nID = 0;
  285. CHAR szUid[20] = {0};
  286. CHAR szMaxID[MAX_ID] = {0};
  287. nCount = m_ctrlListBoxDest1.GetCount();
  288. CDBInterface::GetInstancePtr()->DelUserDevInfo( m_nGroupID );
  289. for( i = 0; i < nCount; i++ )
  290. {
  291. m_ctrlListBoxDest1.GetText( i, str );
  292. CDBInterface::GetInstancePtr()->GetDevUID( (char *)(LPCTSTR)str, szUid );
  293. CDBInterface::GetInstancePtr()->GetMaxID("t_role_equip", "id", szMaxID);
  294. if( atoi(szMaxID) > 0 )
  295. {
  296. nID = atoi(szMaxID) + 1;
  297. }
  298. else if( atoi(szMaxID) == 0 )
  299. {
  300. nID = 1;
  301. }
  302. CDBInterface::GetInstancePtr()->AddUserDevInfo(nID, m_nGroupID, szUid);
  303. }
  304. }
  305. AfxMessageBox( "保存完成!" );
  306. //OnOK();
  307. }
  308. void CDlg_GroupManage::OnNMDblclkTreeGroup(NMHDR *pNMHDR, LRESULT *pResult)//
  309. {
  310. // TODO: 在此添加控件通知处理程序代码
  311. HTREEITEM hSelectedItem = m_wndTree.GetSelectedItem();
  312. HTREEITEM hParent = m_wndTree.GetParentItem( hSelectedItem );
  313. CString str;
  314. if( hParent && m_hCurretItem!=hSelectedItem )
  315. {
  316. str = m_wndTree.GetItemText( hSelectedItem );
  317. CDBInterface::GetInstancePtr()->GetGroupIDByName( str,m_nGroupID );
  318. m_sCurrentGroupName = str;
  319. m_hCurretItem = hSelectedItem;
  320. m_ctrlListBoxDest.ResetContent();
  321. m_ctrlListBoxSrc.ResetContent();
  322. m_ctrlListBoxDest1.ResetContent();
  323. m_ctrlListBoxSrc1.ResetContent();
  324. m_ctrlListBoxDest2.ResetContent();
  325. m_ctrlListBoxSrc2.ResetContent();
  326. CDBInterface::GetInstancePtr()->GetGroupPermitByID( &m_ctrlListBoxDest,m_nGroupID );
  327. CDBInterface::GetInstancePtr()->GetGroupPermitByID( &m_ctrlListBoxSrc,&m_ctrlListBoxDest );
  328. CDBInterface::GetInstancePtr()->GetGroupUserByID( &m_ctrlListBoxDest2,m_nGroupID );
  329. CDBInterface::GetInstancePtr()->GetGroupUserByID( &m_ctrlListBoxSrc2,&m_ctrlListBoxDest2 );
  330. GetGroupDevice();
  331. }
  332. *pResult = 0;
  333. }
  334. void CDlg_GroupManage::GetGroupDevice()
  335. {
  336. m_ctrlListBoxSrc1.ResetContent();
  337. m_ctrlListBoxDest1.ResetContent();
  338. int nChannelsSize = pDevicesManager->m_channels.GetSize();
  339. int nDeviceSize = 0;
  340. int nSrcIndex = 0, nDestIndex = 0;
  341. for( int i = 0; i < nChannelsSize; i++ )
  342. {
  343. nDeviceSize = pDevicesManager->m_channels[i]->m_Devices.GetSize();
  344. for( int j = 0; j < nDeviceSize; j++ )
  345. {
  346. if( !CDBInterface::GetInstancePtr()->HasDevAlloc( m_nGroupID,(char *)(LPCTSTR)pDevicesManager->m_channels[i]->m_Devices[j]->m_strUID) )
  347. {
  348. m_ctrlListBoxSrc1.InsertString(nSrcIndex, pDevicesManager->m_channels[i]->m_Devices[j]->m_strName);
  349. nSrcIndex++;
  350. }
  351. else
  352. {
  353. m_ctrlListBoxDest1.InsertString(nDestIndex, pDevicesManager->m_channels[i]->m_Devices[j]->m_strName);
  354. nDestIndex++;
  355. }
  356. }
  357. }
  358. }
  359. void CDlg_GroupManage::OnBnClickedBtnSelSingle1()
  360. {
  361. CString str;
  362. int nCount, i, nIndex = 0;
  363. CArray<int,int> arrayListSel;
  364. nCount = m_ctrlListBoxSrc1.GetSelCount();
  365. arrayListSel.SetSize( nCount );
  366. m_ctrlListBoxSrc1.GetSelItems( nCount, arrayListSel.GetData() );
  367. for( i = 0; i < nCount; i++ )
  368. {
  369. m_ctrlListBoxSrc1.GetText( arrayListSel[i] - nIndex, str );
  370. m_ctrlListBoxSrc1.DeleteString( arrayListSel[i] - nIndex );
  371. m_ctrlListBoxSrc1.SetSel( arrayListSel[i] - nIndex, FALSE );
  372. m_ctrlListBoxDest1.AddString( str );
  373. nIndex++;
  374. }
  375. }
  376. void CDlg_GroupManage::OnBnClickedBtnSelAll1()
  377. {
  378. CString str;
  379. int i, nCount, nIndex = 0;
  380. nCount = m_ctrlListBoxSrc1.GetCount();
  381. for( i = 0; i < nCount; i++ )
  382. {
  383. m_ctrlListBoxSrc1.GetText( i - nIndex, str );
  384. m_ctrlListBoxSrc1.DeleteString( i - nIndex );
  385. m_ctrlListBoxDest1.AddString( str );
  386. nIndex++;
  387. }
  388. }
  389. void CDlg_GroupManage::OnBnClickedBtnReverseSelSingle1()
  390. {
  391. CString str;
  392. int nCount, i, nIndex = 0;
  393. CArray<int,int> arrayListSel;
  394. nCount = m_ctrlListBoxDest1.GetSelCount();
  395. arrayListSel.SetSize( nCount );
  396. m_ctrlListBoxDest1.GetSelItems( nCount, arrayListSel.GetData() );
  397. for( i = 0; i < nCount; i++ )
  398. {
  399. m_ctrlListBoxDest1.GetText( arrayListSel[i] - nIndex, str );
  400. m_ctrlListBoxDest1.DeleteString( arrayListSel[i] - nIndex );
  401. m_ctrlListBoxDest1.SetSel( arrayListSel[i] - nIndex, FALSE );
  402. m_ctrlListBoxSrc1.AddString( str );
  403. nIndex++;
  404. }
  405. }
  406. void CDlg_GroupManage::OnBnClickedBtnReverseSelAll1()
  407. {
  408. CString str;
  409. int i, nCount, nIndex = 0;
  410. nCount = m_ctrlListBoxDest1.GetCount();
  411. for( i = 0; i < nCount; i++ )
  412. {
  413. m_ctrlListBoxDest1.GetText( i - nIndex, str );
  414. m_ctrlListBoxDest1.DeleteString( i - nIndex );
  415. m_ctrlListBoxSrc1.AddString( str );
  416. nIndex++;
  417. }
  418. }
  419. void CDlg_GroupManage::OnBnClickedBtnSelSingle2()
  420. {
  421. CString str;
  422. int nCount, i, nIndex = 0;
  423. CArray<int,int> arrayListSel;
  424. nCount = m_ctrlListBoxSrc2.GetSelCount();
  425. arrayListSel.SetSize( nCount );
  426. m_ctrlListBoxSrc2.GetSelItems( nCount, arrayListSel.GetData() );
  427. for( i = 0; i < nCount; i++ )
  428. {
  429. m_ctrlListBoxSrc2.GetText( arrayListSel[i] - nIndex, str );
  430. m_ctrlListBoxSrc2.DeleteString( arrayListSel[i] - nIndex );
  431. m_ctrlListBoxSrc2.SetSel( arrayListSel[i] - nIndex, FALSE );
  432. m_ctrlListBoxDest2.AddString( str );
  433. nIndex++;
  434. }
  435. }
  436. void CDlg_GroupManage::OnBnClickedBtnSelAll2()
  437. {
  438. CString str;
  439. int i, nCount, nIndex = 0;
  440. nCount = m_ctrlListBoxSrc2.GetCount();
  441. for( i = 0; i < nCount; i++ )
  442. {
  443. m_ctrlListBoxSrc2.GetText( i - nIndex, str );
  444. m_ctrlListBoxSrc2.DeleteString( i - nIndex );
  445. m_ctrlListBoxDest2.AddString( str );
  446. nIndex++;
  447. }
  448. }
  449. void CDlg_GroupManage::OnBnClickedBtnReverseSelSingle2()
  450. {
  451. CString str;
  452. int nCount, i, nIndex = 0;
  453. CArray<int,int> arrayListSel;
  454. nCount = m_ctrlListBoxDest2.GetSelCount();
  455. arrayListSel.SetSize( nCount );
  456. m_ctrlListBoxDest2.GetSelItems( nCount, arrayListSel.GetData() );
  457. for( i = 0; i < nCount; i++ )
  458. {
  459. m_ctrlListBoxDest2.GetText( arrayListSel[i] - nIndex, str );
  460. m_ctrlListBoxDest2.DeleteString( arrayListSel[i] - nIndex );
  461. m_ctrlListBoxDest2.SetSel( arrayListSel[i] - nIndex, FALSE );
  462. m_ctrlListBoxSrc2.AddString( str );
  463. nIndex++;
  464. }
  465. }
  466. void CDlg_GroupManage::OnBnClickedBtnReverseSelAll2()
  467. {
  468. CString str;
  469. int i, nCount, nIndex = 0;
  470. nCount = m_ctrlListBoxDest2.GetCount();
  471. for( i = 0; i < nCount; i++ )
  472. {
  473. m_ctrlListBoxDest2.GetText( i - nIndex, str );
  474. m_ctrlListBoxDest2.DeleteString( i - nIndex );
  475. m_ctrlListBoxSrc2.AddString( str );
  476. nIndex++;
  477. }
  478. }
  479. void CDlg_GroupManage::IsVisibleCtrl()
  480. {
  481. UpdateData( );
  482. if( m_nType==0 )
  483. {
  484. GetDlgItem(IDC_STATIC1)->SetWindowText( "可选权限" );
  485. GetDlgItem(IDC_STATIC2)->SetWindowText( "已选权限" );
  486. GetDlgItem(IDC_LIST_SRC)->ShowWindow( true );
  487. GetDlgItem(IDC_LIST_DEST)->ShowWindow( true );
  488. GetDlgItem(IDC_BTN_SEL_SINGLE)->ShowWindow( true );
  489. GetDlgItem(IDC_BTN_SEL_ALL)->ShowWindow( true );
  490. GetDlgItem(IDC_BTN_REVERSE_SEL_SINGLE)->ShowWindow( true );
  491. GetDlgItem(IDC_BTN_REVERSE_SEL_ALL)->ShowWindow( true );
  492. GetDlgItem(IDC_LIST_SRC2)->ShowWindow( false );
  493. GetDlgItem(IDC_LIST_DEST2)->ShowWindow( false );
  494. GetDlgItem(IDC_BTN_SEL_SINGLE2)->ShowWindow( false );
  495. GetDlgItem(IDC_BTN_SEL_ALL2)->ShowWindow( false );
  496. GetDlgItem(IDC_BTN_REVERSE_SEL_SINGLE2)->ShowWindow( false );
  497. GetDlgItem(IDC_BTN_REVERSE_SEL_ALL2)->ShowWindow( false );
  498. GetDlgItem(IDC_LIST_SRC3)->ShowWindow( false );
  499. GetDlgItem(IDC_LIST_DEST3)->ShowWindow( false );
  500. GetDlgItem(IDC_BTN_SEL_SINGLE3)->ShowWindow( false );
  501. GetDlgItem(IDC_BTN_SEL_ALL3)->ShowWindow( false );
  502. GetDlgItem(IDC_BTN_REVERSE_SEL_SINGLE3)->ShowWindow( false );
  503. GetDlgItem(IDC_BTN_REVERSE_SEL_ALL3)->ShowWindow( false );
  504. }
  505. else if( m_nType==1 )
  506. {
  507. GetDlgItem(IDC_STATIC1)->SetWindowText( "可选设备" );
  508. GetDlgItem(IDC_STATIC2)->SetWindowText( "已选设备" );
  509. GetDlgItem(IDC_LIST_SRC)->ShowWindow( false );
  510. GetDlgItem(IDC_LIST_DEST)->ShowWindow( false );
  511. GetDlgItem(IDC_BTN_SEL_SINGLE)->ShowWindow( false );
  512. GetDlgItem(IDC_BTN_SEL_ALL)->ShowWindow( false );
  513. GetDlgItem(IDC_BTN_REVERSE_SEL_SINGLE)->ShowWindow( false );
  514. GetDlgItem(IDC_BTN_REVERSE_SEL_ALL)->ShowWindow( false );
  515. GetDlgItem(IDC_LIST_SRC2)->ShowWindow( true );
  516. GetDlgItem(IDC_LIST_DEST2)->ShowWindow( true );
  517. GetDlgItem(IDC_BTN_SEL_SINGLE2)->ShowWindow( true );
  518. GetDlgItem(IDC_BTN_SEL_ALL2)->ShowWindow( true );
  519. GetDlgItem(IDC_BTN_REVERSE_SEL_SINGLE2)->ShowWindow( true );
  520. GetDlgItem(IDC_BTN_REVERSE_SEL_ALL2)->ShowWindow( true );
  521. GetDlgItem(IDC_LIST_SRC3)->ShowWindow( false );
  522. GetDlgItem(IDC_LIST_DEST3)->ShowWindow( false );
  523. GetDlgItem(IDC_BTN_SEL_SINGLE3)->ShowWindow( false );
  524. GetDlgItem(IDC_BTN_SEL_ALL3)->ShowWindow( false );
  525. GetDlgItem(IDC_BTN_REVERSE_SEL_SINGLE3)->ShowWindow( false );
  526. GetDlgItem(IDC_BTN_REVERSE_SEL_ALL3)->ShowWindow( false );
  527. }
  528. else
  529. {
  530. GetDlgItem(IDC_STATIC1)->SetWindowText( "可选用户" );
  531. GetDlgItem(IDC_STATIC2)->SetWindowText( "已选用户" );
  532. GetDlgItem(IDC_LIST_SRC)->ShowWindow( false );
  533. GetDlgItem(IDC_LIST_DEST)->ShowWindow( false );
  534. GetDlgItem(IDC_BTN_SEL_SINGLE)->ShowWindow( false );
  535. GetDlgItem(IDC_BTN_SEL_ALL)->ShowWindow( false );
  536. GetDlgItem(IDC_BTN_REVERSE_SEL_SINGLE)->ShowWindow( false );
  537. GetDlgItem(IDC_BTN_REVERSE_SEL_ALL)->ShowWindow( false );
  538. GetDlgItem(IDC_LIST_SRC2)->ShowWindow( false );
  539. GetDlgItem(IDC_LIST_DEST2)->ShowWindow( false );
  540. GetDlgItem(IDC_BTN_SEL_SINGLE2)->ShowWindow( false );
  541. GetDlgItem(IDC_BTN_SEL_ALL2)->ShowWindow( false );
  542. GetDlgItem(IDC_BTN_REVERSE_SEL_SINGLE2)->ShowWindow( false );
  543. GetDlgItem(IDC_BTN_REVERSE_SEL_ALL2)->ShowWindow( false );
  544. GetDlgItem(IDC_LIST_SRC3)->ShowWindow( true );
  545. GetDlgItem(IDC_LIST_DEST3)->ShowWindow( true );
  546. GetDlgItem(IDC_BTN_SEL_SINGLE3)->ShowWindow( true );
  547. GetDlgItem(IDC_BTN_SEL_ALL3)->ShowWindow( true );
  548. GetDlgItem(IDC_BTN_REVERSE_SEL_SINGLE3)->ShowWindow( true );
  549. GetDlgItem(IDC_BTN_REVERSE_SEL_ALL3)->ShowWindow( true );
  550. }
  551. }
  552. void CDlg_GroupManage::OnBnClickedRadio1()
  553. {
  554. IsVisibleCtrl();
  555. }
  556. void CDlg_GroupManage::OnBnClickedRadio2()
  557. {
  558. IsVisibleCtrl();
  559. }
  560. void CDlg_GroupManage::OnBnClickedRadio3()
  561. {
  562. IsVisibleCtrl();
  563. }