private void Load_AutoCompleteSource() { DichVu_WCFClient dv_wcf = new DichVu_WCFClient(); var acsc = new AutoCompleteStringCollection(); try { foreach (DichVu_Ent item in dv_wcf.GetDichVus()) { acsc.Add(item.TenDichVu.ToString()); } this.txtTimKiemDV.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtTimKiemDV.AutoCompleteCustomSource = acsc; } catch (Exception) { return; } }
private void cbxLoaiDichVu_SelectedIndexChanged(object sender, EventArgs e) { if (isReload) { isReload = false; return; } if (!isShowing) { if (cbxLoaiDichVu.SelectedIndex == -1) { return; } else { DichVu_WCFClient dv_wcf = new DichVu_WCFClient(); int idLoai = dv_wcf.GetIDLoaiDV_byTenLoai(cbxLoaiDichVu.Text.Trim()); List <DichVu_Ent> dsDichVu = dv_wcf.TimKiemDichVu_byIDLoaiDV(idLoai).ToList(); Loading_DSDV(DataTable_DSDV(dsDichVu)); Custom_DataGridView(dgv_DSDichVu); } } }
private void btnThanhToan_Click(object sender, EventArgs e) { DichVu_WCFClient dv_wcf = new DichVu_WCFClient(); Phong_WCFClient p_wcf = new Phong_WCFClient(); PhieuCheckIn_WCFClient pck_wcf = new PhieuCheckIn_WCFClient(); KhachHang_WCFClient kh_wcf = new KhachHang_WCFClient(); PhieuCheckIn_Ent p_dv_ent = new PhieuCheckIn_Ent(); int idPhong = p_wcf.GetIDPhong_by_SoPhong(txtSoPhong.Text.Trim()); if (txtSoPhong.Text.Trim().Equals("")) { MessageBox.Show("Nhập Số Phòng", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int idKhach = 0; foreach (var item in pck_wcf.GetPhieuCheckIns()) { if (item.Id_Phong == idPhong && item.TrangThaiHoaDon == 0) { idKhach = item.Id_khach; } } PhieuCheckIn_Ent p_ent = new PhieuCheckIn_Ent(); foreach (var item in pck_wcf.GetPhieuCheckIns().ToList()) { if (item.Id_khach == idKhach) { p_ent.Ngay_check_in = item.Ngay_check_in; p_ent.Gio_check_in = item.Gio_check_in; p_ent.Ngay_check_out = item.Ngay_check_out; p_ent.Gio_check_out = item.Gio_check_out; p_ent.Giam_gia = item.Giam_gia; p_ent.SoLuongKhach = item.SoLuongKhach; } } int checkLoi = 0; for (int i = 0; i < dgvCTDV.Rows.Count - 1; i++) { p_dv_ent.Id_Phong = idPhong; p_dv_ent.Id_khach = Convert.ToInt32(idKhach); p_dv_ent.Id_NhanVien = idNhanVien; p_dv_ent.Id_DichVu = dv_wcf.GetIDDichVu_byTenDV(dgvCTDV.Rows[i].Cells[0].Value.ToString()); p_dv_ent.SoLuongDichVu = Convert.ToInt32(dgvCTDV.Rows[i].Cells[1].Value); p_dv_ent.Ngay_check_in = (DateTime)p_ent.Ngay_check_in; p_dv_ent.Gio_check_in = p_ent.Gio_check_in; p_dv_ent.Ngay_check_out = p_ent.Ngay_check_out; p_dv_ent.Gio_check_out = p_ent.Gio_check_out; p_dv_ent.Giam_gia = p_ent.Giam_gia; p_dv_ent.SoLuongKhach = p_ent.SoLuongKhach; p_dv_ent.TrangThaiHoaDon = 1; p_dv_ent.SoLuongDichVu = Convert.ToInt32(dgvCTDV.Rows[i].Cells[1].Value.ToString().Trim()); if (!pck_wcf.ThemPhieuCheckIn_DichVu(p_dv_ent)) { checkLoi = 1; MessageBox.Show("Có Lỗi Xảy Ra!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (checkLoi == 0) { MessageBox.Show("Lưu Thành Công", "", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
//DataTable public DataTable DataTable_DSP(List <PhieuCheckIn_Ent> dsPCI) { Phong_WCFClient ph_wcf = new Phong_WCFClient(); KhachHang_WCFClient kh_wcf = new KhachHang_WCFClient(); DichVu_WCFClient dv_wcf = new DichVu_WCFClient(); DataTable dt = new DataTable(); dt.Columns.Add("Mã Phiếu Check In", typeof(string)); dt.Columns.Add("Loại Phòng", typeof(string)); dt.Columns.Add("Số Phòng", typeof(string)); dt.Columns.Add("Họ Tên Khách Hàng", typeof(string)); dt.Columns.Add("Thời Gian Check In", typeof(string)); dt.Columns.Add("Thời gian Check Out", typeof(string)); dt.Columns.Add("Tên Dịch Vụ", typeof(string)); dt.Columns.Add("Số Lượng Dịch Vụ", typeof(string)); dt.Columns.Add("Tổng Tiền", typeof(string)); dt.Columns.Add("Tình Trạng", typeof(string)); //Lọc Dữ Liệu Phiếu Đặt Phòng và Phiếu Mua Bán Dịch Vụ foreach (PhieuCheckIn_Ent p_ent in dsPCI) { string nameServ = dv_wcf.GetTenDichVu_byIdDichVu(p_ent.Id_DichVu); if (p_ent.Id_DichVu != 0) { string tinhTrang = ""; if (p_ent.TrangThaiHoaDon == 0) { tinhTrang = "Chưa Thanh Toán"; } if (p_ent.TrangThaiHoaDon == 1) { tinhTrang = "Đã Thanh Toán"; } dt.Rows.Add(p_ent.Id_phieu_checkin, ph_wcf.GetTenLoaiPhong_by_IDLoai(p_ent.Id_Phong), ph_wcf.getsoPhong_byID(p_ent.Id_Phong), kh_wcf.getHoKhacHang_byID(p_ent.Id_khach) + " " + kh_wcf.getTenKhacHang_byID(p_ent.Id_khach), p_ent.Gio_check_in + " " + p_ent.Ngay_check_in.ToShortDateString(), p_ent.Gio_check_out + " " + p_ent.Ngay_check_out.ToShortDateString(), nameServ, p_ent.SoLuongDichVu.ToString(), (p_ent.SoLuongDichVu * dv_wcf.GetGiaDichVu_byIdDichVu(p_ent.Id_DichVu)), tinhTrang); } else { TimeSpan date = p_ent.Ngay_check_out - p_ent.Ngay_check_in; decimal donGia = ph_wcf.DonGia(ph_wcf.GetIDLoaiPhong_by_IDPhong(p_ent.Id_Phong).ToString()); string tienPhong = (donGia * Convert.ToInt32(date.Days)).ToString(); string tinhTrang = ""; if (p_ent.TrangThaiHoaDon == 0) { tinhTrang = "Trống"; } if (p_ent.TrangThaiHoaDon == 1) { tinhTrang = "Có Khách"; } dt.Rows.Add(p_ent.Id_phieu_checkin, ph_wcf.GetTenLoaiPhong_by_IDLoai(p_ent.Id_Phong), ph_wcf.getsoPhong_byID(p_ent.Id_Phong), kh_wcf.getHoKhacHang_byID(p_ent.Id_khach) + " " + kh_wcf.getTenKhacHang_byID(p_ent.Id_khach), p_ent.Gio_check_in + " " + p_ent.Ngay_check_in.ToShortDateString(), p_ent.Gio_check_out + " " + p_ent.Ngay_check_out.ToShortDateString(), nameServ, p_ent.SoLuongDichVu.ToString(), tienPhong, tinhTrang); } } return(dt); }