コード例 #1
0
        public ActionResult Create(BangDia bangdia)
        {
            if (ModelState.IsValid)
            {
                db.BangDias.Add(bangdia);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.MaCL = new SelectList(db.ChatLuongs, "MaCL", "TenCL", bangdia.MaCL);
            ViewBag.MaDM = new SelectList(db.DanhMucs, "MaDM", "TenDanhMuc", bangdia.MaDM);
            ViewBag.MaHSX = new SelectList(db.HangSanXuats, "MaHSX", "TenHSX", bangdia.MaHSX);
            ViewBag.MaLoai = new SelectList(db.LoaiDias, "MaLoai", "TenLoai", bangdia.MaLoai);
            return View(bangdia);
        }
コード例 #2
0
        public ActionResult Create(BangDia bangdia)
        {
            if (ModelState.IsValid)
            {
                bangdia.NgayCapNhat = DateTime.Today;
                bangdia.LuotThue = 0;
                bangdia.LuotBan = 0;
                bangdia.LuotView = 0;
                bangdia.NgayTao = DateTime.Today;
                bangdia.AnhDaiDien = bangdia.AnhDaiDien.Replace("/Images/","");
                bangdia.An = false;
                db.BangDias.Add(bangdia);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.MaCL = new SelectList(db.ChatLuongs, "MaCL", "TenCL", bangdia.MaCL);
            ViewBag.MaDM = new SelectList(db.DanhMucs, "MaDM", "TenDanhMuc", bangdia.MaDM);
            ViewBag.MaHSX = new SelectList(db.HangSanXuats, "MaHSX", "TenHSX", bangdia.MaHSX);
            ViewBag.MaLoai = new SelectList(db.LoaiDias, "MaLoai", "TenLoai", bangdia.MaLoai);
            return View(bangdia);
        }
コード例 #3
0
 public ActionResult Edit(BangDia bangdia)
 {
     int a = bangdia.MaBD;
     if (ModelState.IsValid)
     {
         if (bangdia.An == true)
         {
             bangdia.NgayCapNhat = DateTime.Today;;
         }
          db.Entry(bangdia).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.MaCL = new SelectList(db.ChatLuongs, "MaCL", "TenCL", bangdia.MaCL);
     ViewBag.MaDM = new SelectList(db.DanhMucs, "MaDM", "TenDanhMuc", bangdia.MaDM);
     ViewBag.MaHSX = new SelectList(db.HangSanXuats, "MaHSX", "TenHSX", bangdia.MaHSX);
     ViewBag.MaLoai = new SelectList(db.LoaiDias, "MaLoai", "TenLoai", bangdia.MaLoai);
     return View(bangdia);
 }