private void cancel_open(BathDBDataContext db_new, HotelRoom seat) { InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd(); if (BathClass.getAuthority(db_new, LogIn.m_User, "取消开牌") || (inputEmployee.ShowDialog() != DialogResult.OK && BathClass.getAuthority(db_new, inputEmployee.employee, "取消开牌"))) { if (seat.status != 2) { BathClass.printErrorMsg("该台位不在使用中,不能取消开台!"); return; } if (db_new.Options.Count() != 0) { Options options = db_new.Options.ToList()[0]; var q = options.取消开牌时限; if (q != null && BathClass.Now(LogIn.connectionString) - seat.openTime >= TimeSpan.Parse("00:" + q.ToString() + ":00")) { BathClass.printErrorMsg("已超过取消开牌时限!"); return; } } var orders = db_new.Orders.Where(x => x.systemId == seat.systemId); if (orders.Count() > 2) { BathClass.printErrorMsg("已经点单,不能取消开台"); return; } if (BathClass.printAskMsg("确认取消开台?") != DialogResult.Yes) { return; } Operation op = new Operation(); if (inputEmployee.employee != null) { op.employee = inputEmployee.employee.id; } else { op.employee = LogIn.m_User.id; } op.seat = seat.text; op.openEmployee = seat.openEmployee; op.openTime = seat.openTime; op.explain = "取消开牌"; op.opTime = BathClass.Now(LogIn.connectionString); db_new.Operation.InsertOnSubmit(op); db_new.Orders.DeleteAllOnSubmit(db_new.Orders.Where(x => x.systemId == seat.systemId)); BathClass.reset_seat(seat); db_new.SubmitChanges(); dgv_shoe_show(); } else { BathClass.printErrorMsg("不具有取消开牌权限!"); } }
//重打账单 private void CtxReprint_Click(object sender, EventArgs e) { BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); var seat = getContextSenderSeat(db_new, sender); if (seat.systemId == null || seat.status != 3) { BathClass.printErrorMsg("已经重新开牌,不能重打账单!"); return; } var account = db_new.Account.FirstOrDefault(x => x.systemId.Contains(seat.systemId) && x.abandon == null); DataGridView dgv = new DataGridView(); DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = "手牌号"; dgv.Columns.Add(col); 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("手牌"); printCols.Add("项目名称"); printCols.Add("技师"); printCols.Add("单价"); printCols.Add("数量"); printCols.Add("金额"); var co_name = db_new.Options.FirstOrDefault().companyName; if (account != null) { var ids = account.systemId.Split('|'); var orders = db_new.HisOrders.Where(x => ids.Contains(x.systemId) && x.paid && x.deleteEmployee == null); foreach (var order in orders) { string[] row = new string[6]; row[0] = order.text; row[1] = order.menu; row[2] = order.technician; var menu = db_new.Menu.FirstOrDefault(x => x.name == order.menu); if (menu != null) { row[3] = menu.price.ToString(); } row[4] = order.number.ToString(); row[5] = order.money.ToString(); dgv.Rows.Add(row); } PrintBill.Print_DataGridView(account, "存根单", dgv, printCols, co_name); } else { var orders = db_new.Orders.Where(x => x.text == seat.text && !x.paid && x.deleteEmployee == null); foreach (var order in orders) { string[] row = new string[6]; row[0] = order.text; row[1] = order.menu; row[2] = order.technician; var menu = db_new.Menu.FirstOrDefault(x => x.name == order.menu); if (menu != null) { row[3] = menu.price.ToString(); } row[4] = order.number.ToString(); row[5] = order.money.ToString(); dgv.Rows.Add(row); } var money = BathClass.get_cur_orders_money(orders, LogIn.connectionString, BathClass.Now(LogIn.connectionString)); List <HotelRoom> seats = new List <HotelRoom>(); seats.Add(seat); PrintSeatBill.Print_DataGridView(seats, "转账确认单", dgv, printCols, money.ToString(), co_name); } }
//取消开牌 private void CtxCancelOpen_Click(object sender, EventArgs e) { BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); var seat = getContextSenderSeat(db_new, sender); InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd(); if (inputEmployee.ShowDialog() != DialogResult.OK) { return; } if (!BathClass.getAuthority(db_new, inputEmployee.employee, "取消开牌")) { BathClass.printErrorMsg(inputEmployee.employee.id + "不具有取消开台权限!"); return; } if (seat.status != 2) { BathClass.printErrorMsg("该台位不在使用中,不能取消开台!"); return; } var options = db_new.Options.FirstOrDefault(); if (options != null) { var q = options.取消开牌时限; if (q != null && GeneralClass.Now - seat.openTime >= TimeSpan.Parse("00:" + q.ToString() + ":00")) { BathClass.printErrorMsg("已超过取消开牌时限!"); return; } } var orders = db_new.Orders.Where(x => x.systemId == seat.systemId); if (orders.Count() > 2) { BathClass.printErrorMsg("已经点单,不能取消开台"); return; } if (BathClass.printAskMsg("确认取消开台?") != DialogResult.Yes) { return; } Operation op = new Operation(); op.employee = inputEmployee.employee.id; op.seat = seat.text; op.openEmployee = seat.openEmployee; op.openTime = seat.openTime; op.explain = "取消开牌"; op.opTime = BathClass.Now(LogIn.connectionString); db_new.Operation.InsertOnSubmit(op); db_new.Orders.DeleteAllOnSubmit(db_new.Orders.Where(x => x.systemId == seat.systemId)); BathClass.reset_seat(seat); db_new.SubmitChanges(); }
//手工打折 private void discountTool_Click(object sender, EventArgs e) { var dc = new BathDBDataContext(LogIn.connectionString); Employee oper = null; if (BathClass.getAuthority(dc, LogIn.m_User, "手工打折")) { oper = LogIn.m_User; } if (oper == null) { InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd(); if (inputEmployee.ShowDialog() != DialogResult.OK) { return; } if (BathClass.getAuthority(dc, inputEmployee.employee, "手工打折")) { oper = inputEmployee.employee; } else { BathClass.printErrorMsg("没有手工打折权限"); return; } } if (oper == null) { return; } InputNumber inputNumberForm = new InputNumber("输入折扣率(<10)"); if (inputNumberForm.ShowDialog() != DialogResult.OK) { return; } double number = inputNumberForm.number; double discountRate = 0; if (number < 1) { discountRate = number; } else { discountRate = number / 10.0; } var os = dc.Orders.Where(x => m_Seats.Select(y => y.systemId).Contains(x.systemId) && x.deleteEmployee == null); foreach (Orders o in os) { o.money = Math.Round(o.money * discountRate); } foreach (HotelRoom seat in m_Seats) { seat.discount = inputNumberForm.number; seat.discountEmployee = oper.id; } Operation op = new Operation(); op.employee = oper.name; op.seat = string.Join("|", m_Seats.Select(y => y.text).ToArray()); op.openEmployee = string.Join("|", m_Seats.Select(y => y.openEmployee).ToArray()); //op.openTime = seat.openTime; op.explain = "手工打折"; op.note1 = number.ToString(); op.note2 = string.Join("|", m_Seats.Select(y => y.systemId).ToArray()); op.opTime = BathClass.Now(LogIn.connectionString); dc.Operation.InsertOnSubmit(op); dc.SubmitChanges(); dgvExpense_show(dc); setStatus(dc); }