//构造函数 public RoomForm(BathDBDataContext dc, Room room, RoomManagementForm rm) { db = dc; m_rmForm = rm; if (room != null) { newRoom = false; m_Room = room; } InitializeComponent(); }
//生成按钮状态 private void btn_status(Button btn, Room room) { if (room.status == "空闲") btn.BackColor = Color.FromArgb(1, 175, 3); else if (room.status == "入住") btn.BackColor = Color.FromArgb(43, 76, 255); else if (room.status == "等待服务") btn.BackColor = Color.FromArgb(255,255,0); else if (room.status == "预约服务") btn.BackColor = Color.FromArgb(128, 0, 128); else if (room.status == "服务") btn.BackColor = Color.FromArgb(198, 0, 0); else if (room.status == "等待清洁") btn.BackColor = Color.FromArgb(255, 115, 39); }
//点击确定 private void btnOk_Click(object sender, EventArgs e) { if (name.Text == "") { name.Focus(); GeneralClass.printErrorMsg("请输入房号"); return; } m_Room.name = name.Text; m_Room.population = Convert.ToInt32(population.Text); m_Room.note = note.Text; if (newRoom) { if (db.Room.FirstOrDefault(x => x.name == name.Text) != null) { name.SelectAll(); name.Focus(); GeneralClass.printErrorMsg("已存在" + name.Text + "房间,不能重复添加"); return; } m_Room.status = "空闲"; db.Room.InsertOnSubmit(m_Room); db.SubmitChanges(); m_rmForm.dgv_show(); m_Room = new Room(); name.Text = ""; population.Text = "1"; note.Text = ""; } else { db.SubmitChanges(); this.DialogResult = DialogResult.OK; } }
//创建客房按钮 private void createButton(int x, int y, Room room, int i, Control sp) { Button btn = new Button(); btn.Font = new Font("SimSun", 14F, FontStyle.Bold); btn.Location = new System.Drawing.Point(x, y); if (room.population == 1) btn.Name = room.id.ToString(); else btn.Name = room.id.ToString() + "-" + (i + 1).ToString(); btn.Text = getBtnString(room, i); btn.TextAlign = System.Drawing.ContentAlignment.TopLeft; btn.Size = new System.Drawing.Size(140, 110); btn.FlatStyle = FlatStyle.Popup; btn.UseVisualStyleBackColor = true; btn_status(btn, room, i); btn.Click += new System.EventHandler(btn_Click); sp.Controls.Add(btn); }
//获取button显示字符串 private string getBtnString(Room room) { int roomId = room.id; string str = "房间:" + room.name; if (room.status == "入住") { //int minute = (int)(DateTime.Now - room.openTime.Value).TotalMinutes; //str += "\n已住:" + minute.ToString() + "分钟"; //if (room.orderTechId != null && room.orderTechId != "") // str += "\n技师:" + room.orderTechId; } else if (room.status == "等待服务") { //int minute = (int)(DateTime.Now - room.orderTime.Value).TotalMinutes; //str += "\n已等:" + minute.ToString() + "分钟"; //if (room.orderTechId != null && room.orderTechId != "") // str += "\n技师:" + room.orderTechId; } else if (room.status == "预约服务") { //int minute = (int)(DateTime.Now - room.reserveTime.Value).TotalMinutes; //str += "\n已住:" + minute.ToString() + "分钟"; //if (room.reserveId != null && room.reserveId != "") // str += "\n技师:" + room.reserveId; //if (room.reserveTime.HasValue) // str += "\n预约:" + room.reserveTime.Value.ToString("HH:mm"); } else if (room.status == "服务") { //str += "\n技师:" + room.techId; //str += "\n时间:" + room.serverTime.ToString(); //int minute = (int)(room.serverTime - (DateTime.Now - room.startTime.Value).TotalMinutes); //str += "\n还剩:" + minute.ToString() + "分钟"; } else if (room.status == "等待清洁") { //if (room.techId != null) // str += "\n技师:" + room.techId; //if (room.startTime != null && room.serverTime != null) // str += "\n下钟:" + (room.startTime.Value.AddMinutes(room.serverTime.Value)).ToString("HH:mm"); } return str; }
partial void DeleteRoom(Room instance);
partial void UpdateRoom(Room instance);
partial void InsertRoom(Room instance);
//创建客房按钮 private void createButton(int x, int y, Room room, Control sp) { Button btn = new Button(); btn.Font = new Font("SimSun", 14F, FontStyle.Bold); btn.Location = new System.Drawing.Point(x, y); btn.Name = room.id.ToString(); btn.Text = getBtnString(room); btn.TextAlign = System.Drawing.ContentAlignment.TopLeft; btn.Size = new System.Drawing.Size(140, 100); btn.FlatStyle = FlatStyle.Popup; btn.UseVisualStyleBackColor = true; btn.BackColor = Color.LightGreen; btn.Click += new System.EventHandler(btn_Click); btn.TabStop = false; btn_status(room, btn); sp.Controls.Add(btn); }
private void btn_status(Room room, Button btn) { int cur_pop = 0; var ids = room.seatIds; if (ids != null) cur_pop = ids.Split('|').Length; int pop = room.population; if (cur_pop == 0) btn.BackColor = Color.LightGreen; else if (cur_pop != 0 && cur_pop < pop) btn.BackColor = Color.Cyan; else if (cur_pop != 0 && cur_pop == pop) btn.BackColor = Color.Red; }
//构造函数 public CabPopForm(string roomId) { dc = new BathDBDataContext(LogIn.connectionString); m_room = dc.Room.FirstOrDefault(x => x.id.ToString() == roomId); InitializeComponent(); }
private void set_btn_status(Button btn, Room room, int i) { btn.Text = getBtnString(room, i); btn_status(btn, room, i); }
//获取button显示字符串 private void btn_status(Button btn, Room room) { int roomId = room.id; string str = "房间:" + room.name; int pop = room.population; str += "\n可住:" + pop.ToString() + "人"; int number_in = 0; string status = "空闲"; for (int i = 0; i < pop; i++ ) { status = "空闲"; try { status = room.status.Split('|')[i]; } catch { } if (status=="入住"||status=="等待服务"||status=="预约服务"||status=="服务"||status=="等待清洁") { number_in++; } } str += "\n已住:" + number_in.ToString() + "人"; btn.Text = str; if (number_in == 0) { btn.BackColor = avi_color; avi_number++; } else if (number_in != 0 && number_in < pop) { btn.BackColor = in_color; in_number++; } else if (number_in == pop) { btn.BackColor = full_color; full_number++; } }
//获取button显示字 //房间号、技师号、手牌、服务项目、服务时间 private string getBtnString(Room room, int i) { int roomId = room.id; string str = "房间:" + room.name; if (room.population != 1) str += "-" + (i + 1).ToString(); string status = "空闲"; string seat = ""; try { status = room.status.Split('|')[i]; seat = room.seat.Split('|')[i]; } catch { } if (status == "入住") { str += "\n手牌:" + seat; try { var openTime = Convert.ToDateTime(room.openTime.Split('|')[i]); int minute = (int)(DateTime.Now - openTime).TotalMinutes; str += "\n已住:" + minute.ToString() + "分"; if (room.orderTechId != null) { var orderTechId = room.orderTechId.Split('|')[i]; str += "\n技师:" + orderTechId; } } catch { } } else if (status == "等待服务") { str += "\n手牌:" + seat; try { var orderTime = Convert.ToDateTime(room.orderTime.Split('|')[i]); int minute = (int)(DateTime.Now - orderTime).TotalMinutes; str += "\n已等:" + minute.ToString() + "分"; if (room.orderTechId != null) { var orderTechId = room.orderTechId.Split('|')[i]; if (orderTechId == "") { orderTechId = room.selectId.Split('|')[i]; } str += "\n技师:" + orderTechId; } } catch { } } else if (status == "预约服务") { str += "\n手牌:" + seat; try { var reserveTime = Convert.ToDateTime(room.reserveTime.Split('|')[i]); int minute = (int)(DateTime.Now - reserveTime).TotalMinutes; str += "\n预约:" + reserveTime.ToString("HH:mm"); str += "\n已约:" + minute.ToString() + "分"; if (room.reserveId != null) { var reserveId = room.reserveId.Split('|')[i]; str += "\n技师:" + reserveId; } } catch { } } else if (status == "服务") { str += "\n手牌:" + seat; try { str += "\n技师:" + room.techId.Split('|')[i]; str += "\n时间:" + room.serverTime.Split('|')[i]; int serverTime = Convert.ToInt32(room.serverTime.Split('|')[i]); var st = Convert.ToDateTime(room.startTime.Split('|')[i]); int minute = (int)(serverTime - (DateTime.Now - st).TotalMinutes); str += "\n还剩:" + minute.ToString() + "分"; } catch { } } else if (status == "等待清洁") { str += "\n手牌:" + seat; try { if (room.techId != null) str += "\n技师:" + room.techId.Split('|')[i]; if (room.startTime != null && room.serverTime != null) { var st = Convert.ToDateTime(room.startTime.Split('|')[i]); var l = Convert.ToInt32(room.serverTime.Split('|')[i]); str += "\n下钟:" + (st.AddMinutes(l)).ToString("HH:mm"); } } catch { } } return str; }
//获取button显示字符串 //房间号、技师号、手牌、服务项目、服务时间 private string getBtnString(Room room) { int roomId = room.id; string str = "房间:" + room.name; str += "\n可住:" + room.population.ToString() + "人"; str += "\n" + room.seatIds; return str; }
//生成按钮状态 private void btn_status(Button btn, Room room, int i) { string status = "空闲"; try { status = room.status.Split('|')[i]; } catch { } if (status == "空闲") btn.BackColor = Color.FromArgb(1, 175, 3); else if (status == "入住") btn.BackColor = Color.FromArgb(43, 76, 255); else if (status == "等待服务") btn.BackColor = Color.FromArgb(198, 0, 0); else if (status == "预约服务") btn.BackColor = Color.FromArgb(128, 0, 128); else if (status == "服务") btn.BackColor = Color.FromArgb(255, 255, 0); else if (status == "等待清洁") btn.BackColor = Color.FromArgb(255, 115, 39); }
//重置客房 public static void reset_room(Room room) { room.openTime = null; room.seat = null; room.systemId = null; room.menu = null; room.orderTechId = null; room.techId = null; room.startTime = null; room.serverTime = null; room.status = "空闲"; room.note = null; }