📄 repairpwdlg.cpp
字号:
// Repairpwdlg.cpp : implementation file
//
#include "stdafx.h"
#include "Myhotel.h"
#include "Repairpwdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CMyhotelApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CRepairpwdlg dialog
CRepairpwdlg::CRepairpwdlg(CWnd* pParent /*=NULL*/)
: CDialog(CRepairpwdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRepairpwdlg)
m_userid = _T("");
m_newpwd = _T("");
m_oldpwd = _T("");
//}}AFX_DATA_INIT
}
void CRepairpwdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRepairpwdlg)
DDX_Text(pDX, IDC_EDIT_userid, m_userid);
DDX_Text(pDX, IDC_userpwd_new, m_newpwd);
DDX_Text(pDX, IDC_userpwd_old, m_oldpwd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRepairpwdlg, CDialog)
//{{AFX_MSG_MAP(CRepairpwdlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRepairpwdlg message handlers
void CRepairpwdlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
m_pRecordset.CreateInstance(__uuidof(Recordset));
//INSERT INTO checkinregtable (凭证号码)VALUES('%s')
CString strsql;
strsql.Format("SELECT * FROM usertalbe where user_name='%s' and user_pwd='%s'",m_userid,m_oldpwd);
//打开数据表
try
{
m_pRecordset->Open(_variant_t(strsql), // 查询表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)//捕获异常情况
{
AfxMessageBox(e->ErrorMessage());
}
if(!m_pRecordset->BOF)//判断指针是否在数据集最后
m_pRecordset->MoveFirst();
else
{
MessageBox("输入操作员代号错误,没有此代号!","客房管理系统");
return;
}
try
{ //写入数据表
m_pRecordset->PutCollect("user_pwd", _variant_t(m_newpwd));
m_pRecordset->Update();//更新数据表
MessageBox("修改成功!","客房管理系统");
// UpdateData(false);
}
catch(_com_error *e)//捕获发生的异常
{
AfxMessageBox(e->ErrorMessage());
}
m_pRecordset->Close();
m_pRecordset = NULL;
// CDialog::OnOK();
}
BOOL CRepairpwdlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==VK_RETURN)
{
DWORD def_id=GetDefID();
if(def_id!=0)
{
//MSG消息的结构中的hwnd存储的是接收该消息的窗口句柄
CWnd *wnd=FromHandle(pMsg->hwnd);
char class_name[16];
if(GetClassName(wnd->GetSafeHwnd(),class_name,sizeof(class_name))!=0)
{
DWORD style=::GetWindowLong(pMsg->hwnd,GWL_STYLE);
if((style&ES_MULTILINE)==0)
{
if(strnicmp(class_name,"edit",5)==0)
{ //将焦点设置到默认按钮上面
GetDlgItem(LOWORD(def_id))->SetFocus();
pMsg->wParam=VK_TAB;//重载回车键盘消息为table键盘消息,ok!2006.4.18
}
}
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -