private void cbx_SoPhong_SelectedIndexChanged(object sender, EventArgs e) { Phong_WCFClient p_wcf = new Phong_WCFClient(); decimal donGia = 0; if (cbx_LoaiPhong.Text.Equals("Phòng Standard")) { donGia = p_wcf.DonGia("1"); } else if (cbx_LoaiPhong.Text.Equals("Phòng Deluxe")) { donGia = p_wcf.DonGia("2"); } else if (cbx_LoaiPhong.Text.Equals("Phòng Express View")) { donGia = p_wcf.DonGia("3"); } else { donGia = p_wcf.DonGia("4"); } txtTang.Text = cbx_SoPhong.Tag.ToString(); if (DateTime.Now.Hour < 14) { txtPhuThu.Text = (Convert.ToDecimal(0.3) * donGia).ToString(); } }
private void frmTextPhong_Load(object sender, EventArgs e) { if (kieuForm == 2) { Phong_WCFClient p_wcf = new Phong_WCFClient(); Phong_Ent p_ent = p_wcf.GetPhong_by_ID(id_Phong); txtSoPhong.Text = p_ent.So_Phong.Trim(); cbx_SoNguoi.Text = (p_ent.So_luong_nguoi.ToString()); cbx_Tang.Text = p_ent.Tang.ToString(); if (p_ent.Id_loai_phong.Equals("1")) { cbx_LoaiPhong.Text = "Phòng Standard"; } else if (p_ent.Id_loai_phong.Equals("2")) { cbx_LoaiPhong.Text = "Phòng Deluxe"; } if (p_ent.Id_loai_phong.Equals("3")) { cbx_LoaiPhong.Text = "Phòng Express View"; } else { cbx_LoaiPhong.Text = "Phòng VIP"; } } else { lbTieuDe.Text = Lb_TitleName; cbx_LoaiPhong.SelectedIndex = 0; cbx_SoNguoi.SelectedIndex = 0; cbx_Tang.SelectedIndex = 0; //cbx_TinhTrang.SelectedIndex = 0; } }
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)); foreach (PhieuCheckIn_Ent p_ent in dsPCI) { string nameServ = dv_wcf.GetTenDichVu_byIdDichVu(p_ent.Id_DichVu); 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()); } return(dt); }
private void btnXoa_Click(object sender, EventArgs e) { if (dgv_DSPhong.SelectedRows.Count == 0) { return; } DialogResult dr = MessageBox.Show("Bạn Có Muốn Xóa ?", "XÓA PHÒNG", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { if (dgv_DSPhong.SelectedRows.Count >= 1) { Phong_WCFClient p_wcf; for (int i = 0; i < dgv_DSPhong.SelectedRows.Count; i++) { string id = dgv_DSPhong.SelectedRows[i].Cells[0].Value.ToString().Trim(); p_wcf = new Phong_WCFClient(); if (!p_wcf.XoaPhong(id)) { break; } } p_wcf = new Phong_WCFClient(); Loading_DSP(DataTable_DSP(p_wcf.GetPhongs().ToList())); Custom_DataGridView(dgv_DSPhong); } } else { return; } }
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 frmTextPhong_FormClosing(object sender, FormClosingEventArgs e) { Phong_WCFClient p_wcf = new Phong_WCFClient(); frmQLP.Loading_DSP(frmQLP.DataTable_DSP(p_wcf.GetPhongs().ToList())); frmQLP.Custom_DataGridView(frmQLP.dgv_DSPhong); }
private void btnTimKiem_Click(object sender, EventArgs e) { Phong_WCFClient p_wcf = new Phong_WCFClient(); List <Phong_Ent> dsP = p_wcf.Tim_Kiem_By_SoPhong(txtTimKiem.Text).ToList(); Loading_DSP(DataTable_DSP(dsP)); Custom_DataGridView(dgv_DSPhong); }
private void frmQuanLyPhong_Load(object sender, EventArgs e) { btnReload.Image = imgs_Button.Images[0]; Phong_WCFClient p_wcf = new Phong_WCFClient(); List <Phong_Ent> dsP = p_wcf.GetPhongs().ToList(); Loading_DSP(DataTable_DSP(dsP)); Custom_DataGridView(dgv_DSPhong); }
void locPhong() { Phong_WCFClient p_wcf = new Phong_WCFClient(); foreach (var item in p_wcf.GetPhongTrong_byLoaiPhong(cbx_LoaiPhong.SelectedIndex)) { cbx_SoPhong.Items.Add(item.So_Phong); cbx_SoPhong.Tag = item.Tang; } }
private void btnReload_Click(object sender, EventArgs e) { cbx_Tang.SelectedIndex = 0; cbx_TinhTrang.SelectedIndex = 0; cbx_LoaiPhong.SelectedIndex = 0; txtTimKiem.Clear(); Phong_WCFClient p_wcf = new Phong_WCFClient(); List <Phong_Ent> dsP = p_wcf.GetPhongs().ToList(); Loading_DSP(DataTable_DSP(dsP)); Custom_DataGridView(dgv_DSPhong); }
private void cbx_LoaiPhong_SelectedIndexChanged(object sender, EventArgs e) { if (cbx_LoaiPhong.SelectedIndex == 0) { return; } else { Phong_WCFClient p_wcf = new Phong_WCFClient(); List <Phong_Ent> dsP = p_wcf.SapXepLoaiPhong(cbx_LoaiPhong.SelectedItem.ToString()).ToList(); Loading_DSP(DataTable_DSP(dsP)); Custom_DataGridView(dgv_DSPhong); } }
private void cbx_LoaiPhong_SelectedIndexChanged(object sender, EventArgs e) { cbx_SoPhong.Items.Clear(); locPhong(); TimeSpan date = dtpNgayTraPhong.Value - DateTime.Now.Date; if (isShowing || date.Days <= 0) { return; } Phong_WCFClient p_wcf = new Phong_WCFClient(); if (date.Days <= 0) { MessageBox.Show("Nhập Ngày Lớn Hơn Ngày Hiện Tại", "", MessageBoxButtons.OK, MessageBoxIcon.Error); dtpNgayTraPhong.Focus(); return; } else { decimal donGia = 0; if (cbx_LoaiPhong.Text.Equals("Phòng Standard")) { donGia = p_wcf.DonGia("1"); } else if (cbx_LoaiPhong.Text.Equals("Phòng Deluxe")) { donGia = p_wcf.DonGia("2"); } else if (cbx_LoaiPhong.Text.Equals("Phòng Express View")) { donGia = p_wcf.DonGia("3"); } else if (cbx_LoaiPhong.Text.Equals("Phòng VIP")) { donGia = p_wcf.DonGia("4"); } txtTienPhong.Text = (donGia * Convert.ToInt32(date.Days)).ToString(); } }
private void btnSua_Click(object sender, EventArgs e) { if (dgv_DSPhong.SelectedRows.Count == 1) { Phong_WCFClient ph_wcf = new Phong_WCFClient(); int id = ph_wcf.getIDPhong(dgv_DSPhong.SelectedRows[0].Cells[1].Value.ToString().Trim()); frmTextPhong ftph = new frmTextPhong(this, "Sửa Nhân Viên", id.ToString()); ftph.ShowDialog(); } else { MessageBox.Show("Chọn 1 Phòng Cần Sửa", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); return; } // string idp = dgv_DSPhong.SelectedRows[0].Cells[1].Value.ToString().Trim(); //// MessageBox.Show(idp); // frmTextPhong ftp = new frmTextPhong(this, "Sửa Phòng",idp); // ftp.ShowDialog(); }
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 dtpNgayTraPhong_ValueChanged(object sender, EventArgs e) { Phong_WCFClient p_wcf = new Phong_WCFClient(); TimeSpan date = dtpNgayTraPhong.Value - DateTime.Now.Date; if (date.Days <= 0) { MessageBox.Show("Nhập Ngày Lớn Hơn Ngày Hiện Tại", "", MessageBoxButtons.OK, MessageBoxIcon.Error); dtpNgayTraPhong.Focus(); } else if (cbx_LoaiPhong.Text.Equals("")) { MessageBox.Show("Chọn Loại Phòng Cần Đặt", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbx_LoaiPhong.Focus(); } else { decimal donGia = 0; if (cbx_LoaiPhong.Text.Equals("Phòng Standard")) { donGia = p_wcf.DonGia("1"); } else if (cbx_LoaiPhong.Text.Equals("Phòng Deluxe")) { donGia = p_wcf.DonGia("2"); } else if (cbx_LoaiPhong.Text.Equals("Phòng Express View")) { donGia = p_wcf.DonGia("3"); } else if (cbx_LoaiPhong.Text.Equals("Phòng VIP")) { donGia = p_wcf.DonGia("4"); } txtTienPhong.Text = (donGia * Convert.ToInt32(date.Days)).ToString(); } }
//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); }
private void Luu_Sua() { if (!CheckNull()) { MessageBox.Show("Chưa Nhập Đủ Thông Tin", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Phong_WCFClient p_wcf = new Phong_WCFClient(); Phong_Ent p_ent = new Phong_Ent(); p_ent.Id_Phong = Convert.ToInt32(id_Phong); p_ent.So_Phong = txtSoPhong.Text.Trim(); p_ent.Ghi_chu = txtGhiChu.Text.Trim(); if (cbx_LoaiPhong.SelectedIndex == 0) { p_ent.Id_loai_phong = "1"; } if (cbx_LoaiPhong.SelectedIndex == 1) { p_ent.Id_loai_phong = "2"; } if (cbx_LoaiPhong.SelectedIndex == 2) { p_ent.Id_loai_phong = "3"; } if (cbx_LoaiPhong.SelectedIndex == 3) { p_ent.Id_loai_phong = "4"; } if (cbx_Tang.SelectedIndex == 0) { p_ent.Tang = 1; } if (cbx_Tang.SelectedIndex == 1) { p_ent.Tang = 2; } if (cbx_Tang.SelectedIndex == 2) { p_ent.Tang = 3; } if (cbx_Tang.SelectedIndex == 3) { p_ent.Tang = 4; } if (cbx_SoNguoi.SelectedIndex == 0) { p_ent.So_luong_nguoi = 1; } if (cbx_SoNguoi.SelectedIndex == 1) { p_ent.So_luong_nguoi = 2; } if (cbx_SoNguoi.SelectedIndex == 2) { p_ent.So_luong_nguoi = 3; } if (cbx_SoNguoi.SelectedIndex == 3) { p_ent.So_luong_nguoi = 4; } if (cbx_SoNguoi.SelectedIndex == 4) { p_ent.So_luong_nguoi = 5; } if (p_wcf.CapNhatPhong(p_ent)) { DialogResult ds = MessageBox.Show("Lưu Thành Công, Tiếp Tục ?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ds == DialogResult.Yes) { Clear_TextBox(); return; } else { this.Close(); } } else { DialogResult ds = MessageBox.Show("Lưu Thất Bại, Thử Lại ?", "Lỗi", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (ds == DialogResult.Yes) { return; } else { this.Close(); } } }
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(); } }
private void btnLuuDatPhong_Click(object sender, EventArgs e) { TimeSpan date = dtpNgayTraPhong.Value - DateTime.Now.Date; if (date.Days <= 0) { MessageBox.Show("Nhập Ngày Lớn Hơn Ngày Hiện Tại", "", MessageBoxButtons.OK, MessageBoxIcon.Error); dtpNgayTraPhong.Focus(); return; } Phong_WCFClient ph_wcf = new Phong_WCFClient(); NhanVien_WCFClient nv_wcf = new NhanVien_WCFClient(); PhieuCheckIn_WCFClient phieu_wcf = new PhieuCheckIn_WCFClient(); PhieuCheckIn_Ent p_ent = new PhieuCheckIn_Ent(); if (!CheckNull()) { MessageBox.Show("Chưa Nhập Đủ Thông Tin", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } p_ent.Id_khach = Convert.ToInt32(maKH); p_ent.Id_NhanVien = ID_NV; p_ent.Id_Phong = ph_wcf.getIDPhong(cbx_SoPhong.Text); p_ent.Giam_gia = Convert.ToDouble(txtGiamGia.Text); p_ent.SoLuongKhach = Convert.ToInt32(cbox_SoNguoi.Text); p_ent.Ngay_check_in = Convert.ToDateTime(DateTime.Now.ToShortDateString()); TimeSpan gio_in = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); p_ent.Gio_check_in = gio_in; p_ent.Ngay_check_out = Convert.ToDateTime(dtpNgayTraPhong.Text.ToString()); TimeSpan gio_out = new TimeSpan(14, 00, 00); //p_ent.Id_DichVu = 0; p_ent.Gio_check_out = gio_out; if (phieu_wcf.ThemPhieuCheckIn(p_ent)) { DialogResult ds = MessageBox.Show("Lưu Thành Công, Tiếp Tục ?", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information); if (ds == DialogResult.OK) { List <PhieuCheckIn_Ent> list = new List <PhieuCheckIn_Ent>(); list = phieu_wcf.lsPhieuCheckIn_ToDate(DateTime.Now.Date).ToList(); ph_wcf.update_TinhTrangPhong(p_ent.Id_Phong, 1); Loading_DSP(DataTable_DSP(list)); Custom_DataGridView(dgv_DSPhieuCheckIn); return; } } else { DialogResult ds = MessageBox.Show("Lưu Thất Bại, Thử Lại ?", "Lỗi", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (ds == DialogResult.Yes) { return; } else { this.Close(); } } }