コード例 #1
0
ファイル: HangBLL.cs プロジェクト: anhtuan29592/mobilestore
 public static bool ThemHang(Hang hang)
 {
     try
     {
         db.Hangs.AddObject(hang);
         db.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #2
0
ファイル: HangBLL.cs プロジェクト: anhtuan29592/mobilestore
 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;
     }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
        public ActionResult AddBrand(Hang hang)
        {
            if (!Roles.IsUserInRole("admin"))
            {
                return RedirectToAction("Index", "Admin");
            }

            HangBLL.ThemHang(hang);
            return View();
        }
コード例 #6
0
 /// <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);
 }
コード例 #7
0
 /// <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;
 }