C++开发源码分析(103)

C++开发源码分析(103)
(一)头文件
#if !defined(AFX_CHECKINREGDLG_H__79A26C36_3B51_4360_A8F3_49B4ECB59B6A__INCLUDED_)
#define AFX_CHECKINREGDLG_H__79A26C36_3B51_4360_A8F3_49B4ECB59B6A__INCLUDED_

#include "CheckinregSET.h"
#include "Roominfoset.h"

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Checkinregdlg.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CCheckinregdlg dialog

class CCheckinregdlg : public CDialog
{
// Construction
public:
CCheckinregdlg(CWnd* pParent = NULL); // standard constructor

CCheckinregSET mycheckinregset;
CRoominfoset myroominfoset;
void enable(bool bEnabled);

CString regnumber;
CString gustname;
CString gustaddr;

CString zhengjian;
CString zhengjian_number;
CString checkinreg_reason;

bool issave;
// 定义ADO连接、命令、记录集变量指针
_ConnectionPtr m_pConnection;
_CommandPtr m_pCommand;
_RecordsetPtr m_pRecordset;
// CEdit m_room_money;
// CEdit m_pre_handinmoney;
// Dialog Data
//{{AFX_DATA(CCheckinregdlg)
enum { IDD = IDD_DIg_checkinreg };
CDateTimeCtrl m_checkindatectr;
CComboBox m_roomnumberctr;
CEdit m_room_money;
CString m_regnumber;
CString m_gustname;
CString m_gustaddr;
CString m_beizhu;
float m_pre_discount;
CString m_roomlevel;
CString m_zhengjian_number;
CString m_checkinreg_reason;
CString m_discount_kind;
CString m_roomnumber;
CString m_zhengjian;
CTime m_checkindate;
CTime m_alarmdate;
CTime m_alarmtime;
CTime m_checkintime;
CTime m_checkoutdate;
CTime m_checkouttime;
double m_checkdays;
double m_discountnumber;
CString m_realmoney;
CString m_pre_handinmoney;
CString m_showuser;
//}}AFX_DATA


// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCheckinregdlg)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:

// Generated message map functions
//{{AFX_MSG(CCheckinregdlg)
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
virtual BOOL OnInitDialog();
afx_msg void Oncheckreg();
virtual void OnOK();
afx_msg void OnChangeEDITcheckdays();
afx_msg void OnCloseupCOMBOroomnumber();
afx_msg void OnChangediscountnumber();
afx_msg void OnCancel_regin();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CHECKINREGDLG_H__79A26C36_3B51_4360_A8F3_49B4ECB59B6A__INCLUDED_)
(二)源文件
// Checkinregdlg.cpp : implementation file
//

#include "stdafx.h"
#include "Myhotel.h"
#include "Checkinregdlg.h"
#include
#include


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

e

xtern CString loguserid;
extern CMyhotelApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CCheckinregdlg dialog


CCheckinregdlg::CCheckinregdlg(CWnd* pParent /*=NULL*/)
: CDialog(CCheckinregdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCheckinregdlg)
m_regnumber = _T("");
m_gustname = _T("");
m_gustaddr = _T("");
m_beizhu = _T("");
m_pre_discount = 0.0f;
m_roomlevel = _T("");
m_zhengjian_number = _T("");
m_checkinreg_reason = _T("");
m_discount_kind = _T("");
m_roomnumber = _T("");
m_zhengjian = _T("");
m_checkindate = 0;
m_alarmdate = 0;
m_alarmtime = 0;
m_checkintime = 0;
m_checkoutdate = 0;
m_checkouttime = 0;
m_checkdays = 0.0;
m_discountnumber = 0.0;
m_realmoney = _T("");
m_pre_handinmoney = _T("");
m_showuser = _T("");
issave = false;
//}}AFX_DATA_INIT
}


void CCheckinregdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCheckinregdlg)
DDX_Control(pDX, IDC_DATETIMEPICKER_checkindate, m_checkindatectr);
DDX_Control(pDX, IDC_COMBO_roomnumber, m_roomnumberctr);
DDX_Control(pDX, IDC_room_money, m_room_money);
DDX_Text(pDX, IDC_EDIT_NO, m_regnumber);
DDX_Text(pDX, IDC_EDIT_name, m_gustname);
DDX_Text(pDX, IDC_EDIT_address, m_gustaddr);
DDX_Text(pDX, IDC_EDIT1_beizhu, m_beizhu);
DDX_Text(pDX, IDC_pre_discount, m_pre_discount);
DDX_Text(pDX, IDC_room_level, m_roomlevel);
DDX_Text(pDX, IDC_zhengjian_number, m_zhengjian_number);
DDX_Text(pDX, IDC_checkinreg_reason, m_checkinreg_reason);
DDX_CBString(pDX, IDC_COMBO_discountkind, m_discount_kind);
DDX_CBString(pDX, IDC_COMBO_roomnumber, m_roomnumber);
DDX_CBString(pDX, IDC_COMBO_zhengjian, m_zhengjian);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_checkindate, m_checkindate);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKERalarmdate, m_alarmdate);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKERalarmtime, m_alarmtime);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKERcheckintime, m_checkintime);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKERcheckoutdate, m_checkoutdate);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKERcheckouttime, m_checkouttime);
DDX_Text(pDX, IDC_EDIT_check_days, m_checkdays);
DDX_Text(pDX, IDC_discountnumber, m_discountnumber);
DDX_Text(pDX, IDC_realmoney, m_realmoney);
DDX_Text(pDX, IDC_pre_handinmoney, m_pre_handinmoney);
DDX_Text(pDX, IDC_STATICshowuser, m_showuser);
//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCheckinregdlg, CDialog)
//{{AFX_MSG_MAP(CCheckinregdlg)
ON_WM_KEYUP()
ON_BN_CLICKED(ID_checkreg, Oncheckreg)
ON_EN_CHANGE(IDC_EDIT_check_days, OnChangeEDITcheckdays)
ON_CBN_CLOSEUP(IDC_COMBO_roomnumber, OnCloseupCOMBOroomnumber)
ON_EN_CHANGE(IDC_discountnumber, OnChangediscountnumber)
ON_BN_CLICKED(ID_CANCEL, OnCancel_regin)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCheckinregdlg message handlers

void CCheckinregdlg::OnKey

Up(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default

// atof(m_realmoney)*m_discountnumber/100

CDialog::OnKeyUp(nChar, nRepCnt, nFlags);
}
void CCheckinregdlg::enable(bool bEnabled)
{
// m_ComYSFS.EnableWindow(bEnabled);
//更改输入框等控件状态,方便使用,防止错误操作
GetDlgItem(IDC_room_money)->EnableWindow(bEnabled);
GetDlgItem(IDC_EDIT_NO)->EnableWindow(bEnabled);
GetDlgItem(IDC_EDIT_name)->EnableWindow(bEnabled);
GetDlgItem(IDC_EDIT_address)->EnableWindow(bEnabled);
GetDlgItem(IDC_EDIT1_beizhu)->EnableWindow(bEnabled);
GetDlgItem(IDC_pre_discount)->EnableWindow(bEnabled);
GetDlgItem(IDC_zhengjian_number)->EnableWindow(bEnabled);
GetDlgItem(IDC_checkinreg_reason)->EnableWindow(bEnabled);
GetDlgItem(IDC_COMBO_roomnumber)->EnableWindow(bEnabled);

GetDlgItem(IDC_DATETIMEPICKER_checkindate)->EnableWindow(bEnabled);
GetDlgItem(IDC_DATETIMEPICKERalarmdate)->EnableWindow(bEnabled);
GetDlgItem(IDC_DATETIMEPICKERalarmtime)->EnableWindow(bEnabled);
GetDlgItem(IDC_DATETIMEPICKERcheckintime)->EnableWindow(bEnabled);
GetDlgItem(IDC_DATETIMEPICKERcheckoutdate)->EnableWindow(bEnabled);
GetDlgItem(IDC_DATETIMEPICKERcheckouttime)->EnableWindow(bEnabled);
GetDlgItem(IDC_EDIT_check_days)->EnableWindow(bEnabled);
GetDlgItem(IDC_discountnumber)->EnableWindow(bEnabled);
GetDlgItem(IDC_realmoney)->EnableWindow(bEnabled);
GetDlgItem(IDC_pre_handinmoney)->EnableWindow(bEnabled);
GetDlgItem(IDC_room_level)->EnableWindow(bEnabled);
GetDlgItem(IDOK)->EnableWindow(bEnabled);
}


