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);
        }
        public bool CapNhatKhachHang(KhachHang_Ent kh_ent)
        {
            KhachHang kh = db.KhachHangs.Where(n => n.id_khach.Equals(kh_ent.Id_khach)).SingleOrDefault();

            if (kh == null)
            {
                return(false);
            }

            try
            {
                kh.ho            = kh_ent.Ho;
                kh.ten           = kh_ent.Ten;
                kh.date_of_birth = kh_ent.Date_of_birth;
                kh.so_cmnd       = kh_ent.So_cmnd;
                kh.so_dien_thoai = kh_ent.Sodienthoai;
                if (kh_ent.Gioi_tinh == "nam")
                {
                    kh.gioi_tinh = 1;
                }
                if (kh_ent.Gioi_tinh == "nu")
                {
                    kh.gioi_tinh = 0;
                }
                kh.quoc_tich = kh_ent.Quoc_tich;
                db.SubmitChanges();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
        public bool CapNhatDichVu(DichVu_Ent dv_ent)
        {
            DichVu     dv     = db.DichVus.Where(n => n.id_DichVu.Equals(dv_ent.Id_DichVu)).SingleOrDefault();
            LoaiDichVu loaiDV = db.LoaiDichVus.Where(n => n.ten_loai_dich_vu.Equals(dv_ent.TenLoaiDichVu)).SingleOrDefault();

            if (dv == null)
            {
                return(false);
            }

            if (loaiDV == null)
            {
                try
                {
                    LoaiDichVu ldv = new LoaiDichVu();

                    ldv.ten_loai_dich_vu = dv_ent.TenLoaiDichVu;

                    db.LoaiDichVus.InsertOnSubmit(ldv);
                    db.SubmitChanges();
                }
                catch
                {
                    return(false);
                }
            }

            db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.LoaiDichVus);

            try
            {
                dv.ten_dich_vu     = dv_ent.TenDichVu;
                dv.gia_dich_vu     = dv_ent.DonGia;
                dv.id_loai_dich_vu = db.LoaiDichVus.Where(n => n.ten_loai_dich_vu.Equals(dv_ent.TenLoaiDichVu)).SingleOrDefault().id_LoaiDichVu;

                db.SubmitChanges();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
        public bool CapNhatPhong(Phong_Ent phong_ent)
        {
            Phong p = db.Phongs.Where(n => n.id_Phong.Equals(phong_ent.Id_Phong)).SingleOrDefault();

            if (p == null)
            {
                return(false);
            }
            try
            {
                p.id_loai_phong  = Convert.ToInt32(phong_ent.Id_loai_phong);
                p.ghi_chu        = phong_ent.Ghi_chu;
                p.so_luong_nguoi = phong_ent.So_luong_nguoi;
                p.so_Phong       = phong_ent.So_Phong;
                p.tang           = phong_ent.Tang;
                db.SubmitChanges();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Beispiel #5
0
        public bool ThemNhanVien(NhanVien_Ent nv_ent, string matKhau)
        {
            NhanVien nv;

            NhanVien NVTestEmail = db.NhanViens.Where(n => n.email.Equals(nv_ent.Email)).SingleOrDefault();

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

            try
            {
                nv = new NhanVien();

                nv.ho  = nv_ent.Ho;
                nv.ten = nv_ent.Ten;

                if (nv_ent.GioiTinh == "nam")
                {
                    nv.gioi_tinh = 1;
                }
                if (nv_ent.GioiTinh == "nu")
                {
                    nv.gioi_tinh = 0;
                }

                nv.ngay_sinh = nv_ent.NgaySinh;

                if (nv_ent.ChucVu == "nhanvien")
                {
                    nv.chuc_vu = 2;
                }
                if (nv_ent.ChucVu == "quanly")
                {
                    nv.chuc_vu = 1;
                }

                if (nv_ent.CaLamViec == "sang")
                {
                    nv.ca_lam_viec = 1;
                }
                if (nv_ent.CaLamViec == "chieu")
                {
                    nv.ca_lam_viec = 2;
                }
                if (nv_ent.CaLamViec == "toi")
                {
                    nv.ca_lam_viec = 3;
                }

                nv.email    = nv_ent.Email;
                nv.mat_khau = matKhau;

                db.NhanViens.InsertOnSubmit(nv);
                db.SubmitChanges();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }