public ActionResult Edit([Bind(Include = "BILLDESC,BILLSPEC,STAMP")] CSBILLDESC cSBILLDESC) { if (ModelState.IsValid) { try { cSBILLDESC.STAMP = cSBILLDESC.STAMP + 1; db.Entry(cSBILLDESC).State = EntityState.Modified; 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(cSBILLDESC)); }
public ActionResult DeleteConfirmed(string id) { CSBILLDESC cSBILLDESC = db.CSBILLDESCs.Find(MyHtmlHelpers.ConvertByteStrToId(id)); try { db.CSBILLDESCs.Remove(cSBILLDESC); 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(cSBILLDESC)); }
// GET: CSBILLDESCs/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSBILLDESC cSBILLDESC = db.CSBILLDESCs.Find(MyHtmlHelpers.ConvertByteStrToId(id)); if (cSBILLDESC == null) { return(HttpNotFound()); } return(View(cSBILLDESC)); }