Esempio n. 1
0
 public ActionResult Edit(FormCollection fc, JF_DonViTinh obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var o = ctx.JF_DonViTinh.Where(x => x.ten.ToLower() == obj.ten.ToLower() && x.kichhoat == true).FirstOrDefault();
             if (o.id != obj.id)
             {
                 ModelState.AddModelError("", "Đã tồn tại dvt này !");
                 return(View());
             }
             o.ten              = obj.ten;
             o.mota             = obj.mota;
             ctx.Entry(o).State = EntityState.Modified;
             int cn = ctx.SaveChanges();
             if (cn > 0)
             {
                 SetAlert("Cập nhật thành công", AlertType.Success);
                 return(RedirectToAction("Index", "JF_DonViTinh"));
             }
             else
             {
                 SetAlert("Cập nhật không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
 public ActionResult Index(FormCollection fc, JF_ThongTinLienHe obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ctx.Entry(obj).State = EntityState.Modified;
             int cn = ctx.SaveChanges();
             if (cn > 0)
             {
                 SetAlert("Cập nhật thành công", AlertType.Success);
                 return(RedirectToAction("Index", "JF_ThongTinLienHe"));
             }
             else
             {
                 SetAlert("Cập nhật không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Esempio n. 3
0
 public ActionResult Details(FormCollection fc, int id, string motaxuly)
 {
     try
     {
         var o = ctx.JF_DonHang.Find(id);
         if (ModelState.IsValid)
         {
             o.trangthai        = o.trangthai == 1 ? 0 : 1;
             o.motaxuly         = motaxuly;
             ctx.Entry(o).State = EntityState.Modified;
             int cn = ctx.SaveChanges();
             if (cn > 0)
             {
                 SetAlert("Cập nhật thành công", AlertType.Success);
             }
             else
             {
                 SetAlert("Cập nhật không thành công", AlertType.Error);
             }
         }
         return(View(o));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Esempio n. 4
0
 public ActionResult Edit(FormCollection fc, JF_SanPham obj)
 {
     try
     {
         TempData.Keep("loaisanpham");
         TempData.Keep("donvitinh");
         if (ModelState.IsValid)
         {
             var o = ctx.JF_SanPham.Find(obj.id);
             o.ten              = obj.ten;
             o.giatruockm       = obj.giatruockm;
             o.giatien          = obj.giatien;
             o.id_donvitinh     = obj.id_donvitinh;
             o.id_loaisanpham   = obj.id_loaisanpham;
             o.hinhdaidien      = obj.hinhdaidien;
             o.hientrangchu     = obj.hientrangchu == null ? false : true;
             o.noibat           = obj.noibat == null ? false : true;
             o.mota             = obj.mota;
             ctx.Entry(o).State = EntityState.Modified;
             int cn = ctx.SaveChanges();
             if (cn > 0)
             {
                 SetAlert("Cập nhật thành công", AlertType.Success);
                 return(RedirectToAction("Index", "JF_SanPham"));
             }
             else
             {
                 SetAlert("Cập nhật không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }