private void reset_order_money(COrders order) { var menu = dao.get_Menu("name", order.menu); //var menu = db.Menu.FirstOrDefault(x => x.name == order.menu); if (menu != null) { if (order.priceType == "每小时") order.money = Convert.ToDouble(menu.addMoney); else if (order.comboId == null) order.money = menu.price * order.number; else if (order.comboId != null) { var combo = dao.get_Combo("id", order.comboId); if (combo == null) return; var freeIds = combo.disAssemble_freeIds(); var pars = new List<string>(); var vals = new List<string>(); int count = freeIds.Count; for (int i = 0; i < count; i++) { pars.Add("id"); vals.Add(freeIds[i].ToString()); } var freeMenus = dao.get_Menus(pars, vals, "or").Select(x => x.name); if (!freeMenus.Contains(order.menu)) order.money = menu.price * order.number; } } else { var combo = dao.get_Combo("id", order.comboId); order.money = combo.get_combo_price(dao); } }
public COrders get_order(List<string> key, List<string> key_val, string logic) { COrders order = null; SqlConnection sqlCn = null; try { sqlCn = new SqlConnection(_con_str); sqlCn.Open(); string cmd_str = "Select * from [Seat] where ("; int count = key.Count; for (int i = 0; i < count; i++) { cmd_str += key + "='" + key_val + "'"; if (i != count - 1) cmd_str += ", " + logic + " "; } SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { order = new COrders(); order.id = (int)dr["id"]; order.menu = dr["menu"].ToString(); order.text = dr["text"].ToString(); order.systemId = dr["systemId"].ToString(); order.number = (double)dr["number"]; order.priceType = dr["priceType"].ToString(); order.money = (double)dr["money"]; order.technician = dr["technician"].ToString(); order.techType = dr["techType"].ToString(); order.inputTime = (DateTime)dr["inputTime"]; order.inputEmployee = dr["inputEmployee"].ToString(); order.deleteEmployee = dr["deleteEmployee"].ToString(); order.comboId = ToInt(dr["comboId"]); order.paid = (bool)dr["paid"]; order.accountId = ToInt(dr["accountId"]); order.billId = dr["billId"].ToString(); } } } catch (System.Exception e) { BathClass.printErrorMsg(e.Message); } finally { close_connection(sqlCn); } return order; }
public List<COrders> get_orders(string cmd_str) { List<COrders> orders = new List<COrders>(); SqlConnection sqlCn = null; try { sqlCn = new SqlConnection(_con_str); sqlCn.Open(); cmd_str = "Select * from [Orders] where (" + cmd_str + ")"; SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { var order = new COrders(); order.id = (int)dr["id"]; order.menu = dr["menu"].ToString(); order.text = dr["text"].ToString(); order.systemId = dr["systemId"].ToString(); order.number = (double)dr["number"]; order.priceType = dr["priceType"].ToString(); order.money = (double)dr["money"]; order.technician = dr["technician"].ToString(); order.techType = dr["techType"].ToString(); order.inputTime = (DateTime)dr["inputTime"]; order.inputEmployee = dr["inputEmployee"].ToString(); order.deleteEmployee = dr["deleteEmployee"].ToString(); order.comboId = ToInt(dr["comboId"]); order.paid = (bool)dr["paid"]; order.accountId = ToInt(dr["accountId"]); order.billId = dr["billId"].ToString(); orders.Add(order); } } } catch (System.Exception e) { //IOUtil.insert_file(DateTime.Now.ToString() + "=" + cmd_str); //BathClass.printErrorMsg(cmd_str); IOUtil.insert_file(e.Message); IOUtil.insert_file("time=" + DateTime.Now.ToString() + ",cmd_str=" + cmd_str); IOUtil.insert_file("\n"); BathClass.printErrorMsg(e.Message); } finally { close_connection(sqlCn); } return orders; }
public COrders get_order(string key, object key_val) { COrders order = null; SqlConnection sqlCn = null; try { sqlCn = new SqlConnection(_con_str); sqlCn.Open(); string cmd_str = "Select * from [Orders] where " + key + "='" + key_val.ToString() + "'"; SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { order = new COrders(); order.id = (int)dr["id"]; order.menu = dr["menu"].ToString(); order.text = dr["text"].ToString(); order.systemId = dr["systemId"].ToString(); order.number = (double)dr["number"]; order.priceType = dr["priceType"].ToString(); order.money = (double)dr["money"]; order.technician = dr["technician"].ToString(); order.techType = dr["techType"].ToString(); order.inputTime = (DateTime)dr["inputTime"]; order.inputEmployee = dr["inputEmployee"].ToString(); order.deleteEmployee = dr["deleteEmployee"].ToString(); order.comboId = ToInt(dr["comboId"]); order.paid = (bool)dr["paid"]; order.accountId = ToInt(dr["accountId"]); order.billId = dr["billId"].ToString(); order.donorExplain = dr["donorExplain"].ToString(); } } } catch (System.Exception e) { BathClass.printErrorMsg(e.Message); } finally { close_connection(sqlCn); } return order; }