宾馆管理系统 数据库课程设计报告
{
AfxMessageBox(_T(\住房单价:请输入非零数字\
return; }
m_sPrice.Format(\if ( atof(m_sPrice)>99999999.99 ) {
AfxMessageBox(_T(\住房单价溢出,请不要超过
99999999.99\
MB_ICONEXCLAMATION); return; } _variant_t strQuery; if (m_bAppend) { // Judge Room Type is Unique strQuery = \ theApp.ADOExecute(theApp.m_pADOSet, strQuery); int iCount = theApp.m_pADOSet->GetRecordCount(); if ( 0!=iCount ) { AfxMessageBox(_T(\已经存在此标准编号的记录!\ return; } // Judge Room Name is Unique strQuery = \* from roomtype where typeid!='\and typename='\ theApp.ADOExecute(theApp.m_pADOSet, strQuery); iCount = theApp.m_pADOSet->GetRecordCount(); if ( 0!=iCount ) { AfxMessageBox(_T(\已经存相同客房标准的记录!\ return; } }
// Get other info CString sAir(\ if ( ((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISAIRCON))->GetCurSel() ) sAir=\ if ( ((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTEL))->GetCurSel() ) sTel=\ if ( ((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTV))->GetCurSel() ) sTV=\ if ( ((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTOILET))->GetCurSel() ) sToilet=\ if (m_bAppend)// Append Record { strQuery = \roomtype (typeid, typename, area, bednum, price, haircondition, htelephone, htelevision, htoilet) \\values ('\ \
26
宾馆管理系统 数据库课程设计报告
\ if ( theApp.ADOExecute(theApp.m_pADOSet, strQuery) ) { AfxMessageBox(_T(\添加记录成功!\ // Clear all input
m_sTypeID=m_sTypeName=m_sArea=m_sBedNo=m_sPrice=\
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISAIRCON))->SetCurSel(1); ((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTEL))->SetCurSel(1); ((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTV))->SetCurSel(1); ((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTOILET))->SetCurSel(1); UpdateData(false); } else AfxMessageBox(_T(\添加记录失败!\
} else// Alter Record { strQuery = \roomtype set area=\bednum=\price=\haircondition=\\\htelephone=\htelevision=\htoilet=\ if ( theApp.ADOExecute(theApp.m_pADOSet, strQuery) ) AfxMessageBox(_T(\修改记录成功!\ else AfxMessageBox(_T(\修改记录失败!\ } // Refresh RoomType List CHotel_MISView* p
(CHotel_MISView*)(((CMainFrame*)AfxGetMainWnd())->GetActiveView()); p->RefreshRoomType(); if (!m_bAppend) CDialog::OnOK(); }
=
1.3 客房信息管理模块的实现
void CRoomDLG::OnOK() { // TODO: Add extra validation here UpdateData(true); m_sNo.TrimRight(\
m_sPosition.TrimRight(\ m_sPrice.TrimRight(\ m_sMemo.TrimRight(\ // Make sure all needed info is available CString sWarning=\ if ( \客房编号\
else if ( \客房位置\ else if ( \客房价格\
27
宾馆管理系统 数据库课程设计报告
if ( \ {
sWarning += _T(\不能为空\
AfxMessageBox(sWarning, MB_ICONEXCLAMATION); return; }
// Make sure the Number info is valid float fPrice=atof(m_sPrice); if ( 0==fPrice ) { AfxMessageBox(_T(\客房单价:请输入非零数字\ return; }
m_sPrice.Format(\_variant_t strQuery; if (m_bAppend) { // Judge Room No is Unique
strQuery = \ theApp.ADOExecute(theApp.m_pADOSet, strQuery); int iCount = theApp.m_pADOSet->GetRecordCount(); if ( 0!=iCount ) {
AfxMessageBox(_T(\已经存在此客房编号的记录!\
return; } } if (m_bAppend)// Append Record { strQuery = \ values ('\'\ '\\'\ if ( theApp.ADOExecute(theApp.m_pADOSet, strQuery) ) { AfxMessageBox(_T(\添加记录成功!\ // Clear all input
m_sNo=m_sType=m_sPosition=m_sPrice=m_sMemo=\
((CComboBox*)GetDlgItem(IDD_ROOM_TYPE))->SetCurSel(0); UpdateData(false); } else AfxMessageBox(_T(\添加记录失败!\ } else {
28
宾馆管理系统 数据库课程设计报告
strQuery = \rooms set roomtype='\roomposition='\roomNo='\ if ( theApp.ADOExecute(theApp.m_pADOSet, strQuery) ) AfxMessageBox(_T(\修改记录成功!\ else AfxMessageBox(_T(\修改记录失败!\ } // Refresh Room List strQuery = \ CHotel_MISView* p
(CHotel_MISView*)(((CMainFrame*)AfxGetMainWnd())->GetActiveView()); p->RefreshRoom(strQuery); if (!m_bAppend) CDialog::OnOK(); }
BOOL CRoomDLG::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here // Set Edit Text limit ((CEdit*)GetDlgItem(IDD_ROOM_NO))->SetLimitText(10); ((CEdit*)GetDlgItem(IDD_ROOM_POSITION))->SetLimitText(20); ((CEdit*)GetDlgItem(IDD_ROOM_PRICE))->SetLimitText(8); if (m_bAppend) { // Update Dialog Caption SetWindowText(_T(\添加客房信息\ // Init Combobox _variant_t strQuery, Holder; strQuery = \ theApp.ADOExecute(theApp.m_pADOSet, strQuery); int iCount = theApp.m_pADOSet->GetRecordCount(); theApp.m_pADOSet->MoveFirst(); for (int i=0; i
=
29
宾馆管理系统 数据库课程设计报告
theApp.m_pADOSet->MoveNext(); }
((CComboBox*)GetDlgItem(IDD_ROOM_TYPE))->SetCurSel(0); } else { // Update Dialog Caption SetWindowText(_T(\修改客房信息\
// Disable room no edit GetDlgItem(IDD_ROOM_NO)->EnableWindow(false); // Init Combobox _variant_t strQuery, Holder; CString sType; int iSel=0; strQuery = \ theApp.ADOExecute(theApp.m_pADOSet, strQuery); int iCount = theApp.m_pADOSet->GetRecordCount(); theApp.m_pADOSet->MoveFirst(); for (int i=0; i
void CRoomDLG::OnRoomTypeChange() { // TODO: Add your control notification handler code here UpdateData(true); // Get Room type int iIndex = ((CComboBox*)GetDlgItem(IDD_ROOM_TYPE))->GetCurSel(); CString sType;
((CComboBox*)GetDlgItem(IDD_ROOM_TYPE))->GetLBText(iIndex, sType); _variant_t strQuery, Holder;
strQuery = \ theApp.ADOExecute(theApp.m_pADOSet, strQuery); int iCount = theApp.m_pADOSet->GetRecordCount();
30