public ActionResult Insert(ConveyanceInOut convInOut, bool wantClose) { //ConveyanceInOut convInOut = new ConveyanceInOut(); this.convInOutRepo.CurrentUserName = HttpContext.User.Identity.Name; try { convInOutRepo.DoNewRecord(convInOut); UpdateModel(convInOut); convInOutRepo.DoSave(convInOut, true); TempData.AddInfo(Resources.Messages.SaveSuccess); if (!wantClose) { return(RedirectToAction("Edit", new { id = convInOut.Id })); } return(RedirectToAction("Index2")); } catch (RulesException ex) { ex.CopyTo(ModelState); TempData.AddWarning(Resources.Messages.SaveError + ex.ExMessage()); } catch (Exception ex) { TempData.AddWarning(Resources.Messages.SaveError + ex.ExMessage()); } return(doInsert(convInOut)); }
public ActionResult Delete(int id) { ConveyanceInOut convInOut = convInOutRepo.GetOne(id); if (convInOut != null) { try { //Delete the record convInOutRepo.DoDelete(convInOut); new RecordDeletedEvent("ConveyanceInOut", convInOut.Id, 0, convInOut.Code, convInOut.Conveyance.Name, null).Raise(); TempData.AddInfo(Resources.Messages.DeleteSuccess + " (" + convInOut.Code + "-" + convInOut.Conveyance.Name + ")"); } catch (Exception ex) { TempData.AddError(ex.ExMessage()); return(RedirectToAction("Edit", new { id = id })); } } else { TempData.AddError(Resources.Messages.NotFoundData); } return(RedirectToAction("Index2")); }
private ActionResult doInsert(ConveyanceInOut convInOut) { ToolbarMenuHelpers.SetToolBar(ViewData, new { Save = "btnSave", New = "Insert", Close = "Index2" }, "ConveyanceInOut"); //makeReferenceViewData(); convInOut.Code = convInOutRepo.GetNewCode(); return(View(convInOut)); }
private ActionResult doEdit(ConveyanceInOut convInOut, bool?backToSearch = null) { ToolbarMenuHelpers.SetToolBar(ViewData, new { Save = "btnSave", New = "Insert", GiveUp = "btnDelete", Close = "Index2" }, "ConveyanceInOut", new { backToSearch }); //ส่งผ่านตัวแปรเพื่อทำ combobox //makeReferenceViewData(); if (convInOut != null) { return(View(convInOut)); } else { TempData.AddError(Resources.Messages.NotFoundData); return(RedirectToAction("Index2")); } }