//确定 private void BtnOK_Click(object sender, EventArgs e) { BtnOK.Enabled = false; BtnOK.Enabled = true; m_Seat = dao.get_seat("text='" + text.Text + "' or oId='" + text.Text + "'"); //m_Seat = db.Seat.FirstOrDefault(x => x.text == text.Text || x.oId == text.Text); if (m_Seat == null) { BathClass.printErrorMsg("所选择台位不存在"); return; } if (m_Status != -1) { if (m_Status != (int)m_Seat.status) { BathClass.printErrorMsg("所选择台位不可用"); return; } } else if (!m_StatusList.Contains((int)m_Seat.status)) { BathClass.printErrorMsg("所选择台位不可用"); return; } this.DialogResult = DialogResult.OK; }
//构造函数 public OrderCheckForm(CSeat seat, string con_str, COptions options) { m_con_str = con_str; m_Seat = seat; m_options = options; dao = new DAO(con_str); InitializeComponent(); }
//构造函数 public DepositForm(CSeat seat) { db = new BathDBDataContext(LogIn.connectionString); m_Seat = seat; dao = new DAO(LogIn.connectionString); //m_Seat = db.Seat.FirstOrDefault(x => x.systemId == seat.systemId); InitializeComponent(); }
//构造函数 public OrderForm(CSeat seat, Employee user, string con_str, bool has_user) { //st = DateTime.Now; //db = new BathDBDataContext(con_str); //m_Seat = db.Seat.FirstOrDefault(x => x.systemId == seat.systemId); m_Seat = seat; m_user = user; m_has_user = has_user; m_con_str = con_str; InitializeComponent(); abcOrderPanel.Dock = DockStyle.Fill; touchOrderPanel.Dock = DockStyle.Fill; abcOrderPanel.Visible = false; }
public OpenSeatForm(CSeat seat, bool open) { m_open = open; //var db = new BathDBDataContext(LogIn.connectionString); m_Seats.Add(seat); seat_length = seat.text.Length; dao = new DAO(LogIn.connectionString); chainId = dao.chainId(); seatlock = LogIn.options.启用手牌锁.Value; lock_type = LogIn.options.手牌锁类型; auto_seat_card = MConvert<bool>.ToTypeOrDefault(LogIn.options.自动感应手牌, false); InitializeComponent(); seatBox.Enabled = MConvert<bool>.ToTypeOrDefault(LogIn.options.允许手工输入手牌号开牌, false); dgv_show(); }
private bool _close = false; //线程终止标志 #endregion Fields #region Constructors //构造函数 public SeatExpenseForm(CSeat seat, int _seat_length, bool _seatLock, bool _auto_seat_card, DAO _dao) { seatLock = _seatLock; auto_seat_card = _auto_seat_card; seat_length = _seat_length; dao = _dao; if (seatLock) { m_Seats.Add(dao.get_seat("text", seat.text)); } else { string cmd_str = "((chainId is null and text='" + seat.text + "') or (chainId is not null and chainId='" + seat.chainId + "'))" + @" and (status=2 or status=6 or status=7 or status=8)"; var seats = dao.get_seats(cmd_str); m_Seats.AddRange(seats); } var pars = new List<string>(); pars.Add("paying"); var vals = new List<string>(); vals.Add("True"); int count = m_Seats.Count; string update_str = @"update [Seat] set paying='True' where "; for (int i = 0; i < count; i++ ) { update_str += "text='" + m_Seats[i].text + "'"; if (i != count - 1) update_str += " or "; } if (!dao.execute_command(update_str)) { BathClass.printErrorMsg("手牌状态更新失败,如有超时浴资,请删除手牌重新载入"); } InitializeComponent(); }
//载入消费 private void btnReload_Click(object sender, EventArgs e) { if (seatText.Text != "") { //m_Seat = dc_new.Seat.FirstOrDefault(x => x.text == seatText.Text || x.oId == seatText.Text); var keys = new List<string>(); keys.Add("text"); keys.Add("oId"); var key_vals = new List<string>(); key_vals.Add(seatText.Text); key_vals.Add(seatText.Text); m_Seat = dao.get_seat(keys, key_vals, "or"); seatText.Text = ""; if (m_Seat == null || m_Seat.status != SeatStatus.USING && m_Seat.status != SeatStatus.WARNING && m_Seat.status != SeatStatus.DEPOSITLEFT && m_Seat.status != SeatStatus.REPAIED) { BathClass.printErrorMsg("该手牌不在使用中,不能结账!"); return; } if (m_Seats.FirstOrDefault(x=>x.text==m_Seat.text) == null) { if (m_Seat.note != null && m_Seat.note != "") BathClass.printInformation(m_Seat.note); string t = m_Seat.openTime.Value.ToString("HH:mm"); //var seatType = dc_new.SeatType.FirstOrDefault(x => x.id == m_Seat.typeId); var seatType = dao.get_seattype("id", m_Seat.typeId); var hotel = (seatType.department == "客房部"); name.Text = m_Seat.name; phone.Text = m_Seat.phone; dgvChain.Rows.Add(); dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[0].Value = m_Seat.text; dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[1].Value = (seatLock && !hotel); dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[2].Value = t; order_guoye(m_Seat); m_Seats.Add(m_Seat); //m_Seat.paying = true; //dc_new.SubmitChanges(); //var pars = new List<string>(); //pars.Add("paying"); //var vals = new List<string>(); //vals.Add("True"); //var txts = new List<string>(); //txts.Add(m_Seat.text); //dao.update_table_multi_row("Seat", "text", txts, pars, vals); if (!dao.execute_command("update [Seat] set paying='True' where text='" + m_Seat.text + "'")) { BathClass.printErrorMsg("手牌状态更新失败,如有超时浴资,请删除手牌重新载入"); } dgvChain.CurrentCell = null; dgvExpense_show(); } } }
private void update_ui(CSeat seat) { string t = seat.openTime.Value.ToString("HH-mm"); dgvChain.Rows.Add(); dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[0].Value = seat.text; dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[1].Value = false; dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[2].Value = t; order_guoye(seat); //m_Seat.paying = true; //dc.SubmitChanges(); //var pars = new List<string>(); //pars.Add("paying"); //var vals = new List<string>(); //vals.Add("True"); //var txts = new List<string>(); //txts.Add(seat.text); //dao.update_table_multi_row("Seat", "text", txts, pars, vals); if (!dao.execute_command("update [Seat] set paying='True' where text='"+seat.text+"'")) { BathClass.printErrorMsg("手牌状态更新失败,如有超时浴资,请删除手牌重新载入"); } dgvChain.CurrentCell = null; dgvExpense_show(); }
//对话框载入 private void SeatExpenseForm_Load(object sender, EventArgs e) { dgvExpense.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 20); dgvExpense.RowsDefaultCellStyle.Font = new Font("宋体", 20); dgvChain.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 17); dgvChain.RowsDefaultCellStyle.Font = new Font("宋体", 17); printBill = MConvert<bool>.ToTypeOrDefault(LogIn.options.结账打印结账单, false); printShoe = MConvert<bool>.ToTypeOrDefault(LogIn.options.结账打印取鞋小票, false); printStubBill = MConvert<bool>.ToTypeOrDefault(LogIn.options.结账打印存根单, false); inputBillId = MConvert<bool>.ToTypeOrDefault(LogIn.options.录单输入单据编号, false); companyName = LogIn.options.companyName; auto_shoe = MConvert<bool>.ToTypeOrDefault(LogIn.options.启用鞋部, false); payByOrder = MConvert<bool>.ToTypeOrDefault(LogIn.options.启用分单结账, false); use_pad = MConvert<bool>.ToTypeOrDefault(LogIn.options.启用客房面板, false); ; dgvExpense.Columns[11].Visible = use_pad; payAll.Visible = payByOrder; payAll.Checked = payByOrder; lock_type = LogIn.options.手牌锁类型; now = BathClass.Now(LogIn.connectionString); if (seatLock && auto_seat_card) { m_thread_seatCard = new Thread(new ThreadStart(seat_card_thread)); m_thread_seatCard.Start(); dgvChain.ReadOnly = true; btnReload.Text = "留牌"; } m_Seat = m_Seats[0]; name.Text = m_Seat.name; phone.Text = m_Seat.phone; dgvChain_show(); dgvChain.CurrentCell = dgvChain[0, 0]; dgvExpense.Columns[0].Visible = false; dgvExpense.Columns[2].Visible = inputBillId; dgvExpense.Columns[1].Visible = payByOrder; foreach (var seat in m_Seats) order_guoye(seat); string room_name = dao.get_seat_room(m_Seats[0].text); if (room_name == "") { roomId.Visible = false; } else { roomId.Text = room_name; roomId.Visible = true; } dgvExpense_show(); }
private void lock_unlock(CSeat seat, Employee employee) { if (seat.status == SeatStatus.AVILABLE || seat.status == SeatStatus.USING) { string cmd_str = @"update [Seat] set status=4 where text='" + seat.text + "'"; if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("手牌锁定失败"); return; } //seat.status = seat; } else if (seat.status == SeatStatus.LOCKING) { StringBuilder sb = new StringBuilder(); sb.Append(@"insert into [Operation](employee,seat,openEmployee,openTime,explain,opTime) values('"); sb.Append(employee.name + "','" + seat.text + "','" + seat.openEmployee + "','" + seat.openTime + "','解锁手牌',getdate())"); //Operation op = new Operation(); //op.employee = employee.name; //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); if (seat.systemId == null || seat.systemId == "") sb.Append(@" update [Seat] set status=1 where text='" + seat.text + "'"); //s#eat.status = 1; else sb.Append(@" update [Seat] set status=2 where text='" + seat.text + "'"); //seat.status = 2; if (!dao.execute_command(sb.ToString())) { BathClass.printErrorMsg("手牌解锁失败!"); return; } } //db_new.SubmitChanges(); }
private void show_seat_expense_form(CSeat seat) { SeatExpenseForm seatExpenseForm = new SeatExpenseForm(seat, seat_length, seatLock, auto_seat_card, dao); seatExpenseForm.ShowDialog(); }
public CSeat get_seat(string key, object key_val) { CSeat seat = null; SqlConnection sqlCn = open_connection(); if (sqlCn == null || sqlCn.State != ConnectionState.Open) return null; try { string cmd_str = "Select * from [Seat] where " + key + "='" + key_val.ToString() + "'"; SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { seat = new CSeat(); seat.id = (int)dr["id"]; seat.oId = dr["oId"].ToString(); seat.text = dr["text"].ToString(); seat.typeId = (int)dr["typeId"]; seat.systemId = dr["systemId"].ToString(); seat.name = dr["name"].ToString(); seat.population = ToInt(dr["population"]); seat.openTime = ToDateTime(dr["openTime"]); seat.openEmployee = dr["openEmployee"].ToString(); seat.payTime = ToDateTime(dr["payTime"]); seat.payEmployee = dr["payEmployee"].ToString(); seat.discountEmployee = dr["discountEmployee"].ToString(); seat.discount = ToDouble(dr["discount"]); seat.memberDiscount = ToBool(dr["memberDiscount"]); seat.memberPromotionId = dr["memberPromotionId"].ToString(); seat.chainId = dr["chainId"].ToString(); seat.status = (SeatStatus)dr["status"]; seat.ordering = ToBool(dr["ordering"]); seat.paying = ToBool(dr["paying"]); seat.note = dr["note"].ToString(); seat.unwarn = dr["unwarn"].ToString(); seat.roomStatus = dr["roomStatus"].ToString(); seat.deposit = ToInt(dr["deposit"]); seat.depositBank = ToInt(dr["depositBank"]); seat.dueTime = ToDateTime(dr["dueTime"]); } } } catch (System.Exception e) { BathClass.printErrorMsg(e.Message); IOUtil.insert_file(e.Message + "\n"); } finally { close_connection(sqlCn); } return seat; }
public OpenRoomForm(CSeat seat) { m_seat = seat; InitializeComponent(); }
public ContinueRoomForm(CSeat seat) { m_seat = seat; InitializeComponent(); }
public OpenDepositForm(CSeat seat) { m_seat = seat; InitializeComponent(); }
public static void Print_DataGridView(string title, CSeat seat, string openEmployee, string name, string phone, string openTime, string dueTime, string deposit, string coName) { PrintPreviewDialog ppvw; try { printer = printDoc.PrinterSettings.PrinterName; // Getting DataGridView object to print tmpTop = 0; companyName = coName; m_Seat = seat; m_title = title; m_openTime = openTime; m_dueTime = dueTime; m_openEmployee = openEmployee; m_name = name; m_phone = phone; m_deposit = deposit; DashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; printDoc.PrinterSettings.PrinterName = printer; printDoc.DefaultPageSettings.Margins.Left = 3; printDoc.DefaultPageSettings.Margins.Right = 3; printDoc.DefaultPageSettings.Margins.Top = 0; printDoc.DefaultPageSettings.Margins.Bottom = 30; PrintController printController = new StandardPrintController(); printDoc.PrintController = printController; ppvw = new PrintPreviewDialog(); ppvw.Document = printDoc; // Showing the Print Preview Page //printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); // Printing the Documnet printDoc.Print(); //printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); //printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
//构造函数 public MemberPopForm(CSeat seat) { m_Seat = seat; InitializeComponent(); }
public CSeat get_seat(string state_str) { CSeat seat = null; SqlConnection sqlCn = null; try { sqlCn = new SqlConnection(_con_str); sqlCn.Open(); string cmd_str = "Select * from [Seat]"; if (state_str != null && state_str!="") cmd_str += " where (" + state_str + ")"; SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { seat = new CSeat(); seat.id = (int)dr["id"]; seat.oId = dr["oId"].ToString(); seat.text = dr["text"].ToString(); seat.typeId = (int)dr["typeId"]; seat.systemId = dr["systemId"].ToString(); seat.name = dr["name"].ToString(); seat.population = ToInt(dr["population"]); seat.openTime = ToDateTime(dr["openTime"]); seat.openEmployee = dr["openEmployee"].ToString(); seat.payTime = ToDateTime(dr["payTime"]); seat.payEmployee = dr["payEmployee"].ToString(); seat.discountEmployee = dr["discountEmployee"].ToString(); seat.discount = ToDouble(dr["discount"]); seat.memberDiscount = ToBool(dr["memberDiscount"]); seat.memberPromotionId = dr["memberPromotionId"].ToString(); seat.chainId = dr["chainId"].ToString(); seat.status = (SeatStatus)dr["status"]; seat.ordering = ToBool(dr["ordering"]); seat.paying = ToBool(dr["paying"]); seat.note = dr["note"].ToString(); seat.unwarn = dr["unwarn"].ToString(); seat.roomStatus = dr["roomStatus"].ToString(); seat.deposit = ToInt(dr["deposit"]); seat.depositBank = ToInt(dr["depositBank"]); seat.dueTime = ToDateTime(dr["dueTime"]); } } } catch (System.Exception e) { BathClass.printErrorMsg(e.Message); } finally { close_connection(sqlCn); } return seat; }
//点击台位按钮 private void btn_Click(object sender, EventArgs e) { Button btn = sender as Button; btn.Enabled = false; btn.Enabled = true; //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); var manuInput = MConvert<bool>.ToTypeOrDefault(LogIn.options.允许手工输入手牌号结账, false); //m_Seat = db_new.Seat.FirstOrDefault(x => x.text == btn.Text); m_Seat = dao.get_seat("text", btn.Text); var mtype = dao.get_seattype("id", m_Seat.typeId); //var mtype = db_new.SeatType.FirstOrDefault(x => x.id == m_Seat.typeId); switch (m_Seat.status) { case SeatStatus.AVILABLE://可用 case SeatStatus.PAIED://已经结账 case SeatStatus.RESERVE://预定客房 if (mtype.department == "客房部") { var form = new OpenRoomForm(m_Seat); form.ShowDialog(); } else if (mtype.menuId == null) { BathClass.printErrorMsg("手牌未开牌"); return; } else if (!manuInput && mtype.menuId != null) { BathClass.printErrorMsg("不允许手工输入手牌号结账!"); return; } break; case SeatStatus.USING://正在使用 case SeatStatus.WARNING://警告 case SeatStatus.DEPOSITLEFT://押金离场 case SeatStatus.REPAIED://重新结账 if (MConvert<bool>.ToTypeOrDefault(m_Seat.ordering, false)) { BathClass.printErrorMsg("正在录单!"); return; } if (mtype.department != "客房部" && !manuInput && mtype.menuId != null) { BathClass.printErrorMsg("不允许手工输入手牌号结账!"); return; } if (m_Seat.deposit != null) BathClass.printInformation("交押金:" + m_Seat.deposit.ToString()); if (m_Seat.note != null && m_Seat.note != "") BathClass.printInformation(m_Seat.note); if (mtype.menuId == null) { SeatExpenseForm seatExpenseForm = new SeatExpenseForm(m_Seat, seat_length, false, false, dao); seatExpenseForm.Show(); } else { SeatExpenseForm seatExpenseForm = new SeatExpenseForm(m_Seat, seat_length, seatLock, auto_seat_card, dao); seatExpenseForm.Show(); } break; case SeatStatus.LOCKING://锁定 break; case SeatStatus.STOPPED://停用 BathClass.printErrorMsg("台位已经停用!"); break; default: break; } }
public CSeat get_seat(List<string> key, List<string> key_val, string logic) { CSeat seat = null; var sqlCn = open_connection(); if (sqlCn == null || sqlCn.State != System.Data.ConnectionState.Open) return null; StringBuilder sb = new StringBuilder(); try { sqlCn = new SqlConnection(_con_str); sqlCn.Open(); sb.Append("Select * from [Seat] where ("); int count = key.Count; for (int i = 0; i < count; i++ ) { sb.Append(key[i]); sb.Append("='"); sb.Append(key_val[i]); sb.Append("'"); if (i != count - 1) sb.Append(" " + logic + " "); } sb.Append(")"); SqlCommand cmdSelect = new SqlCommand(sb.ToString(), sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { seat = new CSeat(); seat.id = (int)dr["id"]; seat.oId = dr["oId"].ToString(); seat.text = dr["text"].ToString(); seat.typeId = (int)dr["typeId"]; seat.systemId = dr["systemId"].ToString(); seat.name = dr["name"].ToString(); seat.population = ToInt(dr["population"]); seat.openTime = ToDateTime(dr["openTime"]); seat.openEmployee = dr["openEmployee"].ToString(); seat.payTime = ToDateTime(dr["payTime"]); seat.payEmployee = dr["payEmployee"].ToString(); seat.discountEmployee = dr["discountEmployee"].ToString(); seat.discount = ToDouble(dr["discount"]); seat.memberDiscount = ToBool(dr["memberDiscount"]); seat.memberPromotionId = dr["memberPromotionId"].ToString(); seat.chainId = dr["chainId"].ToString(); seat.status = (SeatStatus)dr["status"]; seat.ordering = ToBool(dr["ordering"]); seat.paying = ToBool(dr["paying"]); seat.note = dr["note"].ToString(); seat.unwarn = dr["unwarn"].ToString(); seat.roomStatus = dr["roomStatus"].ToString(); seat.deposit = ToInt(dr["deposit"]); seat.depositBank = ToInt(dr["depositBank"]); seat.dueTime = ToDateTime(dr["dueTime"]); } } } catch (System.Exception e) { BathClass.printErrorMsg(sb.ToString()); BathClass.printErrorMsg(e.Message); } finally { close_connection(sqlCn); } return seat; }
//开单个牌,用于以刷卡方式 private void open_one_seat(CSeat seat) { string systemId = dao.systemId(); StringBuilder sb = new StringBuilder(); if (seat.status == SeatStatus.PAIED) { sb.Append(dao.reset_seat_string() + "text='" + seat.text + "')"); } sb.Append("update [Seat] set openEmployee='" + LogIn.m_User.id + "',openTime=getdate(),systemId='"); sb.Append(systemId + "',status=2 where text='" + seat.text + "' "); sb.Append("insert into [SystemIds](systemId) values('" + systemId + "') "); //var menu = dao.get_seat_menu(seat.text); //if (menu != null) //{ // sb.Append(@" insert into [Orders](menu, text,systemId,number,money,inputTime,inputEmployee,paid) "); // sb.Append(@"values('" + menu.name + "','" + seat.text + "','" + systemId + "',1," + menu.price + ",getdate(),'"); // sb.Append(LogIn.m_User.id + "','False')"); //} if (!dao.execute_command(sb.ToString())) { BathClass.printErrorMsg("开牌失败,请重试!"); return; } }
public List<CSeat> get_seats(string key, List<object> key_val) { var seats = new List<CSeat>(); SqlConnection sqlCn = null; try { sqlCn = new SqlConnection(_con_str); sqlCn.Open(); } catch { close_connection(sqlCn); //BathClass.printErrorMsg("网络出错!"); return seats; } try { string cmd_str = "Select * from [Seat]"; if (key != null) { int count = key_val.Count; for (int i = 0; i < count; i++ ) { cmd_str += " where " + key + "='" + key_val[i].ToString() + "'"; if (i != count - 1) cmd_str += " or "; } } SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { var seat = new CSeat(); seat.id = (int)dr["id"]; seat.oId = dr["oId"].ToString(); seat.text = dr["text"].ToString(); seat.typeId = (int)dr["typeId"]; seat.systemId = dr["systemId"].ToString(); seat.name = dr["name"].ToString(); seat.population = ToInt(dr["population"]); seat.openTime = ToDateTime(dr["openTime"]); seat.openEmployee = dr["openEmployee"].ToString(); seat.payTime = ToDateTime(dr["payTime"]); seat.payEmployee = dr["payEmployee"].ToString(); seat.discountEmployee = dr["discountEmployee"].ToString(); seat.discount = ToDouble(dr["discount"]); seat.memberDiscount = ToBool(dr["memberDiscount"]); seat.memberPromotionId = dr["memberPromotionId"].ToString(); seat.chainId = dr["chainId"].ToString(); seat.status = (SeatStatus)dr["status"]; seat.ordering = ToBool(dr["ordering"]); seat.paying = ToBool(dr["paying"]); seat.note = dr["note"].ToString(); seat.unwarn = dr["unwarn"].ToString(); seat.roomStatus = dr["roomStatus"].ToString(); seat.deposit = ToInt(dr["deposit"]); seat.dueTime = ToDateTime(dr["dueTime"]); seats.Add(seat); } } } catch (System.Exception e) { //BathClass.printErrorMsg(e.Message); } finally { close_connection(sqlCn); } return seats; }
//退单 F10 private void toolReturn_Click(object sender, EventArgs e) { if (dgvExpense.CurrentCell == null) { BathClass.printErrorMsg("需要输入订单!"); return; } int orderId = MConvert<int>.ToTypeOrDefault(dgvExpense.CurrentRow.Cells[0].Value, 0); var order = dao.get_order("id", orderId); m_Seat = m_Seats.FirstOrDefault(x => x.systemId == order.systemId); if (order == null || order.menu.Contains("套餐优惠")) { BathClass.printErrorMsg("不能删除套餐优惠!"); return; } InputEmployeeByPwd inputServerForm = new InputEmployeeByPwd(); Employee del_employee; if (dao.get_authority(LogIn.m_User, "退单")) del_employee = LogIn.m_User; else if (inputServerForm.ShowDialog() != DialogResult.OK) return; else if (!dao.get_authority(inputServerForm.employee, "退单")) { BathClass.printErrorMsg("没有退单权限"); return; } else del_employee = inputServerForm.employee; var form = new DeleteExplainForm(); if (form.ShowDialog() != DialogResult.OK) return; string deleteExpalin = form.txt; string cmd_str = @"update [Orders] set deleteEmployee='" + del_employee.id + "', deleteExplain='" + deleteExpalin + "', deleteTime=getdate() where id=" + order.id; if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("退单失败,请重试!"); return; } BathClass.find_combo(LogIn.connectionString, m_Seat.systemId, m_Seat.text); dgvExpense_show(); if (!dao.execute_command("update [OrderStockOut] set deleteEmployee='" + del_employee.id + "' where orderId=" + order.id.ToString())) { BathClass.printErrorMsg("退换消耗品失败!"); } }
public List<CSeat> get_all_seats() { var seats = new List<CSeat>(); SqlConnection sqlCn = null; try { sqlCn = new SqlConnection(_con_str); sqlCn.Open(); } catch { close_connection(sqlCn); } if (sqlCn == null || sqlCn.State != System.Data.ConnectionState.Open) return seats; try { string cmd_str = "Select * from [Seat]"; SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { var seat = new CSeat(); seat.id = (int)dr["id"]; seat.oId = dr["oId"].ToString(); seat.text = dr["text"].ToString(); seat.typeId = (int)dr["typeId"]; seat.systemId = dr["systemId"].ToString(); seat.name = dr["name"].ToString(); seat.population = ToInt(dr["population"]); seat.openTime = ToDateTime(dr["openTime"]); seat.openEmployee = dr["openEmployee"].ToString(); seat.payTime = ToDateTime(dr["payTime"]); seat.payEmployee = dr["payEmployee"].ToString(); seat.discountEmployee = dr["discountEmployee"].ToString(); seat.discount = ToDouble(dr["discount"]); seat.memberDiscount = ToBool(dr["memberDiscount"]); seat.memberPromotionId = dr["memberPromotionId"].ToString(); seat.chainId = dr["chainId"].ToString(); seat.status = (SeatStatus)dr["status"]; seat.ordering = ToBool(dr["ordering"]); seat.paying = ToBool(dr["paying"]); seat.note = dr["note"].ToString(); seat.unwarn = dr["unwarn"].ToString(); seat.roomStatus = dr["roomStatus"].ToString(); seat.deposit = ToInt(dr["deposit"]); seat.dueTime = ToDateTime(dr["dueTime"]); seats.Add(seat); } } } catch (System.Exception e) { //BathClass.printErrorMsg(e.Message); } finally { close_connection(sqlCn); } return seats; }
//删除手牌 private void btnDel_Click(object sender, EventArgs e) { if (dgvChain.CurrentCell == null) { BathClass.printErrorMsg("未选择手牌!"); return; } if (dgvChain.Rows.Count == 1) { BathClass.printErrorMsg("已经只剩下一个手牌,不能删除!"); return; } string text = dgvChain.CurrentRow.Cells[0].Value.ToString(); int i = m_Seats.IndexOf(m_Seats.FirstOrDefault(x => x.text == text)); if (seatLock && dgvChain.Rows[i].Cells[1].EditedFormattedValue.ToString() == "False") { BathClass.printErrorMsg("已经刷手牌,不能删除!"); return; } dgvChain.Rows.RemoveAt(i); m_Seats.Remove(m_Seats.FirstOrDefault(x => x.text == text)); //var pars = new List<string>(); //pars.Add("paying"); //var vals = new List<string>(); //vals.Add("False"); //var txts = new List<string>(); //txts.Add(text); //dao.update_table_multi_row("Seat", "text", txts, pars, vals); if (!dao.execute_command("update [Seat] set paying='False' where text='" + text + "'")) { BathClass.printErrorMsg("手牌状态更新失败"); } //var dc_new = new BathDBDataContext(LogIn.connectionString); //dc_new.Seat.FirstOrDefault(x => x.text == text).paying = false; //dc_new.SubmitChanges(); //dgvChain_show(); m_Seat = null; dgvChain.CurrentCell = null; //chain = true; dgvExpense_show(); }
//F6开牌 private void tool_open_seat() { //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); string text = tSeat.Text; m_Seat = dao.get_seat("text='" + text + "' or oId='" + text + "'"); //m_Seat = db_new.Seat.FirstOrDefault(x => x.text == text || x.oId == text); if (m_Seat == null) { BathClass.printErrorMsg("手牌不可用!"); return; } switch (m_Seat.status) { case SeatStatus.AVILABLE://可用 case SeatStatus.PAIED://已经结账 BathClass.printErrorMsg("手牌未开牌"); break; case SeatStatus.USING://正在使用 case SeatStatus.DEPOSITLEFT://押金离场 if (!dao.get_authority(LogIn.m_User, "完整点单") && !dao.get_authority(LogIn.m_User, "可见本人点单")) { BathClass.printErrorMsg("权限不够!"); break; } if (MConvert<bool>.ToTypeOrDefault(m_Seat.paying, false)) { BathClass.printErrorMsg("正在结账!"); break; } //if (BathClass.ToBool(m_Seat.ordering)) //{ // BathClass.printErrorMsg("正在录单!"); // break; //} //m_Seat.ordering = true; //db_new.SubmitChanges(); OrderForm orderForm = new OrderForm(m_Seat, LogIn.m_User, LogIn.connectionString, false); orderForm.ShowDialog(); //m_Seat.ordering = false; //db_new.SubmitChanges(); break; case SeatStatus.LOCKING://锁定 BathClass.printErrorMsg("手牌已经锁定!"); break; case SeatStatus.STOPPED://停用 BathClass.printErrorMsg("手牌已经停用!"); break; case SeatStatus.WARNING://警告 OrderCheckForm orderCheckForm = new OrderCheckForm(m_Seat, LogIn.connectionString,LogIn.options); orderCheckForm.ShowDialog(); break; case SeatStatus.REPAIED: BathClass.printErrorMsg("补救台位不能录单"); break; default: break; } tSeat.Text = ""; }
private void dgvChain_CellClick(object sender, DataGridViewCellEventArgs e) { if (dgvChain.CurrentRow == null) return; string id = dgvChain.CurrentRow.Cells[0].Value.ToString(); m_Seat = m_Seats.FirstOrDefault(x => x.text == id); //if (!use_oyd) //{ // if (dgvChain.CurrentCell.ColumnIndex != 1) // chain = false; // else // chain = true; // setStatus(); // dgvExpense_show(); //} }
//点击台位按钮 private void btn_Click(object sender, EventArgs e) { Button btn = sender as Button; btn.Enabled = false; btn.Enabled = true; //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); //m_Seat = db_new.Seat.FirstOrDefault(x => x.text == btn.Text); m_Seat = dao.get_seat("text", btn.Text); SeatStatus status = m_Seat.status; switch (status) { case SeatStatus.AVILABLE://可用 case SeatStatus.PAIED://已经结账 BathClass.printErrorMsg("手牌未开牌"); break; case SeatStatus.USING://正在使用 case SeatStatus.DEPOSITLEFT://押金离场 if (!dao.get_authority(LogIn.m_User, "完整点单") && !dao.get_authority(LogIn.m_User, "可见本人点单")) { BathClass.printErrorMsg("权限不够!"); break; } if (MConvert<bool>.ToTypeOrDefault(m_Seat.paying, false)) { BathClass.printErrorMsg("正在结账!"); break; } //if (BathClass.ToBool(m_Seat.ordering)) //{ // BathClass.printErrorMsg("正在录单!"); // break; //} //m_Seat.ordering = true; //db_new.SubmitChanges(); OrderForm orderForm = new OrderForm(m_Seat, LogIn.m_User, LogIn.connectionString, false); orderForm.ShowDialog(); //m_Seat.ordering = false; //db_new.SubmitChanges(); break; case SeatStatus.LOCKING://锁定 BathClass.printErrorMsg("手牌已经锁定!"); break; case SeatStatus.STOPPED://停用 BathClass.printErrorMsg("台位已经停用!"); break; case SeatStatus.WARNING://警告 OrderCheckForm orderCheckForm = new OrderCheckForm(m_Seat, LogIn.connectionString, LogIn.options); orderCheckForm.ShowDialog(); break; case SeatStatus.REPAIED: BathClass.printErrorMsg("补救台位不能录单"); break; default: break; } }
//加收过夜费 private void order_guoye(CSeat seat) { if (!MConvert<bool>.ToTypeOrDefault(LogIn.options.自动加收过夜费, false) || seat.openTime == null || seat.systemId == null || seat.status == SeatStatus.REPAIED) return; if (dao.has_ordered_guoye(seat.systemId)) return; var m_OverMenu = dao.get_Menu("name", "过夜费"); //var m_OverMenu = dc.Menu.FirstOrDefault(x => x.name == "过夜费"); if (m_OverMenu == null) return; DateTime lastday = now.AddDays(-1); string year = now.Year.ToString(); string month = now.Month.ToString(); string day = now.Day.ToString(); string date = year+"-"+month+"-"+day+" "; string lastdate = lastday.Year.ToString() + "-" + lastday.Month.ToString() + "-" + lastday.Day.ToString() + " "; string time = ":00:00"; int qi = MConvert<int>.ToTypeOrDefault(LogIn.options.过夜费起点, 0); int zh = MConvert<int>.ToTypeOrDefault(LogIn.options.过夜费终点, 0); DateTime st = DateTime.Parse(date + LogIn.options.过夜费起点 + time); if (qi > zh) st = DateTime.Parse(lastdate + LogIn.options.过夜费起点 + time); DateTime et = DateTime.Parse(date + LogIn.options.过夜费终点 + time); DateTime open_time = seat.openTime.Value; if ((now >= et && open_time >= et) || (open_time <= st && now <= st)) return; string cmd_str = @"insert into [Orders](menu,text,systemId,number,money,inputTime,inputEmployee,paid) values(" + @"'过夜费','" + seat.text + "','" + seat.systemId + "',1,'" + m_OverMenu.price.ToString() + "',getdate(),'过夜费','False')"; if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("手牌:" + seat.text + ",过夜费添加失败,请手动添加!"); return; } BathClass.find_combo(LogIn.connectionString, m_Seat.systemId, m_Seat.text); }
public ReserveOverDueForm(Seat seat) { dao = new DAO(LogIn.connectionString); m_seat = dao.get_seat("text='" + seat.text + "'"); InitializeComponent(); }