public ActionResult DeleteConfirmed(string id) { CSCASEDOC cSCASEDOC = db.CSCASEDOCs.Find(id); db.CSCASEDOCs.Remove(cSCASEDOC); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "CASECODE,DOCINVID,DOCINVDESC,DOCINVQTY,STAMP")] CSCASEDOC cSCASEDOC) { if (ModelState.IsValid) { try { cSCASEDOC.STAMP = 0; db.CSCASEDOCs.Add(cSCASEDOC); db.SaveChanges(); return(RedirectToAction("Index")); } 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); } } } return(View(cSCASEDOC)); }
public ActionResult Edit([Bind(Include = "CASECODE,DOCINVID,DOCINVDESC,DOCINVQTY,STAMP")] CSCASEDOC cSCASEDOC) { if (ModelState.IsValid) { db.Entry(cSCASEDOC).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cSCASEDOC)); }
public ActionResult DeleteConfirmed(string id) { CSCASEDOC cSCASEDOC = db.CSCASEDOCs.Find(id); try { db.CSCASEDOCs.Remove(cSCASEDOC); db.SaveChanges(); return(RedirectToAction("Index")); } 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); } } return(View(cSCASEDOC)); }
public ActionResult Create([Bind(Include = "CASECODE,DOCINVID,DOCINVDESC,DOCINVQTY,STAMP")] CSCASEDOC cSCASEDOC) { if (ModelState.IsValid) { db.CSCASEDOCs.Add(cSCASEDOC); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cSCASEDOC)); }
// GET: CSCASEDOCs/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSCASEDOC cSCASEDOC = db.CSCASEDOCs.Find(id); if (cSCASEDOC == null) { return(HttpNotFound()); } return(View(cSCASEDOC)); }