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 okBtn_Click(object sender, EventArgs e) { if (priceType.SelectedIndex == 1 && price.Text == "") { GeneralClass.printErrorMsg("需要输入价格"); return; } if (priceType.SelectedIndex == 0 && dgvFreeItems.Rows.Count == 0) { GeneralClass.printErrorMsg("需要输入减免项目"); return; } if (priceType.SelectedIndex == 2 && upTo.Text == "") { GeneralClass.printErrorMsg("需要输入价格"); return; } if (priceType.SelectedIndex == 2 && dgvFreeItems3.Rows.Count == 0) { GeneralClass.printErrorMsg("需要输入减免项目"); return; } if (priceType.SelectedIndex == 0 || priceType.SelectedIndex == 1) { m_Combo.menuIds = ComboManagementForm.assembleCombo(menuIdList); m_Combo.originPrice = ComboManagementForm.getComboOriginPrice(db, menuIdList); } if (priceType.SelectedIndex == 0) { m_Combo.priceType = "免项目"; m_Combo.freeMenuIds = ComboManagementForm.assembleCombo(freeIdList); m_Combo.price = m_Combo.originPrice - BathClass.get_combo_price(db, m_Combo); } else if (priceType.SelectedIndex == 1) { m_Combo.priceType = "减金额"; m_Combo.freeMenuIds = null; m_Combo.price = Convert.ToDouble(price.Text); } else if (priceType.SelectedIndex == 2) { m_Combo.priceType = "消费满免项目"; m_Combo.menuIds = ComboManagementForm.assembleCombo(menuIdList); m_Combo.freeMenuIds = ComboManagementForm.assembleCombo(freeIdList); m_Combo.expenseUpTo = Convert.ToDouble(upTo.Text); } m_Combo.freePrice = BathClass.get_combo_price(db, m_Combo); if (newCombo) { db.Combo.InsertOnSubmit(m_Combo); } db.SubmitChanges(); this.DialogResult = DialogResult.OK; this.Close(); }