//夜审 private void clearTool_Click(object sender, EventArgs e) { bool hasto = true; DateTime now = GeneralClass.Now; var cnt = db.ClearTable.FirstOrDefault(x => x.clearTime.Date == now.Date); if (cnt != null) { ClearOptionsForm clearOptionsForm = new ClearOptionsForm(cnt.clearTime); if (clearOptionsForm.ShowDialog() == DialogResult.OK) { db.ClearTable.DeleteOnSubmit(cnt); db.SubmitChanges(); } else hasto = false; } if (!hasto) return; var seats = db.Seat.Where(x => x.status == 3); foreach (Seat seat in seats) { BathClass.reset_seat(seat); } ClearTable ct = new ClearTable(); ct.clearTime = GeneralClass.Now; db.ClearTable.InsertOnSubmit(ct); db.SubmitChanges(); }
//开单个牌,用于以刷卡方式 private void open_one_seat(Seat seat, BathDBDataContext dc) { if (seat.status == 3) { BathClass.reset_seat(seat); dc.SubmitChanges(); } seat.openEmployee = LogIn.m_User.id.ToString(); seat.openTime = BathClass.Now(LogIn.connectionString); seat.systemId = BathClass.systemId(dc, LogIn.connectionString); //seat.chainId = chainId; seat.status = 2; //SeatType seatType = db.SeatType.FirstOrDefault(x => x.id == seat.typeId); //var menu = db.Menu.FirstOrDefault(x => x.id == seatType.menuId); //if (menu != null) //{ // Orders order = new Orders(); // order.menu = menu.name; // order.text = seat.text; // order.systemId = seat.systemId; // order.number = 1; // order.money = menu.price; // order.inputTime = BathClass.Now(LogIn.connectionString); // order.inputEmployee = LogIn.m_User.id.ToString(); // order.paid = false; // dc.Orders.InsertOnSubmit(order); //} dc.SubmitChanges(); }
//更换手牌 private void CtxChangeSeat_Click(object sender, EventArgs e) { BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); Seat 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; } List <int> sLst = new List <int>(); sLst.Add(1); sLst.Add(3); InputSeatForm inputSeatForm = new InputSeatForm(sLst); if (inputSeatForm.ShowDialog() != DialogResult.OK) { return; } Seat newSeat = db_new.Seat.FirstOrDefault(x => x == inputSeatForm.m_Seat); var orders = db_new.Orders.Where(x => x.systemId == seat.systemId); foreach (Orders order in orders) { order.text = newSeat.text; } newSeat.systemId = seat.systemId; newSeat.name = seat.name; newSeat.population = seat.population; newSeat.openTime = BathClass.Now(LogIn.connectionString); newSeat.openEmployee = LogIn.m_User.name; newSeat.phone = seat.phone; newSeat.chainId = seat.chainId; newSeat.status = seat.status; newSeat.note = seat.note; newSeat.ordering = seat.ordering; BathClass.reset_seat(seat); db_new.SubmitChanges(); }
private void open_one_seat(HotelRoom seat, bool child, BathDBDataContext dc) { if (seat.status == 3) { BathClass.reset_seat(seat); dc.SubmitChanges(); } seat.openEmployee = LogIn.m_User.id.ToString(); seat.openTime = BathClass.Now(LogIn.connectionString); seat.systemId = BathClass.systemId(db, LogIn.connectionString); seat.status = 2; if (!seatlock) { seat.chainId = chainId; } HotelRoomType seatType = dc.HotelRoomType.FirstOrDefault(x => x.id == seat.typeId); var menu = dc.Menu.FirstOrDefault(x => x.id == seatType.menuId); if (menu != null) { Orders order = new Orders(); order.menu = menu.name; order.text = seat.text; order.systemId = seat.systemId; order.number = 1; order.money = menu.price; order.inputTime = BathClass.Now(LogIn.connectionString); order.inputEmployee = LogIn.m_User.id.ToString(); order.paid = false; dc.Orders.InsertOnSubmit(order); } if (child) { var child_menu = dc.Menu.FirstOrDefault(x => x.name == "儿童浴资"); if (child_menu != null) { Orders order = new Orders(); order.menu = child_menu.name; order.text = seat.text; order.systemId = seat.systemId; order.number = 1; order.money = child_menu.price; order.inputTime = BathClass.Now(LogIn.connectionString); order.inputEmployee = LogIn.m_User.id.ToString(); order.paid = false; dc.Orders.InsertOnSubmit(order); } } dc.SubmitChanges(); }
private void change_seat(BathDBDataContext db_new, HotelRoom seat) { if (!BathClass.getAuthority(db_new, LogIn.m_User, "更换手牌")) { BathClass.printErrorMsg(LogIn.m_User.name + "不具有更换房间操作权限!"); return; } if (seat.status != 2) { BathClass.printErrorMsg("该房间目前不在使用中,不能换房!"); return; } List <int> sLst = new List <int>(); sLst.Add(1); sLst.Add(3); InputHotelRoomForm inputSeatForm = new InputHotelRoomForm(sLst); if (inputSeatForm.ShowDialog() != DialogResult.OK) { return; } HotelRoom newSeat = db_new.HotelRoom.FirstOrDefault(x => x.text == inputSeatForm.m_Seat.text); var orders = db_new.Orders.Where(x => x.systemId == seat.systemId); foreach (Orders order in orders) { order.text = newSeat.text; } newSeat.systemId = seat.systemId; newSeat.name = seat.name; newSeat.population = seat.population; newSeat.openTime = BathClass.Now(LogIn.connectionString); newSeat.openEmployee = LogIn.m_User.name; //newSeat.money = seat.money; newSeat.phone = seat.phone; newSeat.chainId = seat.chainId; newSeat.status = seat.status; newSeat.note = seat.note; newSeat.ordering = seat.ordering; BathClass.reset_seat(seat); db_new.SubmitChanges(); dgv_shoe_show(); }
private void set_one_seat_status(HotelRoom seat, BathDBDataContext dc) { if (seat.status == 3) { BathClass.reset_seat(seat); dc.SubmitChanges(); } seat.openEmployee = LogIn.m_User.id.ToString(); seat.openTime = BathClass.Now(LogIn.connectionString); seat.systemId = BathClass.systemId(dc, LogIn.connectionString); seat.status = 2; dc.SubmitChanges(); }
//夜审并且备份数据库,并且发送夜审短信 private void clearTool_Click(object sender, EventArgs e) { bool hasCleared = false; DateTime now = GeneralClass.Now; var ct = db.ClearTable.FirstOrDefault(x => x.clearTime.Date == now.Date); if (ct != null) { hasCleared = true; ClearOptionsForm clearOptionsForm = new ClearOptionsForm(ct.clearTime); if (clearOptionsForm.ShowDialog() != DialogResult.OK) { return; } } var seats = db.Seat.Where(x => x.status == 3); foreach (Seat seat in seats) { BathClass.reset_seat(seat); } if (!hasCleared) { ct = new ClearTable(); } ct.clearTime = GeneralClass.Now; if (!hasCleared) { db.ClearTable.InsertOnSubmit(ct); } db.SubmitChanges(); Thread td = new Thread(new ThreadStart(send_sms_thread)); td.Start(); backUp(); }
//取消开牌 private void CtxCancelOpen_Click(object sender, EventArgs e) { BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); Seat 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; } if (db_new.Options.Count() != 0) { Options options = db_new.Options.FirstOrDefault(); 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(); 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 btnOk_Click(object sender, EventArgs e) { var dc_new = new BathDBDataContext(LogIn.connectionString); if (m_open) { int i = 0; foreach (var seat in m_Seats) { var seat_tmp = dc_new.HotelRoom.FirstOrDefault(x => x.text == seat.text); var child = Convert.ToBoolean(dgv.Rows[i].Cells[2].Value); if (!seatlock) { open_one_seat(seat_tmp, child, dc_new); } else { var mtype = dc_new.HotelRoomType.FirstOrDefault(x => x.id == seat_tmp.typeId); if (mtype.menuId == null) { if (seat_tmp.status == 3) { BathClass.reset_seat(seat_tmp); dc_new.SubmitChanges(); } seat_tmp.openEmployee = LogIn.m_User.id.ToString(); seat_tmp.openTime = BathClass.Now(LogIn.connectionString); seat_tmp.systemId = BathClass.systemId(db, LogIn.connectionString); seat_tmp.status = 2; } seat_tmp.chainId = chainId; HotelRoomType seatType = dc_new.HotelRoomType.FirstOrDefault(x => x.id == seat_tmp.typeId); var menu = dc_new.Menu.FirstOrDefault(x => x.id == seatType.menuId); var child_menu = dc_new.Menu.FirstOrDefault(x => x.name == "儿童浴资"); if (menu != null) { Orders order = new Orders(); order.menu = menu.name; order.text = seat_tmp.text; order.systemId = seat_tmp.systemId; order.number = 1; order.money = menu.price; order.inputTime = BathClass.Now(LogIn.connectionString); order.inputEmployee = LogIn.m_User.id.ToString(); order.paid = false; order.departmentId = 1; dc_new.Orders.InsertOnSubmit(order); if (child) { Orders child_order = new Orders(); child_order.menu = child_menu.name; child_order.text = seat_tmp.text; child_order.systemId = seat_tmp.systemId; child_order.number = 1; child_order.money = child_menu.price; child_order.inputTime = BathClass.Now(LogIn.connectionString); child_order.inputEmployee = LogIn.m_User.id.ToString(); child_order.paid = false; order.departmentId = 1; dc_new.Orders.InsertOnSubmit(child_order); } } } i++; } dc_new.SubmitChanges(); } else { foreach (var seat in m_Seats) { seat.chainId = chainId; } db.SubmitChanges(); } this.DialogResult = DialogResult.OK; }
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("不具有取消开牌权限!"); } }