Account.cpp 17 KB

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