public ActionResult DeleteConfirmed(string id, string refno) { CSCODEB cSCODEB = db.CSCODEBs.Find(MyHtmlHelpers.ConvertByteStrToId(id), refno); try { db.CSCODEBs.Remove(cSCODEB); db.SaveChanges(); return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCODEB.CONO) }) + "#Debenture")); } 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(cSCODEB)); }
public ActionResult DeleteConfirmed(string id) { CSCODEB cSCODEB = db.CSCODEBs.Find(id); db.CSCODEBs.Remove(cSCODEB); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CONO,REFNO,REFDATE,DEEDDATE,PRSCODE,SECUREAMT,ISSUEAMT,DEBCOND,DEBINFO,REM,STAMP")] CSCODEB cSCODEB) { if (ModelState.IsValid) { db.Entry(cSCODEB).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PRSCODE = new SelectList(db.CSPRS, "PRSCODE", "CONSTCODE", cSCODEB.PRSCODE); return(View(cSCODEB)); }
// GET: CSCODEBs/Create public ActionResult Create(string id) { CSCODEB cSCODEB = new CSCODEB(); cSCODEB.CONO = MyHtmlHelpers.ConvertByteStrToId(id); cSCODEB.REFDATE = DateTime.Today; cSCODEB.DEEDDATE = DateTime.Today; ViewBag.PRSCODE = new SelectList(db.CSPRS.OrderBy(x => x.PRSNAME), "PRSCODE", "PRSNAME"); cSCODEB.CSCOMSTR = db.CSCOMSTRs.Find(cSCODEB.CONO); return(View(cSCODEB)); }
// GET: CSCODEBs/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSCODEB cSCODEB = db.CSCODEBs.Find(id); if (cSCODEB == null) { return(HttpNotFound()); } return(View(cSCODEB)); }
// GET: CSCODEBs/Delete/5 public ActionResult Delete(string id, string refno) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSCODEB cSCODEB = db.CSCODEBs.Find(MyHtmlHelpers.ConvertByteStrToId(id), refno); if (cSCODEB == null) { return(HttpNotFound()); } return(View(cSCODEB)); }
// GET: CSCODEBs/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSCODEB cSCODEB = db.CSCODEBs.Find(id); if (cSCODEB == null) { return(HttpNotFound()); } ViewBag.PRSCODE = new SelectList(db.CSPRS, "PRSCODE", "CONSTCODE", cSCODEB.PRSCODE); return(View(cSCODEB)); }
// GET: CSCODEBs/Edit/5 public ActionResult Edit(string id, string refno) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSCODEB cSCODEB = db.CSCODEBs.Find(MyHtmlHelpers.ConvertByteStrToId(id), refno); if (cSCODEB == null) { return(HttpNotFound()); } Session["CSCODEB_ORIG"] = cSCODEB; ViewBag.PRSCODE = new SelectList(db.CSPRS.OrderBy(x => x.PRSNAME), "PRSCODE", "PRSNAME", cSCODEB.PRSCODE); return(View(cSCODEB)); }
public ActionResult Create([Bind(Include = "CONO,REFNO,REFDATE,DEEDDATE,PRSCODE,SECUREAMT,ISSUEAMT,DEBCOND,DEBINFO,DEBINFOStr,REM,STAMP")] CSCODEB cSCODEB) { if (ModelState.IsValid) { try { cSCODEB.STAMP = 0; db.CSCODEBs.Add(cSCODEB); db.SaveChanges(); return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCODEB.CONO) }) + "#Debenture")); } 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); } } ViewBag.PRSCODE = new SelectList(db.CSPRS.OrderBy(x => x.PRSNAME), "PRSCODE", "PRSNAME", cSCODEB.PRSCODE); cSCODEB.CSCOMSTR = db.CSCOMSTRs.Find(cSCODEB.CONO); return(View(cSCODEB)); }