public void LoadSchedule(DTO.Booking b) { BookingBUS bBus = new BookingBUS(); GuestBUS gBUS = new GuestBUS(); RoomBUS rBUS = new RoomBUS(); string id = b.BookingID.ToString(); Guest g = gBUS.getGuestByID(b.GuestID); Room r = rBUS.getRoomByID(b.RoomID); RoomType rt = rBUS.getRoomTypeByID(r.RoomType); schedulerControl1.ActiveViewType = DevExpress.XtraScheduler.SchedulerViewType.Month; schedulerControl1.OptionsCustomization.AllowInplaceEditor = DevExpress.XtraScheduler.UsedAppointmentType.None; String roomID = b.RoomID; String name = g.FullName.Trim(); DateTime checkin = b.CheckIn; DateTime checkout = b.CheckOut; Appointment app = schedulerStorage1.CreateAppointment(AppointmentType.Normal); DateTime start = checkin; DateTime end = checkout; app.Start = start; app.End = end; app.AllDay = false; app.LabelKey = 3; app.StatusKey = 1; app.Subject = "Room " + roomID + " - " + name; app.SetId(id); schedulerStorage1.Appointments.Add(app); }
private void btnLuu_Click(object sender, EventArgs e) { PhongDTO infor = LayThongTinPhong(); if (btnThemPhong.Text == "Ngừng") { if (RoomBUS.ThemPhong(infor)) { MessageBox.Show("Bạn đã thêm phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); frmQuanLiPhong_Load(sender, e); KhoiTaoLai(); gcDanhSachPhong.Enabled = true; btnThemPhong.Text = "Thêm phòng"; } else { MessageBox.Show("Lỗi"); } } else if (btnCapNhat.Text == "Ngừng") { if (RoomBUS.SuaThongTinPhong(infor)) { MessageBox.Show("Bạn đã sửa thông tin phòng " + txtMaPhong.Text + " thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); frmQuanLiPhong_Load(sender, e); KhoiTaoLai(); gcDanhSachPhong.Enabled = true; btnCapNhat.Text = "Cập nhật"; } else { MessageBox.Show("Lỗi"); } } }
private void BtnDelRoom_Click(object sender, EventArgs e) { var RoomID = tbListRoomID.Text; var dialogResult = MessageBox.Show( "Bạn có muốn xoá phòng " + RoomID + "?", "XÁC NHẬN XOÁ PHÒNG", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { if (RoomBUS.DeleteRoom(RoomID)) { MessageBox.Show( "Xoá phòng " + RoomID + " thành công!", "XOÁ PHÒNG THÀNH CÔNG", MessageBoxButtons.OK, MessageBoxIcon.Information); this.ReLoadRoomData(); this.ReLoadAvailableRoom(); this.ReLoadFindRoom(); } else { MessageBox.Show( "Không thể xoá phòng đang thuê!", "XOÁ PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void BtnAddLeaseCustomer_Click(object sender, EventArgs e) { if (CustomerTypeBUS.GetCustomerTypeList().Rows.Count > 0) { if (this.dgvLeaseCustomer.Rows.Count == RoomBUS.GetMaxCustomerInRoom()) { MessageBox.Show( "Số khách trong phòng đã đạt mức tối đa!", "THÊM KHÁCH THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var CustomerForm = new CustomerForm(); CustomerForm.Tag = "AddForm"; CustomerForm.ShowDialog(this); } } else { MessageBox.Show( "Chưa có loại khách!", "THÊM KHÁCH THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void ReloadGridViewRoomAndBookingDetail() { this.comboBoxRoomType.SelectedIndex = 0; this.availableRoom = RoomBUS.GetAvailableRooms(this.dateTimePickerBookingStart.Value, this.dateTimePickerBookingEnd.Value); this.roomDTOBindingSource.DataSource = this.availableRoom; this.bookingRoomDetails = new List <BookingDetailDTO>(); this.dgvBookingDetail.DataSource = this.BookingRoomTale(this.bookingRoomDetails); }
public void GetAvailableRoomsTest() { var start = new DateTime(2016, 11, 20); var end = new DateTime(2016, 11, 30); var actual = RoomBUS.GetAvailableRooms(start, end).Count; var expected = 115; Assert.AreEqual(expected, actual); }
private void listView1_Click(object sender, EventArgs e) { lstPhong = new List <PhongDTO>(); lstPhong = RoomBUS.LayMaPhongLoaiPhong(); txtMaPhong.Text = lstPhong[int.Parse(lvPhong.SelectedItems[0].SubItems[0].Text)].MaPhong.ToString(); txtLoaiPhong.Text = lstPhong[int.Parse(lvPhong.SelectedItems[0].SubItems[0].Text)].TenLoaiPhong; txtGhiChu.Text = lstPhong[int.Parse(lvPhong.SelectedItems[0].SubItems[0].Text)].GhiChu; txtDonGia.Text = string.Format("{0:0,0}", lstPhong[int.Parse(lvPhong.SelectedItems[0].SubItems[0].Text)].DonGia); }
private void SuKienLoadForm() { cmbLoaiPhong.DataSource = RoomBUS.LoaiPhong(); lstt = RoomBUS.DanhSachPhong(); for (int i = 0; i < lstt.Count; i++) { lstt[i].DonGia = Convert.ToDecimal(string.Format("{0:0,0}", lstt[i].DonGia)); } gcDanhSachPhong.DataSource = lstt; btnDatPhong.Enabled = false; }
private void metroTile_Delete_Click(object sender, EventArgs e) { if (RoomBUS.DeleteRoom(idRoomCurrent) == true) { MessageBox.Show("Room was deleted !"); Load_Room(); } else { MessageBox.Show("Can't delete this room because it's being used !"); } }
public void getRoomType() { RoomBUS r = new RoomBUS(); RoomType room = new RoomType(); List <Room> list = r.getRoomByRoomType(roomTypeComboBox.Text); foreach (Room Aroom in list) { Console.WriteLine(Aroom.RoomID); roomComboBox.Properties.Items.Add(Aroom.RoomID); } }
private void frmQuanLiPhong_Load(object sender, EventArgs e) { cmbLoaiPhong.DataSource = RoomBUS.LoaiPhong(); ThietLapTextbox(false); ThietLapButton(false); List <PhongDTO> lstt = new List <PhongDTO>(); lstt = RoomBUS.DanhSachPhong(); for (int i = 0; i < lstt.Count; i++) { lstt[i].DonGia = Convert.ToDecimal(string.Format("{0:0,0}", lstt[i].DonGia)); } gcDanhSachPhong.DataSource = lstt; }
private void frmPhieuThuePhong_Load(object sender, EventArgs e) { txtMaPhong.Text = room; txtLoaiPhong.Text = roomtype; cmbLoaiKhachHang.DataSource = CustomerBUS.LayDSLoaiKhach(); cmbLoaiKhachHang.ValueMember = "MaLoaiKhach"; cmbLoaiKhachHang.DisplayMember = "LoaiKhach"; #region List <ParameDTO> lstMaxCus = RoomBUS.SoLuongKhachToiDa(); maxCus = lstMaxCus[0].SLKhachToiDa; #endregion }
private void BtnConfirm_Click(object sender, EventArgs e) { RoomDTO room = new RoomDTO(); room.RoomID = this.tbRoomID.Text; room.RoomTypeID = this.cbRoomType.Text; room.RoomNote = this.rtbRoomNote.Text; room.RoomStatusID = ((KeyValuePair<string, string>)this.cbRoomStatus.SelectedItem).Value; switch (this.Tag) { case "AddForm": { if (RoomBUS.InsertRoom(room)) { MessageBox.Show("Thêm phòng " + room.RoomID + " thành công!", "THÊM PHÒNG THÀNH CÔNG", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Phòng đã tồn tại hoặc tên phòng không được để trống", "THÊM PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } break; } case "EditForm": { if (RoomBUS.UpdateRoom(room)) { MessageBox.Show("Sửa phòng " + room.RoomID + " thành công!", "SỬA PHÒNG THÀNH CÔNG", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Không thể sửa phòng đang thuê", "SỬA PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } break; } } MainForm mainForm = (MainForm)Owner; mainForm.ReLoadRoomData(); mainForm.ReLoadAvailableRoom(); mainForm.ReLoadFindRoom(); }
//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")); } }
// Tab 02: Room Lease public void ReLoadAvailableRoom() { this.cbLeaseRoomID.Items.Clear(); this.deLeaseRoomDate.Text = DateTime.Now.ToString(); var dt = RoomBUS.GetAvailableRoomList(); if (dt.Rows.Count != 0) { foreach (DataRow dr in dt.Rows) { this.cbLeaseRoomID.Items.Add(dr["MaPhong"]); } this.cbLeaseRoomID.SelectedIndex = 0; } }
private void btAddRoom_Click_1(object sender, EventArgs e) { errorProvider1.Clear(); errorProvider2.Clear(); errorProvider3.Clear(); errorProvider4.Clear(); if (txtNameRoom.Text == "") { errorProvider1.SetError(txtNameRoom, "not null!"); } else if (txtKindRoom.Text == "") { errorProvider2.SetError(txtKindRoom, "not null!"); } else if (txtBedsAmount.Text == "") { errorProvider3.SetError(txtBedsAmount, "not null!"); } else if (txtCost.Text == "") { errorProvider4.SetError(txtCost, "not null!"); } else { rmBus = new RoomBUS(); RoomDTO rm = new RoomDTO(); rm.Idr = txtNameRoom.Text; rm.Name = txtNameRoom.Text; rm.Roomkind = txtKindRoom.Text; rm.Status = "Empty"; rm.Bedamount = int.Parse(txtBedsAmount.Text); rm.Cost = Decimal.Parse(txtCost.Text); bool kq = rmBus.add(rm); if (kq == false) { MessageBox.Show("Fail!"); } else { MessageBox.Show("Sussces"); } this.loadData(); } }
private void metroTile_Edit_Click(object sender, EventArgs e) { if (metroTextBox_name.Text == "") { MessageBox.Show("Please input room's name !"); return; } DTO.RoomDTO r = new DTO.RoomDTO(); r.IdRoom = int.Parse(metroTextBox_id.Text); r.Name = metroTextBox_name.Text; if (metroRadioButton_Available.Checked == true) { r.Status = 0; } else if (metroRadioButton_NotAvailable.Checked == true) { r.Status = 1; } else { r.Status = 2; } if (metroRadioButton_roomNormal.Checked == true) { r.Kind_Of_Room = 0; } else { r.Kind_Of_Room = 1; } r.Price = int.Parse(metroTextBox_price.Text); if (RoomBUS.EditRoom(r) == true) { MessageBox.Show("Room was updated !"); Load_Room(); } else { MessageBox.Show("Can't update this room !"); } }
private void SuKienLoadForm() { txtTenKhachHang.Text = ""; txtDiaChi.Text = ""; txtCMND.Text = ""; List <KhachHangDTO> lst = CustomerBUS.LayDSLoaiKhach(); cmbLoaiKhach.Items.Clear(); for (int i = 0; i < (lst.Count); i++) { cmbLoaiKhach.Items.Add(lst[i].LoaiKhach); } cmbPhong.DisplayMember = "MaPhong"; cmbPhong.ValueMember = "MaPhong"; cmbPhong.DataSource = RoomBUS.DanhSachPhongDangDuocThue(); gcDanhSachKhachHang.DataSource = CustomerBUS.DanhSachKhachHang(); }
public void ReLoadRoomData() { this.dgvListRoom.DataSource = RoomBUS.GetRoomList(); if (dgvListRoom.Rows.Count > 0) { this.btnDelRoom.Enabled = this.btnEditRoom.Enabled = true; } else { this.btnDelRoom.Enabled = this.btnEditRoom.Enabled = false; this.tbListRoomID.Text = this.tbListRoomPrice.Text = this.tbListRoomStatus.Text = this.tbListRoomType.Text = this.rtbListRoomNote.Text = null; } }
private void cmbLoaiPhong_SelectedIndexChanged(object sender, EventArgs e) { List <PhongDTO> ldg = RoomBUS.LoadDonGia("A"); List <PhongDTO> ldg1 = RoomBUS.LoadDonGia("B"); List <PhongDTO> ldg2 = RoomBUS.LoadDonGia("C"); if (cmbLoaiPhong.Text == "A") { txtDonGia.Text = string.Format("{0:0,0 VNĐ}", ldg[0].DonGia.Value); } if (cmbLoaiPhong.Text == "B") { txtDonGia.Text = string.Format("{0:0,0 VNĐ}", ldg1[0].DonGia.Value); } if (cmbLoaiPhong.Text == "C") { txtDonGia.Text = string.Format("{0:0,0 VNĐ}", ldg2[0].DonGia.Value); } }
// //---- EVENTS // #region Events private void BtCheckIn_Click(object sender, EventArgs e) { TimeSpan a = dtCheckOut.Value.Subtract(dtCheckIn.Value); decimal x = a.Days + 1; decimal y = Decimal.Parse(lbCost.Text) * x; bllBUS = new BillBUS(); BillDTO bll = new BillDTO(); bll.IDB = lbNameCustomer.Text + "/" + dtCheckIn.Text + "/" + dtCheckOut.Text + "@" + lbNameCustomer.Text; bll.IDC = lbNameCustomer.Text; bll.IDR = lbNameRoom.Text; bll.CheckIn = DateTime.Parse(dtCheckIn.Text); bll.CheckOut = DateTime.Parse(dtCheckOut.Text); bll.COST = Decimal.Parse(lbCost.Text) * x; bool kq = bllBUS.add(bll); if (kq == false) { MessageBox.Show("Fail!"); } else { rmBUS = new RoomBUS(); RoomDTO rm = new RoomDTO(); rm.Idr = lbNameRoom.Text; rm.Status = "Có Khách"; bool kq1 = rmBUS.editStatus(rm); if (kq == false) { MessageBox.Show("Fail!"); } else { MessageBox.Show("Sussces"); } } this.Close(); }
private void btCheckOut_Click_1(object sender, EventArgs e) { srvBUS = new RoomServiceBUS(); RoomServiceDTO srv = new RoomServiceDTO(); srv.IDR = lbNameRoom.Text; bllBus = new BillBUS(); BillDTO bll = new BillDTO(); bll.IDC = lbNameCustomer.Text; bll.IDR = lbNameRoom.Text; bll.CheckIn = DateTime.Parse(lbCheckIn.Text); bll.CheckOut = DateTime.Parse(lbCheckOut.Text); lbCostRoom.Text = bll.COST.ToString(); bll.COST = Decimal.Parse(lbCostRoom.Text); bool kq = bllBus.editCost(bll); if (kq == false) { MessageBox.Show("Fail!"); } else { rmBUS = new RoomBUS(); RoomDTO rm = new RoomDTO(); rm.Idr = lbNameRoom.Text; rm.Status = "Trống"; bool kq1 = rmBUS.editStatus(rm); if (kq == false) { MessageBox.Show("Fail!"); } else { MessageBox.Show("Sussces"); } } this.Close(); }
private void BtnFindRoom_Click(object sender, EventArgs e) { this.dgvFindRoom.DataSource = RoomBUS.FindRoom( ((KeyValuePair <string, string>)cbFindRoomID.SelectedItem).Value, ((KeyValuePair <string, string>)cbFindRoomType.SelectedItem).Value, ((KeyValuePair <string, Int64>)cbFindRoomPrice.SelectedItem).Value, ((KeyValuePair <string, string>)cbFindRoomStatus.SelectedItem).Value); if (this.dgvFindRoom.Rows.Count == 0) { this.tbFindRoomID.Text = this.tbFindRoomType.Text = this.tbFindRoomPrice.Text = this.tbFindRoomStatus.Text = this.rtbFindRoomNote.Text = null; MessageBox.Show("Không tìm thấy phòng phù hợp!", "KHÔNG TÌM THẤY KẾT QUẢ", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void setOverview() { rbus = new RoomBUS(); List <Room> r = rbus.getAllRoom(); foreach (Room aRoom in r) { LoadRoomList(aRoom); } standarList.updateHeight(); superiorList.updateHeight(); deluxeList.updateHeight(); premiumDeluxeList.updateHeight(); familyDeluxeList.updateHeight(); familySuiteList.updateHeight(); standarList.Dock = DockStyle.Top; superiorList.Dock = DockStyle.Top; deluxeList.Dock = DockStyle.Top; premiumDeluxeList.Dock = DockStyle.Top; familyDeluxeList.Dock = DockStyle.Top; familySuiteList.Dock = DockStyle.Top; }
private void btDeleteRoom_Click_1(object sender, EventArgs e) { rmBus = new RoomBUS(); RoomDTO rm = new RoomDTO(); rm.Idr = txtNameRoom.Text; rm.Name = txtNameRoom.Text; rm.Roomkind = txtKindRoom.Text; rm.Status = "Empty"; rm.Bedamount = int.Parse(txtBedsAmount.Text); rm.Cost = Decimal.Parse(txtCost.Text); bool kq = rmBus.delete(rm); if (kq == false) { MessageBox.Show("Fail!"); } else { MessageBox.Show("Sussces"); } this.loadData(); }
private void LayDanhSachPhongTrong() { List <PhongDTO> danhmuclst = new List <PhongDTO>(); danhmuclst = RoomBUS.LayDanhSachLoaiPhong(); for (int i = 0; i < danhmuclst.Count; i++) { string lp = danhmuclst[i].MaLoaiPhong; int num = RoomBUS.LaySLPhongTrongTheoLoai(lp); DirectoryInfo dir; dir = new DirectoryInfo(@"..\..\ICON\" + lp); for (int j = 1; j <= num; j++) { foreach (FileInfo file in dir.GetFiles()) { //imgListRoom.Images.Add(Image.FromFile(file.FullName)); try { imgListRoom.Images.Add(Image.FromFile(file.FullName)); } catch { } } } } for (int j = 0; j < this.imgListRoom.Images.Count; j++) { ListViewItem item = new ListViewItem(); item.ImageIndex = j; string a = Convert.ToString(j); item.Text = a; this.lvPhong.Items.Add(item); } }
private void btnLuuPhieuThue_Click(object sender, EventArgs e) { PhieuThuePhongDTO p = LayThongTinPhong(); ChiTietPhieuThueDTO ct = LayMaKeTiep(); if (RentalBUS.ThemPhieuThuePhong(ct, p)) { for (int i = 0; i < dgvDanhSachPhieuThue.Rows.Count; i++) { CustomerDTO kh = LayThongTinKhachHang(i); if (CustomerBUS.ThemKhachHang(kh)) { if (!RentalBUS.ThemCTPhieuThuePhong(ct, kh)) { MessageBox.Show("Không thêm được chi tiết phiếu thuê", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("Không thêm được thông tin khách hàng" + kh.TenKhachHang + "", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } if (RoomBUS.CapNhatTinhTrangPhong(p)) { MessageBox.Show("Lập phiếu thuê thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ((System.Windows.Forms.Form) this.TopLevelControl).Close(); } else { MessageBox.Show("Không cập nhật được tình trạng phòng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("Không thêm được phiếu thuê", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void btnTimPhongTraGanNhat_Click(object sender, EventArgs e) { List <PhieuThuePhongDTO> pt = new List <PhieuThuePhongDTO>(); pt = RoomBUS.NgayTraPhong(); int k = 0; for (int i = 0; i < pt.Count; i++) { if (DateTime.Today == pt[i].NgayTraPhong) { MessageBox.Show("Phòng trả trong ngày hôm nay(" + DateTime.Today.ToString("d") + "): " + pt[i].MaPhong); } else { k++; } } if (k == pt.Count) { MessageBox.Show("Không có phòng được trả trong ngày hôm nay! "); } gcDanhSachPhong.DataSource = RoomBUS.DanhSachPhongTraGanNhat(); }
private void btnXoaPhong_Click(object sender, EventArgs e) { if (txtMaPhong.Text != "" && txtTinhTrang.Text == "Trống") { PhongDTO infor = LayThongTinPhong(); DialogResult result = (MessageBox.Show("Bạn có muốn xóa phòng " + txtMaPhong.Text + " không?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question)); if (result == DialogResult.Yes) { if (RoomBUS.XoaPhongTrongCTHoaDon(infor)) { if (RoomBUS.XoaPhong(infor)) { MessageBox.Show("Bạn đã xóa phòng " + txtMaPhong.Text + " thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); frmQuanLiPhong_Load(sender, e); KhoiTaoLai(); } } } } if (txtTinhTrang.Text == "Đầy") { MessageBox.Show("Không thể xóa phòng đang được đặt", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void BtnConfirm_Click(object sender, EventArgs e) { if (RoomBUS.UpdateMaxCustomerInRoom(Convert.ToInt16(this.nudMaxCustomers.Value))) { MessageBox.Show( "Chỉnh sửa số khách tối đa trong phòng thành công!\n" + "Lưu ý: Số khách tối đa có thể quy định là " + this.nudMaxCustomers.Maximum.ToString() + " khách!", "CHỈNH SỬA THÀNH CÔNG!", MessageBoxButtons.OK, MessageBoxIcon.Information); var mainForm = (MainForm)Owner; mainForm.ReLoadMaxCustomerInRoom(); this.Close(); } else { MessageBox.Show( "Chỉnh sửa số khách tối đa trong phòng thất bại!", "CHỈNH SỬA THẤT BẠI!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }