public void tienPhuThu() { ChiTietThuePhongBUS cttpbus = new ChiTietThuePhongBUS(); PhongBUS pbus = new PhongBUS(); eHoaDonTienPhong pt = new eHoaDonTienPhong(); if (cttpbus.getCTTP_By_MaPhong_TrangThai(pbus.maPhong_byTen(TenPhong), false).GhiChu == null) { phuthu = pt.tinhTienPhuThu(cttpbus.getCTTP_By_MaPhong_TrangThai(pbus.maPhong_byTen(TenPhong), false), tienPhong(pbus.getLoaiPhong_ByID(pbus.maPhong_byTen(TenPhong)))); } else { phuthu = pt.tinhTienPhuThu(cttpbus.getCTTP_By_MaPhong_TrangThai(pbus.maPhong_byTen(TenPhong), false), tienPhong(pbus.getLoaiPhong_ByID(pbus.maPhong_byTen(cttpbus.getCTTP_By_MaPhong_TrangThai(pbus.maPhong_byTen(TenPhong), false).GhiChu.Substring(0, 8))))); } txtPhuThu.Text = string.Format("{0:#,##0}", phuthu).ToString(); }
private void btnIn_Click(object sender, EventArgs e) { HoaDon bc = new HoaDon(); List <eKhachHang> listkh = new List <eKhachHang>(); ChiTietThuePhongBUS cttpbus = new ChiTietThuePhongBUS(); PhongBUS pbus = new PhongBUS(); for (int i = 0; i < gridViewLuongKhach.RowCount; i++) { eKhachHang kh = new eKhachHang(); kh.SoPhong = gridViewLuongKhach.GetRowCellValue(i, gridViewLuongKhach.Columns[0]).ToString(); kh.TenKH = gridViewLuongKhach.GetRowCellValue(i, gridViewLuongKhach.Columns[1]).ToString(); kh.SoCMND = gridViewLuongKhach.GetRowCellValue(i, gridViewLuongKhach.Columns[2]).ToString(); kh.SoDT = gridViewLuongKhach.GetRowCellValue(i, gridViewLuongKhach.Columns[3]).ToString(); string tgian = cttpbus.getCTTP_By_MaPhong_TrangThai(pbus.maPhong_byTen(kh.SoPhong), false).GioVao + " " + cttpbus.getCTTP_By_MaPhong_TrangThai(pbus.maPhong_byTen(kh.SoPhong), false).NgayVao.ToShortDateString(); kh.ThoiGianNhanPhong = tgian; listkh.Add(kh); } bc.thoiGianInHD = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString(); frmPrint frmInBCDV = new frmPrint(); frmInBCDV.InBaoCaoInLuongKhachTuReport(bc, listkh.ToList()); frmInBCDV.ShowDialog(); this.Close(); }
private void cboPhongTrong_SelectedIndexChanged(object sender, EventArgs e) { LoaiPhongBUS lpbus = new LoaiPhongBUS(); PhongBUS pbus = new PhongBUS(); ChiTietThuePhongBUS cttpbus = new ChiTietThuePhongBUS(); eChiTietThuePhong cttp = new eChiTietThuePhong(); eHoaDonTienPhong hdtp = new eHoaDonTienPhong(); cttp = cttpbus.getCTTP_By_MaPhong_TrangThai(pbus.maPhong_byTen(TenPhong), false); double tienPhongCu = hdtp.tinhTienPhong(cttp, lpbus.donGia(pbus.getLoaiPhong_ByID(pbus.maPhong_byTen(TenPhong))), Convert.ToDateTime(cttp.GioVao + " " + cttp.NgayVao.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString())); double tienPhongMoi = hdtp.tinhTienPhong(cttp, lpbus.donGia(pbus.getLoaiPhong_ByID(pbus.maPhong_byTen(cboPhongTrong.Text.Trim()))), Convert.ToDateTime(cttp.GioVao + " " + cttp.NgayVao.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString())); tienkhac = tienPhongCu - tienPhongMoi + cttp.TienKhac; lblTienKhac.Text = (string.Format("{0:#,##0 vnd}", tienkhac).ToString()); }
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; } }