public ActionResult Index()
        {
            SanPhamF spf = new SanPhamF();
            var      lst = spf.SanPhams.ToList();

            return(View(lst));
        }
Beispiel #2
0
        public ActionResult AddItem(string id, string returnURL)
        {
            var product = new SanPhamF().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;
            }

            if (string.IsNullOrEmpty(returnURL))
            {
                return(RedirectToAction("Index"));
            }

            return(Redirect(returnURL));
        }
        public ActionResult AddItem(long Id, string returnURL)
        {
            var product = new SanPhamF().FindEntity(Id);
            var cart    = (Cart)Session[CartSession];

            var sizemau = Request.Form["sizemau"];

            Console.WriteLine(sizemau);

            if (cart != null)
            {
                cart.AddItem(product, 1, sizemau);
                //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, sizemau);
                //Gán vào session
                Session[CartSession] = cart;
            }

            if (string.IsNullOrEmpty(returnURL))
            {
                return(RedirectToAction("Index"));
            }

            return(Redirect(returnURL));
        }
Beispiel #4
0
        public ActionResult SanPhamDM(string id)
        {
            SanPhamF SPF   = new SanPhamF();
            var      model = SPF.SanPhams.Where(x => x.IDHang == id).ToList();

            return(View("DanhSachSanPham", model));
        }
        public ActionResult AllSanPham(int page = 1, int pageSize = 3)
        {
            var model = new SanPhamF().ListAllPaging(page, pageSize);

            ViewBag.ListAllSP = new SanPhamF().ListAllSP();
            return(View(model));
        }
Beispiel #6
0
        public ActionResult TimKiem(string TuKhoa)
        {
            SanPhamF SPF   = new SanPhamF();
            var      model = SPF.SanPhams.Where(x => x.TenSanPham.Contains(TuKhoa)).ToList();

            return(View("DanhSachSanPham", model));
        }
Beispiel #7
0
        public ActionResult ChiTietSanPham(string id)
        {
            SanPhamF SPF = new SanPhamF();
            var      sp  = SPF.ChitietSanPham(id);

            return(View(sp));
        }
Beispiel #8
0
        public ActionResult DanhSachSanPham()
        {
            SanPhamF SPF = new SanPhamF();
            var      lst = SPF.SanPhams.ToList();

            return(View(lst));
        }
        public ActionResult XemChiTiet(string id)
        {
            SanPhamF spf   = new SanPhamF();
            SanPham  model = spf.ChitietSanPham(id);

            return(View(model));
        }
