Login.cpp
上传用户:hahaxixi
上传日期:2022-04-15
资源大小:1939k
文件大小:2k
源码类别:

手机短信编程

开发平台:

Visual C++

  1. // Login.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "NoteManage.h"
  5. #include "Login.h"
  6. #include "ADOConn.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CLogin dialog
  14. CLogin::CLogin(CWnd* pParent /*=NULL*/)
  15. : CDialog(CLogin::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CLogin)
  18. m_Name = _T("");
  19. m_PassWord = _T("");
  20. //}}AFX_DATA_INIT
  21. m_Time = 0;
  22. }
  23. void CLogin::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CDialog::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CLogin)
  27. DDX_Control(pDX, IDOK, m_OK);
  28. DDX_Control(pDX, IDCANCEL, m_Cancel);
  29. DDX_Text(pDX, IDC_EDIT1, m_Name);
  30. DDX_Text(pDX, IDC_EDIT2, m_PassWord);
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(CLogin, CDialog)
  34. //{{AFX_MSG_MAP(CLogin)
  35. // NOTE: the ClassWizard will add message map macros here
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CLogin message handlers
  40. BOOL CLogin::PreTranslateMessage(MSG* pMsg) 
  41. {
  42. // TODO: Add your specialized code here and/or call the base class
  43. if(pMsg->message==WM_KEYDOWN && pMsg->wParam==13)
  44. {
  45. pMsg->wParam = 9;
  46. }
  47. if(pMsg->message == WM_LBUTTONDOWN)
  48. {
  49. CRect rect,rc;
  50. m_OK.GetWindowRect(&rect);
  51. m_Cancel.GetWindowRect(&rc);
  52. CPoint point;
  53. GetCursorPos(&point);
  54. if(rect.PtInRect(point))
  55. {
  56. UpdateData(TRUE);
  57. if(m_Name.IsEmpty() || m_PassWord.IsEmpty())
  58. {
  59. MessageBox("用户名或密码不能为空");
  60. return FALSE;
  61. }
  62. m_Time++;
  63. ADOConn m_AdoConn;
  64. m_AdoConn.OnInitADOConn();
  65. CString sql;
  66. sql.Format("select * from tb_user where 用户名 = '%s' and 密码 = '%s'",
  67. m_Name,m_PassWord);
  68. m_AdoConn.m_pRecordset = m_AdoConn.GetRecordSet((_bstr_t)sql);
  69. if(!m_AdoConn.m_pRecordset->adoEOF)
  70. {
  71. CDialog::OnOK();
  72. }
  73. else
  74. {
  75. if(m_Time == 3)
  76. {
  77. MessageBox("密码3次不正确");
  78. CDialog::OnCancel();
  79. }
  80. else
  81. {
  82. MessageBox("用户名或密码不正确");
  83. m_Name = "";
  84. m_PassWord = "";
  85. UpdateData(FALSE);
  86. }
  87. }
  88. m_AdoConn.ExitConnect();
  89. }
  90. if(rc.PtInRect(point))
  91. {
  92. CDialog::OnCancel();
  93. }
  94. }
  95. return CDialog::PreTranslateMessage(pMsg);
  96. }