📄 setusernamepwdlg.cpp
字号:
// Setusernamepwdlg.cpp : implementation file
//
#include "stdafx.h"
#include "Myhotel.h"
#include "Setusernamepwdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CMyhotelApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CSetusernamepwdlg dialog
CSetusernamepwdlg::CSetusernamepwdlg(CWnd* pParent /*=NULL*/)
: CDialog(CSetusernamepwdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSetusernamepwdlg)
m_pwdsure = _T("");
m_pwd = _T("");
m_userid = _T("");
//}}AFX_DATA_INIT
}
void CSetusernamepwdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetusernamepwdlg)
DDX_Text(pDX, IDC_userpwd_sure, m_pwdsure);
DDX_Text(pDX, IDC_userpwd, m_pwd);
DDX_Text(pDX, IDC_userid, m_userid);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetusernamepwdlg, CDialog)
//{{AFX_MSG_MAP(CSetusernamepwdlg)
ON_BN_CLICKED(ID_CANCEL, OnnamepwdinputCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetusernamepwdlg message handlers
void CSetusernamepwdlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
//判断两次密码是否一样
if(m_pwdsure!=m_pwd)
{
MessageBox("两次密码不同,请重新输入!","客房管理系统");
return;
}
m_pRecordset.CreateInstance(__uuidof(Recordset));
// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//
try
{//打开数据表
m_pRecordset->Open("SELECT * FROM usertalbe", // 查询 表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)//抛出异常
{
AfxMessageBox(e->ErrorMessage());
}
//////////////////////////////////////////////////////////////
try
{
// 写入各字段值
m_pRecordset->AddNew();
m_pRecordset->PutCollect("user_name", _variant_t(m_userid));
m_pRecordset->PutCollect("user_pwd",_variant_t(m_pwd));
m_pRecordset->Update();
//更新数据表完毕,给出提示
MessageBox("设置成功!","客房管理系统");
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
//关闭记录集
m_pRecordset->Close();
m_pRecordset = NULL;
//向setability数据表插入该用户并设置其权限
Onaddinfotosetuserabilitytable();
// CDialog::OnOK();
}
void CSetusernamepwdlg::OnnamepwdinputCancel()
{
// TODO: Add your control notification handler code here
//变量赋值
m_userid=_T("");
m_pwd=_T("");
m_pwdsure=_T("");
//更新显示
UpdateData(false);
}
void CSetusernamepwdlg::Onaddinfotosetuserabilitytable()
{
m_pRecordsetsetabilty.CreateInstance(__uuidof(Recordset));
// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//
try
{//打开数据表
m_pRecordsetsetabilty->Open("SELECT * FROM setability", // 查询 表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)//抛出异常
{
AfxMessageBox(e->ErrorMessage());
}
//////////////////////////////////////////////////////////////
try
{
// 写入各字段值
m_pRecordsetsetabilty->AddNew();
//向数据表中客房预定字段写入数据
m_pRecordsetsetabilty->PutCollect("客房预定", _variant_t("1"));
//向数据表中住宿登记字段写入数据
m_pRecordsetsetabilty->PutCollect("住宿登记", _variant_t("1"));
//向数据表中追加押金字段写入数据
m_pRecordsetsetabilty->PutCollect("追加押金", _variant_t("1"));
//向数据表中调房登记字段写入数据
m_pRecordsetsetabilty->PutCollect("调房登记", _variant_t("1"));
//向数据表中退宿登记字段写入数据
m_pRecordsetsetabilty->PutCollect("退宿登记", _variant_t("1"));
//向数据表中客房管理字段写入数据
m_pRecordsetsetabilty->PutCollect("客房管理", _variant_t("1"));
//向数据表中客房查询字段写入数据
m_pRecordsetsetabilty->PutCollect("客房查询", _variant_t("1"));
//向数据表中房态查看字段写入数据
m_pRecordsetsetabilty->PutCollect("房态查看", _variant_t("1"));
//向数据表中挂帐查询字段写入数据
m_pRecordsetsetabilty->PutCollect("挂帐查询", _variant_t("1"));
//向数据表中客户结款字段写入数据
m_pRecordsetsetabilty->PutCollect("客户结款", _variant_t("1"));
//向数据表中预定房查询字段写入数据
m_pRecordsetsetabilty->PutCollect("预定房查询", _variant_t("1"));
m_pRecordsetsetabilty->PutCollect("住宿查询", _variant_t("1"));
//向数据表中退宿查询字段写入数据
m_pRecordsetsetabilty->PutCollect("退宿查询", _variant_t("1"));
//向数据表中宿费提醒字段写入数据
m_pRecordsetsetabilty->PutCollect("宿费提醒", _variant_t("1"));
//向数据表中登记预收报表字段写入数据
m_pRecordsetsetabilty->PutCollect("登记预收报表", _variant_t("1"));
//向数据表中客房销售报表字段写入数据
m_pRecordsetsetabilty->PutCollect("客房销售报表", _variant_t("1"));
//向数据表中客房销售统计报表字段写入数据
m_pRecordsetsetabilty->PutCollect("客房销售统计报表", _variant_t("1"));
//向数据表中操作员设置字段写入数据
m_pRecordsetsetabilty->PutCollect("操作员设置", _variant_t("1"));
//向数据表中密码设置字段写入数据
m_pRecordsetsetabilty->PutCollect("密码设置", _variant_t("1"));
//向数据表中初始化字段写入数据
m_pRecordsetsetabilty->PutCollect("初始化", _variant_t("1"));
//向数据表中权限设置字段写入数据
m_pRecordsetsetabilty->PutCollect("权限设置", _variant_t("1"));
//向数据表中操作员字段写入数据
m_pRecordsetsetabilty->PutCollect("操作员", _variant_t(m_userid));
//向数据表中密码字段写入数据
m_pRecordsetsetabilty->PutCollect("密码", _variant_t(m_pwd));
//更新数据库
m_pRecordsetsetabilty->Update();
//更新数据表完毕,给出提示
//AfxMessageBox("设置成功!");
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
//关闭记录集
m_pRecordsetsetabilty->Close();
m_pRecordsetsetabilty = NULL;
}
BOOL CSetusernamepwdlg::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 + -