📄 userdlg.cpp
字号:
// Userdlg.cpp : implementation file
//
#include "stdafx.h"
#include "图书管理系统.h"
#include "Userdlg.h"
//#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUserdlg dialog
extern CMyApp theApp;
CUserdlg::CUserdlg(CWnd* pParent /*=NULL*/)
: CDialog(CUserdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUserdlg)
m_uname = _T("");
m_upassword = _T("");
//}}AFX_DATA_INIT
}
void CUserdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUserdlg)
DDX_Text(pDX, IDC_UNAME, m_uname);
DDX_Text(pDX, IDC_UPASSWORD, m_upassword);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUserdlg, CDialog)
//{{AFX_MSG_MAP(CUserdlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUserdlg message handlers
void CUserdlg::OnOK()
{
UpdateData(TRUE);
if (m_uname.IsEmpty() || m_upassword.IsEmpty())
{
MessageBox("用户名称或密码不能为空", "用户登录信息");
GetDlgItem(IDC_UNAME)->SetFocus();
return;
}
sql.Format("select * from reader where readernumber = '%s' and password = '%s'",m_uname,m_upassword);
connect();
try
{
if (!m_pRecordset->BOF)
{
pass = true;
m_pRecordset->Close();
m_pRecordset=NULL;
sql.Format("update reader set now='%s' where readernumber='%s'","1",m_uname);
connect();
EndDialog(0);
}
else
{
m_uname="";
m_upassword="";
MessageBox("用户名或密码不正确.","提示",64);
UpdateData(FALSE);
GetDlgItem(IDC_UNAME)->SetFocus();
}
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
}
void CUserdlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CUserdlg::connect()
{
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
m_pRecordset->Open(sql.AllocSysString(), // 查询数据库表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -