示例#1
0
 public ActionResult _Edit_NONGSAN(Models.NONGSAN _value = null)
 {
     // lấy thông tin đã thay đổi của NONGSAN từ "View Edit HttpPost NONGSAN"
     db.NONGSANs.AddOrUpdate(_value);
     db.SaveChanges();
     return(RedirectToAction("NONGSAN", "Admin"));
 }
示例#2
0
        public ActionResult _Edit_NONGSAN(string id)
        {
            if (CheckLogin())
            {
                // nếu không truyền dữ liệu vào biến id -> tạo mới bản ghi
                if (string.IsNullOrWhiteSpace(id))
                {
                    return(View());
                }

                // còn nếu truyền dữ liệu vào biến id -> update bản ghi
                int tam = 0;
                if (int.TryParse(id, out tam))
                {
                    Models.NONGSAN val = db.Database.SqlQuery <Models.NONGSAN>("SELECT * FROM NONGSAN WHERE MaNongSan = " + tam).SingleOrDefault();
                    return(View(val));
                }

                // ngoại lệ chưa xác định -> chuyển về trang danh sách NONGSAN
                return(RedirectToAction("NONGSAN", "Admin"));
            }
            return(RedirectToAction("LOGIN", "Admin"));
        }