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

            tblagency.idUser = int.Parse(idUser);
            tblagency.Tag    = StringClass.NameToTag(tblagency.Name);
            db.tblAgencies.Add(tblagency);
            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("NhaPhanPhoi/" + StringClass.NameToTag(tblagency.Name) + "-" + tblagency.id + ".aspx", id, "Agency");
            Updatehistoty.UpdateHistory("Add tblagency", 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("/Agencyad/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("/Agencyad/Create"));
            }
            return(Redirect("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult AgencyDetail(string tag, tblAgency tblagencty)
        {
            int    idNew;
            string Chuoi = tag;

            string[] Mang   = Chuoi.Split('-');
            int      one    = int.Parse(Mang.Length.ToString());
            string   chuoi1 = Mang[one - 1].ToString();

            string[] Mang1 = chuoi1.Split('.');
            idNew      = int.Parse(Mang1[0].ToString());
            tblagencty = db.tblAgencies.Find(idNew);
            string chuoinew          = "";
            var    listManufacturers = db.tblAgencies.Where(p => p.idMenu == tblagencty.idMenu && p.id != tblagencty.id && p.Active == true).OrderByDescending(p => p.Ord).Take(3).ToList();

            for (int i = 0; i < listManufacturers.Count; i++)
            {
                chuoinew += "<a href=\"/NhaPhanPhoi/" + listManufacturers[i].Tag + "-" + listManufacturers[i].id + ".aspx\" title=\"" + listManufacturers[i].Name + "\"> - " + listManufacturers[i].Name + "</a>";
            }
            ViewBag.chuoinew    = chuoinew;
            ViewBag.Title       = "<title>" + tblagencty.Name + "</title>";
            ViewBag.Description = "<meta name=\"description\" content=\"" + tblagencty.Description + "\"/>";
            ViewBag.Keyword     = "<meta name=\"keywords\" content=\"" + tblagencty.Name + "\" /> ";
            //var GroupManufacturers = db.tblGroupAgencies.First(p => p.id == tblagencty.idMenu);
            //int dodai = GroupManufacturers.Level.Length / 5;
            //int idcate=int.Parse(tblagencty.idMenu.ToString());
            ViewBag.nUrl = "<a href=\"/\" title=\"Trang chu\" rel=\"nofollow\"><span class=\"iCon\"></span>Trang chủ</a> / Nhà phân phối";

            return(View(tblagencty));
        }
        public ActionResult ManufacturersDetail(string tag)
        {
            int    idNew;
            string Chuoi = tag;

            string[] Mang   = Chuoi.Split('-');
            int      one    = int.Parse(Mang.Length.ToString());
            string   chuoi1 = Mang[one - 1].ToString();

            string[] Mang1 = chuoi1.Split('.');
            idNew = int.Parse(Mang1[0].ToString());
            tblAgency tblmanufacturers = db.tblAgencies.Find(idNew);
            string    chuoinew         = "";
            var       listnew          = db.tblAgencies.Where(p => p.id != tblmanufacturers.id && p.Active == true).OrderByDescending(p => p.Ord).Take(3).ToList();

            for (int i = 0; i < listnew.Count; i++)
            {
                chuoinew += "<a href=\"/4/" + listnew[i].Tag + "-" + listnew[i].id + ".aspx\" title=\"" + listnew[i].Name + "\"> - " + listnew[i].Name + "</a>";
            }
            ViewBag.chuoinew    = chuoinew;
            ViewBag.Title       = "<title>" + tblmanufacturers.Name + "</title>";
            ViewBag.Description = "<meta name=\"description\" content=\"" + tblmanufacturers.Description + "\"/>";
            ViewBag.Keyword     = "<meta name=\"keywords\" content=\"" + tblmanufacturers.Name + "\" /> ";
            //var GroupManufacturer = db.tblGroupAgencies.First(p => p.id == tblmanufacturers.idMenu);
            //int dodai = GroupManufacturer.Level.Length / 5;
            //string nUrl = "";
            //for (int i = 0; i < dodai; i++)
            //{
            //    var NameGroups = db.tblGroupAgencies.First(p => p.Level.Substring(0, (i + 1) * 5) == GroupManufacturer.Level.Substring(0, (i + 1) * 5));
            //    nUrl = nUrl + " <a href=\"/9/" + NameGroups.Tag + " -" + NameGroups.id + ".aspx\" title=\"\"> " + " " + NameGroups.Name + "</a> /";
            //}
            ViewBag.nUrl = "<a href=\"/\" title=\"Trang chu\" rel=\"nofollow\"><span class=\"iCon\"></span>Trang chủ</a> / Hệ thống phân phối ";
            return(View(tblmanufacturers));
        }
        public ActionResult Create(tblAgency tblagency, FormCollection collection)
        {
            tblagency.DateCreate = DateTime.Now;
            string idUser = Request.Cookies["Username"].Values["UserID"];

            tblagency.idUser = int.Parse(idUser);
            tblagency.Tag    = StringClass.NameToTag(tblagency.Name);
            db.tblAgencies.Add(tblagency);
            db.SaveChanges();
            #region [Updatehistory]

            Updatehistoty.UpdateHistory("Add tblagency", 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("/Agencyad/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("/Agencyad/Create"));
            }
            return(Redirect("Index"));
        }
Ejemplo n.º 5
0
 public ActionResult DeleteAgency(int id)
 {
     if (ClsCheckRole.CheckQuyen(15, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
     {
         tblAgency tblagency = db.tblAgencies.Find(id);
         var       result    = string.Empty;
         db.tblAgencies.Remove(tblagency);
         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 }));
     }
 }
Ejemplo n.º 6
0
 public ActionResult Edit(int id = 0)
 {
     if ((Request.Cookies["Username"] == null))
     {
         return(RedirectToAction("LoginIndex", "Login"));
     }
     if (ClsCheckRole.CheckQuyen(15, 2, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
     {
         tblAgency tblagency = db.tblAgencies.Find(id);
         if (tblagency == null)
         {
             return(HttpNotFound());
         }
         return(View(tblagency));
     }
     else
     {
         return(Redirect("/Users/Erro"));
     }
 }
Ejemplo n.º 7
0
        // GET: Convert
        public ActionResult Index()
        {
            var listProduct = db.tblNews.ToList();

            foreach (var item in listProduct)
            {
                int    id         = item.id;
                tblNew tblproduct = db.tblNews.Find(id);
                tblproduct.Tag = StringClass.NameToTag(tblproduct.Name);
                db.SaveChanges();
            }
            var listProducts = db.tblGroupNews.ToList();

            foreach (var item in listProducts)
            {
                int         id         = item.id;
                tblGroupNew tblproduct = db.tblGroupNews.Find(id);
                tblproduct.Tag = StringClass.NameToTag(tblproduct.Name);
                db.SaveChanges();
            }
            var listProductss = db.tblAgencies.ToList();

            foreach (var item in listProductss)
            {
                int       id         = item.id;
                tblAgency tblproduct = db.tblAgencies.Find(id);
                tblproduct.Tag = StringClass.NameToTag(tblproduct.Name);
                db.SaveChanges();
            }
            var listProducstsss = db.tblGroupAgencies.ToList();

            foreach (var item in listProducstsss)
            {
                int            id         = item.id;
                tblGroupAgency tblproduct = db.tblGroupAgencies.Find(id);
                tblproduct.Tag = StringClass.NameToTag(tblproduct.Name);
                db.SaveChanges();
            }
            return(View());
        }
Ejemplo n.º 8
0
        public ActionResult Edit(tblAgency tblagency, int id, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                string idUser = Request.Cookies["Username"].Values["UserID"];
                tblagency.idUser = int.Parse(idUser);
                bool URL = (collection["URL"] == "false") ? false : true;
                if (URL == true)
                {
                    tblagency.Tag = StringClass.NameToTag(tblagency.Name);
                }
                else
                {
                    tblagency.Tag = collection["NameURL"];
                }

                tblagency.DateCreate      = DateTime.Now;
                db.Entry(tblagency).State = EntityState.Modified;

                db.SaveChanges();

                clsSitemap.UpdateSitemap("4/" + StringClass.NameToTag(tblagency.Name) + "-" + tblagency.id + ".aspx", id.ToString(), "Capacity");

                #region [Updatehistory]
                Updatehistoty.UpdateHistory("Edit Agency", 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("/Agencyad/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("/Agencyad/Create"));
                }
            }
            return(View(tblagency));
        }
Ejemplo n.º 9
0
        // GET: Capacityad
        public ActionResult Index(int?page, string id, FormCollection collection)
        {
            if ((Request.Cookies["Username"] == null))
            {
                return(RedirectToAction("LoginIndex", "Login"));
            }
            if (ClsCheckRole.CheckQuyen(15, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
            {
                var ListAgency = db.tblAgencies.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));
                                    tblAgency tblagency = db.tblAgencies.Find(ids);
                                    db.tblAgencies.Remove(tblagency);
                                    db.SaveChanges();
                                    return(RedirectToAction("Index"));
                                }
                                else
                                {
                                    return(Redirect("/Users/Erro"));
                                }
                            }
                        }
                    }
                }
                return(View(ListAgency.ToPagedList(pageNumber, pageSize)));
            }
            else
            {
                return(Redirect("/Users/Erro"));
            }
        }
