www.pudn.com > hotel2003.rar > ChooseRoom.cpp
// ChooseRoom.cpp : implementation file
//
#include "stdafx.h"
#include "qq.h"
#include "ChooseRoom.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChooseRoom dialog
CChooseRoom::CChooseRoom(CWnd* pParent /*=NULL*/)
: CDialog(CChooseRoom::IDD, pParent)
{
//{{AFX_DATA_INIT(CChooseRoom)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CChooseRoom::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChooseRoom)
DDX_Control(pDX, IDC_HANDCODE, HandCode);
DDX_Control(pDX, IDC_BILLCODE, BillCode);
DDX_Control(pDX, IDC_ROOMSELNUM, RoomSelNum);
DDX_Control(pDX, IDC_ROOMSUM, RoomSum);
DDX_Control(pDX, IDC_ROOMBILLLIST, RoomBillList);
DDX_Control(pDX, IDC_ROOMCODELIST, RoomCodeList);
DDX_Control(pDX, IDC_ROOMPRICE, RoomPrice);
DDX_Control(pDX, IDC_ROOMTYPE, RoomType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChooseRoom, CDialog)
//{{AFX_MSG_MAP(CChooseRoom)
ON_CBN_SELCHANGE(IDC_ROOMTYPE, OnSelchangeRoomtype)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChooseRoom message handlers
BOOL CChooseRoom::OnInitDialog()
{
CDialog::OnInitDialog();
HICON m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME2);
this->SetIcon(m_hIcon,true);//设置对话框图标
// TODO: Add extra initialization here
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
RoomType.SetWindowText("标准单人房");
RoomType.AddString("标准单人房");//index==0
RoomType.AddString("标准双人房");
RoomType.AddString("贵族单人房");
RoomType.AddString("贵族双人房");//index==3
//////////////////////////////////
//产生帐单号码
CCreateBillCode billcode;
BillCode.SetWindowText(billcode.GenereBillCodeForCheckOut());
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CChooseRoom::OnSelchangeRoomtype()
{
// TODO: Add your control notification handler code here
///删除以前的记录 this is a bug!!!!
RoomCodeList.ResetContent();//清除所有的项目
CString strComboText;//combobox中的文本
RoomType.GetLBText(RoomType.GetCurSel(),strComboText);//获得选择的文本
/////////////////////////////////////////////////////////////////
// 进行数据库的查询
//roomprice fill
CString SQLstr;
SQLstr="SELECT * FROM RoomInfo where RoomType='" ;
SQLstr=SQLstr+strComboText;
SQLstr=SQLstr+"'";
if(!m_RoomInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE,SQLstr))
{//查询数据库得到数据集合
AfxMessageBox("打开数据库失败!");
return ;
}
CString str;
str.Format("%5.00f",m_RoomInfoSet.m_Price);
RoomPrice.SetWindowText(str);
m_RoomInfoSet.Close(); //关闭数据库
/////////////////////////////////////////////////////////////
if(!m_RoomInfoSet.Open())
{
MessageBox("打开数据库失败!","数据库错误",MB_OK);
return;
}
m_RoomInfoSet.MoveFirst();
while(!m_RoomInfoSet.IsEOF())
{
if(m_RoomInfoSet.m_RoomType==strComboText)
{
if(m_RoomInfoSet.m_RoomStatus=="空")
{
RoomCodeList.AddString(m_RoomInfoSet.m_RoomCode);
}
}
m_RoomInfoSet.MoveNext();
}
m_RoomInfoSet.Close();
////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
int n=RoomCodeList.GetCount();
CString strRoomNum;
strRoomNum.Format("%d",n);
RoomSum.SetWindowText(strRoomNum);//设置总数窗口文本
}
void CChooseRoom::OnAdd()
{
// TODO: Add your control notification handler code here
//将roomcode info add to billinfolist
CString strRoomCode;
if(RoomCodeList.GetCount()==0)
{
return;
}
else
{
if(RoomCodeList.GetCurSel()!=-1)
{
RoomCodeList.GetText(RoomCodeList.GetCurSel(),strRoomCode);
}
}
if(RoomCodeList.GetCurSel()==-1)
{
MessageBox("请选择一个房间","数据为空错误",MB_OK);
return ;
}
CString BillinfoText=strRoomCode;
int n=RoomBillList.GetCount();
CString strTemp="";
bool bSame=false;
for(int i=0;i