private void EditFormRoom_Load(object sender, EventArgs e) { this.cbRoomType.SelectedIndexChanged -= new EventHandler(CbRoomType_SelectedIndexChanged); this.cbRoomType.DataSource = RoomTypeBUS.GetRoomTypeList(); this.cbRoomType.DisplayMember = "MaLoaiPhong"; DataTable dt = RoomStatusBUS.GetRoomStatusList(); Dictionary<string, string> status = new Dictionary<string, string>(); foreach (DataRow dr in dt.Rows) { if (dr["TenTinhTrang"].ToString() != "Thuê") { status.Add(dr["TenTinhTrang"].ToString(), dr["MaTinhTrang"].ToString()); } } this.cbRoomStatus.DataSource = new BindingSource(status, null); this.cbRoomStatus.DisplayMember = "Key"; this.cbRoomStatus.ValueMember = "Value"; switch (this.Tag) { case "AddForm": { this.lbRoomHeader.Text = this.Text = "THÊM THÔNG TIN PHÒNG"; this.cbRoomType.SelectedIndex = 0; this.cbRoomStatus.SelectedIndex = 0; break; } case "EditForm": { MainForm mainForm = (MainForm)Owner; var room = mainForm.GetSelectedRoom(); this.LoadSelectedRoomData(room); this.lbRoomHeader.Text = this.Text = "THAY ĐỔI THÔNG TIN PHÒNG"; this.tbRoomID.ReadOnly = true; this.tbRoomID.TabStop = false; break; } } this.lbRoomHeader.Left = (this.ClientSize.Width - lbRoomHeader.Size.Width) / 2 + 32; this.imgEditRoom.Left = this.lbRoomHeader.Left - 45; this.tbRoomPrice.Text = Convert.ToInt64(RoomTypeBUS.GetRoomPriceByType(cbRoomType.Text)).ToString("N0") + " VND"; this.cbRoomType.SelectedIndexChanged += new EventHandler(CbRoomType_SelectedIndexChanged); }
// Tab 03: Room Search public void ReLoadFindRoom() { DataTable dt = RoomBUS.GetRoomList(); Dictionary <string, string> id = new Dictionary <string, string>() { { "Tất cả phòng", null } }; foreach (DataRow dr in dt.Rows) { var key = dr["MaPhong"].ToString(); var value = key; id.Add(key, value); } this.cbFindRoomID.DataSource = new BindingSource(id, null); this.cbFindRoomID.DisplayMember = "Key"; this.cbFindRoomID.ValueMember = "Value"; dt = RoomTypeBUS.GetRoomTypeList(); Dictionary <string, string> type = new Dictionary <string, string>() { { "Tất cả loại phòng", null } }; foreach (DataRow dr in dt.Rows) { var key = dr["MaLoaiPhong"].ToString(); var value = key; type.Add(key, value); } this.cbFindRoomType.DataSource = new BindingSource(type, null); this.cbFindRoomType.DisplayMember = "Key"; this.cbFindRoomType.ValueMember = "Value"; dt = RoomTypeBUS.GetRoomPriceList(); Dictionary <string, Int64> price = new Dictionary <string, Int64>() { { "Tất cả đơn giá", -1 } }; foreach (DataRow dr in dt.Rows) { var key = Convert.ToInt64(dr["DonGia"]).ToString("N0") + " VND"; var value = Int64.Parse(key.Split()[0].Replace(",", "")); price.Add(key, value); } this.cbFindRoomPrice.DataSource = new BindingSource(price, null); this.cbFindRoomPrice.DisplayMember = "Key"; this.cbFindRoomPrice.ValueMember = "Value"; dt = RoomStatusBUS.GetRoomStatusList(); Dictionary <string, string> status = new Dictionary <string, string>() { { "Tất cả tình trạng", null } }; foreach (DataRow dr in dt.Rows) { var key = dr["TenTinhTrang"].ToString(); var value = dr["MaTinhTrang"].ToString(); status.Add(key, value); } this.cbFindRoomStatus.DataSource = new BindingSource(status, null); this.cbFindRoomStatus.DisplayMember = "Key"; this.cbFindRoomStatus.ValueMember = "Value"; }