private void show_Phong() { lsvPhong.Items.Clear(); tienphong = 0; ptpBUS = new PhieuThuePhongBUS(); PhieuThuePhongDTO ptp = ptpBUS.getPhieuThuePhongByID(cmbMaPT.Text); pdpBUS = new PhieuDatPhongBUS(); PhieuDatPhongDTO pdp = pdpBUS.getPhieuDatPhongByID(ptp.Maphieudat); ctdpBUS = new ChiTietDatPhongBUS(); IList <ChiTietDatPhongDTO> list = ctdpBUS.getChiTietDatPhongByID(pdp.Maphieudat); pBUS = new PhongBUS(); lpBUS = new LoaiPhongBUS(); foreach (ChiTietDatPhongDTO ctdp in list) { int i = lsvPhong.Items.Count; PhongDTO p = pBUS.getPhongByID(ctdp.Maphong); LoaiPhongDTO lp = lpBUS.getLoaiPhongByID(p.Maloai); lsvPhong.Items.Add(ctdp.Maphong); lsvPhong.Items[i].SubItems.Add(lp.Gia.ToString("0,0")); lsvPhong.Items[i].SubItems.Add(pdp.Ngayden.ToShortDateString()); lsvPhong.Items[i].SubItems.Add(pdp.Ngaydi.ToShortDateString()); TimeSpan sno = pdp.Ngaydi.Date.AddDays(1) - pdp.Ngayden.Date; lsvPhong.Items[i].SubItems.Add(sno.Days.ToString()); decimal tp = lp.Gia * sno.Days; lsvPhong.Items[i].SubItems.Add(tp.ToString("0,0")); tienphong += tp; } labTP.Text = tienphong.ToString("0,0"); }
private void Hienthithongtinthuephong(int maPhieuthue) { PhieuThuePhongDTO phieuThuePhongDTO = new PhieuThuePhongDTO(); PhieuThuePhongBUS phieuThuePhongBUS = new PhieuThuePhongBUS(); phieuThuePhongDTO = phieuThuePhongBUS.LayPhieuthuephongTheoma(maPhieuthuephong); maP = phieuThuePhongDTO.MaPhong; PhongDTO phongDTO = new PhongDTO(); PhongBUS phongBUS = new PhongBUS(); phongDTO = phongBUS.LayPhongTheoMaSo(phieuThuePhongDTO.MaPhong); HienthiComboboxLoaiGia(); HienthiKhachhang(phieuThuePhongDTO.MaKhachHang); lbTenPhong.Text = phongDTO.Ten; lbTang.Text = phongDTO.Tang.ToString(); dtpkGioBD.Value = phieuThuePhongDTO.ThoiGianNhanPhong; dtpkGioKT.Value = phieuThuePhongDTO.ThoiGianTraPhong; dtpkNgayBD.Value = phieuThuePhongDTO.ThoiGianNhanPhong; dtpkNgayKT.Value = phieuThuePhongDTO.ThoiGianTraPhong; cbmLoaiDangKy.SelectedValue = phieuThuePhongDTO.MaLoaiThuePhong; lbLoaiPhong.Text = phongBUS.LayLoaiPhong(phongDTO.MaLoaiPhong); HienthiGiaPhong(int.Parse(cbmLoaiDangKy.SelectedValue.ToString()), phongDTO.MaLoaiPhong); HienthiThoiGian(); }
private void show_DV() { lsvDV.Items.Clear(); tiendichvu = 0; ptpBUS = new PhieuThuePhongBUS(); PhieuThuePhongDTO ptp = ptpBUS.getPhieuThuePhongByID(cmbMaPT.Text); cttpBUS = new ChiTietThuePhongBUS(); IList <ChiTietThuePhongDTO> listcttp = cttpBUS.getChiTietThuePhongByID(ptp.Maphieuthue); dvBUS = new DichVuBUS(); foreach (ChiTietThuePhongDTO cttp in listcttp) { int i = lsvDV.Items.Count; DichVuDTO dv = dvBUS.getDichVuByID(cttp.Madichvu); lsvDV.Items.Add(dv.Tendichvu); lsvDV.Items[i].SubItems.Add(cttp.Maphong); lsvDV.Items[i].SubItems.Add(cttp.Ngay.ToShortDateString()); lsvDV.Items[i].SubItems.Add(cttp.Ngay.ToLongTimeString()); lsvDV.Items[i].SubItems.Add(dv.Gia.ToString("0,0")); lsvDV.Items[i].SubItems.Add(cttp.Soluong.ToString()); decimal tt = dv.Gia * cttp.Soluong; lsvDV.Items[i].SubItems.Add(tt.ToString("0,0")); tiendichvu += tt; } labTDV.Text = tiendichvu.ToString("0,0"); }
private void show_Phong() { cmbMaphong.Items.Clear(); string fe = cmbMaPT.SelectedItem.ToString(); ptpBUS = new PhieuThuePhongBUS(); PhieuThuePhongDTO listptp = ptpBUS.getPhieuThuePhongByID(fe); string fe1 = listptp.Maphieudat; pdpBUS = new PhieuDatPhongBUS(); PhieuDatPhongDTO listpdt = pdpBUS.getPhieuDatPhongByID(fe1); string fe2 = listptp.Maphieudat; ctdpBUS = new ChiTietDatPhongBUS(); IList <ChiTietDatPhongDTO> listcttp = ctdpBUS.getChiTietDatPhongByID(fe2); foreach (ChiTietDatPhongDTO ctdp in listcttp) { cmbMaphong.Items.Add(ctdp.Maphong); } if (maphong != "") { cmbMaphong.Text = maphong; } else { cmbMaphong.SelectedValue = 0; } }
private void addButton_Click(object sender, EventArgs e) { PhieuThuePhongDTO phieuThuePhongDTO = new PhieuThuePhongDTO(); List <ChiTietThuePhongDTO> dSChiTietThuePhongDTO = new List <ChiTietThuePhongDTO>(); for (int i = 0; i < DanhSachPhieuThuePhong.Rows.Count; i++) { ChiTietThuePhongDTO chiTietThuePhongDTO = new ChiTietThuePhongDTO(); if (DanhSachPhieuThuePhong.Rows[i].Cells[1].Value == null) { MessageBox.Show("Không được bỏ trống khách hàng", "THÔNG BÁO"); return; } chiTietThuePhongDTO.MaKhachHang = DanhSachPhieuThuePhong.Rows[i].Cells[1].Value.ToString(); dSChiTietThuePhongDTO.Add(chiTietThuePhongDTO); } phieuThuePhongDTO.MaPhong = cbMaPhong.SelectedValue.ToString(); phieuThuePhongDTO.NgayThue = ngayThuePhong.Value.Date.ToString("yyyy-MM-dd"); lapPhieuThuePhongBLL.ThemPhieuThuePhong(phieuThuePhongDTO, dSChiTietThuePhongDTO); MessageBox.Show("Thêm thành công"); DanhSachPhieuThuePhong.Rows.Clear(); index = 0; }
private void bntChiTietThuePhong_Click(object sender, EventArgs e) { if (gridKhachHang.Rows.Count != 0) { if (_loaiKH == 1) { PhieuThuePhongBUS phieuThuePhongBUS = new PhieuThuePhongBUS(); PhieuThuePhongDTO phieuThuePhongDTO = new PhieuThuePhongDTO(); phieuThuePhongDTO = phieuThuePhongBUS.DangO_KhachHang(int.Parse(gridKhachHang.CurrentRow.Cells[0].Value.ToString())); PhieuThuePhong phieuThuePhong = new PhieuThuePhong(); PhieuThuePhong.maKH = Convert.ToInt32(gridKhachHang.CurrentRow.Cells[0].Value.ToString()); PhieuThuePhong.dangO = true; PhieuThuePhong.maPhieuthuephong = phieuThuePhongDTO.Ma; phieuThuePhong.ShowDialog(); Load(); } else if (_loaiKH == 2) { DanhSachDatPhongTheoKhachHang ds = new DanhSachDatPhongTheoKhachHang(); DanhSachDatPhongTheoKhachHang.maKH = Convert.ToInt32(gridKhachHang.CurrentRow.Cells[0].Value.ToString()); ds.MyParent = this; ds.ShowDialog(); } } }
private PhieuThuePhongDTO LayThongTinPhong() { PhieuThuePhongDTO p = new PhieuThuePhongDTO(); p.MaPhong = int.Parse(txtMaPhong.Text); p.NgayThue = Convert.ToDateTime(dtpNgayThuePhong.Text); p.NgayTraPhong = Convert.ToDateTime(dtpNgayTraPhong.Text); return(p); }
//Sửa public void updatePhieuThuePhong(PhieuThuePhongDTO ptpDTO) { var querry = (from ptp in htDataContext.phieuthuephongs where ptp.maphieuthue == ptpDTO.Maphieuthue select ptp).FirstOrDefault <phieuthuephong>(); querry.maphieudat = ptpDTO.Maphieudat; querry.username = ptpDTO.Username; htDataContext.SubmitChanges(); }
//Thêm public void insertPhieuThuePhong(PhieuThuePhongDTO ptpDTO) { phieuthuephong ptp = new phieuthuephong(); ptp.maphieuthue = ptpDTO.Maphieuthue; ptp.maphieudat = ptpDTO.Maphieudat; ptp.username = ptpDTO.Username; htDataContext.phieuthuephongs.InsertOnSubmit(ptp); htDataContext.SubmitChanges(); }
public static bool ThemPhieuThuePhong(ChiTietPhieuThueDTO ct, PhieuThuePhongDTO p) { int i = DateTime.Compare(p.NgayThue, p.NgayTraPhong.Value); if (i <= 0) { return(RentalDAO.ThemPhieuThuePhong(ct, p)); } return(false); }
public int updatePhieuThuePhong(PhieuThuePhongDTO ptpDTO) { try { ptpDAO.updatePhieuThuePhong(ptpDTO); return(1); } catch { return(0); } }
public int insertPhieuThuePhong(PhieuThuePhongDTO ptpDTO) { try { ptpDAO.insertPhieuThuePhong(ptpDTO); return(1); } catch { return(0); //throw new Exception("Không thêm được dữ liệu!"); } }
private void bntDatPhong_Click(object sender, EventArgs e) { PhieuThuePhongDTO phieuThuePhongDTO = new PhieuThuePhongDTO(); phieuThuePhongDTO.MaPhong = maP; if (maKH != 0) { phieuThuePhongDTO.MaKhachHang = maKH; } else { phieuThuePhongDTO.MaKhachHang = ThemKhachHang(); } if (isSodoKScall) { DateTime s = dtpkNgayBD.Value.Date; TimeSpan ts = dtpkGioBD.Value.TimeOfDay; _thoiGianNhan = s.Date + ts; DateTime f = dtpkNgayKT.Value.Date; TimeSpan tf = dtpkGioKT.Value.TimeOfDay; _thoiGianTra = f.Date + tf; } phieuThuePhongDTO.ThoiGianNhanPhong = _thoiGianNhan; phieuThuePhongDTO.ThoiGianTraPhong = _thoiGianTra; phieuThuePhongDTO.MaLoaiThuePhong = int.Parse(cbmLoaiDangKy.SelectedValue.ToString()); phieuThuePhongDTO.Gia = float.Parse(lbGiaPhong.Text); phieuThuePhongDTO.TrangThai = 1; phieuThuePhongDTO.TraTruoc = float.Parse(lbTraTruoc.Text); PhieuThuePhongBUS phieuThuePhongBUS = new PhieuThuePhongBUS(); if (phieuThuePhongBUS.ThemPhieuThuePhong(phieuThuePhongDTO)) { MessageBoxDS m = new MessageBoxDS(); MessageBoxDS.thongbao = "Đặt phòng thành công!"; MessageBoxDS.maHinh = 1; m.ShowDialog(); result = true; } else { MessageBoxDS m = new MessageBoxDS(); MessageBoxDS.thongbao = "Đặt phòng thất bại!"; MessageBoxDS.maHinh = 3; m.ShowDialog(); } }
public static bool CapNhatTinhTrangPhong(PhieuThuePhongDTO p) { SqlParameter maphong = new SqlParameter("@MaPhong", p.MaPhong); try { context.Database.ExecuteSqlCommand("spCapNhatTinhTrangPhong @MaPhong", maphong); return(true); } catch { return(false); } }
public PhieuThuePhongDTO ChuyenRowThanhObject(DataRow row) { PhieuThuePhongDTO phieuThuePhong = new PhieuThuePhongDTO(); phieuThuePhong.Ma = int.Parse(row[0].ToString()); phieuThuePhong.MaPhong = int.Parse(row[1].ToString()); phieuThuePhong.MaKhachHang = int.Parse(row[2].ToString()); phieuThuePhong.ThoiGianNhanPhong = DateTime.Parse(row[3].ToString()); phieuThuePhong.ThoiGianTraPhong = DateTime.Parse(row[4].ToString()); phieuThuePhong.MaLoaiThuePhong = int.Parse(row[5].ToString()); phieuThuePhong.Gia = float.Parse(row[6].ToString()); phieuThuePhong.TrangThai = int.Parse(row[7].ToString()); return(phieuThuePhong); }
//Nhận mã phiếu đặt phòng từ FormPhieuDatPhong(khi nhấn button nhận phòng) rồi tạo mã phiếu thuê phòng và thêm vào database private void nhanphong(string maphieudat) { ptpDTO = new PhieuThuePhongDTO(); ptpDTO.Maphieuthue = "PT00" + showid(); ptpDTO.Maphieudat = maphieudat; ptpDTO.Username = frmMain.m_username; if (ptphong.insertPhieuThuePhong(ptpDTO) == 1) { show_MaPT(); show_CTTP(); MessageBox.Show("Đã tạo Phiếu Thuê Phòng từ Phiếu Đặt Phòng: " + maphieudat); } else { MessageBox.Show("Lỗi thêm dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static bool ThemPhieuThuePhong(ChiTietPhieuThueDTO ct, PhieuThuePhongDTO p) { SqlParameter mapt = new SqlParameter("@MaPT", ct.MaPT); SqlParameter ngaythue = new SqlParameter("@NgayThue", p.NgayThue); SqlParameter maphong = new SqlParameter("@MaPhong", p.MaPhong); SqlParameter ngaytraphong = new SqlParameter("@NgayTraPhong", p.NgayTraPhong); try { context.Database.ExecuteSqlCommand("spThemPhieuThue @MaPT , @NgayThue , @MaPhong , @NgayTraPhong", mapt, ngaythue, maphong, ngaytraphong); return(true); } catch { return(false); } }
public PhieuThuePhongDTO[] LayDanhSachPhieuThuePhong() { PhieuThuePhongDTO[] phieuThuePhongs = null; string query = "Select * From PhieuThuePhong"; DataTable tb = new DataTable(); tb = dataProvider.ExecuteQuery_DataTble(query); phieuThuePhongs = new PhieuThuePhongDTO[tb.Rows.Count]; int n = tb.Rows.Count; for (int i = 0; i < n; i++) { phieuThuePhongs[i] = ChuyenRowThanhObject(tb.Rows[i]); } return(phieuThuePhongs); }
public HttpResponseMessage DatPhongAPI([FromBody] PhieuThuePhongDTO phieuThuePhongDTO) { if (phieuThuePhongDTO != null) { PhieuThuePhongBUS phieuThuePhongBUS = new PhieuThuePhongBUS(); try { phieuThuePhongBUS.ThemPhieuThuePhong(phieuThuePhongDTO); return(Request.CreateResponse(HttpStatusCode.OK, "success")); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.GatewayTimeout, "error")); } } return(Request.CreateResponse(HttpStatusCode.GatewayTimeout, "error")); }
//Load data lên listview thông tin khách hàng private void show_kh() { PhieuThuePhongDTO listptp = ptphong.getPhieuThuePhongByID(cmbMaPT.Text); PhieuDatPhongDTO listpdp = pdphong.getPhieuDatPhongByID(listptp.Maphieudat); KhachHangDTO listkh = khg.getKhachHangByID(listpdp.Makhachhang); emtylsvgKH(); lsvKH.Items[0].SubItems[1].Text = listkh.Makhachhang; lsvKH.Items[1].SubItems[1].Text = listkh.Tenkhachhang; lsvKH.Items[2].SubItems[1].Text = listkh.CMND_PASSPORT; lsvKH.Items[3].SubItems[1].Text = listkh.Diachi; lsvKH.Items[4].SubItems[1].Text = listkh.Pass; lsvKH.Items[5].SubItems[1].Text = listkh.Sodienthoai; lsvKH.Items[6].SubItems[1].Text = listkh.Email; }
public bool ThemPhieuThuePhong(PhieuThuePhongDTO phieuThuePhongDTO) { string query = "INSERT INTO Phieuthuephong(Maphong,Makhachhang,Thoigiannhanphong,Thoigiantraphong," + "Maloaithuephong,Gia,TrangThai,TraTruoc) VALUES ('" + phieuThuePhongDTO.MaPhong + "','" + phieuThuePhongDTO.MaKhachHang + "','" + phieuThuePhongDTO.ThoiGianNhanPhong.ToString("yyyy-MM-dd HH:mm:ss") + "','" + phieuThuePhongDTO.ThoiGianTraPhong.ToString("yyyy-MM-dd HH:mm:ss") + "','" + phieuThuePhongDTO.MaLoaiThuePhong + "','" + phieuThuePhongDTO.Gia + "','" + phieuThuePhongDTO.TrangThai + "','" + phieuThuePhongDTO.TraTruoc + "')"; try { dataProvider.ExecuteUpdateQuery(query); return(true); } catch { return(false); } }
public void CapNhatTrangThaiPhieuThuePhongCoMaPhong(int maPhong) { PhieuThuePhongDTO[] phieuThuePhongs = phieuThuePhongDAO.LayDanhSachPhieuThuePhong(); if (phieuThuePhongs != null) { try { DateTime date = DateTime.Now; PhieuThuePhongDTO phieuThuePhong = phieuThuePhongs.Where(tp => tp.TrangThai == 1 && tp.MaPhong == maPhong && tp.ThoiGianNhanPhong <= date).FirstOrDefault(); if (phieuThuePhong != null) { CapNhatTinhTrang(phieuThuePhong.Ma, 2); } }catch (Exception ex) { throw ex.InnerException; } } }
private void show_KH() { //lsvKH.Items.Clear(); PhieuThuePhongDTO listptp = pthueph.getPhieuThuePhongByID(cmbMaPT.Text); PhieuDatPhongDTO pdp = pdatph.getPhieuDatPhongByID(listptp.Maphieudat); // emtylsvgKH(); KhachHangDTO khg = kh.getKhachHangByID(pdp.Makhachhang); lsvKH.Items[0].SubItems[1].Text = khg.Makhachhang; lsvKH.Items[1].SubItems[1].Text = khg.Tenkhachhang; lsvKH.Items[2].SubItems[1].Text = khg.CMND_PASSPORT; lsvKH.Items[3].SubItems[1].Text = khg.Diachi; lsvKH.Items[4].SubItems[1].Text = khg.Pass; lsvKH.Items[5].SubItems[1].Text = khg.Sodienthoai; lsvKH.Items[6].SubItems[1].Text = khg.Email; }
private void show_KH() { //lsvKH.Items.Clear(); ptpBUS = new PhieuThuePhongBUS(); PhieuThuePhongDTO listptp = ptpBUS.getPhieuThuePhongByID(cmbMaPT.Text); pdpBUS = new PhieuDatPhongBUS(); PhieuDatPhongDTO pdp = pdpBUS.getPhieuDatPhongByID(listptp.Maphieudat); labTDC.Text = pdp.Sotiendatcoc.ToString("0,0"); khBUS = new KhachHangBUS(); // emtylsvgKH(); KhachHangDTO kh = khBUS.getKhachHangByID(pdp.Makhachhang); lsvKH.Items[0].SubItems[1].Text = kh.Makhachhang; lsvKH.Items[1].SubItems[1].Text = kh.Tenkhachhang; lsvKH.Items[2].SubItems[1].Text = kh.CMND_PASSPORT; lsvKH.Items[3].SubItems[1].Text = kh.Diachi; lsvKH.Items[4].SubItems[1].Text = kh.Coquan; lsvKH.Items[5].SubItems[1].Text = kh.Sodienthoai; lsvKH.Items[6].SubItems[1].Text = kh.Email; }
public PhieuThuePhongDTO DangO_KhachHang(int maKH) { PhieuThuePhongDTO phieuThuePhongDTO = new PhieuThuePhongDTO(); string query = "Select * From Phieuthuephong Where TrangThai = 2 and Makhachhang = " + maKH + ""; DataTable tb = new DataTable(); tb = dataProvider.ExecuteQuery_DataTble(query); if (tb.Rows.Count > 0 && tb != null) { foreach (DataRow row in tb.Rows) { phieuThuePhongDTO.Ma = int.Parse(row[0].ToString()); phieuThuePhongDTO.MaPhong = int.Parse(row[1].ToString()); phieuThuePhongDTO.MaKhachHang = int.Parse(row[2].ToString()); phieuThuePhongDTO.ThoiGianNhanPhong = DateTime.Parse(row[3].ToString()); phieuThuePhongDTO.ThoiGianTraPhong = DateTime.Parse(row[4].ToString()); phieuThuePhongDTO.MaLoaiThuePhong = int.Parse(row[5].ToString()); phieuThuePhongDTO.Gia = float.Parse(row[6].ToString()); } return(phieuThuePhongDTO); } return(null); }
private void btnLuuPhieuThue_Click(object sender, EventArgs e) { PhieuThuePhongDTO p = LayThongTinPhong(); ChiTietPhieuThueDTO ct = LayMaKeTiep(); if (PhieuThueBUS.ThemPhieuThuePhong(ct, p)) { for (int i = 0; i < dgvDanhSachPhieuThue.Rows.Count; i++) { KhachHangDTO kh = LayThongTinKhachHang(i); if (KhachHangBUS.ThemKhachHang(kh)) { if (!PhieuThueBUS.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 (PhongBUS.CapNhatTinhTrangPhong(p)) { MessageBox.Show("Lập phiếu thuê thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ((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); } }
public static bool CapNhatTinhTrangPhong(PhieuThuePhongDTO p) { return(PhongDAO.CapNhatTinhTrangPhong(p)); }
private void nhanphong(string maphieudat) { ptpDTO = new PhieuThuePhongDTO(); ptpDTO.Maphieuthue = "PT00" + showid(); ptpDTO.Maphieudat = maphieudat; ptpDTO.Username = frmMain.m_username; if(ptphong.insertPhieuThuePhong(ptpDTO)==1) { show_MaPT(); show_CTTP(); MessageBox.Show("Đã tạo Phiếu Thuê Phòng từ Phiếu Đặt Phòng: " + maphieudat); } else { MessageBox.Show("Lỗi thêm dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//public void functionGetThongTinDangNhap(NHANVIEN nhanVien) //{ // this.nhanVien = nhanVien; //} public void LoadPhong() { flowBody.Controls.Clear(); PhongBUS phongBUS = new PhongBUS(); PhongDTO[] phongs = phongBUS.LayDanhSachPhong(); PhieuThuePhongBUS phieuThuePhongBUS = new PhieuThuePhongBUS(); PhieuThuePhongDTO[] phieuThuePhongs = phieuThuePhongBUS.LayDanhSachPhieuThuePhongTrangThai1Va2(); KhachHangBUS khachHangBUS = new KhachHangBUS(); int i; int j, coTrongPhieuThuePhong = 0; int numberPhong = phongBUS.LaySoLuongPhongLonNhatTrongCacTang(); int with_sizeCustomePhong = flowBody.Size.Width / numberPhong - numberPhong - 1; for (i = 0; i < phongs.Length; i++) { // khai báo control customePhong CustomePhong customePhong = new CustomePhong(phongs[i]); customePhong.Size = new Size(with_sizeCustomePhong, customePhong.Size.Height); coTrongPhieuThuePhong = 0; for (j = 0; j < phieuThuePhongs.Length; j++) { if (phongs[i].Ma == phieuThuePhongs[j].MaPhong) { coTrongPhieuThuePhong = 1; if (phieuThuePhongs[j].TrangThai == 1) // khách hàng chưa nhận phòng { PhieuThuePhongDTO phieuThuePhongKiemTra = phieuThuePhongBUS.CoPhaiPhongCoNguoiDangO(phongs[i].Ma); if (phieuThuePhongKiemTra != null) { string strtime = String.Format("{0:MM/dd/yyyy HH:mm}", phieuThuePhongKiemTra.ThoiGianTraPhong); KhachHangDTO khachHang = khachHangBUS.LayKhachHangCoMaSo(phieuThuePhongKiemTra.MaKhachHang); string tenKhachHang = ""; if (khachHang != null) { tenKhachHang = khachHang.Ten; } customePhong.ThayDoiTrangThaiDangO(strtime, tenKhachHang); // kiểm tra khách hàng có quá hạn hay không int time = (int)(DateTime.Now - phieuThuePhongKiemTra.ThoiGianTraPhong).TotalMinutes; if (time > 0) { if (time < 60) // nhỏ hơn 60 phút { strtime = time + " phút "; } else if (time < 60 * 24) // nhỏ hơn 24h { strtime = time / 60 + " giờ "; } else // lớn hơn 24h { strtime = time / (60 * 24) + " ngày "; } strtime += String.Format("{0:MM/dd/yyyy HH:mm}", phieuThuePhongKiemTra.ThoiGianTraPhong); customePhong.ThayDoiTrangThaiQuaHan(strtime, tenKhachHang); } } else { string time = String.Format("{0:MM/dd/yyyy HH:mm}", phieuThuePhongs[j].ThoiGianNhanPhong); KhachHangDTO khachHang = khachHangBUS.LayKhachHangCoMaSo(phieuThuePhongs[j].MaKhachHang); string tenKhachHang = ""; if (khachHang != null) { tenKhachHang = khachHang.Ten; } customePhong.ThayDoiTrangThaiDaDat(time, tenKhachHang); } } else if (phieuThuePhongs[j].TrangThai == 2) // khách hàng đã nhận phòng { string strtime = String.Format("{0:MM/dd/yyyy HH:mm}", phieuThuePhongs[j].ThoiGianTraPhong); KhachHangDTO khachHang = khachHangBUS.LayKhachHangCoMaSo(phieuThuePhongs[j].MaKhachHang); string tenKhachHang = ""; if (khachHang != null) { tenKhachHang = khachHang.Ten; } customePhong.ThayDoiTrangThaiDangO(strtime, tenKhachHang); // kiểm tra khách hàng có quá hạn hay không int time = (int)(DateTime.Now - phieuThuePhongs[j].ThoiGianTraPhong).TotalMinutes; if (time > 0) { if (time < 60) // nhỏ hơn 60 phút { strtime = time + " phút "; } else if (time < 60 * 24) // nhỏ hơn 24h { strtime = time / 60 + " giờ "; } else // lớn hơn 24h { strtime = time / (60 * 24) + " ngày "; } strtime += String.Format("{0:MM/dd/yyyy HH:mm}", phieuThuePhongs[j].ThoiGianTraPhong); customePhong.ThayDoiTrangThaiQuaHan(strtime, tenKhachHang); } } break; } } if (coTrongPhieuThuePhong == 0) { customePhong.ThayDoiTrangThaiTrong(); } customePhong.EventDatPhong += CustomePhong_EventDatPhong; customePhong.EventNhanPhong += CustomePhong_EventNhanPhong; customePhong.EventThanhToanPhong += CustomePhong_EventThanhToanPhong; flowBody.Controls.Add(customePhong); } }
private void TraPhong_Load(object sender, EventArgs e) { if (isSodoKScall) { PhieuThuePhongDTO phieuThuePhongDTO = new PhieuThuePhongDTO(); PhieuThuePhongBUS phieuThuePhongBUS = new PhieuThuePhongBUS(); phieuThuePhongDTO = phieuThuePhongBUS.DangO_Phong(maP); maLoaiThuePhong = phieuThuePhongDTO.MaLoaiThuePhong; maPhieuthuephong = phieuThuePhongDTO.Ma; PhongDTO phongDTO = new PhongDTO(); PhongBUS phongBUS = new PhongBUS(); phongDTO = phongBUS.LayPhongTheoMaSo(phieuThuePhongDTO.MaPhong); HienthiKhachhang(phieuThuePhongDTO.MaKhachHang); lbTenPhong.Text = phongDTO.Ten; dtpkGioBD.Value = phieuThuePhongDTO.ThoiGianNhanPhong; dtpkGioKT.Value = phieuThuePhongDTO.ThoiGianTraPhong; dtpkNgayBD.Value = phieuThuePhongDTO.ThoiGianNhanPhong; dtpkNgayKT.Value = phieuThuePhongDTO.ThoiGianTraPhong; lbLoaiDangKy.Text = phongBUS.LayLoaiDangKy(phieuThuePhongDTO.MaLoaiThuePhong); lbLoaiPhong.Text = phongBUS.LayLoaiPhong(phongDTO.MaLoaiPhong); HienthiGiaPhong(phieuThuePhongDTO.MaLoaiThuePhong, phongDTO.MaLoaiPhong); HienthiThoiGian(); HienthiTongTienDichVu(); HienthiTongTienPhaiTra(); } else { PhieuThuePhongDTO phieuThuePhongDTO = new PhieuThuePhongDTO(); PhieuThuePhongBUS phieuThuePhongBUS = new PhieuThuePhongBUS(); phieuThuePhongDTO = phieuThuePhongBUS.DangO_KhachHang(maKH); maLoaiThuePhong = phieuThuePhongDTO.MaLoaiThuePhong; maPhieuthuephong = phieuThuePhongDTO.Ma; maP = phieuThuePhongDTO.MaPhong; PhongDTO phongDTO = new PhongDTO(); PhongBUS phongBUS = new PhongBUS(); phongDTO = phongBUS.LayPhongTheoMaSo(phieuThuePhongDTO.MaPhong); HienthiKhachhang(phieuThuePhongDTO.MaKhachHang); lbTenPhong.Text = phongDTO.Ten; dtpkGioBD.Value = phieuThuePhongDTO.ThoiGianNhanPhong; dtpkGioKT.Value = phieuThuePhongDTO.ThoiGianTraPhong; dtpkNgayBD.Value = phieuThuePhongDTO.ThoiGianNhanPhong; dtpkNgayKT.Value = phieuThuePhongDTO.ThoiGianTraPhong; lbLoaiDangKy.Text = phongBUS.LayLoaiDangKy(phieuThuePhongDTO.MaLoaiThuePhong); lbLoaiPhong.Text = phongBUS.LayLoaiPhong(phongDTO.MaLoaiPhong); HienthiGiaPhong(phieuThuePhongDTO.MaLoaiThuePhong, phongDTO.MaLoaiPhong); HienthiThoiGian(); HienthiTongTienDichVu(); HienthiTongTienPhaiTra(); } }
private void btnTinhTien_Click(object sender, EventArgs e) { if (kiemtra()) { labTPT.Text = Math.Round(decimal.Parse(labTP.Text) + decimal.Parse(labTDV.Text) - decimal.Parse(labTDC.Text), 0).ToString("0,0"); ptpBUS = new PhieuThuePhongBUS(); hdBUS = new HoaDonBUS(); pdpBUS = new PhieuDatPhongBUS(); hdDTO = new HoaDonDTO(); ctdpBUS = new ChiTietDatPhongBUS(); pBUS = new PhongBUS(); PhieuThuePhongDTO ptp = ptpBUS.getPhieuThuePhongByID(cmbMaPT.Text); PhieuDatPhongDTO pdp = pdpBUS.getPhieuDatPhongByID(ptp.Maphieudat); hdDTO.Mahoadon = labMaHD.Text; hdDTO.Ngaythanhtoan = dtpNgay.Value; hdDTO.Tongtien = decimal.Parse(labTPT.Text); hdDTO.Maphieuthue = cmbMaPT.Text; hdDTO.Makhachhang = pdp.Makhachhang; hdDTO.Username = frmMain.m_username; if (hdBUS.insertHoaDon(hdDTO) == 1) { pdpDTO = new PhieuDatPhongDTO(); pdpDTO.Maphieudat = pdp.Maphieudat; pdpDTO.Makhachhang = pdp.Makhachhang; pdpDTO.Ngayden = pdp.Ngayden; pdpDTO.Ngaydi = pdp.Ngaydi; pdpDTO.Sotiendatcoc = pdp.Sotiendatcoc; pdpDTO.Username = pdp.Username; pdpDTO.Tinhtrang = "finish"; pdpDTO.Songuoi = pdp.Songuoi; if (pdpBUS.updatePhieuDatPhong(pdpDTO) == 1) { IList <ChiTietDatPhongDTO> listctdp = ctdpBUS.getChiTietDatPhongByID(pdp.Maphieudat); foreach (ChiTietDatPhongDTO ctdp in listctdp) { pDTO = new PhongDTO(); PhongDTO p = pBUS.getPhongByID(ctdp.Maphong); pDTO.Maphong = p.Maphong; pDTO.Maloai = p.Maloai; pDTO.Dadat = false; pDTO.Danhan = false; if (pBUS.updatePhong(pDTO) == 1) { } else { MessageBox.Show("Lỗi sửa phòng!"); } } } else { MessageBox.Show("Lỗi sửa phiếu đặt phòng!"); } flagtinhtien = true; show_KH(); show_Phong(); show_DV(); //show_MaPT(); frmMain.CapNhatPhong(); MessageBox.Show("Đã tính tiền!"); btnInhoadon.Visible = true; } else { MessageBox.Show("Lỗi dữ liệu!"); } } }