📄 login.cpp
字号:
// Login.cpp : implementation file
//
#include "stdafx.h"
#include "IvrServer.h"
#include "Login.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLogin dialog
bool lhblyq=false;
extern CDatabase g_Database;
CLogin::CLogin(CWnd* pParent /*=NULL*/)
: CDialog(CLogin::IDD, pParent)
{
//{{AFX_DATA_INIT(CLogin)
m_operatorid = _T("");
m_operatorpass = _T("");
//}}AFX_DATA_INIT
}
void CLogin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLogin)
DDX_Control(pDX, IDC_BTN_OK, m_btn_ok);
DDX_Control(pDX, IDC_BTN_CANCEL, m_btn_cancel);
DDX_Text(pDX, IDC_EDIT1, m_operatorid);
DDV_MaxChars(pDX, m_operatorid, 4);
DDX_Text(pDX, IDC_EDIT2, m_operatorpass);
DDV_MaxChars(pDX, m_operatorpass, 6);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLogin, CDialog)
//{{AFX_MSG_MAP(CLogin)
ON_BN_CLICKED(IDC_BTN_OK, OnBtnOk)
ON_WM_CANCELMODE()
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 LoginTable where loginname='%s' and passwd='%s' ",m_operatorid,m_operatorpass);
//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("对不起,您不能操作本系统!");
lhblyq=true;
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_ICON2);
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
lhblyq=true;
PostQuitMessage(0);
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -