//确定 private void BtnOK_Click(object sender, EventArgs e) { BtnOK.Enabled = false; BtnOK.Enabled = true; 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 != m_Seat.status) { BathClass.printErrorMsg("所选择台位不可用"); return; } } else if (!m_StatusList.Contains(m_Seat.status)) { BathClass.printErrorMsg("所选择台位不可用"); return; } this.DialogResult = DialogResult.OK; }
//构造函数 public SeatExpenseForm(Seat seat) { db = new BathDBDataContext(LogIn.connectionString); m_Seat = db.Seat.FirstOrDefault(x => x.text == seat.text); InitializeComponent(); }
//构造函数 public MemberPromotionForm(Seat seat) { //m_systemId = systemid; db = new BathDBDataContext(LogIn.connectionString); m_Seat = db.Seat.FirstOrDefault(x => x.text == seat.text); //m_Seats.AddRange(db.Seat.Where(x => seat.Contains(x))); InitializeComponent(); }
//构造函数 public SeatForm(BathDBDataContext dc, Seat seat, SeatManagementForm smf) { db = dc; m_mForm = smf; if (seat != null) { newSeat = false; m_Seat = seat; } InitializeComponent(); }
//构造函数 public OrderForm(Seat seat, Employee employee) { db = new BathDBDataContext(MainWindow.connectionString); m_Seat = db.Seat.FirstOrDefault(x => x == seat); m_Employee = employee; read_File(); if (typeList.Count == 0) typeList = db.Catgory.Select(x => x.name).ToList(); InitializeComponent(); createMenuTypePanel(); }
//增加 private void btnAdd_Click(object sender, EventArgs e) { m_Seat = db.Seat.FirstOrDefault(x => x.text == seatBox.Text); if (m_Seat == null) { seatBox.SelectAll(); seatBox.Focus(); BathClass.printErrorMsg("手牌不存在!"); return; } dgv_show(); //seatBox.Enabled = false; }
//构造函数 public TransferSelectForm(List<Seat> seats, SeatExpenseForm form) { db = new BathDBDataContext(LogIn.connectionString); //m_Seat = db.Seat.FirstOrDefault(x => x.text == seat.text); foreach (var s in seats) { m_Seats.Add(db.Seat.FirstOrDefault(x => x.text == s.text)); } m_Seat = m_Seats[0]; m_form = form; InitializeComponent(); }
private void tool_open_seat() { var db_new = new BathDBDataContext(LogIn.connectionString); string text = tSeat.Text; m_Seat = db_new.Seat.FirstOrDefault(x => x.text == text); if (m_Seat == null || (m_Seat.status != 2 && m_Seat.status != 6 && m_Seat.status != 7 && m_Seat.status != 8)) { GeneralClass.printErrorMsg("手牌不存在或者不在使用中,不可查看消费!"); return; } var dao = new DAO(LogIn.connectionString); var s = dao.get_seat("text", m_Seat.text); OrderCheckForm orderCheckForm = new OrderCheckForm(s, LogIn.connectionString, LogIn.options); orderCheckForm.ShowDialog(); tSeat.Text = ""; }
//确定 private void btnOk_Click(object sender, EventArgs e) { if (newSeat && db.Seat.FirstOrDefault(x => x.text == id.Text) != null) { id.SelectAll(); id.Focus(); GeneralClass.printErrorMsg("该台位已经存在!"); return; } m_Seat.text = id.Text; m_Seat.name = name.Text; m_Seat.typeId = db.SeatType.FirstOrDefault(x => x.name == typeName.Text).id; m_Seat.oId = oId.Text; m_Seat.note = note.Text; if (newSeat) { m_Seat.status = 1; db.Seat.InsertOnSubmit(m_Seat); db.SubmitChanges(); id.Text = ""; name.Text = ""; oId.Text = ""; note.Text = ""; m_mForm.dgv_show(); m_Seat = new Seat(); return; } else { db.SubmitChanges(); this.DialogResult = DialogResult.OK; } }
//创建单个台位按钮 private static void createButton(int x, int y, Seat table, Control sp, EventHandler btn_Click, ContextMenuStrip cm) { Button btn = new Button(); //根椐手牌长度确定字体的大小 Single bf = 13F; int l = table.text.Length; if (l == 3) bf = 13F; else if (l == 4) bf = 10f; btn.Font = new Font("SimSun", bf); btn.Location = new System.Drawing.Point(x, y); //button的位置 btn.Name = table.id.ToString(); //button.Name btn.Text = table.text; //button.Text btn.Size = new System.Drawing.Size(btn_size, btn_size);//button.Size btn.FlatStyle = FlatStyle.Popup; btn.UseVisualStyleBackColor = true; if (cm != null) btn.ContextMenuStrip = cm; //button的右键菜单 btn.TabStop = false; btn.Click += btn_Click; //button click事件 btn_status(btn, table.status); //button 状态,以button和手牌状态为参数 sp.Controls.Add(btn); //控件上添加该button }
partial void InsertSeat(Seat instance);
//获取手牌消费金额 public double get_seat_expense(BathDBDataContext dc, Seat seat) { var orders = dc.Orders.Where(x => x.systemId == seat.systemId && x.deleteEmployee == null && !x.paid); double money = 0; var tmp_orders = orders.Where(x => x.priceType == null || x.priceType == "停止消费"); if (tmp_orders.Count() != 0) money = tmp_orders.Sum(x => x.money); tmp_orders = orders.Where(x => x.priceType == "每小时"); if (tmp_orders.Count() != 0) money += tmp_orders.Sum(x => x.money * Math.Ceiling((DateTime.Now - x.inputTime).TotalHours)); return Math.Round(money, 0); }
private void print_seat_bill(Seat seat) { 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); double money_pay = 0; var orders = db.Orders.Where(x => x.systemId == seat.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.Menu.FirstOrDefault(x => x.name == order.menu); if (menu != null) row[3] = menu.price.ToString(); row[4] = order.number.ToString(); double money_tmp = 0; if (order.priceType == "每小时") { row[3] = order.money.ToString() + "/时"; money_tmp = Math.Ceiling((GeneralClass.Now - order.inputTime).TotalHours) * order.money; } else { money_tmp = order.money; } money_pay += money_tmp; row[5] = money_tmp.ToString(); dgv.Rows.Add(row); } List<string> printCols = new List<string>(); List<string> m_rooms = new List<string>(); printCols.Add("包厢"); printCols.Add("手牌"); printCols.Add("项目名称"); printCols.Add("技师"); printCols.Add("单价"); printCols.Add("数量"); printCols.Add("金额"); List<CSeat> seats = new List<CSeat>(); var dao = new DAO(LogIn.connectionString); seats.Add(dao.get_seat("text='" + seat.text + "'")); foreach (var s in seats) { m_rooms.Add(dao.get_seat_room(s.text)); } PrintSeatBill.Print_DataGridView(seats,m_rooms, null, "预打账单", dgv, printCols, money_pay.ToString(), LogIn.options.companyName); }
//获取手牌消费金额 public static double get_seat_expense(Seat seat, BathDBDataContext db, string connectionString) { var orders = db.Orders.Where(x => x.systemId == seat.systemId && x.deleteEmployee == null && !x.paid && x.departmentId == null); double money = 0; var tmp_orders = orders.Where(x => x.priceType == null || x.priceType == "停止消费"); if (tmp_orders.Count() != 0) money = tmp_orders.Sum(x => x.money); tmp_orders = orders.Where(x => x.priceType == "每小时"); if (tmp_orders.Count() != 0) { DateTime now = BathClass.Now(connectionString); money += tmp_orders.Sum(x => x.money * Math.Ceiling((now - x.inputTime).TotalHours)); } return Math.Round(money, 0); }
//重置台位 public static void reset_seat(Seat seat) { seat.systemId = null; seat.name = null; seat.population = null; seat.openTime = null; seat.openEmployee = null; seat.payTime = null; seat.payEmployee = null; seat.phone = null; seat.discount = null; seat.discountEmployee = null; seat.memberDiscount = null; seat.memberPromotionId = null; seat.freeEmployee = null; seat.chainId = null; seat.status = 1; seat.ordering = null; seat.paying = null; seat.note = null; seat.unwarn = null; seat.roomStatus = null; seat.deposit = null; seat.dueTime = null; }
partial void UpdateSeat(Seat instance);
public ReserveOverDueForm(Seat seat) { dao = new DAO(LogIn.connectionString); m_seat = dao.get_seat("text='" + seat.text + "'"); InitializeComponent(); }
partial void DeleteSeat(Seat instance);
private void show_reserve_over_dur_form(Seat seat) { var form = new ReserveOverDueForm(seat); form.ShowDialog(); }
//刷新线程 /*private void update_seats_ui() { while (true) { if (m_close) break; try { var db_new = new BathDBDataContext(LogIn.connectionString); var seats_tmp = db_new.Seat.Select(x => x.status).ToList(); bool changed = false; for (int i = 0; i < seats_tmp.Count; i++) { if (seats_tmp[i] != all_seats[i]) { var btn = seatPanel.Controls.Find(all_seats_id[i].ToString(), false).FirstOrDefault(); var btns = btn as Button; btn_status(btns, seats_tmp[i]); changed = true; } } if (changed) { setStatus(); all_seats = seats_tmp; } } catch { } } }*/ //每隔1分钟监听一次,吧台消息 /*private void msgTimer_Elapsed(object sender, EventArgs e) { msgTimer.Stop(); var dc_check = new BathDBDataContext(LogIn.connectionString); var barMsg = dc_check.BarMsg.FirstOrDefault(x => !x.read.Value); if (barMsg != null) { play(); this.Invoke(new show_msg_delegate(show_msg), new object[] { "房间号:" + barMsg.roomId.Trim() + "," + barMsg.msg}); barMsg.read = true; dc_check.SubmitChanges(); sp.Stop(); } msgTimer.Start(); } //每隔1分钟监听一次,吧台消息 private void roomTimer_Elapsed(object sender, EventArgs e) { var dc_check = new BathDBDataContext(LogIn.connectionString); roomTimer.Stop(); if (dc_check.Room.Any(x => x.status == "等待服务" && (DateTime.Now - x.orderTime.Value).TotalMinutes >= msg_delay)) { play(); this.Invoke(new watchSeatDelegate(roomwaitover_show)); sp.Stop(); } roomTimer.Start(); } private void roomwaitover_show() { RoomWaitOverForm form = new RoomWaitOverForm(); form.ShowDialog(); } //播放声音 private void play() { if (!File.Exists(@"msg.wav")) return; sp.SoundLocation = @"msg.wav"; sp.PlayLooping(); } private delegate void show_msg_delegate(string msg); private delegate void watchSeatDelegate(); private void show_msg(string msg) { InformationDlg dlg = new InformationDlg(msg); dlg.ShowDialog(); //MessageBox.Show(msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); }*/ //监控台位数据库改变 /*private void watchSeat() { if (m_connection == null) m_connection = new SqlConnection(LogIn.connectionString); if (m_connection.State != ConnectionState.Open) m_connection.Open(); SqlCommand cmd = m_connection.CreateCommand(); cmd.Notification = null;//清除 cmd.CommandText = "select id, oId, text, typeId, systemId, openTime, openEmployee, payTime, payEmployee, chainId, status From dbo.Seat"; //监控台位数据库 SqlDependency dependency = new SqlDependency(cmd); dependency.OnChange += new OnChangeEventHandler(seat_OnChange); //SqlDependency绑定的SqlCommand对象必须要执行一下,才能将SqlDependency对象的HasChange属性设为true SqlDataAdapter thisAdapter = new SqlDataAdapter(cmd); DataSet posDataSet = new DataSet(); thisAdapter.Fill(posDataSet, "Seat"); //刷新台位信息 if (this.WindowState != FormWindowState.Minimized) update_seats(); //刷新状态栏 setStatus(); }*/ /* //监控台位数据库改变 private void seat_OnChange(object sender, SqlNotificationEventArgs e) { //因为是子线程,需要用invoke方法更新ui if (this.InvokeRequired) { this.Invoke(new watchSeatDelegate(watchSeat), null); } else { watchSeat(); } SqlDependency dependency = (SqlDependency)sender; //通知之后,当前dependency失效,需要重新设置通知 dependency.OnChange -= seat_OnChange; }*/ //创建单个台位按钮 private void createButton(int x, int y, Seat table, Control sp) { Button btn = new Button(); Single bf = 13F; int l = table.text.Length; if (l == 3) bf = 13F; else if (l == 4) bf = 10f; btn.Font = new Font("SimSun", bf); btn.Location = new System.Drawing.Point(x, y); btn.Name = table.id.ToString(); btn.Text = table.text; btn.Size = new System.Drawing.Size(btn_size, btn_size); btn.FlatStyle = FlatStyle.Popup; btn.UseVisualStyleBackColor = true; //btn.ContextMenuStrip = seatContext; btn.TabStop = false; btn.Click += new System.EventHandler(btn_Click); btn_status(btn, table.status); sp.Controls.Add(btn); }