void ChangeDish::OnCbnSelchangeComboChangedishTablenumbers() { // TODO: 在此添加控件通知处理程序代码 //step 1. //获取下拉列表中当前被选中的餐桌号 CString tableNo; m_Combo.GetLBText(m_Combo.GetCurSel(), tableNo); //step 2. 获取当前餐桌已经点过的菜品信息 CString sqlCommand("select * from paybill where 桌号="); sqlCommand += tableNo; m_pRs= theApp.m_PConn->Execute((_bstr_t)sqlCommand,NULL,adCmdText); m_List_OrderInfo.DeleteAllItems(); //step 3. 查询将该餐桌已点的菜品信息添加到列表控件中 while (!m_pRs->adoEOF) { CString dName; CString dCount; dName = m_pRs->GetCollect("菜名"); dCount = m_pRs->GetCollect("数量"); m_List_OrderInfo.InsertItem(0,_T("")); m_List_OrderInfo.SetItemText(0,0,dName); m_List_OrderInfo.SetItemText(0,1,dCount); m_pRs->MoveNext(); } }
BOOL OrderDish::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 在此添加额外的初始化 SetIcon(LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON3)), TRUE); m_recipeList.SetExtendedStyle(LVS_EX_FLATSB | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES); m_recipeList.InsertColumn(0, _T("菜名"), LVCFMT_LEFT, 140, 0); m_recipeList.InsertColumn(1, _T("单价 (份/元)"), LVCFMT_LEFT, 140, 1); m_recipeOrderedList.InsertColumn(0, _T("菜名"), LVCFMT_LEFT, 140, 0); m_recipeOrderedList.InsertColumn(1, _T("数量(份)"), LVCFMT_LEFT, 140, 1); CString sqlCommand("select * from caishInfo"); m_pRs = theApp.m_PConn->Execute((_bstr_t)sqlCommand, NULL, adCmdText); int index = 0; while (!m_pRs->adoEOF) { CString tID = m_pRs->GetCollect("菜名"); CString TSta = m_pRs->GetCollect("菜价"); m_recipeList.InsertItem(index, tID); m_recipeList.SetItemText(index, 0, tID); m_recipeList.SetItemText(index, 1, TSta); m_pRs->MoveNext(); } m_combox.AddString(_T("1")); m_combox.AddString(_T("2")); m_combox.AddString(_T("3")); m_combox.AddString(_T("4")); m_combox.AddString(_T("5")); m_combox.AddString(_T("6")); m_combox.AddString(_T("7")); m_combox.AddString(_T("8")); m_combox.AddString(_T("9")); m_combox.AddString(_T("10")); m_combox.AddString(_T("11")); m_combox.SetCurSel(0); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
/** * \brief To initialize the FMS monitor with individual parameters instead of configuration file * \param vishnuId The password of the root user vishnu_user for the connection with the database * \param dbConfig The configuration of the database * \param machineId The machine identifier * \param batchType The batch scheduler type * \return raises an execption */ void MonitorFMS::init(int vishnuId, DbConfiguration dbConfig) { DbFactory factory; mdatabaseVishnu = factory.createDatabaseInstance(dbConfig); std::string sqlCommand("SELECT * FROM vishnu where vishnuid="+vishnu::convertToString(vishnuId)); try { /*connection to the database*/ mdatabaseVishnu->connect(); /* Checking of vishnuid on the database */ boost::scoped_ptr<DatabaseResult> result(mdatabaseVishnu->getResult(sqlCommand.c_str())); if (result->getResults().size() == 0) { throw SystemException(ERRCODE_DBERR, "The vishnuid is unrecognized"); } } catch (VishnuException& e) { exit(0); } }
/** * \brief Function to get user information from the database vishnu * \fn getAttribut(std::string condition, std::string attrname); * \param condition The condition of the select request * \param attrname the name of the attribut to get * \return the value of the attribut or empty string if no results */ std::string UserServer::getAttribut(std::string condition, std::string attrname) { std::string sqlCommand("SELECT "+attrname+" FROM users "+condition); boost::scoped_ptr<DatabaseResult> result(mdatabaseVishnu->getResult(sqlCommand.c_str())); return result->getFirstElement(); }
//加减菜完成后,将用户的点菜信息添加到数据库中 //同时将数据库中用户原来的点菜信息删除 void ChangeDish::OnBnClickedButtonChanngeidshok() { // TODO: 在此添加控件通知处理程序代码 UpdateData(); //step1. 获取顾客的桌号信息 CString tableNo; m_Combo.GetLBText(m_Combo.GetCurSel(), tableNo); if (!tableNo.IsEmpty()) { int dishCount = m_List_OrderInfo.GetItemCount(); if (dishCount==0) { MessageBox(_T("请点菜")); return; } else //删除数据库中此顾客原有的点菜信息 { CString sqlCommand("delete from paybill where 桌号="); sqlCommand += tableNo; theApp.m_PConn->Execute((_bstr_t)sqlCommand,NULL,adCmdText); //将顾客变更后的点菜信息添加到数据库 CString dName; CString dCount; CString dPrice; double totle = 0; CString sTotle; for (size_t i = 0; i < dishCount; i++) { dName= m_List_OrderInfo.GetItemText(i, 0); dCount = m_List_OrderInfo.GetItemText(i, 1); //获取菜价信息 sqlCommand = "select * from caishInfo where 菜名='"; sqlCommand += dName; sqlCommand += "'"; m_pRs = theApp.m_PConn->Execute((_bstr_t)sqlCommand,NULL,adCmdText); dPrice = m_pRs->GetCollect("菜价"); totle = _ttoi(dPrice)*_ttoi(dCount); sTotle.Format(_T("%lf"), totle); sqlCommand = "insert into paybill (桌号,菜名,数量,消费) values ("; sqlCommand += tableNo; sqlCommand += ",'"; sqlCommand += dName; sqlCommand += "',"; sqlCommand += dCount; sqlCommand += ","; sqlCommand += sTotle; sqlCommand += ")"; theApp.m_PConn->Execute((_bstr_t)sqlCommand,NULL,adCmdText); } MessageBox(_T("点菜成功")); CDialog::OnOK(); } } else { MessageBox(_T("请选择桌号")); return; } //step2. }