public ActionResult Details(int?id)
        {
            tbl_header hea = db.tbl_headers.SingleOrDefault(n => n.id == 1);

            Session["title"] = ViewBag.shoptitle;

            Session["icon"] = hea.shortcuticon;
            var CT_SP = (db.tbl_Products.First(sp => sp.ID == id));
            int loai  = int.Parse(CT_SP.IDLoaiSP.ToString());

            ViewBag.TenLoai = (from s in db.tbl_Products
                               from l in db.tbl_product_types
                               where s.ID == id && s.IDLoaiSP == l.ID && s.Status == true
                               select l);
            ViewBag.SP_cungloai = (from s in db.tbl_Products
                                   where s.ID == id && s.IDLoaiSP == loai && s.Status == true
                                   select s).Skip(0).Take(4).ToList();
            ViewBag.SP_khac = (from s in db.tbl_Products
                               where s.ID == id && s.IDLoaiSP != loai && s.Status == true
                               select s).Skip(0).Take(4).ToList();
            //CT_SP.LuotXem += 1;
            //UpdateModel(CT_SP);
            //db.SubmitChanges();
            ViewBag.Title       = CT_SP.title;
            ViewBag.keyword     = CT_SP.keyword;
            ViewBag.description = CT_SP.description;

            return(View(CT_SP));
        }
        public ActionResult ProductType(string id, int?page, string sorting)
        {
            tbl_header hea = db.tbl_headers.SingleOrDefault(n => n.id == 1);

            Session["title"] = ViewBag.shoptitle;

            Session["icon"] = hea.shortcuticon;

            int pageSize = 20;
            int pageNum  = (page ?? 1);

            var laysp = from g in db.tbl_Products
                        from h in db.tbl_product_types
                        where h.alias.Equals(id) && g.IDLoaiSP == h.ID && g.Status == true && h.Status == true
                        select g;

            Session["loai"] = id;
            tbl_product_type loai = db.tbl_product_types.SingleOrDefault(n => n.alias.Equals(id));

            Session["tenloai"] = loai.TenLoaiSP;
            ViewBag.TenLoai    = (from l in db.tbl_product_types
                                  where l.alias.Equals(id)
                                  select l);
            ViewBag.TenSapXep       = "Sắp xếp: A đến Z";
            ViewBag.NameSortParm    = "Name_desc";
            ViewBag.NameSortParmasc = "Name_asc";
            ViewBag.DateSortParm    = "Date_desc";
            ViewBag.PriceSortParm   = "Price_desc";
            ViewBag.PriceSortPasc   = "Price";
            if (sorting == "Name_desc")
            {
                ViewBag.TenSapXep = "Sắp xếp: Z đến A";
                return(View(laysp.OrderByDescending(n => n.TenSP).ToPagedList(pageNum, pageSize)));
            }
            if (sorting == "Name_asc")
            {
                ViewBag.TenSapXep = "Sắp xếp: A đến Z";
                return(View(laysp.OrderBy(n => n.TenSP).ToPagedList(pageNum, pageSize)));
            }
            if (sorting == "Date_desc")
            {
                ViewBag.TenSapXep = "Sản phẩm mới";
                return(View(laysp.OrderByDescending(n => n.NgayCapNhat).ToPagedList(pageNum, pageSize)));
            }
            if (sorting == "Price_desc")
            {
                ViewBag.TenSapXep = "Sắp xếp Giá: Cao Đến Thấp";
                return(View(laysp.OrderByDescending(n => n.GiaHienTai).ToPagedList(pageNum, pageSize)));
            }

            if (sorting == "Price")
            {
                ViewBag.TenSapXep = "Sắp xếp Giá: Thấp đến Cao";
                return(View(laysp.OrderBy(n => n.GiaHienTai).ToPagedList(pageNum, pageSize)));
            }
            return(View(laysp.ToPagedList(pageNum, pageSize)));
        }
        public ActionResult Search(string txttimkiem, string sorting, int?page)
        {
            tbl_header hea = db.tbl_headers.SingleOrDefault(n => n.id == 1);

            Session["icon"] = hea.shortcuticon;

            int    pageNum  = (page ?? 1);
            int    pageSize = 20;
            string tukhoa   = txttimkiem;

            if (String.IsNullOrEmpty(tukhoa))
            {
                tukhoa = "";
            }
            ViewBag.tukhoa     = tukhoa;
            Session["timkiem"] = txttimkiem;
            List <tbl_Product> sp = db.tbl_Products.Where(n => n.TenSP.Contains(tukhoa)).ToList();

            ViewBag.TenSapXep       = "Sắp xếp: A đến Z";
            ViewBag.NameSortParm    = "Name_desc";
            ViewBag.NameSortParmasc = "Name_asc";
            ViewBag.DateSortParm    = "Date_desc";
            ViewBag.PriceSortParm   = "Price_desc";
            ViewBag.PriceSortPasc   = "Price";
            if (sorting == "Name_desc")
            {
                ViewBag.TenSapXep = "Sắp xếp: Z đến A";
                return(View(sp.OrderByDescending(n => n.TenSP).ToPagedList(pageNum, pageSize)));
            }
            if (sorting == "Name_asc")
            {
                ViewBag.TenSapXep = "Sắp xếp: A đến Z";
                return(View(sp.OrderBy(n => n.TenSP).ToPagedList(pageNum, pageSize)));
            }
            if (sorting == "Date_desc")
            {
                ViewBag.TenSapXep = "Sản phẩm mới";
                return(View(sp.OrderByDescending(n => n.NgayCapNhat).ToPagedList(pageNum, pageSize)));
            }
            if (sorting == "Price_desc")
            {
                ViewBag.TenSapXep = "Sắp xếp Giá: Cao Đến Thấp";
                return(View(sp.OrderByDescending(n => n.GiaHienTai).ToPagedList(pageNum, pageSize)));
            }

            if (sorting == "Price")
            {
                ViewBag.TenSapXep = "Sắp xếp Giá: Thấp đến Cao";
                return(View(sp.OrderBy(n => n.GiaHienTai).ToPagedList(pageNum, pageSize)));
            }
            return(View(sp.OrderBy(n => n.TenSP).ToPagedList(pageNum, pageSize)));
        }
        public ActionResult hienthica3(int?page, string sorting)
        {
            tbl_header hea = db.tbl_headers.SingleOrDefault(n => n.id == 1);

            Session["icon"] = hea.shortcuticon;

            int pageSize = 20;
            int pageNum  = (page ?? 1);

            var laysp = from g in db.tbl_Products
                        where g.SachMoiMoiNgay == true && g.Status == true
                        orderby g.NgayCapNhat descending
                        select g;

            ViewBag.TenSapXep = "Sắp xếp: A đến Z";

            ViewBag.NameSortParm    = "Name_desc";
            ViewBag.NameSortParmasc = "Name_asc";
            ViewBag.DateSortParm    = "Date_desc";
            ViewBag.PriceSortParm   = "Price_desc";
            ViewBag.PriceSortPasc   = "Price";
            if (sorting == "Name_desc")
            {
                ViewBag.TenSapXep = "Sắp xếp: Z đến A";
                return(View(laysp.OrderByDescending(n => n.TenSP).ToPagedList(pageNum, pageSize)));
            }
            if (sorting == "Name_asc")
            {
                ViewBag.TenSapXep = "Sắp xếp: A đến Z";
                return(View(laysp.OrderBy(n => n.TenSP).ToPagedList(pageNum, pageSize)));
            }
            if (sorting == "Date_desc")
            {
                ViewBag.TenSapXep = "Sản phẩm mới";
                return(View(laysp.OrderByDescending(n => n.NgayCapNhat).ToPagedList(pageNum, pageSize)));
            }
            if (sorting == "Price_desc")
            {
                ViewBag.TenSapXep = "Sắp xếp Giá: Cao Đến Thấp";
                return(View(laysp.OrderByDescending(n => n.GiaHienTai).ToPagedList(pageNum, pageSize)));
            }

            if (sorting == "Price")
            {
                ViewBag.TenSapXep = "Sắp xếp Giá: Thấp đến Cao";
                return(View(laysp.OrderBy(n => n.GiaHienTai).ToPagedList(pageNum, pageSize)));
            }
            return(View(laysp.ToPagedList(pageNum, pageSize)));
        }
Esempio n. 5
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            // Your logic here...
            tbl_header hea  = db.tbl_headers.SingleOrDefault(n => n.id == 1);
            tbl_shop   shop = db.tbl_shops.SingleOrDefault(n => n.id == 1);

            Session["icon"]     = hea.shortcuticon;
            Session["title"]    = shop.title;
            Session.Timeout     = 40;
            ViewBag.Title       = shop.title;
            ViewBag.icon        = hea.shortcuticon;
            ViewBag.keyword     = shop.keyword;
            ViewBag.shoptitle   = shop.title;
            ViewBag.description = shop.description;
            base.OnActionExecuting(filterContext);
        }
        public ActionResult headerEdit(FormCollection form, HttpPostedFileBase fileUpload, HttpPostedFileBase fileUpload2)
        {
            tbl_header tic    = getHeader();
            var        tittle = form["tittle"];
            var        phone1 = form["phone1"];
            var        phone2 = form["phone2"];


            tic.phone1 = phone1;
            tic.phone2 = phone2;


            if (form["chkClearImg"] != null)
            {
                tic.image = "";
            }
            else if (fileUpload != null)
            {
                var fileName = Path.GetFileName(DateTime.Now.Millisecond + fileUpload.FileName);
                var path     = Path.Combine(Server.MapPath(URLHelper.URL_IMAGE_PATH), fileName);
                if (!System.IO.File.Exists(path))
                {
                    fileUpload.SaveAs(path);
                }
                tic.image = fileName;
            }

            if (form["chkClearImgIcon"] != null)
            {
                tic.shortcuticon = "";
            }
            else if (fileUpload2 != null)
            {
                var fileName = Path.GetFileName(DateTime.Now.Millisecond + fileUpload2.FileName);
                var path     = Path.Combine(Server.MapPath(URLHelper.URL_IMAGE_PATH), fileName);
                if (!System.IO.File.Exists(path))
                {
                    fileUpload2.SaveAs(path);
                }
                tic.shortcuticon = fileName;
            }


            UpdateModel(tic);
            data.SubmitChanges();
            return(RedirectToAction("Index", "Admin"));
        }
Esempio n. 7
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            Session.Timeout = 720;
            // Your logic here...
            tbl_header hea  = db.tbl_headers.SingleOrDefault(n => n.id == 1);
            tbl_shop   shop = db.tbl_shops.SingleOrDefault(n => n.id == 1);

            Session["icon"]             = hea.shortcuticon;
            Session["title"]            = shop.title;
            ViewBag.logo                = hea.image;
            ViewBag.Title               = shop.title;
            ViewBag.icon                = hea.shortcuticon;
            ViewBag.keyword             = shop.keyword;
            ViewBag.shoptitle           = shop.title;
            ViewBag.description         = shop.description;
            ViewBag.CurrentNumberFormat = new System.Globalization.CultureInfo("de-DE", false).NumberFormat;
            ViewBag.phone               = shop.phoneshop;
            base.OnActionExecuting(filterContext);
        }