Psw.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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*/)
  14. : CDialog(Psw::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(Psw)
  17. m_account = _T("");
  18. m_psw = _T("");
  19. m_psw2 = _T("");
  20. m_psw3 = _T("");
  21. //}}AFX_DATA_INIT
  22. }
  23. void Psw::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CDialog::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(Psw)
  27. DDX_Text(pDX, IDC_EDITaccount, m_account);
  28. DDX_Text(pDX, IDC_EDITpsw, m_psw);
  29. DDX_Text(pDX, IDC_EDITpsw2, m_psw2);
  30. DDX_Text(pDX, IDC_EDITpsw3, m_psw3);
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(Psw, CDialog)
  34. //{{AFX_MSG_MAP(Psw)
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // Psw message handlers
  39. void Psw::OnOK()
  40. {
  41. // TODO: Add extra validation here
  42. UpdateData();
  43. BYTE byPsw[50] = {0};
  44. #ifndef UNICODE
  45. memcpy(byPsw, (LPCSTR)m_psw, m_psw.GetLength());
  46. #endif
  47. CMD5 md5;
  48. md5.SetBYTEText(byPsw, strlen((char*)byPsw));
  49. CString strMD5 = md5.GetMD5Digest();
  50. if (strMD5 != m_List1array.ElementAt(0).ElementAt(2))
  51. {
  52. AfxMessageBox("旧密码错误!", MB_ICONINFORMATION);
  53. return;
  54. }
  55. if (m_psw3 != m_psw2)
  56. {
  57. AfxMessageBox("新密码不一至!", MB_ICONINFORMATION);
  58. return;
  59. }
  60. CString sql;
  61. #ifndef UNICODE
  62. memset(byPsw, 0 , 50);
  63. memcpy(byPsw, (LPCSTR)m_psw3, m_psw3.GetLength());
  64. md5.SetBYTEText(byPsw, strlen((char*)byPsw));
  65. #endif
  66. strMD5 = md5.GetMD5Digest();
  67. sql = "update [user] set [psw]='" + strMD5 + "' where [account]='" + m_account + "'";
  68. g_sendhead.bsql = 1;
  69. g_pMainWnd->ProcessChatMessageRequest2(sql);
  70. if (g_bSendOK == 0)return;
  71. CDialog::OnOK();
  72. }
  73. BOOL Psw::OnInitDialog()
  74. {
  75. CDialog::OnInitDialog();
  76. // TODO: Add extra initialization here
  77. g_sendhead.bsql = 0;
  78. g_sendhead.code[0] = 23;
  79. g_sendhead.tabcount = 1;
  80. CString sql;
  81. sql = "name='" + g_user.name + "'";
  82. g_pMainWnd->ProcessChatMessageRequest2(sql);
  83. if (g_bSendOK == 0)return 1;
  84. DataToArray(&m_List1array);
  85. if (m_List1array.GetSize() == 0)
  86. {
  87. CDialog::OnCancel();
  88. return true;
  89. }
  90. m_account = m_List1array.ElementAt(0).ElementAt(0);
  91. UpdateData(false);
  92. this->CenterWindow(g_pMainWnd);
  93. return TRUE; // return TRUE unless you set the focus to a control
  94. // EXCEPTION: OCX Property Pages should return FALSE
  95. }