private void find_combo() { TransactionOptions transOptions = new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }; { db.Orders.DeleteAllOnSubmit(db.Orders.Where(x => x.menu.Contains("套餐"))); var orders = db.Orders.Where(x => x.systemId == m_Seat.systemId && x.deleteEmployee == null); orders = orders.Where(x => !x.inputEmployee.Contains("电脑")); foreach (Orders tmp_order in orders) { tmp_order.comboId = null; } db.SubmitChanges(); var order_menus = orders.Where(x => x.comboId == null).Select(x => x.menu); var menus = db.Menu; var comboList = db.Combo.OrderByDescending(x => x.originPrice - x.price); foreach (Combo combo in comboList) { List <int> menuIds = BathClass.disAssemble(combo.menuIds); var combo_menus = menus.Where(x => menuIds.Contains(x.id)).Select(x => x.name); if (combo_menus.All(x => order_menus.Any(y => y == x))) { foreach (var combo_menu in combo_menus) { var tmp_order = orders.FirstOrDefault(x => x.menu == combo_menu); tmp_order.comboId = combo.id; if (combo.priceType == "免项目") { var freeIds = BathClass.disAssemble(combo.freeMenuIds); var freeMenus = db.Menu.Where(x => freeIds.Contains(x.id)).Select(x => x.name); if (freeMenus.Contains(tmp_order.menu)) { tmp_order.money = 0; } } } if (combo.priceType == "减金额") { Orders comboOrder = new Orders(); comboOrder.menu = "套餐" + combo.id.ToString() + "优惠"; comboOrder.text = m_Seat.text; comboOrder.systemId = m_Seat.systemId; comboOrder.number = 1; comboOrder.inputTime = GeneralClass.Now; comboOrder.inputEmployee = "套餐"; comboOrder.paid = false; comboOrder.comboId = combo.id; comboOrder.money = Convert.ToDouble(combo.price) - combo.originPrice; db.Orders.InsertOnSubmit(comboOrder); m_Orders.Add(comboOrder); } db.SubmitChanges(); } } } }
//显示详细信息 private void dgvDetails_show() { dgvDetails.Rows.Clear(); if (dgv.CurrentCell == null) { return; } string selId = dgv.Rows[dgv.CurrentCell.RowIndex].Cells[0].Value.ToString(); Promotion promotion = db.Promotion.FirstOrDefault(x => x.id.ToString() == selId); Dictionary <string, string> menuDict = BathClass.disAssemble(db, promotion); foreach (string menuId in menuDict.Keys) { string[] row = new string[3]; var menu = db.Menu.FirstOrDefault(x => x.id.ToString() == menuId); if (menu != null) { row[0] = menu.name; row[1] = menu.price.ToString(); row[2] = menuDict[menuId].ToString(); } else { row[0] = menuId; row[2] = menuDict[menuId].ToString(); } dgvDetails.Rows.Add(row); } }
private void reset_order_money(Orders order) { 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; } else if (order.comboId != null) { var combo = db.Combo.FirstOrDefault(x => x.id == order.comboId); if (combo == null) { return; } var freeIds = BathClass.disAssemble(combo.freeMenuIds); var freeMenus = db.Menu.Where(x => freeIds.Contains(x.id)).Select(x => x.name); if (!freeMenus.Contains(order.menu)) { order.money = menu.price; } } } else { var combo = db.Combo.FirstOrDefault(x => x.id == order.comboId); order.money = BathClass.get_combo_price(db, combo); } }
//对话框载入 private void ComboForm_Load(object sender, EventArgs e) { catgory.Items.AddRange(db.Catgory.Select(x => x.name).ToArray()); cboxCat3.Items.AddRange(db.Catgory.Select(x => x.name).ToArray()); priceType.SelectedIndex = 0; menuIdList = BathClass.disAssemble(m_Combo.menuIds); freeIdList = BathClass.disAssemble(m_Combo.freeMenuIds); dgv_show(); dgvMenu_show(); dgvFreeItems_show(); dgvExcept_show(); dgvItems3_show(); dgvFreeItems3_show(); if (!newCombo) { priceType.Text = m_Combo.priceType; if (m_Combo.priceType == "免项目") { price.Enabled = false; } else if (m_Combo.priceType == "减金额") { price.Text = m_Combo.price.ToString(); } else if (m_Combo.priceType == "消费满免项目") { upTo.Text = m_Combo.expenseUpTo.ToString(); } this.Text = "编辑套餐"; } }
//对话框载入 private void PromotionItemAddForm_Load(object sender, EventArgs e) { Dictionary <string, string> pOffer = BathClass.disAssemble(db, m_Promotion); List <string> cats = new List <string>(); foreach (string key in pOffer.Keys) { if (key.Contains("类别$")) { string[] tps = key.Split('$'); cats.Add(tps[1]); } else { menus.Add(key); } } type.Items.Clear(); type.Items.AddRange(db.Catgory.Where(x => !cats.Contains(x.name)).Select(x => x.name).ToArray()); if (type.Items.Count != 0) { type.SelectedIndex = 0; int catId = db.Catgory.FirstOrDefault(x => x.name == type.Text).id; menu.Items.AddRange(db.Menu.Where(x => x.catgoryId == catId && !menus.Contains(x.id.ToString())).Select(x => x.name).ToArray()); } discountType.SelectedIndex = 0; }
private void find_combo(BathDBDataContext dc, Orders theOrder) { dc.Orders.DeleteAllOnSubmit(dc.Orders.Where(x => x.systemId == theOrder.systemId && x.menu.Contains("套餐"))); var orders = dc.Orders.Where(x => x.systemId == theOrder.systemId && x.deleteEmployee == null); orders = orders.Where(x => !x.inputEmployee.Contains("电脑")); foreach (Orders tmp_order in orders) { tmp_order.comboId = null; } dc.SubmitChanges(); var order_menus = orders.Where(x => x.comboId == null).Select(x => x.menu); var menus = dc.Menu; var comboList = dc.Combo.OrderByDescending(x => x.originPrice - x.price); foreach (Combo combo in comboList) { List <int> menuIds = BathClass.disAssemble(combo.menuIds); var combo_menus = menus.Where(x => menuIds.Contains(x.id)).Select(x => x.name); if (combo_menus.All(x => order_menus.Any(y => y == x))) { foreach (var combo_menu in combo_menus) { var tmp_order = orders.FirstOrDefault(x => x.menu == combo_menu); tmp_order.comboId = combo.id; if (combo.priceType == "免项目") { var freeIds = BathClass.disAssemble(combo.freeMenuIds); var freeMenus = dc.Menu.Where(x => freeIds.Contains(x.id)).Select(x => x.name); if (freeMenus.Contains(tmp_order.menu)) { tmp_order.money = 0; } } } if (combo.priceType == "减金额") { Orders comboOrder = new Orders(); comboOrder.menu = "套餐" + combo.id.ToString() + "优惠"; comboOrder.text = theOrder.text; comboOrder.systemId = theOrder.systemId; comboOrder.number = 1; comboOrder.inputTime = GeneralClass.Now; comboOrder.inputEmployee = "套餐"; comboOrder.paid = false; comboOrder.comboId = combo.id; comboOrder.departmentId = 1; comboOrder.money = Convert.ToDouble(combo.price) - combo.originPrice; dc.Orders.InsertOnSubmit(comboOrder); } dc.SubmitChanges(); } } }
//构造函数 public PromotionForm(BathDBDataContext dc, Promotion promotion) { db = dc; if (promotion != null) { newPromotion = false; m_Promotion = promotion; m_Offer = BathClass.disAssemble(db, m_Promotion); } InitializeComponent(); dgv_show(); }
//对话框载入 private void PromotionForm_Load(object sender, EventArgs e) { db = new BathDBDataContext(LogIn.connectionString); m_Promotion = db.GroupBuyPromotion.FirstOrDefault(); if (m_Promotion == null) { m_Promotion = new GroupBuyPromotion(); db.GroupBuyPromotion.InsertOnSubmit(m_Promotion); db.SubmitChanges(); } m_Offer = BathClass.disAssemble(db, m_Promotion); dgvDetails_show(); }
//对话框载入 private void ComboForm_Load(object sender, EventArgs e) { var catArray = db.Catgory.Select(x => x.name).ToArray(); TextMenuCat.Items.AddRange(catArray); TextBigMenuName.Items.AddRange(db.Menu.Select(x => x.name).ToArray()); cboxCat.Items.AddRange(catArray); if (!newBigCombo) { var bigMenu = db.Menu.FirstOrDefault(x => x.id == m_BigCombo.menuid); TextBigMenuName.Text = bigMenu.name; TextMenuCat.Text = db.Catgory.FirstOrDefault(x => x.id == bigMenu.catgoryId).name; TextBigMenuName.Enabled = false; txtBoxPrice.Text = bigMenu.price.ToString(); txtBoxPrice.Enabled = false; SubstIDList = BathClass.disAssemble(m_BigCombo.substmenuid, Constants.SplitChar); } dgvMenus_show(); dgvsubstItems_show(); }
//显示套餐详情清单 private void dgvItems_show(int rowIndex) { if (dgvCombo.Rows.Count == 0 || rowIndex == -1) { return; } int selId = Convert.ToInt32(dgvCombo.Rows[rowIndex].Cells[0].Value); List <int> menuIdList = BathClass.disAssemble(db.BigCombo.FirstOrDefault(x => x.id == selId).substmenuid, Constants.SplitChar); dgvItems.DataSource = from x in db.Menu where menuIdList.Contains(x.id) orderby x.id select new { 编号 = x.id, 称 = x.name, 单价 = x.price }; BathClass.set_dgv_fit(dgvItems); }
public static void reprint_bill(CSeat seat, DAO dao, bool use_pad) { if (seat.status != SeatStatus.PAIED) { BathClass.printErrorMsg("已经重新开牌,不能重打账单!"); return; } var account = dao.get_account("abandon is null and systemId like '%" + seat.systemId + "%'"); if (account == null) { return; } var seats_txt = account.text.Split('|'); string state_str = ""; int count = seats_txt.Count(); for (int i = 0; i < count; i++) { state_str += "text='" + seats_txt[i] + "'"; if (i != count - 1) { state_str += " or "; } } var seats_reprint = dao.get_seats(state_str); List <string> m_rooms = new List <string>(); foreach (var s in seats_reprint) { m_rooms.Add(dao.get_seat_room(s.text)); } DataGridView dgv = new DataGridView(); DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = "手牌"; dgv.Columns.Add(col); DataGridViewTextBoxColumn coll = new DataGridViewTextBoxColumn(); coll.HeaderText = "房间"; dgv.Columns.Add(coll); DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn(); col1.HeaderText = "项目名称"; dgv.Columns.Add(col1); DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn(); col2.HeaderText = "技师"; dgv.Columns.Add(col2); DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn(); col3.HeaderText = "单价"; dgv.Columns.Add(col3); DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn(); col4.HeaderText = "数量"; dgv.Columns.Add(col4); DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn(); col5.HeaderText = "金额"; dgv.Columns.Add(col5); List <string> printCols = new List <string>(); printCols.Add("手牌"); if (use_pad) { printCols.Add("房间"); } printCols.Add("项目名称"); printCols.Add("单价"); printCols.Add("数量"); printCols.Add("金额"); var use_disAssemble = MConvert <bool> .ToTypeOrDefault(LogIn.options.启用大项拆分, false); var co_name = LogIn.options.companyName; if (account != null) { try { var db = new BathDBDataContext(LogIn.connectionString); var orders = db.HisOrders.Where(x => x.deleteEmployee == null && x.accountId == account.id).OrderBy(x => x.text); foreach (var order in orders) { var cmenu = db.Menu.FirstOrDefault(x => x.name == order.menu); var price = ""; if (cmenu != null) { price = cmenu.price.ToString(); if (use_disAssemble && db.BigCombo.FirstOrDefault(x => x.menuid == cmenu.id) != null) { var substIDs = BathClass.disAssemble(db.BigCombo.FirstOrDefault(x => x.menuid == cmenu.id).substmenuid, Constants.SplitChar); for (int i = 0; i < substIDs.Count; i++) { var menu = db.Menu.FirstOrDefault(x => x.id == substIDs[i]); dgv.Rows.Add(order.text, order.roomId, menu.name, order.technician, menu.price, order.number, menu.price * MConvert <double> .ToTypeOrDefault(order.number, 0)); } continue; } } dgv.Rows.Add(order.text, order.roomId, order.menu, order.technician, price, order.number, order.money); } PrintBill.Print_DataGridView(seats_reprint, m_rooms, account, "存根单", dgv, printCols, co_name); } catch (System.Exception ex) { BathClass.printErrorMsg(ex.ToString()); } } else { double money = 0; try { var db = new BathDBDataContext(LogIn.connectionString); var orders = db.Orders.Where(x => x.text == seat.text && x.systemId != seat.systemId && x.deleteEmployee == null).OrderBy(x => x.text); foreach (var order in orders) { var cmenu = db.Menu.FirstOrDefault(x => x.name == order.menu); var price = ""; if (cmenu != null) { price = cmenu.price.ToString(); } dgv.Rows.Add(order.text, order.roomId, order.menu, order.technician, price, order.number, order.money); } if (dgv.Rows.Count != 0) { BathClass.printErrorMsg("未检测到转账单或者结账单"); return; } PrintSeatBill.Print_DataGridView(seats_reprint, m_rooms, "", "转账确认单", dgv, printCols, money.ToString(), co_name); } catch (System.Exception ex) { BathClass.printErrorMsg(ex.ToString()); } } }
//删除菜式 private void delTool_Click(object sender, EventArgs e) { if (dgv.CurrentCell == null) { GeneralClass.printWarningMsg("没有选择行!"); return; } if (GeneralClass.printAskMsg("确认删除?") != DialogResult.Yes) { return; } int delId = Convert.ToInt32(dgv.CurrentRow.Cells[0].Value); bool be_contained_in_combo = false; List <int> combo_ids = new List <int>(); foreach (var combo in db.Combo) { var ids = BathClass.disAssemble(combo.menuIds); var freeIds = BathClass.disAssemble(combo.freeMenuIds); if (ids.Contains(delId) || freeIds.Contains(delId)) { be_contained_in_combo = true; combo_ids.Add(combo.id); } } if (be_contained_in_combo && BathClass.printAskMsg("套餐" + combo_ids[0] + "等中已经包含该项目,若删除项目,则套餐也会被删除,是否删除?") != DialogResult.Yes) { return; } bool be_contained_in_bigcombo = false; List <int> bigcombo_ids = new List <int>(); foreach (var combo in db.BigCombo) { var ids = BathClass.disAssemble(combo.substmenuid, Constants.SplitChar); if (ids.Contains(delId) || combo.menuid == delId) { be_contained_in_bigcombo = true; bigcombo_ids.Add(combo.id); } } if (be_contained_in_bigcombo && BathClass.printAskMsg("大项套餐" + bigcombo_ids[0] + "等中已经包含该项目,若删除项目,则套餐也会被删除,是否删除?") != DialogResult.Yes) { return; } db.Menu.DeleteOnSubmit(db.Menu.FirstOrDefault(s => s.id == delId)); if (be_contained_in_combo) { db.Combo.DeleteAllOnSubmit(db.Combo.Where(x => combo_ids.Contains(x.id))); } if (be_contained_in_bigcombo) { db.BigCombo.DeleteAllOnSubmit(db.BigCombo.Where(x => bigcombo_ids.Contains(x.id))); } db.SubmitChanges(); dgv_show(); }