Example #1
0
        public ActionResult Status(Int16?id)
        {
            int res;

            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            loaitin loaitin = db.loaitins.Find(id);

            if (loaitin.status == 1)
            {
                //res_count = mod.Count_Status_Tl(id, 2);
                loaitin.status = 2;
                res            = mod.Update_Status_TT(id, 2);
            }
            else
            {
                loaitin.status = 1;
                res            = mod.Update_Status_TT(id, 1);
            }
            db.Entry(loaitin).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Edit(loaitailieu loaitailieu)
 {
     if (ModelState.IsValid)
     {
         if (loaitailieu.MaLoai != null)
         {
             try
             {
                 db.Entry(loaitailieu).State = EntityState.Modified;
                 db.SaveChanges();
                 ViewBag.tam     = 1;
                 ViewBag.Message = "Update data success!";
             }
             catch
             {
                 ViewBag.tam     = 2;
                 ViewBag.Message = "Update data failed!";
             }
         }
         else
         {
             ViewBag.tam     = 2;
             ViewBag.Message = "The input data is empty!";
         }
     }
     return(View(loaitailieu));
 }
Example #3
0
        public ActionResult Edit(vanban vanban)
        {
            ViewBag.Idloaivb  = new SelectList(db.loaivanbans, "id", "TenLoaiVB");
            ViewBag.Nguoidang = new SelectList(db.users, "id", "name");
            if (ModelState.IsValid)
            {
                //upload file
                var f = Request.Files["img[]"];
                if (f != null && f.ContentLength > 0)
                {
                    string TenFile   = DateTime.Now.ToString("ddMMyyyyHHmmss") + "_" + f.FileName;
                    string pathfiles = Path.Combine(Server.MapPath("~/File/"), TenFile);
                    vanban.TenFile = TenFile;
                    vanban.Url     = "~/File/" + TenFile;
                    f.SaveAs(pathfiles);
                }

                db.Entry(vanban).State = EntityState.Modified;
                db.SaveChanges();
                ViewBag.tam     = 1;
                ViewBag.Message = "Update data successfully!";
            }
            ViewBag.Idloaivb  = new SelectList(db.loaivanbans, "id", "TenLoaiVB", vanban.Idloaivb);
            ViewBag.Nguoidang = new SelectList(db.users, "id", "name", vanban.Nguoidang);
            return(View(vanban));
        }
 public ActionResult Edit(loaivanban loaivanban)
 {
     if (ModelState.IsValid)
     {
         if (loaivanban.TenLoaiVB != null)
         {
             loaivanban.DateUpdate = DateTime.Now;
             try
             {
                 db.Entry(loaivanban).State = EntityState.Modified;
                 db.SaveChanges();
                 ViewBag.tam     = 1;
                 ViewBag.Message = "Update data success!";
             }
             catch
             {
                 ViewBag.tam     = 2;
                 ViewBag.Message = "Update data failed!";
             }
         }
         else
         {
             ViewBag.tam     = 2;
             ViewBag.Message = "The input data is empty!";
         }
     }
     return(View(loaivanban));
 }
Example #5
0
        public ActionResult Edit(PhanQuyen phanQuyen)
        {
            if (ModelState.IsValid)
            {
                if (phanQuyen.id != null)
                {
                    if (phanQuyen.Quyen == false)//user
                    {
                        phanQuyen.mVanban     = true;
                        phanQuyen.mTheloaiTin = false;
                        phanQuyen.mLoaiTin    = false;
                        phanQuyen.mTinTuc     = false;
                        phanQuyen.mTaiLieu    = true;
                        phanQuyen.mGioiThieu  = false;
                        phanQuyen.mLienHe     = false;
                        phanQuyen.mLoaivanban = true;
                        phanQuyen.mQuantri    = false;
                    }
                    else
                    {
                        phanQuyen.mVanban     = true;
                        phanQuyen.mTheloaiTin = true;
                        phanQuyen.mLoaiTin    = true;
                        phanQuyen.mTinTuc     = true;
                        phanQuyen.mTaiLieu    = true;
                        phanQuyen.mGioiThieu  = true;
                        phanQuyen.mLienHe     = true;
                        phanQuyen.mLoaivanban = true;
                        phanQuyen.mQuantri    = true;
                    }
                    try
                    {
                        db.Entry(phanQuyen).State = EntityState.Modified;
                        db.SaveChanges();
                        ViewBag.tam     = 1;
                        ViewBag.Message = "Update data success!";
                    }
                    catch
                    {
                        ViewBag.tam     = 2;
                        ViewBag.Message = "Update data failed!";
                    }
                }
                else
                {
                    ViewBag.tam     = 2;
                    ViewBag.Message = "The input data is empty!";
                }
            }
            var user =
                db.users
                .Select(s => new
            {
                id       = s.id,
                username = s.id + " - " + s.name
            }).ToList();

            ViewBag.id = new SelectList(user, "id", "username", phanQuyen.id);
            return(View(phanQuyen));
        }
        [ValidateJsonAntiForgeryToken]//check token
        public JsonResult Deltrash(int?id)
        {
            bool result = false;

            try
            {
                tailieu tailieu = db.tailieux.Find(id);
                tailieu.status          = 0;
                db.Entry(tailieu).State = EntityState.Modified;
                db.SaveChanges();
                result = true;
            }
            catch
            {
                result = false;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Status(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            tintuc tintuc = db.tintucs.Find(id);

            if (tintuc.status == 1)
            {
                tintuc.status = 2;
            }
            else
            {
                tintuc.status = 1;
            }
            db.Entry(tintuc).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Idvanban,Donvinhan,Ngayphathanh")] Banhanhvb banhanhvb)
 {
     if (ModelState.IsValid)
     {
         db.Entry(banhanhvb).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Idvanban = new SelectList(db.vanbans, "Id", "Sovb", banhanhvb.Idvanban);
     ViewBag.Idvanban = new SelectList(db.vanbans, "Id", "Sovb", banhanhvb.Idvanban);
     return(View(banhanhvb));
 }
Example #9
0
 public ActionResult Edit(user user)
 {
     if (ModelState.IsValid)
     {
         user.updated_at = DateTime.Now;
         try
         {
             if (string.IsNullOrEmpty(user.password))
             {
                 var user_tmp = new user()
                 {
                     id = user.id, name = user.name, email = user.email, created_at = user.created_at, updated_at = user.updated_at, donvi = user.donvi
                 };
                 db.Entry(user_tmp).State = EntityState.Modified;
                 db.SaveChanges();
                 ViewBag.tam     = 1;
                 ViewBag.Message = "Update data success!";
                 //db.users.Attach(user);
                 //db.Entry(user).Property(x => x.name).IsModified = true;
             }
             else
             {
                 db.Entry(user).State = EntityState.Modified;
                 db.SaveChanges();
                 ViewBag.tam     = 1;
                 ViewBag.Message = "Update data success!";
             }
         }
         catch
         {
             ViewBag.tam     = 2;
             ViewBag.Message = "Update data failed!";
         }
     }
     ViewBag.donvi = new SelectList(db.DonVis, "MS_DV", "TenDonVi", user.donvi);
     return(View(user));
 }
Example #10
0
        public ActionResult Status(int?id)
        {
            int res;

            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            theloai theloai = db.theloais.Find(id);

            if (theloai.status == 1)
            {
                theloai.status = 2;
                res            = mod.Update_Status_LT(id, 2);
            }
            else
            {
                theloai.status = 1;
                res            = mod.Update_Status_LT(id, 1);
            }
            db.Entry(theloai).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void Update(TEntity entity)
 {
     _dbSet.Attach(entity);
     _dbContext.Entry(entity).State = EntityState.Modified;
 }