Esempio n. 1
0
        public ActionResult Edit(NhaSX n)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var nsx = new NhaSanXuat();
                    nsx.idNSX  = n.idNSX;
                    nsx.MoTa   = n.MoTa;
                    nsx.TenNSX = n.TenNSX;
                    nsx.SDT    = n.SDT;
                    nsx.DiaChi = n.DiaChi;

                    NSXBUS.EditNSX(nsx);
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Esempio n. 2
0
        public ActionResult Create(NhaSX n)
        {
            // TODO: Add insert logic here
            if (ModelState.IsValid)
            {
                try {
                    var nsx = new NhaSanXuat();
                    nsx.idNSX  = n.idNSX;
                    nsx.MoTa   = n.MoTa;
                    nsx.TenNSX = n.TenNSX;
                    nsx.SDT    = n.SDT;
                    nsx.DiaChi = n.DiaChi;

                    NSXBUS.SaveNSX(nsx);
                    return(RedirectToAction("Index"));
                }
                catch {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Esempio n. 3
0
        // GET: Admin/NhaSX
        public ActionResult Index(int?page)
        {
            var LstDS      = NSXBUS.DanhSach();
            int pageSize   = 12;
            int pageNumber = (page ?? 1);

            return(View(LstDS.ToPagedList(pageNumber, pageSize)));
        }
Esempio n. 4
0
        public ActionResult Create(SP n)
        {
            // TODO: Add insert logic here
            ViewBag.NhaSX = NSXBUS.DanhSach();
            ViewBag.Loai  = LoaiSPBUS.LoadDSLoaiSP();
            if (ModelState.IsValid)
            {
                try
                {
                    if (HttpContext.Request.Files.Count > 0)
                    {
                        var hpf = HttpContext.Request.Files[0];
                        if (hpf.ContentLength > 0)
                        {
                            string fileName = Guid.NewGuid().ToString();

                            string fullPathWithFileName = "/Assets/Images/products/" + fileName + ".jpg";
                            hpf.SaveAs(Server.MapPath(fullPathWithFileName));

                            n.HinhAnh = fullPathWithFileName;
                            var b = new SanPham()
                            {
                                idSP    = n.idSP,
                                GiaSP   = n.GiaSP,
                                HinhAnh = n.HinhAnh,
                                MaLoai  = n.MaLoai,
                                TenSP   = n.TenSP,
                                MaNSX   = n.MaNSX,
                                MoTa    = n.MoTa
                            };
                            SPBUS.ThemSP(b);
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            return(View());
                        }
                    }
                    else
                    {
                        return(View());
                    }
                }
                catch
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Esempio n. 5
0
        // GET: Admin/NhaSX/Edit/5
        public ActionResult Edit(int id)
        {
            var n   = NSXBUS.LoadNSX(id);
            var nsx = new NhaSX();

            nsx.idNSX  = n.idNSX;
            nsx.MoTa   = n.MoTa;
            nsx.TenNSX = n.TenNSX;
            nsx.SDT    = n.SDT;
            nsx.DiaChi = n.DiaChi;
            return(View(nsx));
        }
Esempio n. 6
0
        // GET: Admin/NhaSX/Edit/5
        public ActionResult Edit(int id)
        {
            ViewBag.NhaSX = NSXBUS.DanhSach();
            ViewBag.Loai  = LoaiSPBUS.LoadDSLoaiSP();
            //////////
            var b = SPBUS.LoadSanPham(id);
            var a = new SP()
            {
                HinhAnh = b.HinhAnh,
                idSP    = b.idSP,
                GiaSP   = int.Parse(b.GiaSP.ToString()),
                MaLoai  = int.Parse(b.MaLoai.ToString()),
                MaNSX   = int.Parse(b.MaNSX.ToString()),
                MoTa    = b.MoTa,
                TenSP   = b.TenSP
            };

            return(View(a));
        }
Esempio n. 7
0
 // GET: Admin/NhaSX/Create
 public ActionResult Create()
 {
     ViewBag.NhaSX = NSXBUS.DanhSach();
     ViewBag.Loai  = LoaiSPBUS.LoadDSLoaiSP();
     return(View());
 }
Esempio n. 8
0
 // GET: Admin/NhaSX/Delete/5
 public ActionResult Delete(int id)
 {
     NSXBUS.DeleteNSX(id);
     return(RedirectToAction("Index"));
 }