📄 login.cpp
字号:
// Login.cpp : implementation file
//
#include "stdafx.h"
#include "DataManger.h"
#include "Login.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLogin dialog
extern class CDatabase g_Database; //系统数据库类查询对象
CLogin::CLogin(CWnd* pParent /*=NULL*/)
: CDialog(CLogin::IDD, pParent)
{
//{{AFX_DATA_INIT(CLogin)
m_operation_id = _T("");
m_password = _T("");
//}}AFX_DATA_INIT
}
void CLogin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLogin)
DDX_Control(pDX, IDC_BTN_CANCEL, m_btn_cancel);
DDX_Control(pDX, IDC_BTN_OK, m_btn_ok);
DDX_Text(pDX, IDC_OPERATION_ID, m_operation_id);
DDV_MaxChars(pDX, m_operation_id, 4);
DDX_Text(pDX, IDC_PASSWORD, m_password);
DDV_MaxChars(pDX, m_password, 6);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLogin, CDialog)
//{{AFX_MSG_MAP(CLogin)
ON_BN_CLICKED(IDC_BTN_OK, OnBtnOk)
ON_BN_CLICKED(IDC_BTN_CANCEL, OnBtnCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogin message handlers
void CLogin::OnBtnOk()
{
// TODO: Add your control notification handler code here
UpdateData(true);
//1.
CString sDSN;
sDSN.Format("select flag from t_Ivr_OperaTion where Operation_Id='%s' and Password='%s' ",m_operation_id,m_password);
//2.取出结果集
m_Recordset.m_pDatabase = &g_Database;
m_Recordset.Open(CRecordset::forwardOnly,sDSN,CRecordset::readOnly);
if(m_Recordset.IsEOF())
{
//2.1.
AfxMessageBox("无此用户名或密码有误,请重新输入!");
m_Recordset.Close();
//2.2.
count++;
if(count==3)
{
AfxMessageBox("对不起,您不能操作本系统!");
OnBtnCancel();
PostQuitMessage(0);
}
return;
}
//3.关闭记录集
m_Recordset.Close();
//调用主窗口
CDialog::OnOK();
return;
}
BOOL CLogin::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
HICON hicon=AfxGetApp()->LoadIcon(IDI_SECUR);
CLogin::SetIcon(hicon,true);
DestroyIcon(hicon);
m_btn_ok.SubclassDlgItem(IDOK, this);
m_btn_ok.SetIcon(IDI_OK);
m_btn_cancel.SubclassDlgItem(IDCANCEL, this);
m_btn_cancel.SetIcon(IDI_CAN);
count=0;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLogin::OnBtnCancel()
{
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -