Login2.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // Login2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "Login2.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // Login2 dialog
  13. Login2::Login2(CWnd* pParent /*=NULL*/)
  14. : CDialog(Login2::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(Login2)
  17. m_psw = _T("");
  18. m_account = _T("");
  19. m_mode = 0;
  20. //}}AFX_DATA_INIT
  21. }
  22. void Login2::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(Login2)
  26. DDX_Control(pDX, IDC_COMBOaccount, m_comboaccount);
  27. DDX_Text(pDX, IDC_EDITpsw, m_psw);
  28. DDX_CBString(pDX, IDC_COMBOaccount, m_account);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(Login2, CDialog)
  32. //{{AFX_MSG_MAP(Login2)
  33. ON_WM_PAINT()
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Login2 message handlers
  38. BOOL Login2::OnInitDialog()
  39. {
  40. CDialog::OnInitDialog();
  41. // TODO: Add extra initialization here
  42. if (m_mode == 1)
  43. SetWindowText("修改订单产品授权");
  44. else if (m_mode == 2)
  45. SetWindowText("订单打折授权");
  46. else if (m_mode == 3)
  47. SetWindowText("修改日期授权");
  48. #if JEFF_TEST_OFF
  49. g_sendhead.bsql = 0;
  50. g_sendhead.code[0] = 23;
  51. g_sendhead.tabcount = 1;
  52. int g_nYearposTemp = g_nYearpos;
  53. g_nYearpos = -1;
  54. g_pMainWnd->ProcessChatMessageRequest2(1);
  55. g_nYearpos = g_nYearposTemp;
  56. if (g_bSendOK == 0)
  57. {
  58. CDialog::OnCancel();
  59. return 1;
  60. }
  61. DataToArray(&m_List1array);
  62. #endif
  63. CenterWindow(g_pMainWnd);
  64. try
  65. {
  66. CFile fp;
  67. if (fp.Open(g_mainpath + "\\loginuser.dat", CFile::modeRead))
  68. {
  69. DWORD length = fp.GetLength();
  70. if (!length)
  71. {
  72. fp.Close();
  73. return false;
  74. }
  75. CArchive ar(&fp, CArchive::load);
  76. m_userarray.Serialize(ar);
  77. fp.Close();
  78. for (int i = 0; i < m_userarray.GetSize(); i++)
  79. {
  80. m_comboaccount.AddString(m_userarray.ElementAt(i));
  81. }
  82. if (m_comboaccount.GetCount()>0)
  83. {
  84. m_comboaccount.SetCurSel(0);
  85. m_comboaccount.GetLBText(0, m_account);
  86. }
  87. }
  88. }
  89. catch (...)
  90. {
  91. }
  92. return TRUE; // return TRUE unless you set the focus to a control
  93. // EXCEPTION: OCX Property Pages should return FALSE
  94. }
  95. void Login2::OnOK()
  96. {
  97. // TODO: Add extra validation here
  98. // AfxMessageBox("login2");
  99. UpdateData();
  100. if (m_account.IsEmpty())
  101. {
  102. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  103. return;
  104. }
  105. #if JEFF_TEST_ON
  106. CString strSQL;
  107. BYTE byPsw[50] = {0};
  108. #ifndef UNICODE
  109. memcpy(byPsw, (LPCSTR)m_psw, m_psw.GetLength());
  110. #endif
  111. CMD5 md5;
  112. md5.SetBYTEText(byPsw, m_psw.GetLength());
  113. strSQL.Format("account='%s' and psw='%s'", m_account, md5.GetMD5Digest());
  114. g_sendhead.bsql = 0;
  115. g_sendhead.code[0] = 23;
  116. g_sendhead.tabcount = 1;
  117. g_pMainWnd->ProcessChatMessageRequest2(strSQL);
  118. if (!g_bSendOK)
  119. {
  120. AfxMessageBox("连接服务器失败");
  121. }
  122. m_List1array.RemoveAll();
  123. DataToArray(&m_List1array);
  124. if (m_List1array.GetSize() == 0)
  125. {
  126. AfxMessageBox("账号或密码错误");
  127. return;
  128. }
  129. else
  130. {
  131. m_name = m_List1array.ElementAt(0).ElementAt(1);
  132. m_rights = m_List1array.ElementAt(0).ElementAt(3);
  133. m_discount = m_List1array.ElementAt(0).ElementAt(5);
  134. m_discount2 = m_List1array.ElementAt(0).ElementAt(6);
  135. CDialog::OnOK();
  136. return;
  137. }
  138. #else
  139. for (int i = 0; i < m_List1array.GetSize(); i++)
  140. {
  141. if (m_account == m_List1array.ElementAt(i).ElementAt(0))
  142. {
  143. if (m_psw != m_List1array.ElementAt(i).ElementAt(2))
  144. {
  145. AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION); return;
  146. }
  147. else
  148. {
  149. m_name = m_List1array.ElementAt(i).ElementAt(1);
  150. m_rights = m_List1array.ElementAt(i).ElementAt(3);
  151. m_discount = m_List1array.ElementAt(i).ElementAt(5);
  152. m_discount2 = m_List1array.ElementAt(i).ElementAt(6);
  153. CDialog::OnOK();
  154. return;
  155. }
  156. }
  157. }
  158. AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
  159. #endif
  160. }
  161. void Login2::OnCancel()
  162. {
  163. // TODO: Add extra cleanup here
  164. CDialog::OnCancel();
  165. }
  166. void Login2::OnPaint()
  167. {
  168. CPaintDC dc(this); // device context for painting
  169. // TODO: Add your message handler code here
  170. #ifdef CCIV_SKIN
  171. CRect rc;
  172. GetClientRect(rc);
  173. CPicture pic;
  174. pic.Load (NULL, MAKEINTRESOURCE(IDR_JPG3), "JPG");
  175. pic.RenderBmp (&dc, rc);
  176. pic.UnloadPicture ();
  177. #endif
  178. // Do not call CDialog::OnPaint() for painting messages
  179. }