Account.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. // Account.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "Account.h"
  6. #include "MyMdi.H"
  7. #include "SetLeftBar.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. //BOOL CALLBACK EnumChildProc_Accout(HWND hwnd, LPARAM lParam);
  14. /////////////////////////////////////////////////////////////////////////////
  15. // Account IDC_EDIT2
  16. IMPLEMENT_DYNCREATE(Account, MyFormView)
  17. Account::Account(): MyFormView(Account::IDD)
  18. {
  19. //{{AFX_DATA_INIT(Account)
  20. m_account = _T("");
  21. m_psw = _T("");
  22. m_psw2 = _T("");
  23. m_discount = "9.0";
  24. m_bAddNew = 1;
  25. m_discount2 = _T("9.0");
  26. m_nPurviewCounts = 66;
  27. //}}AFX_DATA_INIT
  28. }
  29. Account::~Account()
  30. {
  31. }
  32. void Account::DoDataExchange(CDataExchange* pDX)
  33. {
  34. MyFormView::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(Account)
  36. DDX_Control(pDX, IDC_SPIN1, m_spin1);
  37. DDX_Control(pDX, IDC_COMBOname, m_comboname);
  38. DDX_Control(pDX, IDC_LIST2, m_List1);
  39. DDX_Control(pDX, IDC_STATIC1, m_static1);
  40. DDX_Text(pDX, IDC_EDITaccount, m_account);
  41. DDX_Text(pDX, IDC_EDITpsw, m_psw);
  42. DDX_Text(pDX, IDC_EDITpsw2, m_psw2);
  43. DDX_Text(pDX, IDC_EDIT2, m_discount);
  44. DDX_Text(pDX, IDC_EDIT3, m_discount2);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(Account, MyFormView)
  48. //{{AFX_MSG_MAP(Account)
  49. ON_BN_CLICKED(IDC_BUTsave, OnBUTsave)
  50. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  51. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  52. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  53. ON_BN_CLICKED(IDC_BUTadd, OnBUTadd)
  54. ON_BN_CLICKED(IDC_BUTbm1, OnBUTbm1)
  55. ON_BN_CLICKED(IDC_BUTbm6, OnBUTbm6)
  56. ON_BN_CLICKED(IDC_BUTbm2, OnBUTbm2)
  57. ON_BN_CLICKED(IDC_BUTbm3, OnBUTbm3)
  58. ON_BN_CLICKED(IDC_BUTbm4, OnBUTbm4)
  59. ON_BN_CLICKED(IDC_BUTbm5, OnBUTbm5)
  60. ON_BN_CLICKED(IDC_BUTleftbar, OnBUTleftbar)
  61. ON_BN_CLICKED(IDC_CHECK27, OnCheck27)
  62. //}}AFX_MSG_MAP
  63. ON_BN_CLICKED(IDC_ResetPW_BTN, OnBnClickedResetpwBtn)
  64. END_MESSAGE_MAP()
  65. /////////////////////////////////////////////////////////////////////////////
  66. // Account diagnostics
  67. #ifdef _DEBUG
  68. void Account::AssertValid() const
  69. {
  70. MyFormView::AssertValid();
  71. }
  72. void Account::Dump(CDumpContext& dc) const
  73. {
  74. MyFormView::Dump(dc);
  75. }
  76. #endif //_DEBUG
  77. /////////////////////////////////////////////////////////////////////////////
  78. // Account message handlers
  79. void Account::OnInitialUpdate()
  80. {
  81. //AfxMessageBox("用户管理");
  82. MyFormView::OnInitialUpdate();
  83. // TODO: Add your specialized code here and/or call the base class
  84. CMyMdi Mdi;
  85. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  86. #ifdef LKAY_VERSION
  87. GetDlgItem(IDC_CHECK54)->ShowWindow(SW_SHOW);
  88. #endif
  89. #ifdef BASIC_VERSION
  90. GetDlgItem(IDC_BUTleftbar)->ShowWindow(0);
  91. #ifdef BASIC_ADDDRESS
  92. GetDlgItem(IDC_STATIC2)->ShowWindow(1);
  93. GetDlgItem(IDC_CHECK40)->ShowWindow(1);
  94. GetDlgItem(IDC_CHECK41)->ShowWindow(1);
  95. GetDlgItem(IDC_CHECK42)->ShowWindow(1);
  96. GetDlgItem(IDC_CHECK43)->ShowWindow(1);
  97. GetDlgItem(IDC_CHECK44)->ShowWindow(1);
  98. #endif
  99. #endif
  100. #ifdef ENTERPRISE_VERSION
  101. GetDlgItem(IDC_CHECK29)->ShowWindow(1);
  102. #endif
  103. // Here we create the outbar control using the splitter as its parent
  104. // and setting its id to the first pane.
  105. #if 1
  106. CRect rc2;
  107. GetWindowRect(rc2);
  108. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  109. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc_Accout, 0);
  110. m_comboname.GetWindowRect(rc2);
  111. ScreenToClient(rc2);
  112. rc2.bottom += 200;
  113. m_comboname.MoveWindow(rc2);
  114. #endif
  115. ((CEdit*)GetDlgItem(IDC_ResetPW_BTN))->ShowWindow(SW_HIDE);
  116. if(g_user.account == _T("admin") && g_user.name == _T("管理员"))
  117. ((CEdit*)GetDlgItem(IDC_ResetPW_BTN))->ShowWindow(SW_SHOW);
  118. m_spin1.SetRange(0, 10);
  119. m_static1.SetFont(&g_titlefont);
  120. m_List1.SetHeadings("账号, 60;姓名, 60;部门,60");
  121. m_List1.LoadColumnInfo(112);
  122. // Jeff初始化,向服务器获取用户信息;
  123. g_sendhead.bsql = 0;
  124. g_sendhead.code[0] = 23;
  125. g_sendhead.tabcount = 1;
  126. g_pMainWnd->ProcessChatMessageRequest2(5);
  127. if (g_bSendOK == 0) return;
  128. DataToArray(&m_List1array);
  129. int i = 0;
  130. m_List1arrayBak.SetSize(m_List1array.GetSize());
  131. for ( i = 0; i < m_List1array.GetSize(); i++)
  132. {
  133. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(0)); // Jeff.账号;
  134. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(1)); // Jeff.性名;
  135. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(8)); // Jeff.部门;
  136. }
  137. // Jeff:这里需要做个小处理,不添加已有账号的姓名到下拉框中;
  138. #if 0// OldEdition;
  139. for( i=0; i<g_userarray.GetSize(); i++)
  140. m_comboname.AddString (g_userarray.ElementAt (i).ElementAt (1));
  141. #else
  142. for (i = 0; i < g_userarray.GetSize(); i++)
  143. m_strNameArray.Add(g_userarray.ElementAt(i).ElementAt(1));
  144. for (i = 0; i < m_List1array.GetSize(); i++)
  145. {
  146. for (int j = 0; j < m_strNameArray.GetSize(); j++)
  147. if (m_List1array.ElementAt(i).ElementAt(1) == m_strNameArray.ElementAt(j))
  148. {
  149. m_strNameArray.RemoveAt(j);
  150. }
  151. }
  152. CommboboxReLoad();
  153. #endif
  154. FillGrid();
  155. }
  156. void Account::CommboboxReLoad()
  157. {
  158. m_comboname.ResetContent();
  159. for (int i = 0; i < m_strNameArray.GetSize(); i++)
  160. m_comboname.AddString(m_strNameArray.ElementAt(i));
  161. }
  162. void Account::FillGrid()
  163. {
  164. m_List1.DeleteAllItems2();
  165. int ii = 0;
  166. //m_List1.m_arLabels.SetSize( m_List1arrayBak.GetSize (), 1 ); // Jeff:old
  167. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  168. int count = 0;
  169. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  170. {
  171. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1arrayBak.ElementAt(ii));
  172. //m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  173. }
  174. m_List1.m_arLabels.SetSize(count, 1);
  175. ii = count;
  176. m_List1.m_LabelCount = ii;
  177. m_List1.SetItemCountEx(ii);
  178. UpdateData();
  179. //Invalidate();
  180. }
  181. void Account::OnBUTclose()
  182. {
  183. // TODO: Add your control notification handler code here
  184. GetParent()->SendMessage(WM_CLOSE);
  185. }
  186. void Account::ClearCtrl()
  187. {
  188. m_account = _T("");
  189. m_psw = _T("");
  190. m_psw2 = _T("");
  191. m_comboname.SetCurSel(-1);
  192. UpdateData(false);
  193. // m_nPurviewCounts 权限数量;
  194. for (int i = 0; i < m_nPurviewCounts; i++)
  195. ((CButton*)GetDlgItem(IDC_CHECK1 + i))->SetCheck(0);
  196. }
  197. void Account::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  198. {
  199. // TODO: Add your control notification handler code here
  200. ListSelChange();
  201. *pResult = 0;
  202. }
  203. void Account::ListSelChange()
  204. {
  205. #if 1 // Jeff 在选择列表时,启用删除按钮;
  206. GetDlgItem(IDC_BUTdel)->EnableWindow();
  207. #endif
  208. POSITION pos;
  209. pos = m_List1.GetFirstSelectedItemPosition();
  210. if (pos == NULL)
  211. {
  212. OnBUTadd();
  213. return;
  214. }
  215. GetDlgItem(IDC_BUTleftbar)->EnableWindow(1);
  216. m_bAddNew = 0;
  217. GetDlgItem(IDC_EDITaccount)->EnableWindow(0);
  218. GetDlgItem(IDC_COMBOname)->EnableWindow(0);
  219. GetDlgItem(IDC_EDITpsw)->EnableWindow(0);
  220. GetDlgItem(IDC_EDITpsw2)->EnableWindow(0);
  221. int iItem = m_List1.GetNextSelectedItem(pos);
  222. CString account = m_List1.GetItemText(iItem, 0);
  223. for (int ii = 0; ii < m_List1array.GetSize(); ii++)
  224. {
  225. if (m_List1array.ElementAt(ii).ElementAt(0) == account)
  226. {
  227. CString name, rights;
  228. m_account = m_List1array.ElementAt(ii).ElementAt(0);
  229. name = m_List1array.ElementAt(ii).ElementAt(1);
  230. m_psw = m_psw2 = m_List1array.ElementAt(ii).ElementAt(2);
  231. rights = m_List1array.ElementAt(ii).ElementAt(3);
  232. m_discount.Format("%0.1f", atof(m_List1array.ElementAt(ii).ElementAt(5)));
  233. m_discount2.Format("%0.1f", atof(m_List1array.ElementAt(ii).ElementAt(6)));
  234. UpdateData(false);
  235. //int nIndex =0 ;
  236. int pos = m_comboname.FindString(0, name);
  237. if (pos != -1)
  238. m_comboname.SetCurSel(pos);
  239. else
  240. {
  241. m_comboname.InsertString(0, name);
  242. m_comboname.SetCurSel(0);
  243. }
  244. SetRights(rights);
  245. return;
  246. }
  247. }
  248. }
  249. void Account::OnBUTadd() // 添加新账号按钮; 添加时禁用删除按钮;
  250. {
  251. // TODO: Add your control notification handler code here
  252. CommboboxReLoad();
  253. m_bAddNew = 1;
  254. GetDlgItem(IDC_EDITaccount)->EnableWindow(1);
  255. GetDlgItem(IDC_COMBOname)->EnableWindow(1);
  256. GetDlgItem(IDC_EDITpsw)->EnableWindow(1);
  257. GetDlgItem(IDC_EDITpsw2)->EnableWindow(1);
  258. ClearCtrl();
  259. GetDlgItem(IDC_BUTleftbar)->EnableWindow(0);
  260. #if 1 // Jeff添加时禁用删除按钮;
  261. GetDlgItem(IDC_BUTdel)->EnableWindow(0);
  262. #endif
  263. }
  264. void Account::OnBUTsave() // 保存按钮;
  265. {
  266. // TODO: Add your control notification handler code here
  267. UpdateData();
  268. CString name;
  269. CString rights = GetRights();
  270. CString sql;
  271. if (m_bAddNew)
  272. {
  273. if (m_account.IsEmpty())
  274. {
  275. AfxMessageBox("资料不全!", MB_ICONINFORMATION); return;
  276. }
  277. int pos = m_comboname.GetCurSel();
  278. if (pos == -1)
  279. {
  280. AfxMessageBox("资料不全!", MB_ICONINFORMATION); return;
  281. }
  282. m_comboname.GetLBText(pos, name);
  283. if (m_psw != m_psw2)
  284. {
  285. AfxMessageBox("密码不一至!", MB_ICONINFORMATION); return;
  286. }
  287. if (IsExist(m_account, name))
  288. {
  289. AfxMessageBox("已有此账号或姓名,请重新输入!", MB_ICONINFORMATION);
  290. return;
  291. }
  292. // 使用MD5加密密码;
  293. BYTE byPsw[50] = {0};
  294. #ifndef UNICODE
  295. memcpy(byPsw, (LPCSTR)m_psw, m_psw.GetLength());
  296. #endif
  297. CMD5 md5;
  298. md5.SetBYTEText(byPsw, strlen((char*)byPsw));
  299. CString strMD5 = md5.GetMD5Digest();
  300. sql.Format("insert into [user](account,name,psw,rights,discount,discount2) values('%s','%s','%s','%s','%0.1f','%0.1f')", m_account, name, strMD5, rights, atof(m_discount), atof(m_discount2));
  301. sql += USER_REF;
  302. g_sendhead.bsql = 1;
  303. g_pMainWnd->ProcessChatMessageRequest2(sql);
  304. if (g_bSendOK == 0)
  305. return;
  306. #if 1 // Jeff添加成功后,要删除m_strNameArray里的存根;
  307. for (int i(0); i < m_strNameArray.GetSize(); i++)
  308. {
  309. if (name == m_strNameArray.ElementAt(i))
  310. {
  311. m_strNameArray.RemoveAt(i);
  312. break;
  313. }
  314. }
  315. ClearCtrl();
  316. CommboboxReLoad();
  317. #endif
  318. GetData();
  319. }
  320. else//修改
  321. {
  322. sql.Format("update [user] set [rights]='%s',[discount]='%0.1f',[discount2]='%0.1f' where [account]='%s' ", rights, atof(m_discount), atof(m_discount2), m_account);
  323. sql += USER_REF;
  324. g_sendhead.bsql = 1;
  325. g_pMainWnd->ProcessChatMessageRequest2(sql);
  326. if (g_bSendOK == 0)
  327. return;
  328. GetData();
  329. }
  330. UpdateData(FALSE);
  331. }
  332. void Account::OnBUTdel() // 删除按钮;
  333. {
  334. // TODO: Add your control notification handler code here
  335. POSITION pos;
  336. pos = m_List1.GetFirstSelectedItemPosition();
  337. if (pos == NULL)
  338. {
  339. return;
  340. }
  341. if (AfxMessageBox("确认删除吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  342. int iItem = m_List1.GetNextSelectedItem(pos);
  343. CString account = m_List1.GetItemText(iItem, 0);
  344. if (account == "admin")
  345. {
  346. AfxMessageBox("管理员不能删除");
  347. return;
  348. }
  349. CString sql;
  350. sql.Format("delete from [user] where [account]='%s' ", account);
  351. sql += USER_REF;
  352. g_sendhead.bsql = 1;
  353. g_pMainWnd->ProcessChatMessageRequest2(sql);
  354. if (g_bSendOK == 0)
  355. return;
  356. #if 1 // Jeff 删除时要清空文本框;
  357. CString strName = m_List1.GetItemText(iItem, 1);
  358. //BOOL bNameInArray = FALSE;
  359. ClearCtrl();
  360. //for ( int i(0); i < m_strNameArray.GetSize(); i++)
  361. //{
  362. // if ( name == m_strNameArray.ElementAt(i))
  363. // {
  364. // bNameInArray = TRUE;
  365. // break;
  366. // }
  367. // }
  368. //if ( !bNameInArray )
  369. // {
  370. m_strNameArray.Add(strName);
  371. //}
  372. CommboboxReLoad();
  373. #endif
  374. GetData();
  375. }
  376. void Account::GetData()
  377. {
  378. g_sendhead.bsql = 0;
  379. g_sendhead.code[0] = 23;
  380. g_sendhead.tabcount = 1;
  381. g_pMainWnd->ProcessChatMessageRequest2(23);
  382. DataToArray(&m_List1array);
  383. // Jeff add:在getdata里处理;
  384. m_List1arrayBak.RemoveAll();
  385. m_List1arrayBak.SetSize(m_List1array.GetSize());
  386. for (int i = 0; i < m_List1array.GetSize(); i++)
  387. {
  388. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(0));
  389. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(1));
  390. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(8));
  391. }
  392. //
  393. FillGrid();
  394. }
  395. BOOL Account::IsExist(CString account, CString name)
  396. {
  397. for (int i = 0; i < m_List1array.GetSize(); i++)
  398. {
  399. if (account == m_List1array.ElementAt(i).ElementAt(0))return 1;
  400. if (name == m_List1array.ElementAt(i).ElementAt(1))return 1;
  401. }
  402. return 0;
  403. }
  404. CString Account::GetRights()//50
  405. {
  406. CString ret, temp;
  407. // 权限个数;
  408. for (int i = 0; i < m_nPurviewCounts; i++)
  409. {
  410. temp.Format("%d", ((CButton*)GetDlgItem(IDC_CHECK1 + i))->GetCheck());
  411. ret += temp;
  412. }
  413. return ret;
  414. }
  415. void Account::SetRights(CString rights)
  416. {
  417. int i = 0;
  418. for ( i = 0; i < rights.GetLength(); i++)
  419. {
  420. if (i >= m_nPurviewCounts) break;
  421. ((CButton*)GetDlgItem(IDC_CHECK1 + i))->SetCheck(rights.GetAt(i) == '1');
  422. }
  423. for (i = rights.GetLength(); i < m_nPurviewCounts; i++)
  424. {
  425. ((CButton*)GetDlgItem(IDC_CHECK1 + i))->SetCheck(0);
  426. }
  427. }
  428. void Account::OnBUTbm6()
  429. {
  430. // TODO: Add your control notification handler code here
  431. POSITION pos;
  432. pos = m_List1.GetFirstSelectedItemPosition();
  433. if (pos)
  434. {
  435. int iItem = m_List1.GetNextSelectedItem(pos);
  436. CString account = m_List1.GetItemText(iItem, 0);
  437. if (account == "admin")
  438. {
  439. SetRights("\
  440. 0000000000\
  441. 0000000000\
  442. 0000000000\
  443. 0000000000\
  444. 0000000001\
  445. 0000000000\
  446. 000000");
  447. return;
  448. }
  449. }
  450. SetRights("\
  451. 0000000000\
  452. 0000000000\
  453. 0000000000\
  454. 0000000000\
  455. 0000000000\
  456. 0000000000\
  457. 000000");
  458. }
  459. void Account::OnBUTbm1()
  460. {
  461. // TODO: Add your control notification handler code here
  462. ((CButton*)GetDlgItem(IDC_CHECK1 + 0))->SetCheck(1);
  463. ((CButton*)GetDlgItem(IDC_CHECK1 + 15))->SetCheck(1);
  464. }
  465. void Account::OnBUTbm2()
  466. {
  467. // TODO: Add your control notification handler code here
  468. ((CButton*)GetDlgItem(IDC_CHECK1 + 4))->SetCheck(1);
  469. ((CButton*)GetDlgItem(IDC_CHECK1 + 5))->SetCheck(1);
  470. ((CButton*)GetDlgItem(IDC_CHECK1 + 8))->SetCheck(1);
  471. ((CButton*)GetDlgItem(IDC_CHECK1 + 15))->SetCheck(1);
  472. }
  473. void Account::OnBUTbm3()
  474. {
  475. // TODO: Add your control notification handler code here
  476. ((CButton*)GetDlgItem(IDC_CHECK1 + 5))->SetCheck(1);
  477. ((CButton*)GetDlgItem(IDC_CHECK1 + 6))->SetCheck(1);
  478. ((CButton*)GetDlgItem(IDC_CHECK1 + 7))->SetCheck(1);
  479. ((CButton*)GetDlgItem(IDC_CHECK1 + 8))->SetCheck(1);
  480. ((CButton*)GetDlgItem(IDC_CHECK1 + 9))->SetCheck(1);
  481. ((CButton*)GetDlgItem(IDC_CHECK1 + 10))->SetCheck(1);
  482. ((CButton*)GetDlgItem(IDC_CHECK1 + 11))->SetCheck(1);
  483. ((CButton*)GetDlgItem(IDC_CHECK1 + 12))->SetCheck(1);
  484. }
  485. void Account::OnBUTbm4()
  486. {
  487. // TODO: Add your control notification handler code here
  488. ((CButton*)GetDlgItem(IDC_CHECK1 + 16))->SetCheck(1);
  489. ((CButton*)GetDlgItem(IDC_CHECK1 + 17))->SetCheck(1);
  490. ((CButton*)GetDlgItem(IDC_CHECK1 + 18))->SetCheck(1);
  491. ((CButton*)GetDlgItem(IDC_CHECK1 + 19))->SetCheck(1);
  492. ((CButton*)GetDlgItem(IDC_CHECK1 + 20))->SetCheck(1);
  493. ((CButton*)GetDlgItem(IDC_CHECK1 + 21))->SetCheck(1);
  494. ((CButton*)GetDlgItem(IDC_CHECK1 + 22))->SetCheck(1);
  495. }
  496. void Account::OnBUTbm5()
  497. {
  498. // TODO: Add your control notification handler code here
  499. SetRights("\
  500. 1111111111\
  501. 1111111111\
  502. 1111111111\
  503. 1111111111\
  504. 1111111111\
  505. 1111111111\
  506. 111111");
  507. BOOL bCheck = ((CButton*)GetDlgItem(IDC_CHECK50))->GetCheck();
  508. ((CButton*)GetDlgItem(IDC_CHECK50))->SetCheck(!bCheck);
  509. }
  510. void Account::OnBUTleftbar() // 界面设置
  511. {
  512. // TODO: Add your control notification handler code here
  513. SetLeftBar dlg;
  514. dlg.m_account = m_account;
  515. dlg.DoModal();
  516. }
  517. void Account::OnCheck27()
  518. {
  519. // TODO: Add your control notification handler code here
  520. // if(((CButton*)GetDlgItem(IDC_CHECK27))->GetCheck())
  521. // {
  522. // }
  523. }
  524. /************************************************************************/
  525. /*
  526. 函数:EnumChildProc_Accout
  527. 参数:
  528. 返回:
  529. 要求:
  530. 注意:
  531. 示例:
  532. */
  533. /************************************************************************/
  534. BOOL Account::EnumChildProc_Accout(HWND hwnd, LPARAM lParam)
  535. {
  536. // 1182 与 537 是资源对话框的像素值;而不是由GetWindowsRect获得的;
  537. static float fWidthScale = ((float)g_rc.Width()) / 1182.0;
  538. static float fHeightScale = ((float)g_rc.Height()) / 537.0;
  539. // static float fWidthScale = ((float)g_rc.Width()) / m_rct.Width();
  540. // static float fHeightScale = ((float)g_rc.Height()) / m_rct.Height();
  541. CRect rtCtrl, rtWnd; // 子窗口,父窗口;
  542. if (hwnd)
  543. {
  544. float temp;
  545. TCHAR szClassName[MAX_PATH];
  546. ::GetClassName(hwnd, szClassName, MAX_PATH);
  547. ::GetWindowRect(hwnd, &rtCtrl); // 获取控件大小;
  548. ::GetWindowRect(::GetParent(hwnd), &rtWnd); // 获取父窗口大小;
  549. // CString strRect;
  550. // strRect.Format(_T("A %d,%d,%d,%d"),rtCtrl.left,rtCtrl.top,rtCtrl.right,rtCtrl.bottom);
  551. // AfxMessageBox(strRect);
  552. //
  553. // strRect.Format(_T("B %d,%d,%d,%d"),rtWnd.left,rtWnd.top,rtWnd.right,rtWnd.bottom);
  554. // AfxMessageBox(strRect);
  555. //if ( _tcscmp(szClassName,_T("EDIT")) != 0 )
  556. if ( strcmp(szClassName,_T("EDIT")) != 0 )
  557. {
  558. rtCtrl.OffsetRect(-rtWnd.left, -rtWnd.top);
  559. temp = (float)rtCtrl.left*fWidthScale;
  560. rtCtrl.left = (int)temp + g_dx;
  561. temp = (float)rtCtrl.top*fHeightScale;
  562. rtCtrl.top = (int)temp + g_dy;
  563. temp = (float)rtCtrl.right*fWidthScale;
  564. rtCtrl.right = (int)temp + g_dx;
  565. temp = (float)rtCtrl.bottom*fHeightScale;
  566. rtCtrl.bottom = (int)temp + g_dy;
  567. }
  568. else
  569. {
  570. rtCtrl.OffsetRect(-rtWnd.left, -rtWnd.top);
  571. temp = (float)rtCtrl.left*fWidthScale;
  572. rtCtrl.left = (int)temp + g_dx;
  573. temp = (float)rtCtrl.top*fHeightScale;
  574. rtCtrl.top = (int)temp + g_dy;
  575. temp = (float)rtCtrl.right*fWidthScale;
  576. rtCtrl.right = (int)temp + g_dx;
  577. temp = (float)rtCtrl.bottom*fHeightScale;
  578. rtCtrl.bottom = (int)temp + g_dy;
  579. }
  580. ::MoveWindow(hwnd, rtCtrl.left, rtCtrl.top, rtCtrl.Width(), rtCtrl.Height(), TRUE);
  581. return TRUE;
  582. }
  583. else
  584. {
  585. return FALSE;
  586. }
  587. }
  588. void Account::OnBnClickedResetpwBtn() // 重置员工密码;
  589. {
  590. if(g_user.account != _T("admin") || g_user.name != _T("管理员"))
  591. return;
  592. if(m_account == _T(""))
  593. {
  594. MessageBox(_T("请选择要重置的用户"));
  595. return;
  596. }
  597. if(AfxMessageBox(_T("确定要重置此用户的密码?"), MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  598. CString strSql = _T("");
  599. strSql.Format(_T("update [user] set [psw]='81dc9bdb52d04dc20036dbd8313ed055' where [account]='%s'"), m_account);
  600. strSql += USER_REF;
  601. g_sendhead.bsql = 1;
  602. g_pMainWnd->ProcessChatMessageRequest2(strSql);
  603. if (g_bSendOK == 0)
  604. return;
  605. MessageBox(_T("密码重置成功,当前密码:1234"));
  606. }