Login2.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. g_sendhead.bsql=0;
  49. g_sendhead.code[0]=23;
  50. g_sendhead.tabcount=1;
  51. int g_nYearposTemp=g_nYearpos;
  52. g_nYearpos=-1;
  53. g_pMainWnd->ProcessChatMessageRequest2(1);
  54. g_nYearpos=g_nYearposTemp;
  55. if(g_bSendOK==0)
  56. {
  57. CDialog::OnCancel();
  58. return 1;
  59. }
  60. DataToArray(&m_List1array);
  61. CenterWindow(g_pMainWnd);
  62. try
  63. {
  64. CFile fp;
  65. if(fp.Open (g_mainpath+"\\loginuser.dat", CFile::modeRead))
  66. {
  67. DWORD length=fp.GetLength ();
  68. if(!length)
  69. {
  70. fp.Close();
  71. return false;
  72. }
  73. CArchive ar(&fp, CArchive::load);
  74. m_userarray.Serialize (ar);
  75. fp.Close ();
  76. for(int i=0; i<m_userarray.GetSize (); i++)
  77. {
  78. m_comboaccount.AddString (m_userarray.ElementAt (i));
  79. }
  80. if(m_comboaccount.GetCount ()>0)
  81. {
  82. m_comboaccount.SetCurSel (0);
  83. m_comboaccount.GetLBText (0, m_account);
  84. }
  85. }
  86. }
  87. catch(...)
  88. {
  89. }
  90. return TRUE; // return TRUE unless you set the focus to a control
  91. // EXCEPTION: OCX Property Pages should return FALSE
  92. }
  93. void Login2::OnOK()
  94. {
  95. // TODO: Add extra validation here
  96. // AfxMessageBox("login2");
  97. UpdateData();
  98. if(m_account.IsEmpty())
  99. {
  100. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  101. return;
  102. }
  103. for(int i=0; i<m_List1array.GetSize(); i++)
  104. {
  105. if(m_account==m_List1array.ElementAt(i).ElementAt(0))
  106. {
  107. if(m_psw!=m_List1array.ElementAt(i).ElementAt(2))
  108. {
  109. AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION);return;
  110. }
  111. else
  112. {
  113. m_name=m_List1array.ElementAt(i).ElementAt(1);
  114. m_rights=m_List1array.ElementAt(i).ElementAt(3);
  115. m_discount=m_List1array.ElementAt(i).ElementAt(5);
  116. m_discount2=m_List1array.ElementAt(i).ElementAt(6);
  117. CDialog::OnOK();
  118. return;
  119. }
  120. }
  121. }
  122. AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
  123. }
  124. void Login2::OnCancel()
  125. {
  126. // TODO: Add extra cleanup here
  127. CDialog::OnCancel();
  128. }
  129. void Login2::OnPaint()
  130. {
  131. CPaintDC dc(this); // device context for painting
  132. // TODO: Add your message handler code here
  133. #ifdef CCIV_SKIN
  134. CRect rc;
  135. GetClientRect(rc);
  136. CPicture pic;
  137. pic.Load (NULL, MAKEINTRESOURCE(IDR_JPG3), "JPG");
  138. pic.RenderBmp (&dc, rc);
  139. pic.UnloadPicture ();
  140. #endif
  141. // Do not call CDialog::OnPaint() for painting messages
  142. }