📄 uchange.cpp
字号:
// UCHANGE.cpp : implementation file
//
#include "stdafx.h"
#include "图书管理系统.h"
#include "UCHANGE.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CMyApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CUCHANGE dialog
CUCHANGE::CUCHANGE(CWnd* pParent /*=NULL*/)
: CDialog(CUCHANGE::IDD, pParent)
{
//{{AFX_DATA_INIT(CUCHANGE)
m_new = _T("");
m_new1 = _T("");
m_old = _T("");
m_uid = _T("");
//}}AFX_DATA_INIT
}
void CUCHANGE::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUCHANGE)
DDX_Text(pDX, IDC_NEW, m_new);
DDX_Text(pDX, IDC_NEW1, m_new1);
DDX_Text(pDX, IDC_OLD, m_old);
DDX_Text(pDX, IDC_UID, m_uid);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUCHANGE, CDialog)
//{{AFX_MSG_MAP(CUCHANGE)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUCHANGE message handlers
void CUCHANGE::OnOK()
{
UpdateData();
if(m_uid.IsEmpty())
{
MessageBox("请输入读者编号");
return;
}
if(m_old.IsEmpty())
{
MessageBox("请输入原密码");
return;
}
if(m_new.IsEmpty())
{
MessageBox("请输入新密码");
return;
}
if(m_new1.IsEmpty())
{
MessageBox("请再次确认新密码");
return;
}
if(m_new.Compare(m_new1))
{
MessageBox("您两次输入的新密码不一致,请重新输入");
m_new="";
m_new1="";
UpdateData(FALSE);
GetDlgItem(IDC_NEW)->SetFocus();
return;
}
sql.Format("select * from reader where readernumber='%s' and password='%s'",m_uid,m_old);
connect();
if(m_pRecordset->BOF)
{
MessageBox("您输入的用户名或密码不正确,请重新输入");
m_uid="";
m_old="";
m_new="";
m_new1="";
UpdateData(FALSE);
GetDlgItem(IDC_UID)->SetFocus();
return;
}
else
{
try
{
sql.Format("update reader set password='%s' where readernumber='%s'",m_new1,m_uid);
connect();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
MessageBox("修改成功");
m_uid="";
m_old="";
m_new="";
m_new1="";
UpdateData(FALSE);
GetDlgItem(IDC_UID)->SetFocus();
}
}
void CUCHANGE::connect()
{
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
m_pRecordset->Open(sql.AllocSysString(),
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
}
void CUCHANGE::OnCancel()
{
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -