| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- // Login2.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "Login2.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Login2 dialog
- Login2::Login2(CWnd* pParent /*=NULL*/)
- : CDialog(Login2::IDD, pParent)
- {
- //{{AFX_DATA_INIT(Login2)
- m_psw = _T("");
- m_account = _T("");
- m_mode = 0;
- //}}AFX_DATA_INIT
- }
- void Login2::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(Login2)
- DDX_Control(pDX, IDC_COMBOaccount, m_comboaccount);
- DDX_Text(pDX, IDC_EDITpsw, m_psw);
- DDX_CBString(pDX, IDC_COMBOaccount, m_account);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(Login2, CDialog)
- //{{AFX_MSG_MAP(Login2)
- ON_WM_PAINT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // Login2 message handlers
- BOOL Login2::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- if (m_mode == 1)
- SetWindowText("修改订单产品授权");
- else if (m_mode == 2)
- SetWindowText("订单打折授权");
- else if (m_mode == 3)
- SetWindowText("修改日期授权");
- #if JEFF_TEST_OFF
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 23;
- g_sendhead.tabcount = 1;
- int g_nYearposTemp = g_nYearpos;
- g_nYearpos = -1;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- g_nYearpos = g_nYearposTemp;
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return 1;
- }
- DataToArray(&m_List1array);
- #endif
- CenterWindow(g_pMainWnd);
- try
- {
- CFile fp;
- if (fp.Open(g_mainpath + "\\loginuser.dat", CFile::modeRead))
- {
- DWORD length = fp.GetLength();
- if (!length)
- {
- fp.Close();
- return false;
- }
- CArchive ar(&fp, CArchive::load);
- m_userarray.Serialize(ar);
- fp.Close();
- for (int i = 0; i < m_userarray.GetSize(); i++)
- {
- m_comboaccount.AddString(m_userarray.ElementAt(i));
- }
- if (m_comboaccount.GetCount()>0)
- {
- m_comboaccount.SetCurSel(0);
- m_comboaccount.GetLBText(0, m_account);
- }
- }
- }
- catch (...)
- {
- }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void Login2::OnOK()
- {
- // TODO: Add extra validation here
- // AfxMessageBox("login2");
- UpdateData();
- if (m_account.IsEmpty())
- {
- AfxMessageBox("资料不全!", MB_ICONINFORMATION);
- return;
- }
- #if JEFF_TEST_ON
- CString strSQL;
- BYTE byPsw[50] = {0};
- #ifndef UNICODE
- memcpy(byPsw, (LPCSTR)m_psw, m_psw.GetLength());
- #endif
- CMD5 md5;
- md5.SetBYTEText(byPsw, m_psw.GetLength());
- strSQL.Format("account='%s' and psw='%s'", m_account, md5.GetMD5Digest());
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 23;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQL);
- if (!g_bSendOK)
- {
- AfxMessageBox("连接服务器失败");
- }
- m_List1array.RemoveAll();
- DataToArray(&m_List1array);
- if (m_List1array.GetSize() == 0)
- {
- AfxMessageBox("账号或密码错误");
- return;
- }
- else
- {
- m_name = m_List1array.ElementAt(0).ElementAt(1);
- m_rights = m_List1array.ElementAt(0).ElementAt(3);
- m_discount = m_List1array.ElementAt(0).ElementAt(5);
- m_discount2 = m_List1array.ElementAt(0).ElementAt(6);
- CDialog::OnOK();
- return;
- }
- #else
- for (int i = 0; i < m_List1array.GetSize(); i++)
- {
- if (m_account == m_List1array.ElementAt(i).ElementAt(0))
- {
- if (m_psw != m_List1array.ElementAt(i).ElementAt(2))
- {
- AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION); return;
- }
- else
- {
- m_name = m_List1array.ElementAt(i).ElementAt(1);
- m_rights = m_List1array.ElementAt(i).ElementAt(3);
- m_discount = m_List1array.ElementAt(i).ElementAt(5);
- m_discount2 = m_List1array.ElementAt(i).ElementAt(6);
- CDialog::OnOK();
- return;
- }
- }
- }
- AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
- #endif
- }
- void Login2::OnCancel()
- {
- // TODO: Add extra cleanup here
- CDialog::OnCancel();
- }
- void Login2::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- // TODO: Add your message handler code here
- #ifdef CCIV_SKIN
- CRect rc;
- GetClientRect(rc);
- CPicture pic;
- pic.Load (NULL, MAKEINTRESOURCE(IDR_JPG3), "JPG");
- pic.RenderBmp (&dc, rc);
- pic.UnloadPicture ();
- #endif
- // Do not call CDialog::OnPaint() for painting messages
- }
|