Psw.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Psw.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "Psw.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // Psw dialog
  13. Psw::Psw(CWnd* pParent /*=NULL*/): CDialog(Psw::IDD, pParent)
  14. {
  15. m_account = _T("");
  16. m_psw = _T("");
  17. m_psw2 = _T("");
  18. m_psw3 = _T("");
  19. }
  20. void Psw::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(Psw)
  24. DDX_Text(pDX, IDC_EDITaccount, m_account);
  25. DDX_Text(pDX, IDC_EDITpsw, m_psw);
  26. DDX_Text(pDX, IDC_EDITpsw2, m_psw2);
  27. DDX_Text(pDX, IDC_EDITpsw3, m_psw3);
  28. //}}AFX_DATA_MAP
  29. }
  30. BEGIN_MESSAGE_MAP(Psw, CDialog)
  31. //{{AFX_MSG_MAP(Psw)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. void Psw::OnOK()
  36. {
  37. UpdateData();
  38. BYTE byPsw[50] = {0};
  39. #ifndef UNICODE
  40. memcpy(byPsw, (LPCSTR)m_psw, m_psw.GetLength());
  41. #endif
  42. CMD5 md5;
  43. md5.SetBYTEText(byPsw, strlen((char*)byPsw));
  44. CString strMD5 = md5.GetMD5Digest();
  45. if (strMD5 != m_List1array.ElementAt(0).ElementAt(2))
  46. {
  47. AfxMessageBox("旧密码错误!", MB_ICONINFORMATION);
  48. return;
  49. }
  50. if (m_psw3 != m_psw2)
  51. {
  52. AfxMessageBox("新密码不一至!", MB_ICONINFORMATION);
  53. return;
  54. }
  55. CString sql;
  56. #ifndef UNICODE
  57. memset(byPsw, 0 , 50);
  58. memcpy(byPsw, (LPCSTR)m_psw3, m_psw3.GetLength());
  59. md5.SetBYTEText(byPsw, strlen((char*)byPsw));
  60. #endif
  61. strMD5 = md5.GetMD5Digest();
  62. sql = "update [user] set [psw]='" + strMD5 + "' where [account]='" + m_account + "'";
  63. g_sendhead.bsql = 1;
  64. g_pMainWnd->ProcessChatMessageRequest2(sql);
  65. if (g_bSendOK == 0)return;
  66. CDialog::OnOK();
  67. }
  68. BOOL Psw::OnInitDialog()
  69. {
  70. CDialog::OnInitDialog();
  71. g_sendhead.bsql = 0;
  72. g_sendhead.code[0] = 23;
  73. g_sendhead.tabcount = 1;
  74. CString sql;
  75. sql = "name='" + g_user.name + "'";
  76. g_pMainWnd->ProcessChatMessageRequest2(sql);
  77. if (g_bSendOK == 0)return 1;
  78. DataToArray(&m_List1array);
  79. if (m_List1array.GetSize() == 0)
  80. {
  81. CDialog::OnCancel();
  82. return true;
  83. }
  84. m_account = m_List1array.ElementAt(0).ElementAt(0);
  85. UpdateData(false);
  86. this->CenterWindow(g_pMainWnd);
  87. return TRUE;
  88. }