RoomRegister.cpp
上传用户:sunh8215
上传日期:2010-02-13
资源大小:1616k
文件大小:7k
源码类别:

酒店行业

开发平台:

Visual C++

  1. // RoomRegister.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "qq.h"
  5. #include "RoomRegister.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. #include "InfoSet.h"
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CRoomRegister dialog
  14. CGuestRegister::CGuestRegister(CWnd* pParent /*=NULL*/)
  15. : CDialog(CGuestRegister::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CRoomRegister)
  18. m_nCertificatType = 0;
  19. m_nSex = -1;
  20. m_nGuestType = -1;
  21.     Certificate="身份证";
  22. GuestNum=0;
  23. GuestType="个人";
  24. IsMaster=false;
  25. IsMember=false;
  26.     RoomCode="0";
  27. Sex="男";
  28. //}}AFX_DATA_INIT
  29. year=0;
  30. month=0;
  31. day=0;
  32. hour=0;
  33. minute=0;
  34. second=0;
  35. }
  36. void CGuestRegister::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CDialog::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CRoomRegister)
  40. DDX_Control(pDX, IDC_GROUPID, GroupID);
  41. DDX_Control(pDX, IDC_STARTTIME, StartTime);
  42. DDX_Control(pDX, IDC_CERTIFYCODE, CertifyCode);
  43. DDX_Control(pDX, IDC_GUESTNAME, Name);
  44. DDX_Control(pDX, IDC_HANDCODE, HandCode);
  45. DDX_Radio(pDX, IDC_RADIO1, m_nCertificatType);
  46. DDX_Radio(pDX, IDC_RADIO3, m_nSex);
  47. DDX_Radio(pDX, IDC_RADIO5, m_nGuestType);
  48. //}}AFX_DATA_MAP
  49. }
  50. BEGIN_MESSAGE_MAP(CGuestRegister, CDialog)
  51. //{{AFX_MSG_MAP(CRoomRegister)
  52. ON_BN_CLICKED(IDC_RADIO1, OnCertificatType)
  53. ON_BN_CLICKED(IDC_RADIO3, OnSex)
  54. ON_BN_CLICKED(IDC_RADIO5, OnGuestType)
  55. ON_BN_CLICKED(IDC_RADIO2, OnCertificatType)
  56. ON_BN_CLICKED(IDC_RADIO4, OnSex)
  57. ON_BN_CLICKED(IDC_RADIO6, OnGuestType)
  58. //}}AFX_MSG_MAP
  59. END_MESSAGE_MAP()
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CRoomRegister message handlers
  62. void CGuestRegister::OnOK() 
  63. {
  64. // TODO: Add extra validation here
  65. UpdateData(TRUE);
  66. CString str;
  67. HandCode.GetWindowText(str);
  68. /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  69.            检查数据库中是否已经存在这个手牌号码
  70. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
  71. bool bhas=false;
  72. if(!m_GuestInfoSet.Open())
  73. {
  74. MessageBox("打开数据库失败!","数据库错误",MB_OK);
  75. return;
  76. }
  77. while (!m_GuestInfoSet.IsEOF())
  78. {
  79. if(str==m_GuestInfoSet.m_HandCode)
  80. {
  81. bhas=true;
  82. }
  83. m_GuestInfoSet.MoveNext();
  84. }
  85. m_GuestInfoSet.Close();
  86. if(bhas)
  87. {
  88. MessageBox("已经注册了这个客人!","注册错误",MB_OK);
  89. return;
  90. }
  91. //////////////////////////////////////////////////////////////////////////
  92.     /*
  93.      * 检查身份证的号码是否为15位或者为18位
  94.      */
  95. CString strCertifyCode;//证件号码
  96. CertifyCode.GetWindowText(strCertifyCode);//获得证件号码
  97. int nCertifyCodeLength=strCertifyCode.GetLength();//获得证件的长度
  98. if(nCertifyCodeLength!=15&&nCertifyCodeLength!=18)
  99. {
  100. if(m_nCertificatType==0)
  101. {//若选择的是身份证
  102. MessageBox("你的身份证的号码的位数不正确!n应该为15位或者18位!",
  103. "身份证错误",MB_OK);
  104.     return ;
  105. }
  106. }
  107. if(str!="")
  108. {
  109.    /*
  110.     * 判断该客人是否预定了房间
  111.     */
  112. //  [7/1/2003-11:28]
  113. if(!m_RoomDestine.Open())
  114. {
  115. MessageBox("打开数据库失败!","数据库错误",MB_OK);
  116.     return;
  117. }
  118. m_RoomDestine.MoveFirst();
  119. while (!m_RoomDestine.IsEOF())
  120. {
  121. if(strCertifyCode==m_RoomDestine.m_CeritifyCode)
  122. {
  123.                //查找到该客人已经预定了房间
  124. MessageBox("该客人已经预定了房间",NULL,MB_OK);
  125. }
  126. m_RoomDestine.MoveNext();
  127. }
  128. m_RoomDestine.Close();
  129. //////////////////////////////////////////////////////////////////////////
  130.        if(!m_GuestInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE))
  131.    {//连接数据库
  132.   MessageBox("打开数据库失败!","数据库错误",MB_OK);
  133.   return;
  134.    }
  135.        m_GuestInfoSet.AddNew();//添加一个新的空的记录集 
  136.    m_GuestInfoSet.m_Certificate=Certificate;
  137.        CertifyCode.GetWindowText(m_GuestInfoSet.m_CertifyCode);
  138.        GroupID.GetWindowText(m_GuestInfoSet.m_GroupID);
  139.        m_GuestInfoSet.m_GuestNum=GuestNum;
  140.        m_GuestInfoSet.m_GuestType=GuestType;
  141.        HandCode.GetWindowText(m_GuestInfoSet.m_HandCode);
  142.        m_GuestInfoSet.m_IsMaster=IsMaster;
  143.        m_GuestInfoSet.m_IsMember=IsMember;
  144.        Name.GetWindowText(m_GuestInfoSet.m_Name);
  145.        m_GuestInfoSet.m_RoomCode=RoomCode;
  146.        m_GuestInfoSet.m_RoomNum=RoomNum;
  147.        m_GuestInfoSet.m_Sex=Sex;
  148.        m_GuestInfoSet.Update();//数据更新
  149.        m_GuestInfoSet.Close(); //关闭数据库 
  150. }
  151. ////将开始入住时间写入数据库中
  152.     if(!m_BillCheckoutInfoSet.Open())
  153. {
  154. MessageBox("打开数据库失败!","数据库错误",MB_OK);
  155. return;
  156. }
  157. m_BillCheckoutInfoSet.AddNew();
  158.     CTime time(year,month,day,hour,minute,second,0);
  159. m_BillCheckoutInfoSet.m_StartTime=time;//写入开始时间
  160. m_BillCheckoutInfoSet.m_HandCode=str;//写入手牌号码
  161. m_BillCheckoutInfoSet.Update();
  162. m_BillCheckoutInfoSet.Close();//close the DB
  163. CDialog::OnOK();
  164. }
  165. void CGuestRegister::OnCertificatType() 
  166. {
  167. // TODO: Add your control notification handler code here
  168. UpdateData(true);
  169. if(m_nCertificatType==0)
  170. {
  171.         Certificate="身份证";//设置证件类型为"身份证"
  172. }
  173. if(m_nCertificatType==1)
  174. {
  175.         Certificate="军人证";//设置证件类型为"军人证"
  176. }
  177. }
  178. void CGuestRegister::OnSex() 
  179. {
  180. // TODO: Add your control notification handler code here
  181. this->UpdateData(true);
  182. if(m_nSex==0)
  183. {
  184.         Sex="男";
  185. }
  186. if(m_nSex==1)
  187. {
  188.         Sex="女";
  189. }
  190. }
  191. void CGuestRegister::OnGuestType() 
  192. {
  193. // TODO: Add your control notification handler code here
  194. this->UpdateData(true);
  195. if(m_nGuestType==0)
  196. {
  197.         GuestType="团体成员";
  198. IsMaster=false;
  199.         IsMember=true;
  200. }
  201. if(m_nGuestType==1)
  202. {
  203. GuestType="主客";
  204. IsMember=false;
  205. IsMaster=true;
  206. }
  207. }
  208. BOOL CGuestRegister::OnInitDialog() 
  209. {
  210. CDialog::OnInitDialog();
  211. HICON m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME2);
  212. this->SetIcon(m_hIcon,true);//设置对话框图标
  213. // TODO: Add extra initialization here
  214. /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  215.                 将当前的时间显示在开始入住时间栏中
  216.   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
  217.     CTime time=CTime::GetCurrentTime();//构造时间对象
  218. CTime tm(time);//构造时间对象
  219. year=tm.GetYear();
  220. month=tm.GetMonth();
  221. day=tm.GetDay();
  222. hour=tm.GetHour();
  223. minute=tm.GetMinute();
  224. second=tm.GetSecond();
  225. CString strYear,strMonth,strDay;
  226. strYear.Format("%d",year);
  227. strMonth.Format("%d",month);
  228. strDay.Format("%d",day);
  229. CString strShowText;
  230. strShowText=strYear+"-"+strMonth+"-"+strDay;
  231. CString strCurrentTime=time.Format("%H:%M:%S");
  232. strShowText=strShowText+" "+strCurrentTime;
  233. StartTime.SetWindowText(strShowText);//显示当前时间
  234. //////////////////////////////////////////////////////////////////////////
  235. return TRUE;  // return TRUE unless you set the focus to a control
  236. // EXCEPTION: OCX Property Pages should return FALSE
  237. }
  238. void CGuestRegister::OnCancel() 
  239. {
  240. // TODO: Add extra cleanup here
  241. CDialog::OnCancel();
  242. }