コード例 #1
0
        public bool ThemPhieuCheckIn(PhieuCheckIn_Ent phieucheckin_ent)
        {
            Phong phongID = db.Phongs.Where(n => n.id_Phong == phieucheckin_ent.Id_Phong && n.tinh_trang == 1).SingleOrDefault();

            if (phongID != null)
            {
                return(false);
            }

            try
            {
                PhieuCheck_In p = new PhieuCheck_In();
                p.id_phieu_checkin = phieucheckin_ent.Id_phieu_checkin;
                //p.id_DichVu = phieucheckin_ent.Id_DichVu;
                p.id_khach         = phieucheckin_ent.Id_khach;
                p.id_Phong         = phieucheckin_ent.Id_Phong;
                p.id_NhanVien      = phieucheckin_ent.Id_NhanVien;
                p.giam_gia         = phieucheckin_ent.Giam_gia;
                p.ngay_check_in    = phieucheckin_ent.Ngay_check_in;
                p.ngay_check_out   = phieucheckin_ent.Ngay_check_out;
                p.gio_check_in     = phieucheckin_ent.Gio_check_in;
                p.gio_check_out    = phieucheckin_ent.Gio_check_out;
                p.soLuongDichVu    = phieucheckin_ent.SoLuongDichVu;
                p.soLuongKhach     = phieucheckin_ent.SoLuongKhach;
                p.TrangThaiPhieuCK = 0;
                db.PhieuCheck_Ins.InsertOnSubmit(p);
                db.SubmitChanges();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
        public List <PhieuCheckIn_Ent> GetPhieuCheckIns_NoCheckOut_byIDKhach(int idKhach)
        {
            PhieuCheckIn_Ent        p_ent;
            List <PhieuCheckIn_Ent> ls = new List <PhieuCheckIn_Ent>();
            var p = db.PhieuCheck_Ins.Where(n => n.TrangThaiPhieuCK == 0 && n.id_khach == idKhach);

            if (p == null)
            {
                return(null);
            }
            else
            {
                foreach (var item in p)
                {
                    p_ent                  = new PhieuCheckIn_Ent();
                    p_ent.Id_Phong         = Convert.ToInt32(item.id_Phong);
                    p_ent.Id_phieu_checkin = item.id_phieu_checkin;
                    p_ent.Id_khach         = Convert.ToInt32(item.id_khach);
                    p_ent.Ngay_check_in    = (DateTime)item.ngay_check_in;
                    p_ent.Ngay_check_out   = (DateTime)item.ngay_check_out;
                    p_ent.Gio_check_in     = (TimeSpan)item.gio_check_in;
                    p_ent.Gio_check_out    = (TimeSpan)item.gio_check_out;
                    p_ent.Id_NhanVien      = Convert.ToInt32(item.id_NhanVien);
                    p_ent.Id_DichVu        = Convert.ToInt32(item.id_DichVu);
                    p_ent.SoLuongDichVu    = Convert.ToInt32(item.soLuongDichVu);
                    p_ent.TrangThaiHoaDon  = Convert.ToInt32(item.TrangThaiPhieuCK);
                    ls.Add(p_ent);
                }
            }
            return(ls);
        }
コード例 #3
0
        public bool ThemPhieuCheckIn_DichVu(PhieuCheckIn_Ent phieucheckin_ent)
        {
            var ph = db.PhieuCheck_Ins.Where(n => n.id_khach == phieucheckin_ent.Id_khach && n.TrangThaiPhieuCK == phieucheckin_ent.TrangThaiHoaDon);

            if (ph == null)
            {
                return(false);
            }
            foreach (var item in ph)
            {
                if (item.id_DichVu == null)
                {
                    db.PhieuCheck_Ins.DeleteOnSubmit(item);
                    db.SubmitChanges();
                }
            }
            try
            {
                PhieuCheck_In p = new PhieuCheck_In();
                p.id_phieu_checkin = phieucheckin_ent.Id_phieu_checkin;
                p.id_DichVu        = phieucheckin_ent.Id_DichVu;
                p.id_khach         = phieucheckin_ent.Id_khach;
                p.id_Phong         = phieucheckin_ent.Id_Phong;
                p.id_NhanVien      = phieucheckin_ent.Id_NhanVien;
                p.giam_gia         = phieucheckin_ent.Giam_gia;
                p.ngay_check_in    = phieucheckin_ent.Ngay_check_in;
                p.ngay_check_out   = phieucheckin_ent.Ngay_check_out;
                p.gio_check_in     = phieucheckin_ent.Gio_check_in;
                p.gio_check_out    = phieucheckin_ent.Gio_check_out;
                p.soLuongDichVu    = phieucheckin_ent.SoLuongDichVu;
                p.soLuongKhach     = phieucheckin_ent.SoLuongKhach;
                p.TrangThaiPhieuCK = phieucheckin_ent.TrangThaiHoaDon;
                db.PhieuCheck_Ins.InsertOnSubmit(p);
                db.SubmitChanges();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
コード例 #4
0
        public List <PhieuCheckIn_Ent> lsPhieuCheckIn_ToMonth(DateTime date)
        {
            PhieuCheckIn_Ent p_ent;

            List <PhieuCheckIn_Ent> ls = new List <PhieuCheckIn_Ent>();

            var p = db.PhieuCheck_Ins;

            if (p == null)
            {
                return(null);
            }
            else
            {
                foreach (var item in p)
                {
                    if (item.ngay_check_in.Value.Month == date.Month && item.ngay_check_in.Value.Year == date.Year)
                    {
                        p_ent                  = new PhieuCheckIn_Ent();
                        p_ent.Id_Phong         = Convert.ToInt32(item.id_Phong);
                        p_ent.Id_phieu_checkin = item.id_phieu_checkin;
                        p_ent.Id_khach         = Convert.ToInt32(item.id_khach);
                        p_ent.Ngay_check_in    = (DateTime)item.ngay_check_in;
                        p_ent.Ngay_check_out   = (DateTime)item.ngay_check_out;
                        p_ent.Gio_check_in     = (TimeSpan)item.gio_check_in;
                        p_ent.Gio_check_out    = (TimeSpan)item.gio_check_out;
                        p_ent.Id_NhanVien      = Convert.ToInt32(item.id_NhanVien);
                        p_ent.Id_DichVu        = Convert.ToInt32(item.id_DichVu);
                        p_ent.SoLuongDichVu    = Convert.ToInt32(item.soLuongDichVu);
                        p_ent.TrangThaiHoaDon  = Convert.ToInt32(item.TrangThaiPhieuCK);

                        ls.Add(p_ent);
                    }
                }
            }
            return(ls);
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
        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();
                }
            }
        }