public void lblred_MouseHover(object sender, EventArgs e) { PhongBUS pbus = new PhongBUS(); ChiTietThuePhongBUS cttpbus = new ChiTietThuePhongBUS(); ThuePhongBUS tpbus = new ThuePhongBUS(); KhachHangBUS khbus = new KhachHangBUS(); Label lbl = sender as Label; string ttPhong = lbl.Text; string[] lsPhong = ttPhong.Split('\r'); string mathue = cttpbus.getMaThue_By_MaPhong_TrangThai(pbus.maPhong_byTen(lsPhong[0].Trim()), false); string ttThuePhong = ""; int stt = 0; foreach (var item in cttpbus.getChiTietThuePhong_By_MaThue_MaPhong(mathue, pbus.maPhong_byTen(lsPhong[0].Trim()))) { stt++; ttThuePhong += "Khách hàng " + stt + " : " + khbus.getenKH_ByID(item.MaKhach) + "\n"; } foreach (var item in cttpbus.getChiTietThuePhong_By_MaThue_MaPhong(mathue, pbus.maPhong_byTen(lsPhong[0].Trim()))) { if (item.NgayRa < DateTime.Now.Date) { ttThuePhong += "Ngày ra: " + DateTime.Now.Date.ToShortDateString(); } else { ttThuePhong += "Ngày ra: " + item.NgayRa.ToShortDateString(); } break; } toolTipTTThuePhong.SetToolTip(lbl, ttThuePhong); }
public void tinhTienPhong() { TimeSpan nhan6h = new TimeSpan(6, 0, 0); TimeSpan nhan13h = new TimeSpan(13, 0, 0); TimeSpan nhan14h = new TimeSpan(14, 0, 0); PhongBUS pbus = new PhongBUS(); eHoaDonTienPhong hdtp = new eHoaDonTienPhong(); ChiTietThuePhongBUS cttpbus = new ChiTietThuePhongBUS(); foreach (var item in cttpbus.getChiTietThuePhong_By_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong))) { lblNhanPhong.Text = item.GioVao + " " + item.NgayVao.ToShortDateString(); string gioMacDinh = nhan14h + " " + item.NgayVao.ToShortDateString(); lblTraPhong.Text = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString(); TimeSpan date = Convert.ToDateTime(lblTraPhong.Text) - Convert.ToDateTime(lblNhanPhong.Text); int ngay = date.Days; int h = date.Hours; if (item.NgayVao == DateTime.Now.Date) { tienphong = hdtp.tinhTienPhong(item, tienPhong(pbus.getLoaiPhong_ByID(item.MaPhong)), Convert.ToDateTime(lblNhanPhong.Text), Convert.ToDateTime(lblTraPhong.Text)); txtTienPhong.Text = (string.Format("{0:#,##0}", tienphong)).ToString(); } else { tienphong = hdtp.tinhTienPhong(item, tienPhong(pbus.getLoaiPhong_ByID(item.MaPhong)), Convert.ToDateTime(gioMacDinh), Convert.ToDateTime(lblTraPhong.Text)); txtTienPhong.Text = (string.Format("{0:#,##0}", tienphong)).ToString(); } if (ngay == 0 && h < 5) { lblGhiChu.Text = item.GhiChu + "\n" + "\nSố tiền phòng: " + item.GioVao + " " + item.NgayVao.ToShortDateString() + "đến " + lblTraPhong.Text + " là " + string.Format("{0:#,##0}", tienphong).ToString() + " đồng"; phuthu = 0; txtPhuThu.Text = string.Format("{0:#,##0}", phuthu).ToString(); } else { if (item.GioVao > nhan6h && item.GioVao < nhan13h) { lblGhiChu.Text = item.GhiChu + "\n" + "Số tiền khách đến sớm: " + item.GioVao + " " + item.NgayVao.ToShortDateString() + "đến " + nhan14h + " " + item.NgayVao.ToShortDateString() + "là " + string.Format("{0:#,##0}", phuthu).ToString() + " đồng" + "\nSố tiền phòng: " + nhan14h + " " + item.NgayVao.ToShortDateString() + "đến " + lblTraPhong.Text + " là " + string.Format("{0:#,##0}", tienphong).ToString() + " đồng"; } else { lblGhiChu.Text = item.GhiChu + "\n" + "\nSố tiền phòng: " + item.GioVao + " " + item.NgayVao.ToShortDateString() + " đến " + lblTraPhong.Text + " là " + string.Format("{0:#,##0}", tienphong).ToString() + " đồng"; } } tienkhac += item.TienKhac; txtTienKhac.Text = string.Format("{0:#,##0}", tienkhac).ToString(); } }
public void loadKhachHang() { PhongBUS pbus = new PhongBUS(); ChiTietThuePhongBUS cttpbus = new ChiTietThuePhongBUS(); foreach (var item in cttpbus.getChiTietThuePhong_By_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong))) { eKhachHang kh = new eKhachHang(); kh = khbus.getmaKH(item.MaKhach); txtHoTen.Text = kh.TenKH; txtCMND.Text = kh.SoCMND; txtSDT.Text = kh.SoDT; if (kh.GioiTinh) { radNam.Checked = true; } else { radNu.Checked = true; } } }
private void btnLuu_Click(object sender, EventArgs e) { if (Convert.ToInt32(txtGiamTru.Text) > 10 && Convert.ToInt32(txtGiamTru.Text) < 0) { MessageBox.Show("Mức giảm giá phải nhỏ hơn 10%"); txtGiamTru.Focus(); return; } if (txtKhachThanhToan.Text.Equals("")) { MessageBox.Show("Xin hãy nhập số tiền khách thanh toán"); return; } TimeSpan gioHienTai = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); HoaDonTienPhongBUS hdtpbus = new HoaDonTienPhongBUS(); ThuePhongBUS tpbus = new ThuePhongBUS(); ChiTietThuePhongBUS cttpbus = new ChiTietThuePhongBUS(); HoaDonDichVuBUS hddvbus = new HoaDonDichVuBUS(); PhongBUS pbus = new PhongBUS(); int a = 0; int b = 0; if (cttpbus.getChiTietThuePhong_By_MaThue(MaThue).Count < 2) { eHoaDonTienPhong tt_ent = new eHoaDonTienPhong(); tt_ent.MaThue = lblMaThue.Text.Trim(); tt_ent.NgayLap = DateTime.Now; tt_ent.GioLap = gioHienTai; tt_ent.ThueVAT = Convert.ToSingle(10 / 10); tt_ent.KhuyenMai = Convert.ToSingle((Convert.ToSingle(txtGiamTru.Text) * tienphong)); a = hdtpbus.insertThanhToan(tt_ent); } if (tpbus.getMaDoan_ByMaThue(MaThue) != null || ctdvbus.getctdv_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong)).Count != 0) { b++; } /* Với a = 1 thanh toán khách lẻ * Với b = 1 thanh toán khách đoàn */ //Update lại trạng thái phòng ePhong phong = new ePhong(); phong.MaPhong = pbus.maPhong_byTen(TenPhong); phong.TinhTrang = false; pbus.updateTinhTrangPhong(phong); //Update lại trạng thái chi tiết thuê phòng eChiTietThuePhong cttp = new eChiTietThuePhong(); foreach (var item in cttpbus.getChiTietThuePhong_By_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong))) { cttp.MaThue = MaThue; cttp.MaKhach = item.MaKhach; cttp.MaPhong = item.MaPhong; cttp.TrangThai = true; cttpbus.updateTrangThaiChiTietThuePhong(cttp); } //update lại thông tin thuê phòng eThuePhong tp = new eThuePhong(); tp.MaThue = MaThue; tp.TrangThai = true; tpbus.updateThuePhong(tp); if (a == 1) { MessageBox.Show("Đã thanh toán thành công"); KhachHangBUS khbus = new KhachHangBUS(); NhanVienBUS nvbus = new NhanVienBUS(); LoaiPhongBUS lpbus = new LoaiPhongBUS(); HoaDon bc = new HoaDon(); List <eChiTietBaoCao> listphong = new List <eChiTietBaoCao>(); foreach (var item in cttpbus.getChiTietThuePhong_By_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong))) { eChiTietBaoCao ctbc = new eChiTietBaoCao(); ctbc.tenPhong = pbus.getTenPhong_ByID(item.MaPhong); ctbc.tenLoaiPhong = lpbus.getTen_Byma(pbus.getLoaiPhong_ByID(item.MaPhong)); ctbc.thoiGianNhan = item.GioVao + " " + item.NgayVao.Date.ToShortDateString(); ctbc.thoiGianTra = item.GioRa + " " + item.NgayRa.Date.ToShortDateString(); ctbc.tienPhong = tienvat + tienphong + tiendv + Convert.ToDouble(phuthu); listphong.Add(ctbc); break; } if (cttpbus.getChiTietThuePhong_By_MaThue(MaThue).Count < 2) { foreach (var item in cttpbus.getChiTietThuePhong_By_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong))) { bc.tenNV = nvbus.getenNV_ByID(maNVThanhToan); bc.tenKH = khbus.getenKH_ByID(item.MaKhach); bc.soHD = hdtpbus.gemaHD_BymaThue(MaThue); //Cần xem xét lại bc.thoiGianInHD = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString(); } } this.Close(); frmPrint frmp = new frmPrint(); frmp.InHoaDonInTuReport(bc, listphong.ToList()); frmp.ShowDialog(); } if (b == 1) { List <eCTDV> lsctdv = new List <eCTDV>(); DichVuBUS dvbus = new DichVuBUS(); KhachHangBUS khbus = new KhachHangBUS(); NhanVienBUS nvbus = new NhanVienBUS(); LoaiPhongBUS lpbus = new LoaiPhongBUS(); HoaDon bc = new HoaDon(); if (ctdvbus.getctdv_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong)) != null) { foreach (var item in ctdvbus.getctdv_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong))) { eHoaDonDichVu hddv = new eHoaDonDichVu(); hddv.MaHDDV = (DateTime.Now.Day).ToString() + (DateTime.Now.Month).ToString() + (DateTime.Now.Year).ToString() + item.MaThue + item.MaKhach + item.MaPhong; hddv.MaThue = MaThue; hddv.NgayLap = DateTime.Now.Date; hddv.GioLap = gioHienTai; hddv.MaKH = item.MaKhach; hddv.MaPhong = item.MaPhong; hddvbus.insertThanhToanDV(hddv); break; } } foreach (var item in ctdvbus.getctdv_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong))) { eCTDV ctdv = new eCTDV(); ctdv.TenDV = dvbus.getTenDV_byID(item.MaDV); ctdv.SoLuong = item.SoLuong; ctdv.DonGia = dvbus.getDonGia_byID(item.MaDV); lsctdv.Add(ctdv); } foreach (var item in cttpbus.getChiTietThuePhong_By_MaThue_MaPhong(MaThue, pbus.maPhong_byTen(TenPhong))) { if (item.MaPhong.Equals(pbus.maPhong_byTen(TenPhong))) { bc.tenNV = nvbus.getenNV_ByID(maNVThanhToan); bc.tenKH = khbus.getenKH_ByID(item.MaKhach); bc.soHD = hddvbus.gemaHD_BymaThue_maPhong(MaThue, item.MaPhong); bc.thoiGianInHD = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString(); bc.tenPhong = pbus.getTenPhong_ByID(item.MaPhong); } } frmPrint frmInDV = new frmPrint(); frmInDV.InHoaDonInDichVuTuReport(bc, lsctdv.ToList()); frmInDV.ShowDialog(); this.Close(); } }
private void btnLuu_Click(object sender, EventArgs e) { ThuePhongBUS tpbus = new ThuePhongBUS(); ChiTietThuePhongBUS cttpbus = new ChiTietThuePhongBUS(); ChiTietDichVuBUS ctdvbus = new ChiTietDichVuBUS(); PhongBUS pbus = new PhongBUS(); int s = 0; foreach (eThuePhong item in tpbus.getMaThue(maThue)) { eThuePhong etp = new eThuePhong(); etp.MaNV = item.MaNV; etp.MaDoan = item.MaDoan; etp.SoLuongPhong = item.SoLuongPhong; etp.TrangThai = false; s = tpbus.insertThuePhong(etp); } if (s != 1) { return; } if (s == 1) { foreach (eChiTietThuePhong item in cttpbus.getChiTietThuePhong_By_MaThue_MaPhong(maThue, pbus.maPhong_byTen(TenPhong))) { eChiTietThuePhong ect = new eChiTietThuePhong(); ect.GioRa = item.GioRa; ect.GioVao = item.GioVao; ect.MaKhach = item.MaKhach; ect.MaPhong = cboPhongTrong.SelectedValue.ToString(); ect.NgayRa = item.NgayRa; ect.NgayVao = item.NgayVao; ect.TienKhac = tienkhac; ect.MaThue = tpbus.getMaThueCuoi(); ect.TrangThai = false; ect.GhiChu = cttpbus.getCTTP_By_MaPhong_TrangThai(pbus.maPhong_byTen(TenPhong), false).GhiChu + lblTenPhong.Text + " (" + item.GioVao + " " + item.NgayVao.ToShortDateString() + ")" + " đến " + cboPhongTrong.Text + " (" + DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString() + ")"; cttpbus.insertCTTP(ect); } foreach (eChiTietThuePhong item in cttpbus.getChiTietThuePhong_By_MaThue_TrangThai(maThue, 0)) { if (!item.MaPhong.Equals(pbus.maPhong_byTen(TenPhong))) { eChiTietThuePhong ect = new eChiTietThuePhong(); ect.GioRa = item.GioRa; ect.GioVao = item.GioVao; ect.MaKhach = item.MaKhach; ect.MaPhong = item.MaPhong; ect.NgayRa = item.NgayRa; ect.NgayVao = item.NgayVao; ect.MaThue = tpbus.getMaThueCuoi(); ect.TrangThai = false; cttpbus.insertCTTP(ect); } } foreach (eChiTietThuePhong item in cttpbus.getChiTietThuePhong_By_MaThue_TrangThai(maThue, 1)) { eChiTietThuePhong ect = new eChiTietThuePhong(); ect.GioRa = item.GioRa; ect.GioVao = item.GioVao; ect.MaKhach = item.MaKhach; ect.MaPhong = item.MaPhong; ect.NgayRa = item.NgayRa; ect.NgayVao = item.NgayVao; ect.MaThue = tpbus.getMaThueCuoi(); ect.TrangThai = true; cttpbus.insertCTTP(ect); } foreach (eChiTetDichVu item in ctdvbus.getctdv_byMaThue(maThue)) { eChiTetDichVu ctdv = new eChiTetDichVu(); ctdv.MaThue = tpbus.getMaThueCuoi(); ctdv.MaPhong = cboPhongTrong.SelectedValue.ToString(); ctdv.MaKhach = item.MaKhach; ctdv.MaDV = item.MaDV; ctdv.SoLuong = item.SoLuong; ctdvbus.insertCTDV(ctdv); } foreach (var item in cttpbus.getChiTietThuePhong_By_MaThue(maThue)) { if (item.MaPhong.Equals(pbus.maPhong_byTen(TenPhong))) { eChiTietThuePhong ectOld = new eChiTietThuePhong(); ectOld.MaThue = maThue; ectOld.MaPhong = item.MaPhong; //ectOld.MaKhach = cttpbus.getMaKhach_By_MaPhong_TrangThai(ectOld.MaPhong, false); ectOld.MaKhach = item.MaKhach; ectOld.TrangThai = true; ectOld.GhiChu = "Đổi phòng"; cttpbus.updateTrangThaiChiTietThuePhong(ectOld); } else { eChiTietThuePhong ectOld = new eChiTietThuePhong(); ectOld.MaThue = maThue; ectOld.MaPhong = item.MaPhong; ectOld.MaKhach = item.MaKhach; ectOld.TrangThai = true; ectOld.GhiChu = null; cttpbus.updateTrangThaiChiTietThuePhong(ectOld); } } eThuePhong tp = new eThuePhong(); tp.MaThue = maThue; tp.TrangThai = true; tpbus.updateThuePhong(tp); ePhong ep = new ePhong(); ep.MaPhong = pbus.maPhong_byTen(TenPhong); ep.TinhTrang = false; pbus.updateTinhTrangPhong(ep); ePhong newp = new ePhong(); newp.MaPhong = cboPhongTrong.SelectedValue.ToString(); newp.TinhTrang = true; newp.SoNgHienTai = pbus.getEPhong_byID(pbus.maPhong_byTen(TenPhong)).SoNgHienTai; pbus.updateTinhTrangPhong(newp); MessageBox.Show("Thành công"); this.Close(); } else { MessageBox.Show("Không thành công"); return; } }