diff --git a/aike/AddRoomDlg.cpp b/aike/AddRoomDlg.cpp new file mode 100644 index 0000000..8ea88af --- /dev/null +++ b/aike/AddRoomDlg.cpp @@ -0,0 +1,903 @@ +// AddRoomDlg.cpp: 实现文件 +// + +#include "pch.h" +#include "aike.h" +#include "afxdialogex.h" +#include "AddRoomDlg.h" +#include "aikeDlg.h" + + +// AddRoomDlg 对话框 + +IMPLEMENT_DYNAMIC(AddRoomDlg, MyDialog) + +AddRoomDlg::AddRoomDlg(CWnd* pParent /*=nullptr*/) + : MyDialog(IDD_ADDROOM, pParent) +{ + Parent = (RoomSetUpDlg*)pParent; +} + +AddRoomDlg::~AddRoomDlg() +{ +} + +void AddRoomDlg::DoDataExchange(CDataExchange* pDX) +{ + MyDialog::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(AddRoomDlg, MyDialog) + ON_BN_CLICKED(IDOK, &AddRoomDlg::OnBnClickedOk) + ON_CBN_SELCHANGE(IDC_COMBO1, &AddRoomDlg::OnCbnSelchangeCombo1) + ON_CBN_SELCHANGE(IDC_COMBO2, &AddRoomDlg::OnCbnSelchangeCombo2) + ON_CBN_SELCHANGE(IDC_COMBO3, &AddRoomDlg::OnCbnSelchangeCombo3) + ON_CBN_SELCHANGE(IDC_COMBO4, &AddRoomDlg::OnCbnSelchangeCombo4) + ON_CBN_SELCHANGE(IDC_COMBO5, &AddRoomDlg::OnCbnSelchangeCombo5) + ON_CBN_SELCHANGE(IDC_COMBO6, &AddRoomDlg::OnCbnSelchangeCombo6) + ON_CBN_SELCHANGE(IDC_COMBO7, &AddRoomDlg::OnCbnSelchangeCombo7) +END_MESSAGE_MAP() + + +// AddRoomDlg 消息处理程序 + + +void AddRoomDlg::OnBnClickedOk() +{ + // TODO: 在此添加控件通知处理程序代码 +} + + +BOOL AddRoomDlg::OnInitDialog() +{ + MyDialog::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + CRect rt = { 0, 0, 75, 30 }; + rt.MoveToXY(160, 300); + AddButton(1, rt); + + + rt.OffsetRect(80, 0); + AddButton(2, rt); + SetLClick(2, [this](int i) {CloseClick(i); }); + SetButText(2, _T("关闭")); + if (RoomId == _T("")) + { + LoadData(); + SetButText(1, _T("添加")); + SetLClick(1, [this](int i) {AddRoomClick(i); }); + } + else + { + GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE); + LoadData(); + SetButText(1, _T("修改")); + SetLClick(1, [this](int i) {UpdateRoomClick(i); }); + } + + return TRUE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + +VOID AddRoomDlg::LoadData() +{ + CString str1, str2, str3, str4, str5, str6, str7, str8, str9, str10; + int count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5 = 0, count6 = 0, count7 = 0; + if (RoomId != _T("")) + { + CaikeDlg* dlg = (CaikeDlg*)theApp.MainDlg; + _RecordsetPtr m_pRecor; + _variant_t var; + CString str; + str.Format(_T("select a.roomID,a.bedcount,a.roomfloor,b.name 'roomtype',c.name 'roomregion',d.name 'roomstyle1',e.name 'roomstyle2',f.name 'roomstyle3',g.name 'roomstyle4',h.name 'BillingRules' from room a left join roomtype b on a.roomtype = b.ID left join roomregion c on a.roomregion = c.id left join roomstyle d on a.roomstyle1 = d.id left join roomstyle e on a.roomstyle2 = e.id left join roomstyle f on a.roomstyle3 = f.id left join roomstyle g on a.roomstyle4 = g.id left join BillingRules h on a.BillingRules = h.id where roomID = '%s'"), RoomId); + dlg->AdoSql.QuerySql(str, m_pRecor); + str1 = RoomId; + if (!m_pRecor->GetadoEOF()) + { + var = m_pRecor->GetCollect("bedcount"); + if (var.vt != VT_NULL) + { + str2 = (LPCTSTR)_bstr_t(var); + } + var = m_pRecor->GetCollect("roomtype"); + if (var.vt != VT_NULL) + { + str3 = (LPCTSTR)_bstr_t(var); + } + var = m_pRecor->GetCollect("roomregion"); + if (var.vt != VT_NULL) + { + str4 = (LPCTSTR)_bstr_t(var); + } + var = m_pRecor->GetCollect("roomfloor"); + if (var.vt != VT_NULL) + { + str5 = (LPCTSTR)_bstr_t(var); + } + var = m_pRecor->GetCollect("BillingRules"); + if (var.vt != VT_NULL) + { + str6 = (LPCTSTR)_bstr_t(var); + } + var = m_pRecor->GetCollect("roomstyle1"); + if (var.vt != VT_NULL) + { + str7 = (LPCTSTR)_bstr_t(var); + } + var = m_pRecor->GetCollect("roomstyle2"); + if (var.vt != VT_NULL) + { + str8 = (LPCTSTR)_bstr_t(var); + } + var = m_pRecor->GetCollect("roomstyle3"); + if (var.vt != VT_NULL) + { + str9 = (LPCTSTR)_bstr_t(var); + } + var = m_pRecor->GetCollect("roomstyle4"); + if (var.vt != VT_NULL) + { + str10 = (LPCTSTR)_bstr_t(var); + } + } + } + CComboBox* cTmp1 = ((CComboBox*)GetDlgItem(IDC_COMBO1)); + for (int i = cTmp1->GetCount() - 1; i >= 0; i--) + { + cTmp1->DeleteString(i); + } + CComboBox* cTmp2 = ((CComboBox*)GetDlgItem(IDC_COMBO2)); + for (int i = cTmp2->GetCount() - 1; i >= 0; i--) + { + cTmp2->DeleteString(i); + } + CComboBox* cTmp3 = ((CComboBox*)GetDlgItem(IDC_COMBO3)); + for (int i = cTmp3->GetCount() - 1; i >= 0; i--) + { + cTmp3->DeleteString(i); + } + CComboBox* cTmp4 = ((CComboBox*)GetDlgItem(IDC_COMBO4)); + for (int i = cTmp4->GetCount() - 1; i >= 0; i--) + { + cTmp4->DeleteString(i); + } + CComboBox* cTmp5 = ((CComboBox*)GetDlgItem(IDC_COMBO5)); + for (int i = cTmp5->GetCount() - 1; i >= 0; i--) + { + cTmp5->DeleteString(i); + } + CComboBox* cTmp6 = ((CComboBox*)GetDlgItem(IDC_COMBO6)); + for (int i = cTmp6->GetCount() - 1; i >= 0; i--) + { + cTmp6->DeleteString(i); + } + CComboBox* cTmp7 = ((CComboBox*)GetDlgItem(IDC_COMBO7)); + for (int i = cTmp7->GetCount() - 1; i >= 0; i--) + { + cTmp7->DeleteString(i); + } + + cTmp3->AddString(_T("")); + cTmp4->AddString(_T("")); + cTmp5->AddString(_T("")); + cTmp6->AddString(_T("")); + cTmp7->AddString(_T("")); + + if (Parent->roomstyle.Size() != 0) + { + int j = 1; + for (auto i = Parent->roomstyle.getBegin(); i != Parent->roomstyle.getEnd(); i++, j++) + { + cTmp4->AddString(i->first); + cTmp5->AddString(i->first); + cTmp6->AddString(i->first); + cTmp7->AddString(i->first); + if (str7 == i->first) + { + count4 = j; + } + if (str8 == i->first) + { + count5 = j; + } + if (str9 == i->first) + { + count6 = j; + } + if (str10 == i->first) + { + count7 = j; + } + } + } + if (Parent->BillingRules.Size() != 0) + { + int j = 1; + for (auto i = Parent->BillingRules.getBegin(); i != Parent->BillingRules.getEnd(); i++, j++) + { + cTmp3->AddString(i->first); + if (str6 == i->first) + { + count3 = j; + } + } + } + if (Parent->roomregion.Size() != 0) + { + int j = 0; + for (auto i = Parent->roomregion.getBegin(); i != Parent->roomregion.getEnd(); i++, j++) + { + cTmp2->AddString(i->first); + if (str4 == i->first) + { + count2 = j; + } + } + } + if (Parent->roomtype.Size() != 0) + { + int j = 0; + for (auto i = Parent->roomtype.getBegin(); i != Parent->roomtype.getEnd(); i++, j++) + { + cTmp1->AddString(i->first); + if (str3 == i->first) + { + count1 = j; + } + } + } + + SetDlgItemText(IDC_EDIT1, str1); + SetDlgItemText(IDC_EDIT5, str2); + SetDlgItemText(IDC_EDIT2, str5); + + cTmp1->SetCurSel(count1); + cTmp2->SetCurSel(count2); + cTmp3->SetCurSel(count3); + cTmp4->SetCurSel(count4); + cTmp5->SetCurSel(count5); + cTmp6->SetCurSel(count6); + cTmp7->SetCurSel(count7); + + cTmp1->AddString(_T("新增")); + cTmp2->AddString(_T("新增")); + cTmp3->AddString(_T("新增")); + cTmp4->AddString(_T("新增")); + cTmp5->AddString(_T("新增")); + cTmp6->AddString(_T("新增")); + cTmp7->AddString(_T("新增")); + +} + + +void AddRoomDlg::OnCbnSelchangeCombo1() +{ + // TODO: 在此添加控件通知处理程序代码 + CString str; + CComboBox* cTmp = ((CComboBox*)GetDlgItem(IDC_COMBO1)); + cTmp->GetWindowText(str); + if (str == _T("新增")) + { + IDNameDlg dlg(this); + dlg.form = _T("roomtype"); + dlg.DoModal(); + Parent->LoadInfo(); + for (int i = cTmp->GetCount() - 1; i >= 0; i--) + { + cTmp->DeleteString(i); + } + if (Parent->roomtype.Size() != 0) + { + for (auto i = Parent->roomtype.getBegin(); i != Parent->roomtype.getEnd(); i++) + { + cTmp->AddString(i->first); + } + } + cTmp->AddString(_T("新增")); + + cTmp->SetCurSel(0); + } +} + + +void AddRoomDlg::OnCbnSelchangeCombo2() +{ + // TODO: 在此添加控件通知处理程序代码 + CString str; + CComboBox* cTmp = ((CComboBox*)GetDlgItem(IDC_COMBO2)); + cTmp->GetWindowText(str); + if (str == _T("新增")) + { + IDNameDlg dlg(this); + dlg.form = _T("roomregion"); + dlg.DoModal(); + Parent->LoadInfo(); + for (int i = cTmp->GetCount() - 1; i >= 0; i--) + { + cTmp->DeleteString(i); + } + if (Parent->roomregion.Size() != 0) + { + for (auto i = Parent->roomregion.getBegin(); i != Parent->roomregion.getEnd(); i++) + { + cTmp->AddString(i->first); + } + } + cTmp->AddString(_T("新增")); + + cTmp->SetCurSel(0); + } +} + + +void AddRoomDlg::OnCbnSelchangeCombo3() +{ + // TODO: 在此添加控件通知处理程序代码 + CString str; + CComboBox* cTmp = ((CComboBox*)GetDlgItem(IDC_COMBO3)); + cTmp->GetWindowText(str); + if (str == _T("新增")) + { + IDNameDlg dlg(this); + dlg.form = _T("BillingRules"); + dlg.DoModal(); + Parent->LoadInfo(); + for (int i = cTmp->GetCount() - 1; i >= 0; i--) + { + cTmp->DeleteString(i); + } + if (Parent->BillingRules.Size() != 0) + { + for (auto i = Parent->BillingRules.getBegin(); i != Parent->BillingRules.getEnd(); i++) + { + cTmp->AddString(i->first); + } + } + cTmp->AddString(_T("新增")); + + cTmp->SetCurSel(0); + } +} + + +void AddRoomDlg::OnCbnSelchangeCombo4() +{ + // TODO: 在此添加控件通知处理程序代码 + CString str1, str2, str3, str4; + int count1 = 0, count2 = 0, count3 = 0, count4 = 0; + CComboBox* cTmp1 = ((CComboBox*)GetDlgItem(IDC_COMBO4)); + CComboBox* cTmp2 = ((CComboBox*)GetDlgItem(IDC_COMBO5)); + CComboBox* cTmp3 = ((CComboBox*)GetDlgItem(IDC_COMBO6)); + CComboBox* cTmp4 = ((CComboBox*)GetDlgItem(IDC_COMBO7)); + cTmp1->GetWindowText(str1); + if (str1 == _T("新增")) + { + cTmp1->GetWindowText(str1); + cTmp2->GetWindowText(str2); + cTmp3->GetWindowText(str3); + cTmp4->GetWindowText(str4); + IDNameDlg dlg(this); + dlg.form = _T("roomstyle"); + dlg.DoModal(); + Parent->LoadInfo(); + for (int i = cTmp1->GetCount() - 1; i >= 0; i--) + { + cTmp1->DeleteString(i); + } + for (int i = cTmp2->GetCount() - 1; i >= 0; i--) + { + cTmp2->DeleteString(i); + } + for (int i = cTmp3->GetCount() - 1; i >= 0; i--) + { + cTmp3->DeleteString(i); + } + for (int i = cTmp4->GetCount() - 1; i >= 0; i--) + { + cTmp4->DeleteString(i); + } + cTmp1->AddString(_T("")); + cTmp2->AddString(_T("")); + cTmp3->AddString(_T("")); + cTmp4->AddString(_T("")); + int j = 1; + if (Parent->roomstyle.Size() != 0) + { + for (auto i = Parent->roomstyle.getBegin(); i != Parent->roomstyle.getEnd(); i++, j++) + { + cTmp1->AddString(i->first); + cTmp2->AddString(i->first); + cTmp3->AddString(i->first); + cTmp4->AddString(i->first); + if (str1 == i->first) + { + count1 = j; + } + if (str2 == i->first) + { + count2 = j; + } + if (str3 == i->first) + { + count3 = j; + } + if (str4 == i->first) + { + count4= j; + } + } + } + cTmp1->AddString(_T("新增")); + cTmp2->AddString(_T("新增")); + cTmp3->AddString(_T("新增")); + cTmp4->AddString(_T("新增")); + + cTmp1->SetCurSel(count1); + cTmp2->SetCurSel(count2); + cTmp3->SetCurSel(count3); + cTmp4->SetCurSel(count4); + } + else if (str1 != _T("")) + { + cTmp2->GetWindowText(str2); + cTmp3->GetWindowText(str3); + cTmp4->GetWindowText(str4); + if (str1 == str2 || str1 == str3 || str1 == str4) + { + MessageBox(_T("该风格已选,请选择其他风格"), _T("温馨提示")); + cTmp1->SetCurSel(0); + } + } +} + + +void AddRoomDlg::OnCbnSelchangeCombo5() +{ + // TODO: 在此添加控件通知处理程序代码 + CString str1, str2, str3, str4; + int count1 = 0, count2 = 0, count3 = 0, count4 = 0; + CComboBox* cTmp1 = ((CComboBox*)GetDlgItem(IDC_COMBO4)); + CComboBox* cTmp2 = ((CComboBox*)GetDlgItem(IDC_COMBO5)); + CComboBox* cTmp3 = ((CComboBox*)GetDlgItem(IDC_COMBO6)); + CComboBox* cTmp4 = ((CComboBox*)GetDlgItem(IDC_COMBO7)); + cTmp2->GetWindowText(str2); + if (str2 == _T("新增")) + { + cTmp1->GetWindowText(str1); + cTmp2->GetWindowText(str2); + cTmp3->GetWindowText(str3); + cTmp4->GetWindowText(str4); + IDNameDlg dlg(this); + dlg.form = _T("roomstyle"); + dlg.DoModal(); + Parent->LoadInfo(); + for (int i = cTmp1->GetCount() - 1; i >= 0; i--) + { + cTmp1->DeleteString(i); + } + for (int i = cTmp2->GetCount() - 1; i >= 0; i--) + { + cTmp2->DeleteString(i); + } + for (int i = cTmp3->GetCount() - 1; i >= 0; i--) + { + cTmp3->DeleteString(i); + } + for (int i = cTmp4->GetCount() - 1; i >= 0; i--) + { + cTmp4->DeleteString(i); + } + cTmp1->AddString(_T("")); + cTmp2->AddString(_T("")); + cTmp3->AddString(_T("")); + cTmp4->AddString(_T("")); + int j = 1; + if (Parent->roomstyle.Size() != 0) + { + for (auto i = Parent->roomstyle.getBegin(); i != Parent->roomstyle.getEnd(); i++, j++) + { + cTmp1->AddString(i->first); + cTmp2->AddString(i->first); + cTmp3->AddString(i->first); + cTmp4->AddString(i->first); + if (str1 == i->first) + { + count1 = j; + } + if (str2 == i->first) + { + count2 = j; + } + if (str3 == i->first) + { + count3 = j; + } + if (str4 == i->first) + { + count4 = j; + } + } + } + cTmp1->AddString(_T("新增")); + cTmp2->AddString(_T("新增")); + cTmp3->AddString(_T("新增")); + cTmp4->AddString(_T("新增")); + + cTmp1->SetCurSel(count1); + cTmp2->SetCurSel(count2); + cTmp3->SetCurSel(count3); + cTmp4->SetCurSel(count4); + } + else if (str2 != _T("")) + { + cTmp1->GetWindowText(str1); + cTmp3->GetWindowText(str3); + cTmp4->GetWindowText(str4); + if (str1 == str2 || str2 == str3 || str2 == str4) + { + MessageBox(_T("该风格已选,请选择其他风格"), _T("温馨提示")); + cTmp2->SetCurSel(0); + } + } +} + + +void AddRoomDlg::OnCbnSelchangeCombo6() +{ + // TODO: 在此添加控件通知处理程序代码 + CString str1, str2, str3, str4; + int count1 = 0, count2 = 0, count3 = 0, count4 = 0; + CComboBox* cTmp1 = ((CComboBox*)GetDlgItem(IDC_COMBO4)); + CComboBox* cTmp2 = ((CComboBox*)GetDlgItem(IDC_COMBO5)); + CComboBox* cTmp3 = ((CComboBox*)GetDlgItem(IDC_COMBO6)); + CComboBox* cTmp4 = ((CComboBox*)GetDlgItem(IDC_COMBO7)); + cTmp3->GetWindowText(str3); + if (str3 == _T("新增")) + { + cTmp1->GetWindowText(str1); + cTmp2->GetWindowText(str2); + cTmp3->GetWindowText(str3); + cTmp4->GetWindowText(str4); + IDNameDlg dlg(this); + dlg.form = _T("roomstyle"); + dlg.DoModal(); + Parent->LoadInfo(); + for (int i = cTmp1->GetCount() - 1; i >= 0; i--) + { + cTmp1->DeleteString(i); + } + for (int i = cTmp2->GetCount() - 1; i >= 0; i--) + { + cTmp2->DeleteString(i); + } + for (int i = cTmp3->GetCount() - 1; i >= 0; i--) + { + cTmp3->DeleteString(i); + } + for (int i = cTmp4->GetCount() - 1; i >= 0; i--) + { + cTmp4->DeleteString(i); + } + cTmp1->AddString(_T("")); + cTmp2->AddString(_T("")); + cTmp3->AddString(_T("")); + cTmp4->AddString(_T("")); + if (Parent->roomstyle.Size() != 0) + { + int j = 1; + for (auto i = Parent->roomstyle.getBegin(); i != Parent->roomstyle.getEnd(); i++, j++) + { + cTmp1->AddString(i->first); + cTmp2->AddString(i->first); + cTmp3->AddString(i->first); + cTmp4->AddString(i->first); + if (str1 == i->first) + { + count1 = j; + } + if (str2 == i->first) + { + count2 = j; + } + if (str3 == i->first) + { + count3 = j; + } + if (str4 == i->first) + { + count4 = j; + } + } + } + cTmp1->AddString(_T("新增")); + cTmp2->AddString(_T("新增")); + cTmp3->AddString(_T("新增")); + cTmp4->AddString(_T("新增")); + + cTmp1->SetCurSel(count1); + cTmp2->SetCurSel(count2); + cTmp3->SetCurSel(count3); + cTmp4->SetCurSel(count4); + + } + else if (str3 != _T("")) + { + cTmp1->GetWindowText(str1); + cTmp2->GetWindowText(str2); + cTmp4->GetWindowText(str4); + if (str3 == str2 || str1 == str3 || str3 == str4) + { + MessageBox(_T("该风格已选,请选择其他风格"), _T("温馨提示")); + cTmp3->SetCurSel(0); + } + } +} + + +void AddRoomDlg::OnCbnSelchangeCombo7() +{ + // TODO: 在此添加控件通知处理程序代码 + CString str1, str2, str3, str4; + int count1 = 0, count2 = 0, count3 = 0, count4 = 0; + CComboBox* cTmp1 = ((CComboBox*)GetDlgItem(IDC_COMBO4)); + CComboBox* cTmp2 = ((CComboBox*)GetDlgItem(IDC_COMBO5)); + CComboBox* cTmp3 = ((CComboBox*)GetDlgItem(IDC_COMBO6)); + CComboBox* cTmp4 = ((CComboBox*)GetDlgItem(IDC_COMBO7)); + cTmp4->GetWindowText(str4); + if (str4 == _T("新增")) + { + cTmp1->GetWindowText(str1); + cTmp2->GetWindowText(str2); + cTmp3->GetWindowText(str3); + cTmp4->GetWindowText(str4); + IDNameDlg dlg(this); + dlg.form = _T("roomstyle"); + dlg.DoModal(); + Parent->LoadInfo(); + for (int i = cTmp1->GetCount() - 1; i >= 0; i--) + { + cTmp1->DeleteString(i); + } + for (int i = cTmp2->GetCount() - 1; i >= 0; i--) + { + cTmp2->DeleteString(i); + } + for (int i = cTmp3->GetCount() - 1; i >= 0; i--) + { + cTmp3->DeleteString(i); + } + for (int i = cTmp4->GetCount() - 1; i >= 0; i--) + { + cTmp4->DeleteString(i); + } + cTmp1->AddString(_T("")); + cTmp2->AddString(_T("")); + cTmp3->AddString(_T("")); + cTmp4->AddString(_T("")); + if (Parent->roomstyle.Size() != 0) + { + int j = 1; + for (auto i = Parent->roomstyle.getBegin(); i != Parent->roomstyle.getEnd(); i++, j++) + { + cTmp1->AddString(i->first); + cTmp2->AddString(i->first); + cTmp3->AddString(i->first); + cTmp4->AddString(i->first); + if (str1 == i->first) + { + count1 = j; + } + if (str2 == i->first) + { + count2 = j; + } + if (str3 == i->first) + { + count3 = j; + } + if (str4 == i->first) + { + count4 = j; + } + } + } + cTmp1->AddString(_T("新增")); + cTmp2->AddString(_T("新增")); + cTmp3->AddString(_T("新增")); + cTmp4->AddString(_T("新增")); + + cTmp1->SetCurSel(count1); + cTmp2->SetCurSel(count2); + cTmp3->SetCurSel(count3); + cTmp4->SetCurSel(count4); + } + else if (str4 != _T("")) + { + cTmp1->GetWindowText(str1); + cTmp2->GetWindowText(str2); + cTmp3->GetWindowText(str3); + if (str4 == str2 || str4 == str3 || str1 == str4) + { + MessageBox(_T("该风格已选,请选择其他风格"), _T("温馨提示")); + cTmp4->SetCurSel(0); + } + } +} + +VOID AddRoomDlg::AddRoomClick(int id) +{ + CString str1, str2, str3, str4, str5, str6, str7, str8, str9, str10; + GetDlgItemText(IDC_COMBO1, str1); + GetDlgItemText(IDC_COMBO2, str2); + GetDlgItemText(IDC_COMBO3, str3); + GetDlgItemText(IDC_COMBO4, str4); + GetDlgItemText(IDC_COMBO5, str5); + GetDlgItemText(IDC_COMBO6, str6); + GetDlgItemText(IDC_COMBO7, str7); + GetDlgItemText(IDC_EDIT1, str8); + GetDlgItemText(IDC_EDIT2, str9); + GetDlgItemText(IDC_EDIT5, str10); + + if (str8 == _T("") || str8.GetLength() > 10) + { + MessageBox(_T("房间号超长或为空"), _T("温馨提示")); + GetDlgItem(IDC_EDIT1)->SetFocus(); + return; + } + if (str10 == _T("")) + { + MessageBox(_T("请输入房间楼层"), _T("温馨提示")); + GetDlgItem(IDC_EDIT5)->SetFocus(); + return; + } + if (str1 == _T("")) + { + MessageBox(_T("请选择房间类型"), _T("温馨提示")); + return; + } + if (str2 == _T("")) + { + MessageBox(_T("请选择房间区域"), _T("温馨提示")); + return; + } + if (str9 == _T("")) + { + MessageBox(_T("请输入楼层"), _T("温馨提示")); + GetDlgItem(IDC_EDIT2)->SetFocus(); + return; + } + if (Parent->roomtype.Find(str1) != Parent->roomtype.getEnd()) + str1 = Parent->roomtype[str1].asCString(); + if (Parent->roomregion.Find(str2) != Parent->roomregion.getEnd()) + str2 = Parent->roomregion[str2].asCString(); + if (Parent->BillingRules.Find(str3) != Parent->BillingRules.getEnd()) + str3 = Parent->BillingRules[str3].asCString(); + if (Parent->roomstyle.Find(str4) != Parent->roomstyle.getEnd()) + str4 = Parent->roomstyle[str4].asCString(); + if (Parent->roomstyle.Find(str5) != Parent->roomstyle.getEnd()) + str5 = Parent->roomstyle[str5].asCString(); + if (Parent->roomstyle.Find(str6) != Parent->roomstyle.getEnd()) + str6 = Parent->roomstyle[str6].asCString(); + if (Parent->roomstyle.Find(str7) != Parent->roomstyle.getEnd()) + str7 = Parent->roomstyle[str7].asCString(); + + CaikeDlg* dlg = (CaikeDlg*)theApp.MainDlg; + _RecordsetPtr m_pRecor; + _variant_t var; + CString str; + str.Format(_T("select * from room where roomID = '%s'"), str8); + dlg->AdoSql.QuerySql(str, m_pRecor); + int i = 0; + if (!m_pRecor->GetadoEOF()) + { + MessageBox(_T("房间号重复"), _T("温馨提示")); + GetDlgItem(IDC_EDIT2)->SetFocus(); + return; + } + else + { + str.Format(_T("INSERT INTO room (roomID,bedcount,roomtype,roomregion,roomfloor,BillingRules,roomstyle1,roomstyle2,roomstyle3,roomstyle4) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')"), str8, str10, str1, str2, str9, str3, str4, str5, str6, str7); + if (dlg->AdoSql.ImplementSQL(str)) + { + Parent->LoadRoom(); + } + else + { + MessageBox(_T("SQL执行失败"), _T("温馨提示")); + } + } + MyDialog::OnOK(); +} + +VOID AddRoomDlg::UpdateRoomClick(int id) +{ + CString str1, str2, str3, str4, str5, str6, str7, str8, str9, str10; + GetDlgItemText(IDC_COMBO1, str1); + GetDlgItemText(IDC_COMBO2, str2); + GetDlgItemText(IDC_COMBO3, str3); + GetDlgItemText(IDC_COMBO4, str4); + GetDlgItemText(IDC_COMBO5, str5); + GetDlgItemText(IDC_COMBO6, str6); + GetDlgItemText(IDC_COMBO7, str7); + GetDlgItemText(IDC_EDIT1, str8); + GetDlgItemText(IDC_EDIT2, str9); + GetDlgItemText(IDC_EDIT5, str10); + + if (str8 == _T("") || str8.GetLength() > 10) + { + MessageBox(_T("房间号超长或为空"), _T("温馨提示")); + GetDlgItem(IDC_EDIT1)->SetFocus(); + return; + } + if (str10 == _T("")) + { + MessageBox(_T("请输入房间楼层"), _T("温馨提示")); + GetDlgItem(IDC_EDIT5)->SetFocus(); + return; + } + if (str1 == _T("")) + { + MessageBox(_T("请选择房间类型"), _T("温馨提示")); + return; + } + if (str2 == _T("")) + { + MessageBox(_T("请选择房间区域"), _T("温馨提示")); + return; + } + if (str9 == _T("")) + { + MessageBox(_T("请输入楼层"), _T("温馨提示")); + GetDlgItem(IDC_EDIT2)->SetFocus(); + return; + } + if (Parent->roomtype.Find(str1) != Parent->roomtype.getEnd()) + str1 = Parent->roomtype[str1].asCString(); + if (Parent->roomregion.Find(str2) != Parent->roomregion.getEnd()) + str2 = Parent->roomregion[str2].asCString(); + if (Parent->BillingRules.Find(str3) != Parent->BillingRules.getEnd()) + str3 = Parent->BillingRules[str3].asCString(); + if (Parent->roomstyle.Find(str4) != Parent->roomstyle.getEnd()) + str4 = Parent->roomstyle[str4].asCString(); + if (Parent->roomstyle.Find(str5) != Parent->roomstyle.getEnd()) + str5 = Parent->roomstyle[str5].asCString(); + if (Parent->roomstyle.Find(str6) != Parent->roomstyle.getEnd()) + str6 = Parent->roomstyle[str6].asCString(); + if (Parent->roomstyle.Find(str7) != Parent->roomstyle.getEnd()) + str7 = Parent->roomstyle[str7].asCString(); + + CaikeDlg* dlg = (CaikeDlg*)theApp.MainDlg; + _RecordsetPtr m_pRecor; + _variant_t var; + CString str; + str.Format(_T("select * from room where roomID = '%s'"), str8); + dlg->AdoSql.QuerySql(str, m_pRecor); + int i = 0; + if (m_pRecor->GetadoEOF()) + { + MessageBox(_T("该房间已被删除,修改失败"), _T("温馨提示")); + Parent->LoadRoom(); + MyDialog::OnOK(); + return; + } + else + { + str.Format(_T("update room set roomID = '%s',bedcount = '%s',roomtype = '%s',roomregion = '%s',roomfloor = '%s',BillingRules = '%s',roomstyle1 = '%s',roomstyle2 = '%s',roomstyle3 = '%s',roomstyle4 = '%s' where roomID = '%s'"), str8, str10, str1, str2, str9, str3, str4, str5, str6, str7, RoomId); + if (dlg->AdoSql.ImplementSQL(str)) + { + Parent->LoadRoom(); + } + else + { + MessageBox(_T("SQL执行失败"), _T("温馨提示")); + } + } + MyDialog::OnOK(); +} + +VOID AddRoomDlg::CloseClick(int id) +{ + MyDialog::OnCancel(); +} diff --git a/aike/AddRoomDlg.h b/aike/AddRoomDlg.h new file mode 100644 index 0000000..860761a --- /dev/null +++ b/aike/AddRoomDlg.h @@ -0,0 +1,40 @@ +#pragma once +#include "afxdialogex.h" + + +// AddRoomDlg 对话框 + +class AddRoomDlg : public MyDialog +{ + DECLARE_DYNAMIC(AddRoomDlg) + +public: + AddRoomDlg(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~AddRoomDlg(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ADDROOM }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedOk(); + RoomSetUpDlg* Parent; + CString RoomId; + virtual BOOL OnInitDialog(); + VOID LoadData(); + afx_msg void OnCbnSelchangeCombo1(); + afx_msg void OnCbnSelchangeCombo2(); + afx_msg void OnCbnSelchangeCombo3(); + afx_msg void OnCbnSelchangeCombo4(); + afx_msg void OnCbnSelchangeCombo5(); + afx_msg void OnCbnSelchangeCombo6(); + afx_msg void OnCbnSelchangeCombo7(); + VOID AddRoomClick(int id); + VOID UpdateRoomClick(int id); + VOID CloseClick(int id); +}; diff --git a/aike/RoomSetUpDlg.cpp b/aike/RoomSetUpDlg.cpp index 9448912..5b1c616 100644 --- a/aike/RoomSetUpDlg.cpp +++ b/aike/RoomSetUpDlg.cpp @@ -34,6 +34,7 @@ BEGIN_MESSAGE_MAP(RoomSetUpDlg, CDialogEx) ON_BN_CLICKED(IDC_BUTTON5, &RoomSetUpDlg::OnBnClickedButton5) ON_BN_CLICKED(IDC_BUTTON6, &RoomSetUpDlg::OnBnClickedButton6) ON_BN_CLICKED(IDC_BUTTON7, &RoomSetUpDlg::OnBnClickedButton7) + ON_BN_CLICKED(IDC_BUTTON3, &RoomSetUpDlg::OnBnClickedButton3) END_MESSAGE_MAP() @@ -59,7 +60,8 @@ void RoomSetUpDlg::OnOK() void RoomSetUpDlg::OnBnClickedButton1() { // TODO: 在此添加控件通知处理程序代码 - + AddRoomDlg dlg(this); + dlg.DoModal(); } @@ -92,7 +94,8 @@ void RoomSetUpDlg::OnBnClickedButton7() VOID RoomSetUpDlg::LoadRoom() { CaikeDlg* dlg = (CaikeDlg*)theApp.MainDlg; - RoomInfo = Json(); + Json temp; + RoomInfo = temp; m_List.DeleteAllItems(); _RecordsetPtr m_pRecor; _variant_t var; @@ -191,7 +194,155 @@ VOID RoomSetUpDlg::LoadRoom() RoomInfo[roomId] = tmpRoom; i++; } + LoadInfo(); +} +VOID RoomSetUpDlg::LoadInfo() +{ + CString str, roomId, tmp; + CaikeDlg* dlg = (CaikeDlg*)theApp.MainDlg; + Json temp; + roomtype = temp; + roomregion = temp; + BillingRules = temp; + roomstyle = temp; + _RecordsetPtr m_pRecor; + _variant_t var; + str = (_T("select * from roomtype")); + dlg->AdoSql.QuerySql(str, m_pRecor); + while (!m_pRecor->GetadoEOF()) + { + var = m_pRecor->GetCollect("name"); + if (var.vt != VT_NULL) + { + roomId = (LPCTSTR)_bstr_t(var); + if (roomId == _T("")) + { + m_pRecor->MoveNext(); + continue; + } + } + else + { + m_pRecor->MoveNext(); + continue; + } + var = m_pRecor->GetCollect("ID"); + if (var.vt != VT_NULL) + { + tmp = (LPCTSTR)_bstr_t(var); + roomtype[roomId] = tmp; + } + m_pRecor->MoveNext(); + } + str = (_T("select * from roomtype")); + dlg->AdoSql.QuerySql(str, m_pRecor); + while (!m_pRecor->GetadoEOF()) + { + var = m_pRecor->GetCollect("name"); + if (var.vt != VT_NULL) + { + roomId = (LPCTSTR)_bstr_t(var); + if (roomId == _T("")) + { + m_pRecor->MoveNext(); + continue; + } + } + else + { + m_pRecor->MoveNext(); + continue; + } + var = m_pRecor->GetCollect("ID"); + if (var.vt != VT_NULL) + { + tmp = (LPCTSTR)_bstr_t(var); + roomtype[roomId] = tmp; + } + m_pRecor->MoveNext(); + } + str = (_T("select * from roomregion")); + dlg->AdoSql.QuerySql(str, m_pRecor); + while (!m_pRecor->GetadoEOF()) + { + var = m_pRecor->GetCollect("name"); + if (var.vt != VT_NULL) + { + roomId = (LPCTSTR)_bstr_t(var); + if (roomId == _T("")) + { + m_pRecor->MoveNext(); + continue; + } + } + else + { + m_pRecor->MoveNext(); + continue; + } + var = m_pRecor->GetCollect("ID"); + if (var.vt != VT_NULL) + { + tmp = (LPCTSTR)_bstr_t(var); + roomregion[roomId] = tmp; + } + m_pRecor->MoveNext(); + } + str = (_T("select * from BillingRules")); + dlg->AdoSql.QuerySql(str, m_pRecor); + while (!m_pRecor->GetadoEOF()) + { + var = m_pRecor->GetCollect("name"); + if (var.vt != VT_NULL) + { + roomId = (LPCTSTR)_bstr_t(var); + if (roomId == _T("")) + { + m_pRecor->MoveNext(); + continue; + } + } + else + { + m_pRecor->MoveNext(); + continue; + } + var = m_pRecor->GetCollect("ID"); + if (var.vt != VT_NULL) + { + tmp = (LPCTSTR)_bstr_t(var); + BillingRules[roomId] = tmp; + } + m_pRecor->MoveNext(); + } + str = (_T("select * from roomstyle")); + dlg->AdoSql.QuerySql(str, m_pRecor); + while (!m_pRecor->GetadoEOF()) + { + var = m_pRecor->GetCollect("name"); + if (var.vt != VT_NULL) + { + roomId = (LPCTSTR)_bstr_t(var); + if (roomId == _T("")) + { + m_pRecor->MoveNext(); + continue; + } + } + else + { + m_pRecor->MoveNext(); + continue; + } + var = m_pRecor->GetCollect("ID"); + if (var.vt != VT_NULL) + { + tmp = (LPCTSTR)_bstr_t(var); + roomstyle[roomId] = tmp; + } + m_pRecor->MoveNext(); + } } @@ -212,3 +363,20 @@ BOOL RoomSetUpDlg::OnInitDialog() return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } + + +void RoomSetUpDlg::OnBnClickedButton3() +{ + // TODO: 在此添加控件通知处理程序代码 + int nIdx = m_List.GetNextItem(-1, LVIS_SELECTED); + if (nIdx < 0) + { + MessageBox(_T("没有选中任何行"), _T("温馨提示")); + } + else + { + AddRoomDlg dlg(this); + dlg.RoomId = m_List.GetItemText(nIdx, 0); + dlg.DoModal(); + } +} diff --git a/aike/RoomSetUpDlg.h b/aike/RoomSetUpDlg.h index e3b08c2..b25d520 100644 --- a/aike/RoomSetUpDlg.h +++ b/aike/RoomSetUpDlg.h @@ -29,8 +29,11 @@ public: afx_msg void OnBnClickedButton6(); afx_msg void OnBnClickedButton7(); VOID LoadRoom(); + VOID LoadInfo(); CListCtrl m_List; virtual BOOL OnInitDialog(); - Json RoomInfo; + Json RoomInfo, roomtype, roomregion, BillingRules, roomstyle; + + afx_msg void OnBnClickedButton3(); }; diff --git a/aike/aike.rc b/aike/aike.rc index b0c8898..2aae792 100644 Binary files a/aike/aike.rc and b/aike/aike.rc differ diff --git a/aike/aike.vcxproj b/aike/aike.vcxproj index c01ff6e..89f2a8e 100644 --- a/aike/aike.vcxproj +++ b/aike/aike.vcxproj @@ -185,6 +185,7 @@ + @@ -204,6 +205,7 @@ + diff --git a/aike/aike.vcxproj.filters b/aike/aike.vcxproj.filters index f11d6a8..fbbb297 100644 --- a/aike/aike.vcxproj.filters +++ b/aike/aike.vcxproj.filters @@ -66,6 +66,9 @@ 头文件 + + 头文件 + @@ -110,6 +113,9 @@ 源文件 + + 源文件 + diff --git a/aike/pch.h b/aike/pch.h index 60c7143..e1cd644 100644 --- a/aike/pch.h +++ b/aike/pch.h @@ -29,5 +29,6 @@ #include "CouponDlg.h" #include "ParameterDlg.h" #include "LogInDlg.h" +#include "AddRoomDlg.h" #endif //PCH_H diff --git a/aike/resource.h b/aike/resource.h index 71ebc65..7934886 100644 --- a/aike/resource.h +++ b/aike/resource.h @@ -16,6 +16,7 @@ #define IDD_PARAMENTERDLG 141 #define IDD_LOGINDLG 142 #define IDD_IDNAMEDLG 144 +#define IDD_ADDROOM 146 #define IDC_LIST1 1000 #define IDC_BUTTON1 1001 #define IDC_BUTTON2 1002 @@ -24,15 +25,23 @@ #define IDC_BUTTON3 1003 #define IDC_CHECK1 1004 #define IDC_BUTTON4 1004 +#define IDC_EDIT5 1004 #define IDC_STATIC1 1005 #define IDC_BUTTON5 1005 #define IDC_STATIC2 1006 #define IDC_BUTTON6 1006 #define IDC_EDIT3 1007 #define IDC_BUTTON7 1007 +#define IDC_COMBO1 1007 #define IDC_EDIT4 1008 #define IDC_BUTTON8 1008 +#define IDC_COMBO2 1008 #define IDC_STATIC3 1009 +#define IDC_COMBO3 1009 +#define IDC_COMBO4 1010 +#define IDC_COMBO5 1011 +#define IDC_COMBO6 1012 +#define IDC_COMBO7 1013 #define ID_32771 32771 #define ID_32772 32772 #define ID_SHOW_MENU 32773 @@ -42,9 +51,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 146 +#define _APS_NEXT_RESOURCE_VALUE 149 #define _APS_NEXT_COMMAND_VALUE 32775 -#define _APS_NEXT_CONTROL_VALUE 1007 +#define _APS_NEXT_CONTROL_VALUE 1008 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif