private void loadHoaDon() { try { double giaPhong = 100000; dtHoaDon = DTBill.getAllWhere("HOADON", "PHONG = " + txtSoPhong.Tag.ToString() + " AND (TinhTrang = 0 OR TinhTrang = 1)"); string maHD = dtHoaDon.Rows[0]["MaHoaDon"].ToString(); txtSoBill.Text = dtHoaDon.Rows[0]["MaHoaDon"].ToString(); txtPhiDichVu.Text = dtHoaDon.Rows[0]["TongGia"].ToString(); DataTable dtRent = DTRent.getAllWhere("PHIEUTHUE", "MaPhieuThue = " + txtMaPhieuThue.Text); DateTime dateNgayThue = DateTime.ParseExact(dtRent.Rows[0]["NgayBatDau"].ToString(), "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime dateNgayTra = DateTime.ParseExact(dtRent.Rows[0]["NgayKetThuc"].ToString(), "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); double tienThuePhong = Math.Floor((dateNgayTra - dateNgayThue).TotalHours / 24 * giaPhong); txtTienThuePhong.Text = tienThuePhong.ToString(); double phuThu = dtKH.Rows[0]["LoaiKHID"].ToString() == "1" ? 0 : (tienThuePhong * 0.1); txtPhuThu.Text = phuThu.ToString(); txtVAT.Text = ((Double.Parse(dtHoaDon.Rows[0]["TongGia"].ToString()) + tienThuePhong) * 0.1).ToString(); txtTongTien.Text = (Double.Parse(dtHoaDon.Rows[0]["TongGia"].ToString()) + tienThuePhong + ((Double.Parse(dtHoaDon.Rows[0]["TongGia"].ToString()) + tienThuePhong) * 0.1) + phuThu).ToString(); } catch (Exception) { MessageBox.Show("Vui lòng chọn mũi giờ Việt Nam!"); throw; } }
private void btnThanhToan_Click(object sender, EventArgs e) { try { if (String.IsNullOrWhiteSpace(DTRent.getAllWhere("PHIEUTHUE", "MaPhieuThue = " + txtMaPhieuThue.Text.ToString()).Rows[0]["NgayKetThuc"].ToString())) { DTRent.update("NgayKetThuc = '" + DateTime.ParseExact(dtNgayTra.Text, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd HH:mm:ss") + "'", "MaPhieuThue = " + txtMaPhieuThue.Text.ToString()); } loadHoaDon(); DTBill.update("TinhTrang = 2", "MaHoaDon = " + txtSoBill.Text); Phong.update("PHONG", "TinhTrangPhong = -1", "MaPhong = " + txtSoPhong.Tag.ToString()); DTRent.update("TinhTrangPhieuThue = 2", "MaPhieuThue = " + txtMaPhieuThue.Text.ToString()); //load lại danh sách phòng dt = QLThuePhong.getAll(); galleryControl1.Gallery.Groups[0].Items.Clear(); Bitmap image; foreach (DataRow dr in dt.Rows) { int tinhTrang = Int32.Parse(dr["TinhTrangPhong"].ToString()); if (tinhTrang == 1) { image = new Bitmap(Properties.Resources.close); } else if (tinhTrang == 0) { image = new Bitmap(Properties.Resources.checkInRom); } else { image = new Bitmap(Properties.Resources.open); } GalleryItem item = new GalleryItem(image, dr["TenPhong"].ToString(), dr["MoTaPhong"].ToString() == "" ? "Ghi Chú" : dr["MoTaPhong"].ToString()); item.Tag = dr["MaPhong"].ToString() + "_" + dr["TinhTrangPhong"].ToString().Trim(); galleryControl1.Gallery.Groups[0].Items.Add(item); } MessageBox.Show("Thanh Toán Thành Công!"); } catch (Exception) { MessageBox.Show("Lỗi Trong Quá trình thanh toán"); throw; } }
private void galleryControl1_Gallery_ItemClick(object sender, GalleryItemClickEventArgs e) { //clear dữ liệu txtKhachHang.Text = ""; txtSoCMT.Text = ""; txtSoDT.Text = ""; txtSoNguoi.Text = ""; dtNgayTra.Text = ""; dtNgayThue.DateTime = DateTime.Now; txtSoBill.Text = ""; txtTienThuePhong.Text = ""; txtTongTien.Text = ""; txtPhuThu.Text = ""; txtPhiDichVu.Text = ""; cboLoaiKH.Text = ""; string GhiChu = e.Item.Description; maPhongClick = e.Item.Caption; txtSoPhong.Text = e.Item.Caption; string maPhong_TrangThai = e.Item.Tag.ToString(); txtSoPhongBill.Text = e.Item.Caption; //cboLoaiPhong.DataSource = LoaiKH.getAll("LOAIKHACHHANG"); // add maphong vao txtSoPhong.Tag de su dung khi dat phong, ko phai lay lai ma phong txtSoPhong.Tag = maPhong_TrangThai.Split('_')[0]; string trangThaiP = maPhong_TrangThai.Split('_')[1]; if (trangThaiP == "0" || trangThaiP == "1") { btnDatPhong.Enabled = false; btnChuyenPhong.Enabled = true; btnThayDoiThongTin.Enabled = true; btnInPhieuThuePhong.Enabled = true; btnThemKH.Enabled = true; btnXoaKH.Enabled = true; btnSuaKH.Enabled = true; showBill(maPhongClick); // load thong tin người trong phòng try { DataTable dtPhieuThuePhong = DTRent.getAllWhere("PHIEUTHUE", "MaPhong = " + txtSoPhong.Tag.ToString() + " AND TinhTrangPhieuThue = 1"); string maPhieuThue = dtPhieuThuePhong.Rows[0]["MaPhieuThue"].ToString(); txtMaPhieuThue.Text = maPhieuThue; dtKH = KhachHang.getAllWhere("KHACHHANG", "MaKH = " + dtPhieuThuePhong.Rows[0]["MaKH"].ToString()); txtKhachHang.Text = dtKH.Rows[0]["TenKH"].ToString(); txtSoCMT.Text = dtKH.Rows[0]["SoCMND"].ToString(); cboGioiTinh.SelectedItem = dtKH.Rows[0]["GioiTinh"].ToString() == "1" ? "Nam" : "Nữ"; txtSoDT.Text = dtKH.Rows[0]["SoDienThoai"].ToString(); cboLoaiKH.SelectedItem = dtKH.Rows[0]["LoaiKHID"].ToString() == "1" ? "Nội Địa" : "Quốc Tế"; txtSoNguoi.Text = "1"; dtNgayThue.Text = dtPhieuThuePhong.Rows[0]["NgayBatDau"].ToString(); dtNgayTra.Text = dtPhieuThuePhong.Rows[0]["NgayKetThuc"].ToString(); //HD loadHoaDon(); //dsdv hien co DataTable dttb = DTService.getAll(); DataColumn[] keys = new DataColumn[1]; keys[0] = dttb.Columns[0]; dttb.PrimaryKey = keys; gridDSDichVu.DataSource = dttb; //ds dich vu da su dung DataTable dtCTHD = DTBillDetail.getAllWhere("CHITIETHOADON", "MAHD = " + txtSoBill.Text + " AND Phong = " + txtSoPhong.Tag.ToString()); if (dtCTHD.Rows.Count != 0) { string[] arrayDV = new string[dtCTHD.Rows.Count]; for (int i = 0; i < dtCTHD.Rows.Count; i++) { arrayDV[i] = dtCTHD.Rows[i]["MaDichVu"].ToString(); } dtDVSD = DTService.getAllWhere("DICHVU", "MaDichVu in (" + String.Join(",", arrayDV) + ")"); DataColumn[] keysDVSD = new DataColumn[1]; keysDVSD[0] = dtDVSD.Columns[0]; dtDVSD.PrimaryKey = keysDVSD; gridControlDVSuDung.DataSource = dtDVSD; } else { dtDVSD = new DataTable(); gridControlDVSuDung.DataSource = dtDVSD; } } catch (Exception) { return; throw; } } else { btnDatPhong.Enabled = true; btnChuyenPhong.Enabled = false; btnThayDoiThongTin.Enabled = false; btnInPhieuThuePhong.Enabled = false; gridKhachHang.DataSource = null; btnThemKH.Enabled = false; btnXoaKH.Enabled = false; btnSuaKH.Enabled = false; } }