Exemple #1
0
 public static bool ThemHang(Hang hang)
 {
     try
     {
         db.Hangs.AddObject(hang);
         db.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemple #2
0
 public static bool SuaHang(Hang hangMoi)
 {
     try
     {
         db.Attach(hangMoi);
         db.ObjectStateManager.ChangeObjectState(hangMoi, System.Data.EntityState.Modified);
         db.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
 public ActionResult Them(Hang model)
 {
     if (ModelState.IsValid)
     {
         if (HangBLL.ThemHang(model) == true)
         {
             return RedirectToAction("Index");
         }
         else
         {
             ModelState.AddModelError("", "Thêm hãng sản xuất thất bại. Vui lòng kiểm tra lại");
         }
     }
     return View(model);
 }
 public ActionResult Sua(Hang model)
 {
     if (ModelState.IsValid)
     {
         if (HangBLL.SuaHang(model) == true)
         {
             return RedirectToAction("Index");
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật thông tin hãng thất bại. Vui lòng kiểm tra lại");
         }
     }
     return View(model);
 }
        public ActionResult AddBrand(Hang hang)
        {
            if (!Roles.IsUserInRole("admin"))
            {
                return RedirectToAction("Index", "Admin");
            }

            HangBLL.ThemHang(hang);
            return View();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Hangs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToHangs(Hang hang)
 {
     base.AddObject("Hangs", hang);
 }
 /// <summary>
 /// Create a new Hang object.
 /// </summary>
 /// <param name="maHang">Initial value of the MaHang property.</param>
 /// <param name="biXoa">Initial value of the BiXoa property.</param>
 public static Hang CreateHang(global::System.Int32 maHang, global::System.Boolean biXoa)
 {
     Hang hang = new Hang();
     hang.MaHang = maHang;
     hang.BiXoa = biXoa;
     return hang;
 }