Beispiel #1
0
            public List <BuildQuery.IQueryFilter> GetFilters()
            {
                var result = new List <IQueryFilter>();
                var refObj = new LOAIPHONG();

                if (!string.IsNullOrEmpty(this.MALOAIPHONG))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.MALOAIPHONG),
                        Value    = this.MALOAIPHONG,
                        Method   = FilterMethod.Like
                    });
                }
                if (!string.IsNullOrEmpty(this.TENLOAIPHONG))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.TENLOAIPHONG),
                        Value    = this.TENLOAIPHONG,
                        Method   = FilterMethod.Like
                    });
                }
                return(result);
            }
        public ActionResult LoaiPhongEdit([Bind(Include = "MA_LOAIPHONG,TEN_LOAIPHONG,KICHTHUOC,MAMAU,ANH")] LOAIPHONG lOAIPHONG)
        {
            if (ModelState.IsValid)
            {
                var img = Request.Files["ANH"];
                if (img.ContentLength > 0)
                {
                    string postedFileName = System.IO.Path.GetFileName(img.FileName);
                    var    path           = Server.MapPath("/Images/" + postedFileName);
                    img.SaveAs(path);
                    lOAIPHONG.ANH = postedFileName;
                }
                else
                {
                    lOAIPHONG.ANH = Request["anhcu"];
                }

                db.Entry(lOAIPHONG).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("LoaiPhongIndex"));
            }
            ViewBag.tag      = "loaiphong";
            ViewBag.username = ((LoginSessionModel)Session["session"]).name;
            return(View(lOAIPHONG));
        }
Beispiel #3
0
    public static Boolean SoSanh(LOAIPHONG A, LOAIPHONG B)
    {
        Boolean flag = A.Ten.CompareTo(B.Ten) == 0;

        flag = flag && A.DonGia == B.DonGia;
        return(flag);
    }
Beispiel #4
0
    public static String XuatChuoi(LOAIPHONG P)
    {
        String Chuoi = P.Ten + " : ";

        Chuoi = Chuoi + P.DonGia + " dong/ngay";
        return(Chuoi);
    }
Beispiel #5
0
        public async Task <IHttpActionResult> Delete(string id)
        {
            var       result   = new TransferObj <bool>();
            LOAIPHONG instance = await _service.Repository.FindAsync(id);

            if (instance == null)
            {
                return(NotFound());
            }
            try
            {
                _service.Delete(instance.ID);
                int del = await _service.UnitOfWork.SaveAsync();

                if (del > 0)
                {
                    result.Data    = true;
                    result.Status  = true;
                    result.Message = "Xóa thành công bản ghi";
                }
                else
                {
                    result.Data    = false;
                    result.Status  = false;
                    result.Message = "Thao tác không thành công";
                }
            }
            catch (Exception e)
            {
                result.Data    = false;
                result.Status  = false;
                result.Message = e.Message;
            }
            return(Ok(result));
        }
Beispiel #6
0
 public ActionResult Create(LOAIPHONG loaiphong)
 {
     if (ModelState.IsValid)
     {
         if (loaiphong.ANH == null)
         {
             loaiphong.ANH = "";
         }
         if (loaiphong.MOTA == null)
         {
             loaiphong.MOTA = "";
         }
         if (loaiphong.SOGIUONG == null)
         {
             loaiphong.SOGIUONG = 1;
         }
         if (cc.Create(loaiphong))
         {
             return(RedirectToAction("Index", "LoaiPhong"));
         }
         else
         {
             ModelState.AddModelError("", "Lỗi do trường dữ liệu nhập không hợp lệ");
         }
     }
     return(View());
 }
