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 btnKHThem_Click(object sender, EventArgs e) { if (KiemTraTrong()) { string gioitinh = null; if (radKHNam.Checked == true) { gioitinh = "Nam"; } else { gioitinh = "Nu"; } BEL_KhachHang kh = new BEL_KhachHang(txtMaKH.Text, txtHoTenKH.Text, gioitinh, txtSDTKH.Text, PkNgaySinhKH.Value, txtDiaChiKH.Text, txtQuocTichKH.Text, txtKHCMND.Text); if (BAL_KhachHang.Instance.InsertCustomer(kh)) { LoadKhachHang(); MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Hãy điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public int InsertCustomer(BEL_KhachHang kh) { string sql = "INSERT INTO dbo.KhachHang " + " VALUES( @MaKH , @HoTenKH , @GioiTinh , @SDT , @NgaySinh , @DiaChi , @QuocTich , @cmnd , @trangthai )"; int result = DataProvider.Instance.ExecuteNonQuery(sql, new object[] { kh.MaKH, kh.Hotenkh, kh.Gioitinh, kh.Sdt, kh.Ngaysinh, kh.Diachi, kh.Quoctich, kh.Cmnd, "Yes" }); return(result); }
public int UpCustomer(BEL_KhachHang kh) { string sql = " UPDATE [dbo].[KhachHang] " + " SET HoTenKH = @HoTenKH , GioiTinh = @GioiTinh , SDT = @SDT , NgaySinh = @NgaySinh , DiaChi = @DiaChi , QuocTich = @QuocTich , CMND = @cmnd " + " WHERE MaKH = @MaKH "; int result = DataProvider.Instance.ExecuteNonQuery(sql, new object[] { kh.Hotenkh, kh.Gioitinh, kh.Sdt, kh.Ngaysinh, kh.Diachi, kh.Quoctich, kh.Cmnd, kh.MaKH }); return(result); }
public rpHoaDon(string makh, string sophong, BEL_DatPhong dp, BEL_KhachHang kh, BEL_TraPhong tp, BEL_HoaDonThue hd) { InitializeComponent(); this.makh = makh; this.sophong = sophong; this.dp = dp; this.kh = kh; this.tp = tp; this.hd = hd; }
public BEL_KhachHang LoadKhachHangTheoMa(string Makh) { BEL_KhachHang list = null; DataTable data = DAL_KhachHang.Instance.LoadKhachHangTheoMa(Makh); foreach (DataRow row in data.Rows) { list = new BEL_KhachHang(row); } return(list); }
public List <BEL_KhachHang> LoadListKhachHang() { List <BEL_KhachHang> list = new List <BEL_KhachHang>(); DataTable data = DAL_KhachHang.Instance.LoadListKhachHang(); foreach (DataRow row in data.Rows) { BEL_KhachHang item = new BEL_KhachHang(row); list.Add(item); } return(list); }
private void btnDPLuu_Click(object sender, EventArgs e) { if (KiemTraTrongDP()) { string GioiTinh; if (radDPNam.Checked == true) { GioiTinh = "Nam"; } else { GioiTinh = "Nu"; } BEL_KhachHang kh = new BEL_KhachHang(txtDPMaKH.Text, txtDPHoTenKH.Text, GioiTinh, txtSDTDP.Text, TimeDPNgaySinh.Value, txtDPDiaChi.Text, txtDPQuocTich.Text, txtDPCMND.Text); BEL_DatPhong dp = new BEL_DatPhong(txtDPMaDP.Text, txtDPMaKH.Text, cbDPSoPhong.Text, TimeDPNgayDat.Value); BEL_HoaDonThue hd = new BEL_HoaDonThue("NULL", Manv, dp.MaDatPhong, "NULL", kh.MaKH, DateTime.Now, float.Parse(txtDPTienCoc.Text), 0, "Yes"); if (BAL_KhachHang.Instance.LoadKhachHangTheoMa(kh.MaKH) == null) { if (BAL_DatPhong.Instance.LoadDatPhongTheoMa(dp.MaDatPhong) == null) { if (BAL_KhachHang.Instance.InsertCustomer(kh)) { if (BAL_DatPhong.Instance.AddDatPhong(dp)) { MessageBox.Show("Đặt phòng thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); BAL_HoaDonThue.Instance.AddHoaDon(hd, kh.MaKH, dp.SoPhong); BAL_Phong.Instance.UpdateRoomTrangThai(cbDPSoPhong.Text, "Yes"); XoaTrongDP(); BAL_HoaDonThue.Instance.AddChiTiet(BAL_HoaDonThue.Instance.LoadHDThueTheoMaDP(dp.MaDatPhong).Mahd, dp.SoPhong); } } else { MessageBox.Show("Đặt phòng thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Mã đặt phòng trùng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Mã khách hàng trùng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Hãy điền đầy đủ thông tin", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public List <BEL_KhachHang> SeachCus(string tennv) { List <BEL_KhachHang> list = new List <BEL_KhachHang>(); DataTable data = DAL_KhachHang.Instance.SeachCus(tennv); if (data.Rows.Count > 0) { foreach (DataRow row in data.Rows) { BEL_KhachHang item = new BEL_KhachHang(row); list.Add(item); } } return(list); }
public bool UpCustomer(BEL_KhachHang kh) { int result = DAL_KhachHang.Instance.UpCustomer(kh); return(result > 0); }
private void btnTPXuat_Click(object sender, EventArgs e) { if (cbbTPSoPhong.Text != "" && txtTPMaTP.Text != "") { if (BAL_TraPhong.Instansce.KiemTraTonTai(txtTPMaTP.Text) == false) { string sophong = cbbTPSoPhong.Text; BEL_DatPhong dp = BAL_DatPhong.Instance.LoadDatPhongTheoSoPhong(sophong); BEL_KhachHang kh = BAL_KhachHang.Instance.LoadKhachHangTheoMa(dp.MaKH); BEL_TraPhong tp = new BEL_TraPhong(txtTPMaTP.Text, kh.MaKH, dp.SoPhong, DateTime.Now); BEL_HoaDonThue hd = BAL_HoaDonThue.Instance.LoadHDThueTheoMaDP(dp.MaDatPhong); BEL_HoaDonDichVu dv = BAL_HoaDonDichVu.Instance.LayHoaDonTheoMaKH(kh.MaKH); if (dv != null) { if (txtTPThanhTien.Text == "0") { hd.Tongtien = (float.Parse(txtTPThanhTien.Text)) + float.Parse(dv.Thanhtien); } else { if (float.Parse(txtTPThanhTien.Text) < hd.Tiencoc) { hd.Tongtien = (hd.Tiencoc - float.Parse(txtTPThanhTien.Text)) + float.Parse(dv.Thanhtien); } else { hd.Tongtien = (float.Parse(txtTPThanhTien.Text) - hd.Tiencoc) + float.Parse(dv.Thanhtien); } } } else { if (txtTPThanhTien.Text == "0") { hd.Tongtien = (float.Parse(txtTPThanhTien.Text)); } else { if (float.Parse(txtTPThanhTien.Text) < hd.Tiencoc) { hd.Tongtien = (hd.Tiencoc - float.Parse(txtTPThanhTien.Text)); } else { hd.Tongtien = (float.Parse(txtTPThanhTien.Text) - hd.Tiencoc); } } } hd.Matraphong = txtTPMaTP.Text; rpHoaDon rp = new rpHoaDon(dp.MaKH, sophong, dp, kh, tp, hd); rp.ShowDialog(); } else { MessageBox.Show("Trùng mã đặt phòng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Hãy điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }