//async Task<ActionResult> public ActionResult Edit(FormCollection _form, NT_NUOC_MANLO _obj) { List <string> lstKeyName = _form.AllKeys.ToList().Where(s => s.StartsWith("ddlID_DOITUONG_NUOI_MANLO_")).ToList <String>(); List <int> lstInt = new List <int>(); lstKeyName.ForEach(o => lstInt.Add(int.Parse(o.Split('_')[o.Split('_').Count() - 1]))); if (ModelState.IsValid) { _obj.NAM = _obj.LOAI_BAO_CAO == 1 ? _obj.NGAY_BAO_CAO_TU.Value.Year : _obj.NAM; var model = _context.NT_NUOC_MANLO.First(o => o.ID == _obj.ID); FDB.Common.Helpers.CopyObject <NT_NUOC_MANLO>(_obj, ref model); model.NGUOI_NHAP = User.Identity.Name; var dbEntityEntry = _context.Entry(model); _context.NT_NUOC_MANLO.Attach(model); _context.Entry(model).State = System.Data.Entity.EntityState.Modified; //Xóa những detail cũ: _context.NT_NUOC_MANLO_DETAIL.Where(o => o.ID_NUOC_MANLO == _obj.ID).ToList().ForEach(o => _context.NT_NUOC_MANLO_DETAIL.Remove(o)); //Thêm mới detail đã sửa int Id = _obj.ID; if (lstKeyName != null) { for (int i = 0; i < lstInt.Count; i++) { NT_NUOC_MANLO_DETAIL _objDetail = new Models.NT_NUOC_MANLO_DETAIL(); FDB.Common.Helpers.GetValueForm <NT_NUOC_MANLO_DETAIL>(_form, lstInt[i], ref _objDetail); _objDetail.ID_NUOC_MANLO = Id; _context.NT_NUOC_MANLO_DETAIL.Add(_objDetail); } } //Save data: _context.SaveChanges(); this.Information(string.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, "Nuôi thủy sản nước mặn và lợ")); return(RedirectToAction("Index")); } else { TempData["_SUCCESS"] = ""; this.LoadDanhMuc(); _obj.DSNT_NuocManNoDetail = new List <NT_NUOC_MANLO_DETAIL>(); //build html : int maxID = 0; String strHTML = string.Empty; //this.GenderHTML(lstInt, _form, ref maxID); ViewBag.sEditHTML = strHTML; ViewBag.sMaxID = maxID + 1; return(View(_obj)); } }
//async Task<ActionResult> public ActionResult Edit(FormCollection _form, KT_SANLUONG _obj) { List <string> lstKeyName = _form.AllKeys.ToList().Where(s => s.StartsWith("ddlID_KHAITHAC_NHOM_DOITUONG_")).ToList <String>(); List <int> lstInt = new List <int>(); lstKeyName.ForEach(o => lstInt.Add(int.Parse(o.Split('_')[o.Split('_').Count() - 1]))); if (ModelState.IsValid) { var model = _context.KT_SANLUONG.First(o => o.ID == _obj.ID); FDB.Common.Helpers.CopyObject <KT_SANLUONG>(_obj, ref model); var dbEntityEntry = _context.Entry(model); _context.KT_SANLUONG.Attach(model); _context.Entry(model).State = System.Data.Entity.EntityState.Modified; //Xóa những detail cũ: _context.KT_SANLUONG_DETAIL.Where(o => o.ID_KHAITHAC_SANLUONG == _obj.ID).ToList().ForEach(o => _context.KT_SANLUONG_DETAIL.Remove(o)); //Thêm mới detail đã sửa int Id = _obj.ID; if (lstKeyName != null) { for (int i = 0; i < lstInt.Count; i++) { KT_SANLUONG_DETAIL _objDetail = new Models.KT_SANLUONG_DETAIL(); FDB.Common.Helpers.GetValueForm <KT_SANLUONG_DETAIL>(_form, lstInt[i], ref _objDetail); _objDetail.ID_KHAITHAC_SANLUONG = Id; _context.KT_SANLUONG_DETAIL.Add(_objDetail); } } //Save data: _context.SaveChanges(); this.Information(string.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, "Sản lượng")); return(RedirectToAction("Index")); } else { //TempData["_SUCCESS"] = ""; _obj.DSSanLuongDetail = new List <KT_SANLUONG_DETAIL>(); this.LoadDanhMuc(); //build html : int maxID = 0; String strHTML = "";// this.GenderHTML(lstKeyddlDoiTuongNuoi, lstKeyddlNhomNgheKhaiThac, lstKeyddlNgheKhaiThac, lstKeytxtSanLuong, _form, ref maxID); ViewBag.sEditHTML = strHTML; ViewBag.MaxID = maxID + 1; return(View(_obj)); } }
public ActionResult Edit(DM_DOITUONG_NUOI_THIETHAI dm_doituong_nuoi_thiethai) { if (ModelState.IsValid) { db.Entry(dm_doituong_nuoi_thiethai).State = EntityState.Modified; db.SaveChanges(); this.Information(string.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, string.Empty)); return(RedirectToAction("Index")); } return(View(dm_doituong_nuoi_thiethai)); }
public ActionResult Edit([Bind(Include = "DM_NhomNgheID,TenNhomNghe,MoTa")] DM_NHOMNGHE dm_nhomnghe) { if (ModelState.IsValid) { db.Entry(dm_nhomnghe).State = EntityState.Modified; db.SaveChanges(); this.Information(string.Format(Constants.NOTIFY_UPDATE_SUCCESS, string.Empty)); return(RedirectToAction("Index")); } return(View(dm_nhomnghe)); }
public ActionResult Edit(DM_NHOMDOITUONG_KT dm_doituong) { if (ModelState.IsValid) { db.Entry(dm_doituong).State = EntityState.Modified; db.SaveChanges(); this.Information(string.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, string.Empty)); return(RedirectToAction("Index")); } BindComboDM(); return(View(dm_doituong)); }
public ActionResult Edit(KT_KHUBAOTON kt_khubaoton) { if (ModelState.IsValid) { db.Entry(kt_khubaoton).State = EntityState.Modified; db.SaveChanges(); this.Information(String.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, "bản ghi")); return(RedirectToAction("Index")); } else { initialCategoryEditAction(kt_khubaoton); } return(View(kt_khubaoton)); }
public ActionResult Edit(KT_CANGCA kt_cangca) { if (ModelState.IsValid) { db.Entry(kt_cangca).State = EntityState.Modified; db.SaveChanges(); this.Information(String.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, "bản ghi")); return(RedirectToAction("Index")); } else { // BindComboDM_CANGCA(); } return(View(kt_cangca)); }
public ActionResult Edit(NT_THIETHAI nt_thiethai) { if (ModelState.IsValid) { db.Entry(nt_thiethai).State = EntityState.Modified; db.SaveChanges(); this.Information(String.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, "bản ghi")); return(RedirectToAction("Index")); } else { initialCategoryEditAction(nt_thiethai); } return(View(nt_thiethai)); }
public ActionResult Edit(NT_TT_THITRUONG nt_tt_thitruong) { if (ModelState.IsValid) { db.Entry(nt_tt_thitruong).State = EntityState.Modified; nt_tt_thitruong.NGAY_NM = DateTime.Now; db.SaveChanges(); this.Information(String.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, "bản ghi")); return(RedirectToAction("Index")); } else { initialCategory(); } return(View(nt_tt_thitruong)); }
public ActionResult Edit(FormCollection form, DM_CANGCA dm_cangca) { if (ModelState.IsValid) { //Convert.ToBoolean(collection["showAll"].Split(',')[0]) dm_cangca.Status = Convert.ToBoolean(form["cbStatus"].Split(',')[0]); db.Entry(dm_cangca).State = EntityState.Modified; db.SaveChanges(); this.Information(String.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, "bản ghi")); return(RedirectToAction("Index")); } else { initialCategoryEditAction(dm_cangca); } return(View(dm_cangca)); }
public ActionResult Edit(KT_CPUE t) { if (ModelState.IsValid) { t.NGAY_NM = DateTime.Today; t.NGUOI_NM = User.Identity.Name; db.Entry(t).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); this.Information(string.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, "Phỏng vấn sản lượng")); return(RedirectToAction("Index")); } initialCategoryEditAction(); return(View(t)); }
//async Task<ActionResult> public ActionResult Edit(FormCollection _form, KT_DONGSUA_TAUTHUYEN _obj) { List <string> lstKeytxtNAM = _form.AllKeys.ToList().Where(s => s.StartsWith("txtNAM_")).ToList <String>(); List <int> lstInt = new List <int>(); lstKeytxtNAM.ForEach(o => lstInt.Add(int.Parse(o.Split('_')[o.Split('_').Count() - 1]))); //var errors = from modelstate in ModelState.AsQueryable().Where(f => f.Value.Errors.Count > 0) select new { Title = modelstate.Key }; //var a = ModelState.IsValidField("TRONG_TAI_TOIDA_COTHE"); //FDB.Common.Helpers.GetValueForm<KT_DONGSUA_TAUTHUYEN>(_form, ref _obj, "TRONG_TAI_TOIDA_COTHE"); if (ModelState.IsValid) //|| (!ModelState.IsValid && errors.ToList().Count==1 && a == false)) { var model = _context.KT_DONGSUA_TAUTHUYEN.First(o => o.ID == _obj.ID); FDB.Common.Helpers.CopyObject <KT_DONGSUA_TAUTHUYEN>(_obj, ref model); model.NGUOI_NHAP = User.Identity.Name; model.NGAY_NHAP = DateTime.Now; var dbEntityEntry = _context.Entry(model); _context.KT_DONGSUA_TAUTHUYEN.Attach(model); _context.Entry(model).State = System.Data.Entity.EntityState.Modified; //Xóa những detail cũ: _context.KT_DONGSUA_TAUTHUYEN_DETAIL.Where(o => o.ID_DONGSUA_TAUTHUYEN == _obj.ID).ToList().ForEach(o => _context.KT_DONGSUA_TAUTHUYEN_DETAIL.Remove(o)); //Thêm mới detail đã sửa int Id = _obj.ID; if (lstKeytxtNAM != null) { for (int i = 0; i < lstInt.Count; i++) { KT_DONGSUA_TAUTHUYEN_DETAIL _objDetail = new Models.KT_DONGSUA_TAUTHUYEN_DETAIL(); FDB.Common.Helpers.GetValueForm <KT_DONGSUA_TAUTHUYEN_DETAIL>(_form, lstInt[i], ref _objDetail); _objDetail.ID_DONGSUA_TAUTHUYEN = Id; _context.KT_DONGSUA_TAUTHUYEN_DETAIL.Add(_objDetail); } } //Save data: _context.SaveChanges(); this.Information(string.Format(FDB.Common.Constants.NOTIFY_UPDATE_SUCCESS, "Đóng sửa tàu thuyền")); return(RedirectToAction("Index")); } else { TempData["_SUCCESS"] = ""; ApplicationUser curUser = this.getCurrentUser(); var tinh = _context.DTINHTP.Where(u => (curUser.MA_TINHTP == null || curUser.MA_TINHTP.StartsWith("Z")) || u.MA_TINHTP == curUser.MA_TINHTP) .Except(_context.DTINHTP.Where(d => d.MA_TINHTP.StartsWith("Z"))); ViewBag.DM_DonVis = new SelectList(tinh, "MA_TINHTP", "TEN_TINHTP"); var quan = _context.DQUANHUYEN.Where(u => u.MA_TINHTP == _obj.MA_TINHTP); // quan.Insert(0, new DQUANHUYEN()); ViewBag.DMQhuyen = new SelectList(quan, "MA_QUANHUYEN", "TEN_QUANHUYEN"); var phuongxa = _context.DPHUONGXA.Where(u => _obj.MA_QUANHUYEN == null || u.MA_QUANHUYEN == _obj.MA_QUANHUYEN); ViewBag.DMPhuongXa = new SelectList(phuongxa, "MA_PHUONGXA", "TEN_PHUONGXA"); _obj.DSDongSuaTauThuyenDetail = new List <KT_DONGSUA_TAUTHUYEN_DETAIL>(); //build html : int maxID = 0; String strHTML = this.GenderHTML(lstInt, _form, ref maxID); ViewBag.sEditHTML = strHTML; ViewBag.MaxID = maxID + 1; return(View(_obj)); } }