Ejemplo n.º 1
0
        public ActionResult Edit(NhomSanPham nhomsp)
        {
            try
            {
                // TODO: Add update logic here
                DbNhomSanPham nhom = new DbNhomSanPham();

                HttpPostedFileBase File = Request.Files["Anh"];
                if (File.ContentLength > 0)
                {
                    string path    = Server.MapPath("~/Images/" + File.FileName);
                    string img_url = "Images/" + File.FileName;
                    File.SaveAs(path);

                    nhomsp.Anh = img_url;
                }


                nhom.edit(nhomsp);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        // GET: Nhomsanpham/Edit/5
        public ActionResult Edit(int id)
        {
            DbNhomSanPham nhom = new DbNhomSanPham();
            var           data = nhom.GetOneRow(id);

            return(View(data));
        }
Ejemplo n.º 3
0
        public ActionResult Create(NhomSanPham nhomsp)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add insert logic here
                    HttpPostedFileBase File    = Request.Files["Anh"];
                    string             path    = Server.MapPath("~/Images/" + File.FileName);
                    string             img_url = "Images/" + File.FileName;
                    File.SaveAs(path);

                    nhomsp.Anh = img_url;

                    DbNhomSanPham nhom = new DbNhomSanPham();
                    nhom.add(nhomsp);
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
        // GET: Nhomsanpham
        public ActionResult Index()
        {
            DbNhomSanPham nhom = new DbNhomSanPham();
            var           data = nhom.GetAll();

            return(View(data));
        }
Ejemplo n.º 5
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         DbNhomSanPham nhom = new DbNhomSanPham();
         nhom.delete(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 6
0
        public void set_select_nhom(int?selectedID = null)
        {
            var context = new DbNhomSanPham();

            ViewBag.ID_Nhom = new SelectList(context.GetAll(), "ID", "TenNhom", selectedID);
        }