예제 #1
0
 public ActionResult Edit(int id, BoSuuTap bosuutap)
 {
     bosuutap = (from s in data.BoSuuTaps
                 where s.MaBST == id
                 select s).FirstOrDefault();
     UpdateModel(bosuutap);
     if (String.IsNullOrEmpty(bosuutap.TenBST))
     {
         ViewBag.ThongBao = "Chưa nhập";
     }
     else
     {
         try
         {
             data.SubmitChanges();
             ViewBag.ThongBao = "SUCCESS";
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             ViewBag.ThongBao = "Lỗi nhập size(vd: xxl... không lớn hơn 3 chữ cái)";
         }
     }
     return(View());
 }
예제 #2
0
        public ActionResult Delete(int id, BoSuuTap bosuutaps)
        {
            bosuutaps = (from s in data.BoSuuTaps
                         where s.MaBST == id
                         select s).FirstOrDefault();
            SanPham sanpham = (from s in data.SanPhams where s.MaBST == id select s).FirstOrDefault();

            if (sanpham != null)
            {
                return(HttpNotFound());
            }
            else
            {
                try
                {
                    data.BoSuuTaps.DeleteOnSubmit(bosuutaps);
                    data.SubmitChanges();
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }
        }
예제 #3
0
 public ActionResult Create(BoSuuTap bosuutaps)
 {
     data.BoSuuTaps.InsertOnSubmit(bosuutaps);
     if (String.IsNullOrEmpty(bosuutaps.TenBST))
     {
         ViewBag.ThongBao = "Chưa nhập";
     }
     else
     {
         try
         {
             data.SubmitChanges();
             ViewBag.ThongBao = "SUCCESS";
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             ViewBag.ThongBao = "Lỗi nhập size(vd: xxl... không lớn hơn 3 chữ cái)";
         }
     }
     return(this.Create());
 }