Ejemplo n.º 10
0
        public ActionResult AgencyDetail(string tag)
        {
            tblAgency tblagency = db.tblAgencies.First(p => p.Tag == tag);

            ViewBag.Title         = "<title>" + tblagency.Name + "</title>";
            ViewBag.Description   = "<meta name=\"description\" content=\"" + tblagency.Description + "\"/>";
            ViewBag.Keyword       = "<meta name=\"keywords\" content=\"" + tblagency.Name + "\" /> ";
            ViewBag.imageog       = "<meta property=\"og:image\" content=\"http://thayloilocnuoc.com" + tblagency.Images + "\"/>";
            ViewBag.titleog       = "<meta property=\"og:title\" content=\"" + tblagency.Name + "\"/> ";
            ViewBag.site_nameog   = "<meta property=\"og:site_name\" content=\"" + tblagency.Description + "\"/> ";
            ViewBag.urlog         = "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\"/> ";
            ViewBag.descriptionog = "<meta property=\"og:description\" content=\"" + tblagency.Description + "\" />";
            string meta = "";

            ViewBag.canonical = "<link rel=\"canonical\" href=\"http://Thayloilocnuoc.com/5/" + tblagency.Tag + "\" />";

            meta        += "<meta itemprop=\"name\" content=\"" + tblagency.Name + "\" />";
            meta        += "<meta itemprop=\"url\" content=\"" + Request.Url.ToString() + "\" />";
            meta        += "<meta itemprop=\"description\" content=\"" + tblagency.Description + "\" />";
            meta        += "<meta itemprop=\"image\" content=\"http://Thayloilocnuoc.com" + tblagency.Images + "\" />";
            meta        += "<meta property=\"og:title\" content=\"" + tblagency.Name + "\" />";
            meta        += "<meta property=\"og:type\" content=\"product\" />";
            meta        += "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\" />";
            meta        += "<meta property=\"og:image\" content=\"http://Thayloilocnuoc.com" + tblagency.Images + "\" />";
            meta        += "<meta property=\"og:site_name\" content=\"http://Thayloilocnuoc.com\" />";
            meta        += "<meta property=\"og:description\" content=\"" + tblagency.Description + "\" />";
            meta        += "<meta property=\"fb:admins\" content=\"\" />";
            ViewBag.Meta = meta;


            int iduser = int.Parse(tblagency.idUser.ToString());

            ViewBag.User = db.tblUsers.First(p => p.id == iduser).UserName;
            int      idcate    = int.Parse(tblagency.idMenu.ToString());
            DateTime thoigian  = Convert.ToDateTime(tblagency.DateCreate);
            var      listgroup = db.tblAgencies.Where(p => p.Active == true && p.idMenu == idcate && p.DateCreate < thoigian && p.Tag != tag).Take(10).ToList();
            string   chuoiag   = "";

            for (int i = 0; i < listgroup.Count; i++)
            {
                chuoiag += " <a href=\"/5/" + listgroup[i].Tag + "\" title=\"" + listgroup[i].Name + "\">- " + listgroup[i].Name + "</a>";
            }
            ViewBag.chuoiag = chuoiag;
            var groupagency = db.tblGroupAgencies.First(p => p.id == idcate);

            ViewBag.name = groupagency.Name;
            int    dodai = groupagency.Level.Length / 5;
            string nUrl  = "";

            for (int i = 0; i < dodai; i++)
            {
                int leht       = groupagency.Level.Substring(0, (i + 1) * 5).Length;
                var NameGroups = db.tblGroupAgencies.First(p => p.Level.Substring(0, (i + 1) * 5) == groupagency.Level.Substring(0, (i + 1) * 5) && p.Level.Length == (i + 1) * 5);
                nUrl = nUrl + "  <a href=\"/4/" + NameGroups.Tag + "\" title=\"" + NameGroups.Name + "\"> " + " " + NameGroups.Name + " /</a>  ";
            }
            ViewBag.nUrl = " <a href=\"/\" title=\"Trang chu\" rel=\"nofollow\"><span class=\"icon_Homes\"></span>Trang chủ /</a> " + nUrl + " ";

            string tab      = tblagency.Tabs;
            string Tabsnews = "";

            if (tab != null)
            {
                List <int> mangidPd = new List <int>();

                string[] mang     = tab.Split(',');
                int      id       = int.Parse(tblagency.id.ToString());
                string   chuoitab = "";
                Tabsnews  = "<div class=\"Tabs\">";
                Tabsnews += " <span>Tags</span>";
                for (int i = 0; i < mang.Length; i++)
                {
                    Tabsnews += " <a href=\"/TabAgency/" + mang[i] + "\" title=\"" + mang[i] + "\">" + mang[i] + "</a>";

                    string tabs  = mang[i];
                    var    lnews = db.tblAgencies.Where(p => p.Tabs.Contains(tabs) && p.Active == true).ToList();
                    for (int j = 0; j < lnews.Count; j++)
                    {
                        int idn = int.Parse(lnews[j].id.ToString());
                        mangidPd.Add(idn);
                    }
                }
                Tabsnews        += "</div>";
                ViewBag.tabsnews = Tabsnews;
                var listnews = db.tblAgencies.Where(p => mangidPd.Contains(p.id) && p.Active == true && p.id != id).OrderByDescending(p => p.DateCreate).Take(2).ToList();
                if (listnews.Count > 0)
                {
                    chuoitab += "<div class=\"Tintuclienquan\">";
                    for (int j = 0; j < listnews.Count; j++)
                    {
                        chuoitab += " <a href=\"/5/" + listnews[j].Tag + "\" title=\"" + listnews[j].Name + "\">› " + listnews[j].Name + "</a>";
                    }
                    chuoitab += " </div>";
                }
                ViewBag.chuoitab = chuoitab;
            }
            ViewBag.favicon = " <link href=\"" + db.tblConfigs.First().Favicon + "\" rel=\"icon\" type=\"image/x-icon\" />";
            var    listGroupAgency = db.tblGroupAgencies.Where(p => p.Active == true).OrderByDescending(p => p.Ord).ToList();
            string chuoi           = "";

            for (int i = 0; i < listGroupAgency.Count; i++)
            {
                chuoi += "<a href=\"/4/" + listGroupAgency[i].Tag + "\" title=\"" + listGroupAgency[i].Name + "\">› " + listGroupAgency[i].Name + "</a>";
            }
            ViewBag.chuoi = chuoi;
            return(View(tblagency));
        }