private void btnDelRoom_Click(object sender, EventArgs e) { if (KiemTraTrong()) { string maloaiphong = BAL_LoaiPhong.Instance.LoadLoaiPhongTheoTen(cbbMaLoaiPhong.Text).Maloaiphong; string trangthai = BAL_Phong.Instance.LoadRoomSoPhong(txtSoPhong.Text).Trangthaiphong; BEL_Phong Del = new BEL_Phong(txtSoPhong.Text, maloaiphong, trangthai); if (Del.Trangthaiphong != "Yes") { if (BAL_Phong.Instance.DeleteRoom(Del)) { txtSoPhong.Text = ""; flpPhong.Controls.Clear(); LoadRoom(); MessageBox.Show("Đã xoá phòng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Xoá phòng không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Phòng đang sử dụng không thể xoá!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Hãy điền đầy đủ thông tin", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnAddRoom_Click(object sender, EventArgs e) { List <BEL_Phong> room = BAL_Phong.Instance.LoadRoomList(); if (txtSoPhong.Text != "" && cbbMaLoaiPhong.Text != "") { BEL_Phong add = new BEL_Phong(txtSoPhong.Text, BAL_LoaiPhong.Instance.LoadLoaiPhongTheoTen(cbbMaLoaiPhong.Text).Maloaiphong, "No"); bool flag = true; for (int i = 0; i < room.Count; i++) { if (room[i].Sophong == add.Sophong) { flag = false; } } if (flag) { if (BAL_Phong.Instance.InsertRoom(add)) { MessageBox.Show("Đã thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } flpPhong.Controls.Clear(); LoadRoom(); } else { MessageBox.Show("Phòng đã có!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Hãy điền đầy đủ thông tin", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void cbbTPSoPhong_SelectedValueChanged(object sender, EventArgs e) { try { string sophong = cbbTPSoPhong.Text; BEL_DatPhong dp = BAL_DatPhong.Instance.LoadDatPhongTheoSoPhong(sophong); BEL_KhachHang kh = BAL_KhachHang.Instance.LoadKhachHangTheoMa(dp.MaKH); BEL_Phong Phong = BAL_Phong.Instance.LoadRoomSoPhong(sophong); BEL_LoaiPhong loaiphong = BAL_LoaiPhong.Instance.LoadLoaiPhongTheoMa(Phong.Maloaiphong); txtTPHoTen.Text = kh.Hotenkh; TimeTPNgaySinh.Value = kh.Ngaysinh; if (kh.Gioitinh == "Nam") { radTPNam.Checked = true; } else { radTPNu.Checked = true; } txtTPSDT.Text = kh.Sdt; txtTPDiaChi.Text = kh.Diachi; txtTPQuocTich.Text = kh.Quoctich; txtTPCMND.Text = kh.Cmnd; TimeTPNgayDat.Value = dp.NgayDatPhong; DateTime dt = TimeTPNgayTra.Value; TimeSpan t = dt.Subtract(dp.NgayDatPhong); double day = t.TotalDays; txtTPThanhTien.Text = (Math.Round(day) * loaiphong.Giaphong).ToString(); } catch { } }
private void btnUpRoom_Click(object sender, EventArgs e) { List <BEL_Phong> room = BAL_Phong.Instance.LoadRoomList(); if (txtSoPhong.Text != "" && cbbMaLoaiPhong.Text != "") { BEL_Phong add = new BEL_Phong(txtSoPhong.Text, cbbMaLoaiPhong.Text, null); bool flag = false; for (int i = 0; i < room.Count; i++) { if (room[i].Sophong == add.Sophong) { flag = true; } } if (flag) { BAL_Phong.Instance.UpdateRoom(add); flpPhong.Controls.Clear(); LoadRoom(); } else { MessageBox.Show("Không tìm thấy phòng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Hãy điền đầy đủ thông tin", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public int DeleteRoom(BEL_Phong room) { string sql = "UPDATE dbo.Phong SET TrangThai = 'No' WHERE SoPhong = @sophong"; int result = DataProvider.Instance.ExecuteNonQuery(sql, new object[] { room.Sophong }); return(result); }
public int UpdateRoom(BEL_Phong room) { string sql = "UPDATE dbo.Phong SET MaLoaiPhong = @maloaiphong WHERE SoPhong = @sophong"; int result = DataProvider.Instance.ExecuteNonQuery(sql, new object[] { room.Maloaiphong, room.Sophong }); return(result); }
public int InsertRoom(BEL_Phong room) { string sql = "INSERT INTO [dbo].[Phong] VALUES( @SoPhong , @MaLoaiPhong , @TrangThaiPhong , @trangthai )"; int result = DataProvider.Instance.ExecuteNonQuery(sql, new object[] { room.Sophong, room.Maloaiphong, "No", "Yes" }); return(result); }
public BEL_Phong LoadRoomSoPhong(string sophong) { BEL_Phong phong = null; DataTable data = DAL_Phong.Instance.LoadRoomSoPhong(sophong); foreach (DataRow item in data.Rows) { phong = new BEL_Phong(item); } return(phong); }
public List <BEL_Phong> LoadRoomTrangThai(string trangthai) { List <BEL_Phong> roomlist = new List <BEL_Phong>(); DataTable data = DAL_Phong.Instance.LoadRoomTrangThai(trangthai); foreach (DataRow item in data.Rows) { BEL_Phong phong = new BEL_Phong(item); roomlist.Add(phong); } return(roomlist); }
public bool DeleteRoom(BEL_Phong room) { int result = DAL_Phong.Instance.DeleteRoom(room); return(result > 0); }
public bool InsertRoom(BEL_Phong room) { int result = DAL_Phong.Instance.InsertRoom(room); return(result > 0); }