Login2.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. else if (m_mode == 4)
  49. SetWindowText(_T("修改预约单日期授权"));
  50. #if JEFF_TEST_OFF
  51. g_sendhead.bsql = 0;
  52. g_sendhead.code[0] = 23;
  53. g_sendhead.tabcount = 1;
  54. int g_nYearposTemp = g_nYearpos;
  55. g_nYearpos = -1;
  56. g_pMainWnd->ProcessChatMessageRequest2(1);
  57. g_nYearpos = g_nYearposTemp;
  58. if (g_bSendOK == 0)
  59. {
  60. CDialog::OnCancel();
  61. return 1;
  62. }
  63. DataToArray(&m_List1array);
  64. #endif
  65. CenterWindow(g_pMainWnd);
  66. try
  67. {
  68. CFile fp;
  69. if (fp.Open(g_mainpath + "\\loginuser.dat", CFile::modeRead))
  70. {
  71. DWORD length = fp.GetLength();
  72. if (!length)
  73. {
  74. fp.Close();
  75. return false;
  76. }
  77. CArchive ar(&fp, CArchive::load);
  78. m_userarray.Serialize(ar);
  79. fp.Close();
  80. for (int i = 0; i < m_userarray.GetSize(); i++)
  81. {
  82. m_comboaccount.AddString(m_userarray.ElementAt(i));
  83. }
  84. if (m_comboaccount.GetCount()>0)
  85. {
  86. m_comboaccount.SetCurSel(0);
  87. m_comboaccount.GetLBText(0, m_account);
  88. }
  89. }
  90. }
  91. catch (...)
  92. {
  93. }
  94. return TRUE; // return TRUE unless you set the focus to a control
  95. // EXCEPTION: OCX Property Pages should return FALSE
  96. }
  97. void Login2::OnOK()
  98. {
  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. MessageBox(_T("提示"),_T("连接服务器失败"),MB_OK | MB_TOPMOST);
  122. }
  123. m_List1array.RemoveAll();
  124. DataToArray(&m_List1array);
  125. if (m_List1array.GetSize() == 0)
  126. {
  127. AfxMessageBox("账号或密码错误");
  128. return;
  129. }
  130. else
  131. {
  132. m_name = m_List1array.ElementAt(0).ElementAt(1);
  133. m_rights = m_List1array.ElementAt(0).ElementAt(3);
  134. m_discount = m_List1array.ElementAt(0).ElementAt(5);
  135. m_discount2 = m_List1array.ElementAt(0).ElementAt(6);
  136. CDialog::OnOK();
  137. return;
  138. }
  139. #else
  140. for (int i = 0; i < m_List1array.GetSize(); i++)
  141. {
  142. if (m_account == m_List1array.ElementAt(i).ElementAt(0))
  143. {
  144. if (m_psw != m_List1array.ElementAt(i).ElementAt(2))
  145. {
  146. AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION); return;
  147. }
  148. else
  149. {
  150. m_name = m_List1array.ElementAt(i).ElementAt(1);
  151. m_rights = m_List1array.ElementAt(i).ElementAt(3);
  152. m_discount = m_List1array.ElementAt(i).ElementAt(5);
  153. m_discount2 = m_List1array.ElementAt(i).ElementAt(6);
  154. CDialog::OnOK();
  155. return;
  156. }
  157. }
  158. }
  159. AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
  160. #endif
  161. }
  162. void Login2::OnCancel()
  163. {
  164. // TODO: Add extra cleanup here
  165. CDialog::OnCancel();
  166. }
  167. void Login2::OnPaint()
  168. {
  169. CPaintDC dc(this); // device context for painting
  170. // TODO: Add your message handler code here
  171. #ifdef CCIV_SKIN
  172. CRect rc;
  173. GetClientRect(rc);
  174. CPicture pic;
  175. pic.Load (NULL, MAKEINTRESOURCE(IDR_JPG3), "JPG");
  176. pic.RenderBmp (&dc, rc);
  177. pic.UnloadPicture ();
  178. #endif
  179. // Do not call CDialog::OnPaint() for painting messages
  180. }