Exemplo n.º 1
0
        public ActionResult Create(tblCapacity tblcapacity, FormCollection collection)
        {
            tblcapacity.DateCreate = DateTime.Now;
            string idUser = Request.Cookies["Username"].Values["UserID"];

            tblcapacity.idUser = int.Parse(idUser);
            tblcapacity.Tag    = StringClass.NameToTag(tblcapacity.Name);
            db.tblCapacities.Add(tblcapacity);
            db.SaveChanges();
            #region [Updatehistory]
            var    Groups = db.tblCapacities.Where(p => p.Active == true).OrderByDescending(p => p.id).Take(1).ToList();
            string id     = Groups[0].id.ToString();
            clsSitemap.CreateSitemap("loi-loc/" + StringClass.NameToTag(tblcapacity.Name), id, "Capacity");
            Updatehistoty.UpdateHistory("Add tblcapacity", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString());
            #endregion
            if (collection["btnSave"] != null)
            {
                Session["Thongbao"] = "<div  class=\"alert alert-info alert1\">Bạn đã thêm thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";

                return(Redirect("/Capacityad/Index"));
            }
            if (collection["btnSaveCreate"] != null)
            {
                Session["Thongbao"] = "<div  class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm danh mục  mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";
                return(Redirect("/Capacityad/Create"));
            }
            return(Redirect("Index"));
        }
Exemplo n.º 2
0
        public void Add()
        {
            var addCapacity = new tblCapacity
            {
                CapacityName = DCapacityName
            };

            _dbHavalehEntities.tblCapacity.Add(addCapacity);
            _dbHavalehEntities.SaveChanges();
        }
Exemplo n.º 3
0
 public ActionResult DeleteCapacity(int id)
 {
     if (ClsCheckRole.CheckQuyen(14, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
     {
         tblCapacity tblcap = db.tblCapacities.Find(id);
         var         result = string.Empty;
         db.tblCapacities.Remove(tblcap);
         db.SaveChanges();
         result = "Bạn đã xóa thành công.";
         return(Json(new { result = result }));
     }
     else
     {
         var result = string.Empty;
         result = "Bạn không có quyền thay đổi tính năng này";
         return(Json(new { result = result }));
     }
 }
Exemplo n.º 4
0
 public ActionResult Edit(int id = 0)
 {
     if ((Request.Cookies["Username"] == null))
     {
         return(RedirectToAction("LoginIndex", "Login"));
     }
     if (ClsCheckRole.CheckQuyen(14, 2, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
     {
         tblCapacity tblcap = db.tblCapacities.Find(id);
         if (tblcap == null)
         {
             return(HttpNotFound());
         }
         return(View(tblcap));
     }
     else
     {
         return(Redirect("/Users/Erro"));
     }
 }
Exemplo n.º 5
0
        public ActionResult Edit(tblCapacity tblcapacity, int id, FormCollection collection)
        {
            string idUser = Request.Cookies["Username"].Values["UserID"];

            tblcapacity.idUser = int.Parse(idUser);
            bool URL = (collection["URL"] == "false") ? false : true;

            if (URL == true)
            {
                tblcapacity.Tag = StringClass.NameToTag(tblcapacity.Name);
            }
            else
            {
                tblcapacity.Tag = collection["NameURL"];
            }
            tblcapacity.DateCreate      = DateTime.Now;
            db.Entry(tblcapacity).State = EntityState.Modified;
            db.SaveChanges();
            clsSitemap.UpdateSitemap("loi-loc/" + StringClass.NameToTag(tblcapacity.Name), id.ToString(), "Capacity");
            #region [Updatehistory]
            Updatehistoty.UpdateHistory("Edit tblcapacity", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString());
            #endregion
            if (collection["btnSave"] != null)
            {
                Session["Thongbao"] = "<div  class=\"alert alert-info alert1\">Bạn đã sửa  thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";

                return(Redirect("/Capacityad/Index"));
            }
            if (collection["btnSaveCreate"] != null)
            {
                Session["Thongbao"] = "<div  class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";
                return(Redirect("/Capacityad/Create"));
            }

            return(View(tblcapacity));
        }
Exemplo n.º 6
0
        // GET: Capacityad
        public ActionResult Index(int?page, string id, FormCollection collection)
        {
            if ((Request.Cookies["Username"] == null))
            {
                return(RedirectToAction("LoginIndex", "Login"));
            }
            if (ClsCheckRole.CheckQuyen(14, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
            {
                var ListCap = db.tblCapacities.OrderBy(p => p.Ord).ToList();

                const int pageSize   = 20;
                var       pageNumber = (page ?? 1);
                // Thiết lập phân trang
                var ship = new PagedListRenderOptions
                {
                    DisplayLinkToFirstPage                      = PagedListDisplayMode.Always,
                    DisplayLinkToLastPage                       = PagedListDisplayMode.Always,
                    DisplayLinkToPreviousPage                   = PagedListDisplayMode.Always,
                    DisplayLinkToNextPage                       = PagedListDisplayMode.Always,
                    DisplayLinkToIndividualPages                = true,
                    DisplayPageCountAndCurrentLocation          = false,
                    MaximumPageNumbersToDisplay                 = 5,
                    DisplayEllipsesWhenNotShowingAllPageNumbers = true,
                    EllipsesFormat                     = "&#8230;",
                    LinkToFirstPageFormat              = "Trang đầu",
                    LinkToPreviousPageFormat           = "«",
                    LinkToIndividualPageFormat         = "{0}",
                    LinkToNextPageFormat               = "»",
                    LinkToLastPageFormat               = "Trang cuối",
                    PageCountAndCurrentLocationFormat  = "Page {0} of {1}.",
                    ItemSliceAndTotalFormat            = "Showing items {0} through {1} of {2}.",
                    FunctionToDisplayEachPageNumber    = null,
                    ClassToApplyToFirstListItemInPager = null,
                    ClassToApplyToLastListItemInPager  = null,
                    ContainerDivClasses                = new[] { "pagination-container" },
                    UlElementClasses                   = new[] { "pagination" },
                    LiElementClasses                   = Enumerable.Empty <string>()
                };
                ViewBag.ship = ship;
                if (Session["Thongbao"] != null && Session["Thongbao"] != "")
                {
                    ViewBag.thongbao    = Session["Thongbao"].ToString();
                    Session["Thongbao"] = "";
                }
                if (collection["btnDelete"] != null)
                {
                    foreach (string key in Request.Form.Keys)
                    {
                        var checkbox = "";
                        if (key.StartsWith("chk_"))
                        {
                            checkbox = Request.Form["" + key];
                            if (checkbox != "false")
                            {
                                if (ClsCheckRole.CheckQuyen(14, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
                                {
                                    int         ids         = Convert.ToInt32(key.Remove(0, 4));
                                    tblCapacity tblcapacity = db.tblCapacities.Find(ids);
                                    db.tblCapacities.Remove(tblcapacity);
                                    db.SaveChanges();
                                    return(RedirectToAction("Index"));
                                }
                                else
                                {
                                    return(Redirect("/Users/Erro"));
                                }
                            }
                        }
                    }
                }
                return(View(ListCap.ToPagedList(pageNumber, pageSize)));
            }
            else
            {
                return(Redirect("/Users/Erro"));
            }
        }