public RoomLeaseDTO GetRoomLease() { var lease = new RoomLeaseDTO(); lease.RoomID = cbLeaseRoomID.Text; lease.RoomTypeID = RoomTypeBUS.GetRoomTypeByID(lease.RoomID); lease.LeaseDate = DateTime.ParseExact(deLeaseRoomDate.Text, "d/M/yyyy", CultureInfo.InvariantCulture).ToString("d"); lease.RoomPrice = Convert.ToInt64(tbLeaseRoomPrice.Text.Split()[0].Replace(",", "")); return(lease); }
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 06: Room-Rule Edit private void ReLoadRuleRoom() { this.lbMaxCustomerValue.Text = RoomBUS.GetMaxCustomerInRoom().ToString(); this.lbAdditionalCustomerSurchargeValue.Text = RoomLeaseBUS.GetOverCustomerTaxPercent().ToString() + "%"; this.lbForeignCustomerSurchargeValue.Text = RoomLeaseBUS.GetForeignCustomerTaxPercent().ToString() + "%"; this.dgvCustomerType.DataSource = CustomerTypeBUS.GetCustomerTypeList(); var dt = RoomTypeBUS.GetRoomTypeList(); foreach (DataRow dr in dt.Rows) { this.dgvRoomType.Rows.Add (dr["MaLoaiPhong"].ToString(), Convert.ToInt64(dr["DonGia"]).ToString("N0")); } }
private void CbFindRoomType_SelectedIndexChanged(object sender, EventArgs e) { try { var RoomType = cbFindRoomType.Text; if (RoomType != "Tất cả loại phòng") { this.cbFindRoomPrice.Text = RoomTypeBUS.GetRoomPriceByType(RoomType).ToString("N0") + " VND"; } else { this.cbFindRoomPrice.Text = "Tất cả đơn giá"; } } catch (Exception) { } }
private void BtnAddRoom_Click(object sender, EventArgs e) { if (RoomTypeBUS.GetRoomTypeList().Rows.Count > 0) { var RoomForm = new RoomForm(); RoomForm.Tag = "AddForm"; RoomForm.ShowDialog(this); } else { MessageBox.Show("Chưa có loại phòng!", "THÊM PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void BtnDelRoomType_Click(object sender, EventArgs e) { var RoomTypeID = this.dgvRoomType.CurrentRow.Cells["EditRoomTypeID"].Value.ToString(); var dialogResult = MessageBox.Show( "Bạn có muốn xoá loại phòng " + RoomTypeID + "?", "XÁC NHẬN XOÁ LOẠI PHÒNG", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { if (RoomTypeBUS.CountRoomWithType(RoomTypeID) > 0) { MessageBox.Show( "Vẫn còn phòng loại " + RoomTypeID + "!\n" + "Xoá loại phòng thất bại!", "XOÁ LOẠI PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (RoomTypeBUS.DeleteRoomType(RoomTypeID)) { MessageBox.Show( "Xoá loại phòng " + RoomTypeID + " thành công!", "XOÁ LOẠI PHÒNG THÀNH CÔNG", MessageBoxButtons.OK, MessageBoxIcon.Information); this.ReLoadRoomTypeList(); } else { MessageBox.Show( "XOÁ LOẠI PHÒNG THẤT BẠI!", "XOÁ LOẠI PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public void ReLoadRoomTypeList() { this.dgvRoomType.Rows.Clear(); var dt = RoomTypeBUS.GetRoomTypeList(); foreach (DataRow dr in dt.Rows) { this.dgvRoomType.Rows.Add (dr["MaLoaiPhong"].ToString(), Convert.ToInt64(dr["DonGia"]).ToString("N0")); } if (dt.Rows.Count > 0) { this.btnDelRoomType.Enabled = this.btnEditRoomType.Enabled = true; } else { this.btnDelRoomType.Enabled = this.btnEditRoomType.Enabled = false; } }
private void CbRoomType_SelectedIndexChanged(object sender, EventArgs e) { this.tbRoomPrice.Text = Convert.ToInt64(RoomTypeBUS.GetRoomPriceByType(cbRoomType.Text)).ToString("N0") + " VND"; }
// 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"; }
private void CbNoteRoomID_SelectedIndexChanged(object sender, EventArgs e) { var price = RoomTypeBUS.GetRoomPriceByID(cbLeaseRoomID.Text); this.tbLeaseRoomPrice.Text = price.ToString("N0") + " VND"; }
private void BtnConfirm_Click(object sender, EventArgs e) { switch (this.Tag) { case "AddForm": { if (string.IsNullOrEmpty(this.tbRoomTypePrice.Text) || string.IsNullOrEmpty(this.tbRoomType.Text)) { MessageBox.Show("Các thông tin không được để trống", "THÊM LOẠI PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var roomType = new RoomTypeDTO(); roomType.RoomTypeID = this.tbRoomType.Text; roomType.RoomTypePrice = Convert.ToInt64(this.tbRoomTypePrice.Text.Replace(",", "")); if (RoomTypeBUS.InsertRoomType(roomType)) { MessageBox.Show( "Thêm loại phòng " + roomType.RoomTypeID + " thành công!", "THÊM LOẠI PHÒNG THÀNH CÔNG!", MessageBoxButtons.OK, MessageBoxIcon.Information); var mainForm = (MainForm)Owner; mainForm.ReLoadRoomTypeList(); mainForm.ReLoadFindRoom(); this.Close(); } else { MessageBox.Show( "Loại phòng " + roomType.RoomTypeID + " đã tồn tại!", "THÊM LOẠI PHÒNG THẤT BẠI!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } break; } case "EditForm": { if (string.IsNullOrEmpty(this.tbRoomType.Text)) { MessageBox.Show("Các thông tin không được để trống", "THÊM LOẠI PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var roomType = new RoomTypeDTO(); roomType.RoomTypeID = this.tbRoomType.Text; roomType.RoomTypePrice = Convert.ToInt64(this.tbRoomTypePrice.Text.Replace(",", "")); if (RoomTypeBUS.UpdateRoomType(roomType)) { MessageBox.Show( "Sửa loại phòng " + roomType.RoomTypeID + " thành công!", "SỬA LOẠI PHÒNG THÀNH CÔNG!", MessageBoxButtons.OK, MessageBoxIcon.Information); var mainForm = (MainForm)Owner; mainForm.ReLoadRoomTypeList(); mainForm.ReLoadRoomData(); mainForm.ReLoadAvailableRoom(); mainForm.ReLoadFindRoom(); this.Close(); } else { MessageBox.Show( "Sửa loại phòng " + roomType.RoomTypeID + " thất bại!", "THÊM LOẠI PHÒNG THẤT BẠI!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } break; } } }