Beispiel #7
0
 public ActionResult Edit(LOAIPHONG LoaiPhong)
 {
     if (ModelState.IsValid)
     {
         if (LoaiPhong.ANH == null)
         {
             LoaiPhong.ANH = "";
         }
         if (LoaiPhong.MOTA == null)
         {
             LoaiPhong.MOTA = "";
         }
         if (LoaiPhong.SOGIUONG == null)
         {
             LoaiPhong.SOGIUONG = 1;
         }
         if (cc.SuaLOAIPHONG(LoaiPhong))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewBag.ThongBao = "Đã có tên dịch vụ " + LoaiPhong.TEN;
         }
     }
     return(View(LoaiPhong));
 }
        public ActionResult LoaiPhongCreate([Bind(Include = "MA_LOAIPHONG,TEN_LOAIPHONG,KICHTHUOC,MAMAU,ANH")] LOAIPHONG lOAIPHONG)
        {
            var    img            = Request.Files["ANH"];
            string postedFileName = System.IO.Path.GetFileName(img.FileName);
            var    path           = Server.MapPath("/Images/" + postedFileName);

            img.SaveAs(path);

            if (ModelState.IsValid)
            {
                int count = db.LOAIPHONGs.Where(phong => phong.MA_LOAIPHONG == lOAIPHONG.MA_LOAIPHONG).Count();

                if (count == 0)
                {
                    lOAIPHONG.ANH = postedFileName;
                    db.LOAIPHONGs.Add(lOAIPHONG);
                    db.SaveChanges();
                    return(RedirectToAction("LoaiPhongIndex"));
                }
                else
                {
                    ModelState.AddModelError("", "Loại phòng đã tồn tại");
                }
            }
            ViewBag.username = ((LoginSessionModel)Session["session"]).name;
            ViewBag.tag      = "loaiphong";
            return(View(lOAIPHONG));
        }
        public ActionResult DeleteConfirmed(string id)
        {
            LOAIPHONG lOAIPHONG = db.LOAIPHONGs.Find(id);

            db.LOAIPHONGs.Remove(lOAIPHONG);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #10
0
    public static Double TinhTien(LOAIPHONG P, PHIEUTHUE Phieu)
    {
        Double kq = 0;

        if (SoSanh(P, Phieu.LoaiPhong))
        {
            kq = (Double)(P.DonGia * Phieu.SoNgay);
        }
        return(kq);
    }
 public ActionResult Edit([Bind(Include = "MaLoai,TenLoai,ChiTiet")] LOAIPHONG lOAIPHONG)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lOAIPHONG).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(lOAIPHONG));
 }
Beispiel #12
0
        private void btn_luu_Click(object sender, EventArgs e)
        {
            LOAIPHONG lp = new LOAIPHONG();

            if (btn_them.Enabled == true)
            {
                lp.MALOAI  = txt_maloai.Text;
                lp.TENLOAI = txt_tenloai.Text;
                lp.GIA     = decimal.Parse(txt_gia.Text);
                if (txt_maloai.Text == string.Empty && txt_tenloai.Text == string.Empty && txt_gia.Text == string.Empty)
                {
                    MessageBox.Show("không được để trống");
                    return;
                }
                //kiểm tra khóa chính
                if (blp.ktkc_LoaiPhong(lp.MALOAI) == true)
                {
                    MessageBox.Show("Trùng khóa chính");
                    return;
                }
                if (blp.ThemLoaiPhong(lp) == true)
                {
                    grv_loaiPhong.DataSource = blp.loadBangLoaiPhong();
                    MessageBox.Show("Thành công");
                }
                else
                {
                    MessageBox.Show("Thất bại");
                }
                frm_loaiphong_Load(sender, e);
            }
            if (btn_sua.Enabled == true && btn_them.Enabled == false)
            {
                try
                {
                    if (txt_tenloai.Text == string.Empty || txt_gia.Text == string.Empty)
                    {
                        MessageBox.Show(" không được để trống");
                        return;
                    }
                    lp.MALOAI  = txt_maloai.Text;
                    lp.TENLOAI = txt_tenloai.Text;
                    lp.GIA     = decimal.Parse(txt_gia.Text);
                    if (blp.sua_LoaiPhong(lp) == true)
                    {
                        MessageBox.Show("Thành công");
                    }
                }
                catch
                {
                    MessageBox.Show("thất bại");
                }
            }
            frm_loaiphong_Load(sender, e);
        }
Beispiel #13
0
        public bool themLoaiPhong(string maloai, string tenloai)
        {
            LOAIPHONG loaiph = new LOAIPHONG();

            loaiph.MALOAIPH = maloai;
            loaiph.TENLOAI  = tenloai;
            db.LOAIPHONGs.InsertOnSubmit(loaiph);
            db.SubmitChanges();

            return(true);
        }
        public ActionResult Slider(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //tblPhong p = db.tblPhongs.Include(a => a.tblLoaiPhong).Where(a=>a.ma_phong==id).First();
            LOAIPHONG lp = db.LOAIPHONGs.Find(id);

            return(View(lp));
        }
