📄 resetdatabase.cpp
字号:
// Resetdatabase.cpp : implementation file
//
#include "stdafx.h"
#include "Myhotel.h"
#include "Resetdatabase.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CMyhotelApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CResetdatabase dialog
CResetdatabase::CResetdatabase(CWnd* pParent /*=NULL*/)
: CDialog(CResetdatabase::IDD, pParent)
{
//{{AFX_DATA_INIT(CResetdatabase)
m_resetguazhang = FALSE;
m_resetcheckoutreg = FALSE;
m_resetcheckinreg = FALSE;
m_resetroombook = FALSE;
m_resetroomstate = FALSE;
//}}AFX_DATA_INIT
}
void CResetdatabase::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CResetdatabase)
DDX_Check(pDX, IDC_CHECKresetguazhang, m_resetguazhang);
DDX_Check(pDX, IDC_CHECKresetcheckoutreg, m_resetcheckoutreg);
DDX_Check(pDX, IDC_CHECKresetcheckinreg, m_resetcheckinreg);
DDX_Check(pDX, IDC_CHECKresetroombook, m_resetroombook);
DDX_Check(pDX, IDC_CHECKresetroomstate, m_resetroomstate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CResetdatabase, CDialog)
//{{AFX_MSG_MAP(CResetdatabase)
ON_BN_CLICKED(ID_beginresetdatabase, Onbeginresetdatabase)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResetdatabase message handlers
void CResetdatabase::Onbeginresetdatabase()
{
// TODO: Add your control notification handler code here
//使输入框可以接收输入
GetDlgItem(IDOK)->EnableWindow(1);
GetDlgItem(IDC_groupdatabase)->EnableWindow(1);
GetDlgItem(IDC_CHECKresetguazhang)->EnableWindow(1);
GetDlgItem(IDC_CHECKresetcheckoutreg)->EnableWindow(1);
GetDlgItem(IDC_CHECKresetcheckinreg)->EnableWindow(1);
GetDlgItem(IDC_CHECKresetroombook)->EnableWindow(1);
GetDlgItem(IDC_CHECKresetroomstate)->EnableWindow(1);
}
BOOL CResetdatabase::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//初始化各个输入框状态
GetDlgItem(IDOK)->EnableWindow(0);
GetDlgItem(IDC_CHECKresetguazhang)->EnableWindow(0);
GetDlgItem(IDC_CHECKresetcheckoutreg)->EnableWindow(0);
GetDlgItem(IDC_CHECKresetcheckinreg)->EnableWindow(0);
GetDlgItem(IDC_CHECKresetroombook)->EnableWindow(0);
GetDlgItem(IDC_CHECKresetroomstate)->EnableWindow(0);
GetDlgItem(IDC_groupdatabase)->EnableWindow(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CResetdatabase::OnOK()
{
// TODO: Add extra validation here
//获取输入框内的数据
UpdateData(true);
m_pRecordset.CreateInstance(__uuidof(Recordset));
if(m_resetroombook)
{
// AfxMessageBox("wwwwww!");
// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//
CString strsql;
strsql.Format("DELETE FROM kfyd");
try
{//执行SQL语句,先打开数据表然后清空数据表
m_pRecordset->Open((_variant_t)(strsql), // 查询 表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
MessageBox("成功初始化客房预定登记表!","客房管理系统");
}
catch(_com_error *e)//抛出异常情况,因该过程可能有异常出现
{
AfxMessageBox(e->ErrorMessage());
}
//////////////////////////////////////////////////////////////
// m_pRecordset->Close();
m_pRecordset = NULL;
}
m_pRecordsetin.CreateInstance(__uuidof(Recordset));
if(m_resetcheckinreg)
{
// AfxMessageBox("wwwwww!");
// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//
CString strsql;
strsql.Format("DELETE FROM checkinregtable");
try
{//执行SQL语句,先打开数据表然后清空数据表
m_pRecordsetin->Open((_variant_t)(strsql), // 查询 表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
MessageBox("成功初始化住宿登记表!","客房管理系统");
}
catch(_com_error *e)//抛出异常情况,因该过程可能有异常出现
{
AfxMessageBox(e->ErrorMessage());
}
//////////////////////////////////////////////////////////////
// m_pRecordset->Close();
m_pRecordsetin = NULL;
}
m_pRecordsetout.CreateInstance(__uuidof(Recordset));
if(m_resetcheckoutreg)
{
// AfxMessageBox("wwwwww!");
// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//
CString strsql;
strsql.Format("DELETE FROM checkoutregtable");
try
{//执行SQL语句,先打开数据表然后清空数据表
m_pRecordsetout->Open((_variant_t)(strsql), // 查询 表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
MessageBox("成功初始化退宿登记表!","客房管理系统");
}
catch(_com_error *e)//抛出异常情况,因该过程可能有异常出现
{
AfxMessageBox(e->ErrorMessage());
}
//////////////////////////////////////////////////////////////
// m_pRecordset->Close();
m_pRecordsetout = NULL;
}
m_pRecordsetroomstate.CreateInstance(__uuidof(Recordset));
if(m_resetroomstate)
{
// AfxMessageBox("wwwwww!");
// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//
CString strsql;
strsql.Format("DELETE FROM roomsetting");
try
{//执行SQL语句,先打开数据表然后清空数据表
m_pRecordsetroomstate->Open((_variant_t)(strsql), // 查询 表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
MessageBox("成功初始化房态信息表!","客房管理系统");
}
catch(_com_error *e)//抛出异常情况,因该过程可能有异常出现
{
AfxMessageBox(e->ErrorMessage());
}
//////////////////////////////////////////////////////////////
// m_pRecordset->Close();
m_pRecordsetroomstate = NULL;
}
m_pRecordsetgz.CreateInstance(__uuidof(Recordset));
if(m_resetguazhang)
{
// AfxMessageBox("wwwwww!");
// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//
CString strsql;
strsql.Format("DELETE FROM guazhanginfo");
try//执行SQL语句,先打开数据表然后清空数据表
{
m_pRecordsetgz->Open((_variant_t)(strsql), // 查询 表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
MessageBox("成功初始化挂帐信息表!","客房管理系统");
}
catch(_com_error *e)//抛出异常情况,因该过程可能有异常出现
{
AfxMessageBox(e->ErrorMessage());
}
//////////////////////////////////////////////////////////////
// m_pRecordsetgz->Close();
m_pRecordsetgz = NULL;
}
// CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -