📄 logdialog.cpp
字号:
// logdialog.cpp : implementation file
//
#include "stdafx.h"
#include "winmainlast.h"
#include "logdialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// logdialog dialog
logdialog::logdialog(CWnd* pParent /*=NULL*/)
: CDialog(logdialog::IDD, pParent)
{
//{{AFX_DATA_INIT(logdialog)
m_name = _T("");
m_no = _T("");
m_pass = _T("");
m_value = 0;
//}}AFX_DATA_INIT
}
void logdialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(logdialog)
DDX_Text(pDX, IDC_name, m_name);
DDX_Text(pDX, IDC_no, m_no);
DDX_Text(pDX, IDC_pass, m_pass);
DDX_Text(pDX, IDC_value, m_value);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(logdialog, CDialog)
//{{AFX_MSG_MAP(logdialog)
ON_EN_KILLFOCUS(IDC_no, OnKillfocusno)
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// logdialog message handlers
BOOL logdialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_db.OpenEx("dsn=winmainlast;uid=sa;pwd=2222");
// AfxMessageBox("数据库连接成功!",0,0);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void logdialog::OnOK()
{
CString no,name,pass;
CRecordset m_set;
m_set.m_pDatabase=&m_db;
UpdateData(true);
if(!m_no.IsEmpty())
{
CString str;
str.Format("select * from 权限表 where 编号 like '%s'",m_no);
m_set.Open(CRecordset::dynaset,str);
if(!m_set.IsEOF())
{
m_set.GetFieldValue((short)0,no);
no.TrimRight();
m_set.GetFieldValue(2,pass);
pass.TrimRight();
if(pass==m_pass)
{
CDialog::OnOK();
m_set.Close();
}
else
{AfxMessageBox("密码错!");
m_pass="";
GetDlgItem(IDC_pass)->SetFocus();
UpdateData(false);
}
}
}
else
{
AfxMessageBox("请输入员工的编号!");
}
// CDialog::OnOK();
}
void logdialog::OnCancel()
{
int index=AfxMessageBox("你确定要退出吗?",MB_YESNO,1);
if(index==6)
CDialog::OnCancel();
}
void logdialog::OnKillfocusno()
{
CRecordset m_set;
m_set.m_pDatabase=&m_db;
UpdateData(true);
if(!m_no.IsEmpty())
{
CString str;
str.Format("select * from 权限表 where 编号 like '%s'",m_no);
m_set.Open(CRecordset::dynaset,str);
if(!m_set.IsEOF())
{
CString name;
m_set.GetFieldValue(1,m_name);
UpdateData(false);
GetDlgItem(IDC_pass)->SetFocus();
}
else
{
AfxMessageBox("库中没有此编号!");
m_name.Empty();
m_no.Empty();
UpdateData(false);
//GetDlgItem(IDC_no)->SetFocus();
}
m_set.Close();
}
}
void logdialog::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -