Example #1
0
        public ActionResult ViewBL()
        {
            var model = new SANPHAMFunction().ViewBL();
            var query = model.OrderByDescending(p => p.username);

            return(PartialView(query.ToList()));
        }
Example #2
0
        public ActionResult SPKhuyenMai()
        {
            var model = new SANPHAMFunction().SPKhuyenMai();
            var query = model.OrderByDescending(p => p.ID_KM);

            return(View(query.ToList()));
        }
 public ActionResult Create(SANPHAM model, HttpPostedFileBase file)
 {
     try
     {
         // TODO: Add insert logic here
         //
         if (file == null)
         {
             ModelState.AddModelError("File", "Please Upload Your file");
         }
         else if (file.ContentLength > 0)
         {                 //TO:DO
             var fileName = Path.GetFileName(file.FileName);
             var path     = Path.Combine(Server.MapPath("~/Content/images"), fileName);
             file.SaveAs(path);
             //     ModelState.Clear();
             // TODO: Add insert logic here
             model.ImgLink = fileName;
             SANPHAMFunction _sanphamF = new SANPHAMFunction();
             _sanphamF.Insert(model);
             // Upload File đẩy về Server
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult TimKiemSanPhamAdmin(string txttimkiem, int?page)
        {
            int pageNumber = (page ?? 1);
            int pageSize   = 7;
            var sp         = new SANPHAMFunction().SANPHAMs.Where(p => p.tensanpham.Contains(txttimkiem));

            return(View(sp.ToList().OrderBy(n => n.ID_SP).ToPagedList(pageNumber, pageSize)));
        }
Example #5
0
        // [HttpPost]
        public ActionResult KQTimKiem(string txttimkiem, int?page)
        {
            var db       = new SANPHAMFunction();
            var products = db.SANPHAMs.Where(p => string.IsNullOrEmpty(p.tensanpham) == false &&
                                             p.tensanpham.ToLower().Contains(txttimkiem))
                           .ToList();

            return(View());
        }
        //
        // GET: /Admin/SANPHAMADMIN/
        public ActionResult Index(int?page)
        {
            int pageNumber = (page ?? 1);
            int pageSize   = 12;
            var sp         = new SANPHAMFunction().SANPHAMs
                             .Where(p => p.ID_SP != null);

            return(View(sp.ToList().OrderBy(n => n.ID_SP).ToPagedList(pageNumber, pageSize)));
        }
        //
        // GET: /Admin/SANPHAMADMIN/Edit/5
        public ActionResult Edit(int id)
        {
            var model = new SANPHAMFunction().FindEntity(id);
            var dao   = new DANHMUCFunction.DanhMucFunction().DANHMUCs;

            ViewBag.ID_DM = new SelectList(dao, "ID_DM", "tendanhmuc", model.ID_DM);
            var test = new SelectList(dao, "ID_DM", "tendanhmuc", model.ID_DM);

            return(View(model));
        }
        public ActionResult RemoveLine(int Id)
        {
            var product = new SANPHAMFunction().FindEntity(Id);;
            var cart    = (Cart)Session[CartSession];

            if (cart != null)
            {
                cart.RemoveLine(product);
                //Gán vào session
                Session[CartSession] = cart;
            }
            return(RedirectToAction("Index"));
        }
Example #9
0
        public ActionResult FilterSPofDM(int?id)
        {
            var     db      = new SANPHAMFunction();
            MyDB    context = new MyDB();
            DANHMUC dm      = context.DANHMUCs.Find(id);

            if (dm != null)
            {
                ViewBag.TenDM = dm.tendanhmuc;
            }
            var sp = db.SANPHAMs.Where(p => p.ID_DM == id);

            return(View(sp));
        }
Example #10
0
        public ActionResult Delete(int id, SANPHAM model)
        {
            try
            {
                model.ID_SP = id;
                var result = new SANPHAMFunction().Delete(model);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public RedirectToRouteResult AddToCart(int id)
        {
            var product = new SANPHAMFunction().FindEntity(id);;
            var cart    = (Cart)Session[CartSession];

            if (cart != null)
            {
                cart.AddItem(product, 1);
                //Gán vào session
                Session[CartSession] = cart;
            }
            else
            {
                //tạo mới đối tượng cart item
                cart = new Cart();
                cart.AddItem(product, 1);
                //Gán vào session
                Session[CartSession] = cart;
            }
            return(RedirectToAction("Index", "Cart"));
        }
Example #12
0
        public ActionResult AllProducer(string keyword, int?page)
        {
            int pageNumber   = (page ?? 1);
            int itemsPerPage = 16;

            var db = new SANPHAMFunction();

            var products = db.SANPHAMs.ToList();
            var pageSize = products.Count / itemsPerPage;

            var sp = products
                     .Where(p => p.ID_SP != null)
                     .OrderBy(p => p.tensanpham)
                     .ToList();

            if (!string.IsNullOrEmpty(keyword) && !string.IsNullOrWhiteSpace(keyword))
            {
                sp = sp.Where(p => !string.IsNullOrEmpty(p.tensanpham) && p.tensanpham.ToLower().Contains(keyword.ToLower()))
                     .ToList();
            }
            return(View(sp.OrderBy(n => n.ID_SP).ToPagedList(pageNumber, itemsPerPage)));
        }
Example #13
0
        public ActionResult KhoangGia(string keyword, int?page, int?cantren, int?canduoi)
        {
            int pageNumber   = (page ?? 1);
            int itemsPerPage = 12;
            int?ct           = cantren;
            int?cd           = canduoi;
            var db           = new SANPHAMFunction();

            var products = db.SANPHAMs.ToList();
            var pageSize = products.Count / itemsPerPage;

            var sp = products
                     .Where(p => p.giabd > cd & p.giabd <= ct)
                     .OrderBy(p => p.tensanpham)
                     .ToList();

            if (!string.IsNullOrEmpty(keyword) && !string.IsNullOrWhiteSpace(keyword))
            {
                sp = sp.Where(p => !string.IsNullOrEmpty(p.tensanpham) && p.tensanpham.ToLower().Contains(keyword.ToLower()))
                     .ToList();
            }
            return(View("AllProducer", sp.OrderBy(n => n.ID_SP).ToPagedList(pageNumber, itemsPerPage)));
        }
Example #14
0
        public ActionResult Details(int id)
        {
            var result = new SANPHAMFunction().FindSPById(id);

            return(View(result));
        }
Example #15
0
        public PartialViewResult SPOfNew()
        {
            var sp = new SANPHAMFunction().SPOfNew();

            return(PartialView("SPOfNew", sp));
        }