private void btnTraPhong_Click(object sender, EventArgs e) { if (dgv_DSPhieuCheckIn.SelectedRows.Count > 0) { Phong_WCFClient phong_wcf = new Phong_WCFClient(); PhieuCheckIn_WCFClient p_wcf = new PhieuCheckIn_WCFClient(); DateTime date = DateTime.Now; TimeSpan now = new TimeSpan(date.Hour, date.Minute, date.Second); int idPhong = phong_wcf.GetIDPhong_by_SoPhong((dgv_DSPhieuCheckIn.SelectedRows[0].Cells[2].Value.ToString().Trim())); if (p_wcf.TraPhong(Convert.ToInt32(dgv_DSPhieuCheckIn.SelectedRows[0].Cells[0].Value.ToString().Trim()), now, date)) { if (phong_wcf.update_TinhTrangPhong(idPhong, 0)) { MessageBox.Show(this, "Thành Công!"); PhieuCheckIn_WCFClient temp = new PhieuCheckIn_WCFClient(); List <PhieuCheckIn_Ent> lstP = temp.GetPhieuCheckIns_NoCheckOut().ToList(); loaDataToGridView(DataTable_DSPhieu(lstP)); Custom_DataGridView(dgv_DSPhieuCheckIn); } else { MessageBox.Show(this, "Thất Bại!"); } } else { MessageBox.Show(this, "Thất Bại!"); } } }
private void txtSoPhong_TextChanged(object sender, EventArgs e) { Phong_WCFClient p_wcf = new Phong_WCFClient(); PhieuCheckIn_WCFClient pck_wcf = new PhieuCheckIn_WCFClient(); KhachHang_WCFClient kh_wcf = new KhachHang_WCFClient(); int idKhach = 0; int idPhong = p_wcf.GetIDPhong_by_SoPhong(txtSoPhong.Text.Trim()); foreach (var item in pck_wcf.GetPhieuCheckIns()) { if (item.Id_Phong == idPhong && item.TrangThaiHoaDon == 0) { idKhach = item.Id_khach; break; } } txtHoTenKH.Text = kh_wcf.getHoKhacHang_byID(idKhach) + " " + kh_wcf.getTenKhacHang_byID(idKhach); }
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(); } }