Beispiel #10
0
        public ActionResult Shop(string IDNCC)
        {
            if (IDNCC == null)
            {
                var model = new SanPhamF().SanPhams.ToList();
                return(View(model));
            }
            else
            {
                NhaCungCap ncc = db.NhaCungCaps.SingleOrDefault(n => n.IDNCC == IDNCC);
                if (ncc == null)
                {
                    Response.StatusCode = 404;
                    return(null);
                }
                List <SanPham> lis_SP = db.SanPhams.Where(n => n.IDNCC == IDNCC).OrderBy(n => n.IDNCC).ToList();
                return(View(lis_SP));
            }

            //string IDNCC = "NCC01";
            //var Sp = db.Database.SqlQuery<SanPham>("Select*from SanPham where @IDNCC=IDNCC", new SqlParameter("@IDNCC", IDNCC)).ToList();
            //var SP = new SanPhamF().SanPhams.ToList();
            //if (SP != null)
            //{
            //    return View(SP);
            //}
            //else return View();
        }
        public ActionResult UpdateCart(long Id, FormCollection fr)
        {
            var product = new SanPhamF().FindEntity(Id);

            var cart = (Cart)Session[CartSession];

            var sizemau = Request.Form["sizemau"];

            Console.WriteLine(sizemau);

            if (cart != null)
            {
                int NewQuantity = int.Parse(fr["txtQuantity"].ToString());
                cart.UpdateItem(product, NewQuantity);
                //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, sizemau);
                //Gán vào session
                Session[CartSession] = cart;
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(SanPham model, HttpPostedFileBase UrlAnh)
        {
            try
            {
                // TODO: Add update logic here

                if (UrlAnh == null)
                {
                    ModelState.AddModelError("File", "Chưa upload file ảnh");
                }
                else if (UrlAnh.ContentLength > 0)
                {                 //TO:DO
                    var fileName = Path.GetFileName(UrlAnh.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Content/Images"), fileName);
                    UrlAnh.SaveAs(path);                    //

                    SanPhamF spF = new SanPhamF();
                    model.UrlAnh = fileName;
                    if (spF.Insert(model))
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch
            {
                return(View());
            }
            return(View());
        }
        public ActionResult Trangchu1()
        {
            ViewBag.TenDM = "danh sach SP";
            var model = new SanPhamF().DSSanPham.Take(8).ToList();

            return(View("TrangChu", model));
        }
Beispiel #14
0
        public ActionResult Edit_SanPham(SanPham sp, HttpPostedFileBase UploadAnh)
        {
            ViewBag.IDNCC = new SelectList(db.NhaCungCaps, "IDNCC", "TenNCC", sp.IDNCC);
            try
            {
                if (UploadAnh == null)
                {
                    ModelState.AddModelError("File", "Chưa upload file ảnh");
                }
                else
                {
                    if (UploadAnh.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(UploadAnh.FileName);
                        var path     = Path.Combine(Server.MapPath("/Content/Image_Product"), fileName);
                        UploadAnh.SaveAs(path);


                        SanPhamF spf = new SanPhamF();
                        sp.Anh = "/Content/Image_Product/" + fileName;
                        if (spf.Update(sp))
                        {
                            return(RedirectToAction("Tables"));
                        }
                    }
                }
                return(View());
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Xoa(string id)
        {
            MyDBContext db    = new MyDBContext();
            SanPhamF    spf   = new SanPhamF();
            SanPham     model = spf.ChitietSanPham(id);

            return(View(model));
        }
        public ActionResult ChiTietSanPham(long MaSanPham)
        {
            var product = new SanPhamF().ViewDetail(MaSanPham);

            ViewBag.GiayOD = new ChiTietSanPhamF().ViewDetail(product.MaSanPham);
            ViewBag.Giay   = new ChiTietSanPhamF().ListGiaylQ(product.MaSanPham);

            return(View(MaSanPham));
        }
        public ActionResult Sua(string id)
        {
            MyDBContext db    = new MyDBContext();
            SanPhamF    spf   = new SanPhamF();
            SanPham     model = spf.ChitietSanPham(id);

            ViewBag.IDHang = new SelectList(db.Hangs, "IDHang", "TenHang", model.IDHang);
            ViewBag.IDNCC  = new SelectList(db.NhaCungCaps, "IDNCC", "TenNCC", model.IDNCC);
            return(View(model));
        }
        public ActionResult ChiTietSanPham(long MaSanPham)
        {
            var spOD = new SanPhamF().Detail(MaSanPham);

            ViewBag.Detail     = new SanPhamF().Detail(spOD.MaSanPham);
            ViewBag.ListDetail = new SanPhamF().ListDetail(spOD.MaSanPham);
            ViewBag.Topping    = new SanPhamF().Topping();
            ViewBag.Duong      = new SanPhamF().Duong();
            ViewBag.Da         = new SanPhamF().Da();
            return(View(spOD));
        }
Beispiel #19
0
        public ActionResult Category(string id)
        {
            //var category = new DanhMucF().FindEntity(id);
            //if (category == null)
            //{
            //    return View("Error");
            //}
            var model = new SanPhamF().DSSanPham.Where(s => s.MaDM == id).ToList(); //return list of projects in requested category

            return(View("Index", model));
        }
Beispiel #20
0
        public ActionResult Delete_SanPham(string IDSanPham)
        {
            SanPhamF spf = new SanPhamF();

            if (spf.Delete_SanPham(IDSanPham) == true)
            {
                return(RedirectToAction("Tables"));
            }
            else
            {
                return(View());
            }
        }
Beispiel #21
0
 public ActionResult Cart()
 {
     if (Session["TenTK"] == null)
     {
         return(View("Login"));
     }
     else
     {
         ViewBag.TenTK = Session["TenTK"];
         var model = new SanPhamF().DSSP_KH().ToList();
         return(View(model));
     }
 }
        // GET: /Cart/Details/5
        public ActionResult RemoveLine(long Id)
        {
            var product = new SanPhamF().FindEntity(Id);

            var cart = (Cart)Session[CartSession];

            if (cart != null)
            {
                cart.RemoveLine(product);
                //Gán vào session
                Session[CartSession] = cart;
            }
            return(RedirectToAction("Index"));
        }
Beispiel #23
0
 public ActionResult SingleProduct(string ID)
 {
     if (ID == null)
     {
         ID = "SP02";
         var model = new SanPhamF().FindEntity(ID);
         return(View(model));
     }
     else
     {
         var model = new SanPhamF().FindEntity(ID);
         return(View(model));
     }
 }
Beispiel #24
0
 // GET: My
 public ActionResult Index(string IDKhachHang)
 {
     if (IDKhachHang == null)
     {
         var model = new SanPhamF().SanPhams.ToList();
         return(View(model));
     }
     else
     {
         Session["TenTK"] = IDKhachHang;
         ViewBag.TaiKhoan = IDKhachHang;
         var model = new SanPhamF().SanPhams.ToList();
         return(View(model));
     }
 }
        public ActionResult Xoa(SanPham model)
        {
            SanPhamF spf = new SanPhamF();

            try
            {
                if (spf.Delete(model.IDSanPham))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Sua(SanPham model)
        {
            SanPhamF spf = new SanPhamF();

            try
            {
                if (spf.Update(model))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
Beispiel #27
0
        public ActionResult AddItem(string idsanpham, int soluong)
        {
            var sp   = new SanPhamF().ChitietSanPham(idsanpham);
            var cart = Session[CartSession];

            if (cart != null)
            {
                var list = (List <CartItem>)cart;
                if (list.Exists(x => x.SanPham.IDSanPham == idsanpham))
                {
                    foreach (var item in list)
                    {
                        if (item.SanPham.IDSanPham == idsanpham)
                        {
                            item.Soluong += soluong;
                        }
                    }
                }
                else
                {
                    var item = new CartItem();
                    item.SanPham = sp;
                    item.Soluong = soluong;
                    list.Add(item);
                }
                Session[CartSession] = list;
            }

            else
            {
                var item = new CartItem();
                item.SanPham = sp;
                item.Soluong = soluong;
                var list = new List <CartItem>();
                list.Add(item);
                Session[CartSession] = list;
            }
            return(RedirectToAction("Index"));
        }
Beispiel #28
0
        public ActionResult UpdateCart(string id, FormCollection fr)
        {
            var product = new SanPhamF().FindEntity(id);

            var cart = (Cart)Session["CartSession"];

            if (cart != null)
            {
                int NewQuantity = int.Parse(fr["txtQuantity"].ToString());
                cart.UpdateItem(product, NewQuantity);
                //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"));
        }
Beispiel #29
0
        public ActionResult Create(SanPham sp, HttpPostedFileBase fileUpLoad)
        {
            SanPhamF spf = new SanPhamF();


            string fileName  = Path.GetFileNameWithoutExtension(fileUpLoad.FileName);
            string extension = Path.GetExtension(fileUpLoad.FileName);

            fileName = fileName + DateTime.Now.ToString("yymmssff") + extension;
            sp.Anh   = "/Content/Image_Product/" + fileName;
            fileName = Path.Combine(Server.MapPath("~/Content/Image_Product/"), fileName);
            fileUpLoad.SaveAs(fileName);


            if (spf.Insert_SanPham(sp) == true)
            {
                return(RedirectToAction("Tables"));
            }
            else
            {
                return(View());
            }
        }
        public PartialViewResult ListSanPhamLQ()
        {
            var model = new SanPhamF().ListSP(3);

            return(PartialView(model));
        }