BOOL CCheckinregdlg::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here
enable(0);//
//更新输入框状态
int nYear,nDay,nMonth;
CString sYear,sDay,sMonth,stime;
CTime tTime;
tTime=tTime.GetCurrentTime();
//设置登记的默认时间
m_checkindate=tTime;
m_checkintime=tTime;

m_showuser=loguserid;

//显示初始化信息
UpdateData(false);

m_pRecordset.CreateInstance(__uuidof(Recordset));

_variant_t var;
CString strroomnumber;
// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//
try
{
m_pRecordset->Open("SELECT * FROM roomsetting", // 查询 表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)//捕获连接数据库异常
{
AfxMessageBox(e->ErrorMessage());
}
try
{
if(!m_pRecordset->BOF)//判断指针是否在数据集最后
m_pRecordset->MoveFirst();
else
{
AfxMessageBox("表内数据为空");
return false;
}

// read data from the database table

CComboBox* combobox = (CComboBox*)GetDlgItem(IDC_COMBO_roomnumber);
while(!m_pRecordset->adoEOF)
{//读取房间号
var = m_pRecordset->GetColle

ct("房间号");
if(var.vt != VT_NULL)
strroomnumber = (LPCSTR)_bstr_t(var);
combobox->AddString(strroomnumber);//添加到列表

m_pRecordset->MoveNext();//移动记录集指针
}

//

}
catch(_com_error *e)//捕获异常
{
AfxMessageBox(e->ErrorMessage());
}

// 关闭记录集
m_pRecordset->Close();
m_pRecordset = NULL;


return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

void CCheckinregdlg::Oncheckreg()
{
// TODO: Add your control notification handler code here
enable(1);

CString strnowdate,strcheckinnumber;

int nYear,nDay,nMonth;
CString sYear,sDay,sMonth;
CTime tTime;
tTime=tTime.GetCurrentTime(); //获取系统当前的时间
nYear=tTime.GetYear();//提取年份
nDay=tTime.GetDay();//提取月份
nMonth=tTime.GetMonth();//提取日
sYear.Format("%d",nYear);//转换为字符串
sDay.Format("%d",nDay);//转换为字符串
sMonth.Format("%d",nMonth);//转换为字符串,格式化时间
strnowdate.Format("%s-%s-%s",sYear,sMonth,sDay);


// 使用ADO创建数据库记录集
m_pRecordset.CreateInstance(__uuidof(Recordset));

// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//
CString strsql;
strsql.Format("SELECT * FROM checkinregtable where 住宿日期='%s'",strnowdate);
try//打开数据库
{
m_pRecordset->Open(_variant_t(strsql), // 查询表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)//捕获打开数据库时候可能发生的异常情况
{
AfxMessageBox(e->ErrorMessage());
}
strcheckinnumber+=strnowdate;
strcheckinnumber+="D";
strcheckinnumber+=(LPCSTR)_bstr_t(m_pRecordset->GetRecordCount());
//产生登记凭证号码
m_regnumber =strcheckinnumber;

// 关闭记录集
m_pRecordset->Close();
m_pRecordset = NULL;
//更新显示
UpdateData(false);

}

void CCheckinregdlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
//////////////////////////////////////////////////////////////////////////
/*
* 检查身份证的号码是否为15位或者为18位
*/
CString strCertifyCode;//证件号码


//获得证件号码
int nCertifyCodeLength=m_zhengjian_number.GetLength();//获得证件的长度
if(nCertifyCodeLength!=15&&nCertifyCodeLength!=18)
{
if(m_zhengjian=="身份证")
{//若选择的是身份证
MessageBox("你的身份证的号码的位数不正确!\n应该为15位或者18位!",
"身份证错误",MB_OK);
return ;
}
}
//////////////////////////////////////////////////////////////////////////
issave = true;
OnCloseupCOMBOroomnumber() ;

m_pRecordset.CreateInstance(__uuidof(Recordset));

// 在ADO操作中

建议语句中要常用try...catch()来捕获错误信息,
//
try
{//打开数据库
m_pRecordset->Open("SELECT * FROM checkinregtable", // 查询表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)//捕获打开数据库时候的各种异常
{
AfxMessageBox(e->ErrorMessage());
}
//////////////////////////////////////////////////////////////

try
{
// 写入各字段值,准备更新数据库
m_pRecordset->AddNew();
m_pRecordset->PutCollect("凭证号码", _variant_t(m_regnumber));
m_pRecordset->PutCollect("姓名",_variant_t(m_gustname));
m_pRecordset->PutCollect("证件名称", _variant_t(m_zhengjian));
m_pRecordset->PutCollect("证件号码", _variant_t(m_zhengjian_number));

m_pRecordset->PutCollect("详细地址", _variant_t(m_gustaddr));
m_pRecordset->PutCollect("出差事由",_variant_t(m_checkinreg_reason));
m_pRecordset->PutCollect("房间号", _variant_t(m_roomnumber));
m_pRecordset->PutCollect("客房类型", _variant_t(m_roomlevel));

CString str_room_money;
m_room_money.GetWindowText(str_room_money);
m_pRecordset->PutCollect("客房价格", _variant_t(str_room_money));

CString checkindate;//获取登记住宿日期
int nYear,nDay,nMonth;
CString sYear,sDay,sMonth;
nYear=m_checkindate.GetYear();//提取年份
nDay=m_checkindate.GetDay();//提取日
nMonth=m_checkindate.GetMonth();//提取月份
sYear.Format("%d",nYear);//转换为字符串
sDay.Format("%d",nDay);//转换为字符串
sMonth.Format("%d",nMonth);//转换为字符串
checkindate.Format("%s-%s-%s",sYear,sMonth,sDay);//格式化时间
m_pRecordset->PutCollect("住宿日期",_variant_t(checkindate));
//保存
CString checkintime;//准备获取登记住宿时间
int nhour,nmin,nsecond;
CString shour,smin,ssecond;
nhour=m_checkindate.GetHour();//提取小时数
nmin=m_checkindate.GetMinute();//提取分钟
nsecond=m_checkindate.GetSecond();//提取秒
shour.Format("%d",nhour);//转换为字符串
smin.Format("%d",nmin);//转换为字符串
ssecond.Format("%d",nsecond);//转换为字符串
checkintime.Format("%s:%s:%s",shour,smin,ssecond);//格式化时间
m_pRecordset->PutCollect("住宿时间", _variant_t(checkintime));
m_pRecordset->PutCollect("住宿天数", _variant_t(m_checkdays));
//定义临时存储空间
char str_money[50];
_gcvt(atof(str_room_money)*m_checkdays, 4, str_money );
m_pRecordset->PutCollect("宿费", _variant_t(str_money));


m_pRecordset->PutCollect("折扣",_variant_t(m_discountnumber));
//定义临时存储空间
char strhand_money[50];
_gcvt(atof(m_realmoney)*m_discountnumber/100, 4, strhand_money );
m_pRecordset->PutCollect("

应收宿费", _variant_t(strhand_money));
m_pRecordset->PutCollect("预收金额", _variant_t(m_pre_handinmoney));

CString alarmdate;//准备获取提醒日期
nYear=m_alarmdate.GetYear();//提取年份
nDay=m_alarmdate.GetDay();//提取日
nMonth=m_alarmdate.GetMonth();//提取月份
sYear.Format("%d",nYear);//转换为字符串
sDay.Format("%d",nDay);//转换为字符串
sMonth.Format("%d",nMonth);//转换为字符串
alarmdate.Format("%s-%s-%s",sYear,sMonth,sDay);//格式化时间
m_pRecordset->PutCollect("提醒日期", _variant_t(alarmdate));

CString checkoutdate;//准备获取退宿日期
nYear=m_checkoutdate.GetYear();//提取年份
nDay=m_checkoutdate.GetDay();//提取日
nMonth=m_checkoutdate.GetMonth();//提取月份
sYear.Format("%d",nYear);//转换为字符串
sDay.Format("%d",nDay);//转换为字符串
sMonth.Format("%d",nMonth);//转换为字符串
checkoutdate.Format("%s-%s-%s",sYear,sMonth,sDay);//格式化时间
m_pRecordset->PutCollect("退宿日期",_variant_t(checkoutdate));
m_pRecordset->PutCollect("备注", _variant_t(m_beizhu));


CString nowdate,nowtime;//准备获取当前日期
CTime tTime;
tTime=tTime.GetCurrentTime();
nYear=tTime.GetYear();//提取年份
nDay=tTime.GetDay();
nMonth=tTime.GetMonth();//提取月份
sYear.Format("%d",nYear);//转换为字符串
sDay.Format("%d",nDay);//转换为字符串
sMonth.Format("%d",nMonth);//转换为字符串
nowdate.Format("%s-%s-%s",sYear,sMonth,sDay);//格式化时间

nhour=tTime.GetHour();////提取小时数,准备获取当前时间
nmin=tTime.GetMinute();//提取分钟
nsecond=tTime.GetSecond();//提取秒
shour.Format("%d",nhour);//转换为字符串
smin.Format("%d",nmin);//转换为字符串
ssecond.Format("%d",nsecond);//转换为字符串
nowtime.Format("%s:%s:%s",shour,smin,ssecond);//格式化时间
m_pRecordset->PutCollect("日期", _variant_t(nowdate));
m_pRecordset->PutCollect("时间", _variant_t(nowtime));


m_pRecordset->PutCollect("结款方式", _variant_t(m_discount_kind));

CString checkouttime;//准备获取退宿时间
nhour=m_checkouttime.GetHour();//提取小时数
nmin=m_checkouttime.GetMinute();//提取分钟
nsecond=m_checkouttime.GetSecond();//提取秒
shour.Format("%d",nhour);//转换为字符串
smin.Format("%d",nmin);//转换为字符串
ssecond.Format("%d",nsecond);//转换为字符串
checkouttime.Format("%s:%s:%s",shour,smin,ssecond);//格式化时间
m_pRecordset->PutCollect("退宿时间", _variant_t(checkouttime));

CString alarmtime;//准备获取提醒时间
nhour=m_alarmtime.GetHour();//提取小时数
nmin=m_alarmtime.GetMinute();//提取分钟
nsecond=m_alarmtime.GetSecond();//提取秒
shour.Format("%d",nhour);//转换为

字符串
smin.Format("%d",nmin);//转换为字符串
ssecond.Format("%d",nsecond);//转换为字符串
alarmtime.Format("%s:%s:%s",shour,smin,ssecond);//格式化时间
m_pRecordset->PutCollect("提醒时间", _variant_t(alarmtime));
//更新数据库
m_pRecordset->Update();

MessageBox("登记成功!","客房管理系统");
}
catch(_com_error *e)//捕获写入数据库时候可能发生的异常情况
{
AfxMessageBox(e->ErrorMessage());
}
///////////////////////////////////////////////////
//关闭记录集
m_pRecordset->Close();
m_pRecordset = NULL;

// CDialog::OnOK();
}



void CCheckinregdlg::OnChangeEDITcheckdays()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
//获取输入数据
UpdateData(true);
CString str_room_money;
m_room_money.GetWindowText(str_room_money);
m_pre_discount=atof(str_room_money)*m_checkdays;
//更新显示
UpdateData(false);
// TODO: Add your control notification handler code here

}

void CCheckinregdlg::OnCloseupCOMBOroomnumber()
{
// TODO: Add your control notification handler code here
UpdateData(true);
int index=0;
CString roomnumber;
index=m_roomnumberctr.GetCurSel();//获取所选择的列表项目序号
m_roomnumberctr.GetLBText(index,roomnumber);
//获得选择的列表项目内容
CString SQLstr;
SQLstr="SELECT * FROM roomsetting where 房间号='" ;
SQLstr+=roomnumber;
SQLstr+="'";


if(!myroominfoset.Open(AFX_DB_USE_DEFAULT_TYPE,SQLstr))
{//查询数据库得到数据集合
MessageBox("没有此房间号码,打开数据库失败!","客房管理系统");
if(myroominfoset.IsOpen())
{//关闭数据表
myroominfoset.Close();
}
return ;
}
if(myroominfoset.m_column4=="入住")//查看房间状态
{
MessageBox("此房间已经有人入住,请选择其他房间!","客房管理系统");
if(myroominfoset.IsOpen())
{//关闭数据表
myroominfoset.Close();
}
return ;
}
m_roomlevel=myroominfoset.m_column2;//读取数据
m_room_money.SetWindowText(myroominfoset.m_column3);
//////////////////////////////////
myroominfoset.Edit();
//设置数据库操作类型
if (issave)
myroominfoset.m_column4="入住";
myroominfoset.Update();
myroominfoset.Requery();
issave = false;
///////////////////////////////////
if(myroominfoset.IsOpen())//打开数据库
{
myroominfoset.Close();
}
regnumber=m_regnumber;//读入变量对应的将要写入的内容
gustname=m_gustname;
gustaddr=m_gustaddr;//读入变量对应的将要写入的内容

zhengjian=m_zhengjian;//读入变量对应的将要写入的内容
zhengjian_number=m_zhengjian_number;//读入变量对应的将要写入的内


checkinreg_reason=m_checkinreg_reason;//读入变量对应的将要写入的内容
//更新显示
UpdateData(false);
}

void CCheckinregdlg::OnChangediscountnumber()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateData(true);
CString need_room_money;

float fneed_room_money=0;//初始化
m_room_money.GetWindowText(need_room_money);//获取输入内容
fneed_room_money=m_pre_discount*m_discountnumber;
//定义临时存储空间
char strhand_money[50];
//格式转换
_gcvt(fneed_room_money/100, 4, strhand_money );//格式转换
m_realmoney=strhand_money;
//更新显示
UpdateData(false);
// TODO: Add your control notification handler code here

}

void CCheckinregdlg::OnCancel_regin()
{
// TODO: Add your control notification handler code here
//输入数据对应变量初始化
m_regnumber = _T("");
m_gustname = _T("");
m_gustaddr = _T("");
m_beizhu = _T("");
m_pre_discount = 0.0f;
m_roomlevel = _T("");
m_zhengjian_number = _T("");
m_checkinreg_reason = _T("");
m_discount_kind = _T("");
m_roomnumber = _T("");
m_zhengjian = _T("");
m_checkindate = 0;
m_alarmdate = 0;
m_alarmtime = 0;
m_checkintime = 0;
m_checkoutdate = 0;
m_checkouttime = 0;
m_checkdays = 0.0;
m_discountnumber = 0.0;
m_realmoney = _T("");
m_pre_handinmoney = _T("");
m_room_money.SetWindowText("");
//初始化完毕
//更新显示
UpdateData(false);
}

BOOL CCheckinregdlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==VK_RETURN)
{
pMsg->wParam=VK_TAB;

}
return CDialog::PreTranslateMessage(pMsg);
}


相关主题
相关文档
最新文档