Beispiel #15
0
        public bool XoaLoaiPhong(string maloai)
        {
            LOAIPHONG loaiph = (from lp in db.LOAIPHONGs
                                where (lp.MALOAIPH == maloai)
                                select lp).First();

            db.LOAIPHONGs.DeleteOnSubmit(loaiph);
            db.SubmitChanges();

            return(true);
        }
        public ActionResult Create([Bind(Include = "MaLoai,TenLoai,ChiTiet")] LOAIPHONG lOAIPHONG)
        {
            if (ModelState.IsValid)
            {
                db.LOAIPHONGs.Add(lOAIPHONG);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(lOAIPHONG));
        }
 public int ThemLoaiPhong(LOAIPHONG lp)
 {
     try
     {
         db.LOAIPHONGs.Add(lp);
         return(db.SaveChanges());
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
Beispiel #18
0
 public ActionResult Edit([Bind(Include = "MALOAI,MOTA,GIA,TILEPHUTHU,ANH")] LOAIPHONG tblLoaiPhong)
 {
     if (ModelState.IsValid)
     {
         if (tblLoaiPhong.ANH == null)
             tblLoaiPhong.ANH = "[\"/Content/Images/Phong/default.png\"]";
         db.Entry(tblLoaiPhong).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(tblLoaiPhong);
 }
Beispiel #19
0
        public bool Inseart()
        {
            var loaiphong = new LOAIPHONG()
            {
                ID      = 0,
                Ten     = view.Ten,
                GiaNgay = view.GiaNgay,
                GiaDem  = view.GiaDem
            };

            return(model.Insert(loaiphong));
        }
Beispiel #20
0
        public bool SuaLoaiPhong(string maloai, string tenloai)
        {
            LOAIPHONG loaiph = (from lp in db.LOAIPHONGs
                                where (lp.MALOAIPH == maloai)
                                select lp).First();

            loaiph.MALOAIPH = maloai;
            loaiph.TENLOAI  = tenloai;
            db.SubmitChanges();

            return(true);
        }
Beispiel #21
0
        public bool Update()
        {
            var ct = new LOAIPHONG()
            {
                ID      = view.ID,
                Ten     = view.Ten,
                GiaNgay = view.GiaNgay,
                GiaDem  = view.GiaDem
            };

            return(model.Update(ct));
        }
Beispiel #22
0
        public List <LOAIPHONG> LoadLoaiPhong()
        {
            DataTable        data = DataProvider.Instance.ExcuteQuery("pLoadLOAIPHONG");
            List <LOAIPHONG> res  = new List <LOAIPHONG>();

            foreach (DataRow item in data.Rows)
            {
                LOAIPHONG temp = new LOAIPHONG(item);
                res.Add(temp);
            }
            return(res);
        }
Beispiel #23
0
        public bool Delete(int maPhong)
        {
            LOAIPHONG loaiPhongExist = context.LOAIPHONGs.Find(maPhong);

            if (loaiPhongExist == null)
            {
                return(false);
            }
            loaiPhongExist.TrangThai = false;
            context.SaveChanges();
            return(true);
        }
Beispiel #24
0
 //Thêm
 public bool them_LoaiPhong(LOAIPHONG lp)
 {
     try
     {
         data.LOAIPHONGs.InsertOnSubmit(lp);
         data.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #25
0
        public bool Update(LOAIPHONG loaiPhong)
        {
            LOAIPHONG loaiPhongExist = context.LOAIPHONGs.Find(loaiPhong.Id_LoaiPhong);

            if (loaiPhongExist == null)
            {
                return(false);
            }
            loaiPhongExist.HinhAnh      = loaiPhong.HinhAnh;
            loaiPhongExist.TenLoaiPhong = loaiPhong.TenLoaiPhong;
            context.SaveChanges();
            return(true);
        }
Beispiel #26
0
        public ActionResult Index(LOAIPHONG loaiphong, TestDK test)
        {
            if (ModelState.IsValid)
            {
                ViewBag.var1 = new SelectList(cc.LoadLoaiPhong(), "ID", "TEN");// load loai phong len
                ViewBag.var2 = new SelectList(cc.LoadPhong(), "ID", "TENPHONG");

                ViewBag.id = new SelectList(loaiPhong, "id", "tenPhong", loaiphong.ID);
                idMaPhieu  = cc.DangKi(test.CMND, test.TenDK, test.DiaChi, test.SDT, test.TenCongTy);
                return(Redirect("Step2"));
            }
            return(View());
        }
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         LOAIPHONG tblLoaiPhong = db.LOAIPHONGs.Find(id);
         db.LOAIPHONGs.Remove(tblLoaiPhong);
         db.SaveChanges();
     }
     catch
     {
     }
     return(RedirectToAction("Index"));
 }
Beispiel #28
0
        public ActionResult Create([Bind(Include = "MOTA,GIA,TILEPHUTHU,ANH")] LOAIPHONG tblLoaiPhong)
        {
            if (ModelState.IsValid)
            {
                if (tblLoaiPhong.ANH == null)
                    tblLoaiPhong.ANH = "[\"/Content/Images/Phong/default.png\"]";
                db.LOAIPHONGs.Add(tblLoaiPhong);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(tblLoaiPhong);
        }
Beispiel #29
0
 // GET: LoaiPhong/Edit/5
 public ActionResult Edit(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     LOAIPHONG tblLoaiPhong = db.LOAIPHONGs.Find(id);
     if (tblLoaiPhong == null)
     {
         return HttpNotFound();
     }
     return View(tblLoaiPhong);
 }
Beispiel #30
0
 //Xóa
 public bool xoa_LoaiPhong(string pMaLoai)
 {
     try
     {
         LOAIPHONG lp = data.LOAIPHONGs.Where(t => t.MALOAI == pMaLoai).FirstOrDefault();
         data.LOAIPHONGs.DeleteOnSubmit(lp);
         data.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }