public ActionResult DeleteConfirmed(string id, string code) { CSCOLASTNO cSCOLASTNO = db.CSCOLASTNOes.Find(MyHtmlHelpers.ConvertByteStrToId(id), code); try { db.CSCOLASTNOes.Remove(cSCOLASTNO); db.SaveChanges(); return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOLASTNO.CONO) }) + "#LastNo")); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { //string message = string.Format("{0}:{1}", // validationErrors.Entry.Entity.ToString(), // validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage); } } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException != null) { if (updateException.InnerException != null) { var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException; foreach (var error in sqlException.Errors) { if (error.Message != null) { ModelState.AddModelError(string.Empty, error.Message); } } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } return(View(cSCOLASTNO)); }
public ActionResult DeleteConfirmed(string id) { CSCOLASTNO cSCOLASTNO = db.CSCOLASTNOes.Find(id); db.CSCOLASTNOes.Remove(cSCOLASTNO); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CONO,LASTCODE,LASTDESC,LASTPFIX,LASTNO,LASTWD,AUTOGEN,STAMP")] CSCOLASTNO cSCOLASTNO) { if (ModelState.IsValid) { db.Entry(cSCOLASTNO).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cSCOLASTNO)); }
public ActionResult Create([Bind(Include = "CONO,LASTCODE,LASTDESC,LASTPFIX,LASTNO,LASTWD,AUTOGEN,STAMP")] CSCOLASTNO cSCOLASTNO) { if (ModelState.IsValid) { db.CSCOLASTNOes.Add(cSCOLASTNO); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cSCOLASTNO)); }
// GET: CSCOLASTNOes/Edit/5 public ActionResult Edit(string id, string code) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSCOLASTNO cSCOLASTNO = db.CSCOLASTNOes.Find(MyHtmlHelpers.ConvertByteStrToId(id), code); if (cSCOLASTNO == null) { return(HttpNotFound()); } return(View(cSCOLASTNO)); }
// GET: CSCOLASTNOes/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSCOLASTNO cSCOLASTNO = db.CSCOLASTNOes.Find(id); if (cSCOLASTNO == null) { return(HttpNotFound()); } return(View(cSCOLASTNO)); }
public ActionResult Create([Bind(Include = "CONO,PRSCODE,EFFDATE,TERDATE,ENDDATE,FOLIONO,REM,STAMP")] CSCOSH cSCOSH) { if (ModelState.IsValid) { cSCOSH.STAMP = 0; try { int lastRowNo = 0; try { lastRowNo = db.CSCOSHes.Where(m => m.CONO == cSCOSH.CONO).Max(n => n.FOLIONO); } catch (Exception e) { lastRowNo = 0; } finally { }; cSCOSH.FOLIONO = lastRowNo + 1; db.CSCOSHes.Add(cSCOSH); CSCOLASTNO cSCOLASTNO = db.CSCOLASTNOes.Find(cSCOSH.CONO, "SHFOLIO"); if (cSCOLASTNO != null) { cSCOLASTNO.LASTNO = cSCOSH.FOLIONO; db.Entry(cSCOLASTNO).State = EntityState.Modified; } db.SaveChanges(); return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOSH.CONO) }) + "#Member")); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { //string message = string.Format("{0}:{1}", // validationErrors.Entry.Entity.ToString(), // validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage); } } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException != null) { if (updateException.InnerException != null) { var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException; foreach (var error in sqlException.Errors) { if (error.Message != null) { ModelState.AddModelError(string.Empty, error.Message); } } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } } cSCOSH.CSCOMSTR = db.CSCOMSTRs.Find(cSCOSH.CONO); ViewBag.PRSCODE = new SelectList(db.CSPRS.OrderBy(x => x.PRSNAME), "PRSCODE", "PRSNAME", cSCOSH.PRSCODE); return(View(cSCOSH)); }
public ActionResult Edit([Bind(Include = "CONO,LASTCODE,LASTDESC,LASTPFIX,LASTNO,LASTWD,AUTOGENBool,STAMP")] CSCOLASTNO cSCOLASTNO) { if (ModelState.IsValid) { try { cSCOLASTNO.STAMP = cSCOLASTNO.STAMP + 1; db.Entry(cSCOLASTNO).State = EntityState.Modified; db.SaveChanges(); return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOLASTNO.CONO) }) + "#LastNo")); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { //string message = string.Format("{0}:{1}", // validationErrors.Entry.Entity.ToString(), // validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage); } } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException != null) { if (updateException.InnerException != null) { var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException; foreach (var error in sqlException.Errors) { if (error.Message != null) { ModelState.AddModelError(string.Empty, error.Message); } } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } } cSCOLASTNO.CSCOMSTR = db.CSCOMSTRs.Find(cSCOLASTNO.CONO); return(View(cSCOLASTNO)); }