예제 #1
0
        // GET: Sanpham/Details/5
        public ActionResult Details(int id)
        {
            DbSanPham dbsp = new DbSanPham();
            var       data = dbsp.GetOneRow(id);

            return(View(data));
        }
예제 #2
0
        public ActionResult Create(SanPham sp)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add insert logic here
                    HttpPostedFileBase File = Request.Files["AnhSanPham"];

                    string path    = Server.MapPath("~/Images/Sanpham/" + File.FileName);
                    string img_url = "Images/Sanpham/" + File.FileName;
                    File.SaveAs(path);

                    sp.AnhSanPham = img_url;

                    DbSanPham db = new DbSanPham();
                    db.AddNew(sp);

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
예제 #3
0
        // GET: Sanpham
        public ActionResult Index()
        {
            DbSanPham dbsp = new DbSanPham();
            var       data = dbsp.GetAllRow();

            return(View(data));
        }