public ActionResult Insert(Endorse endorse, bool wantClose) { //Endorse endorse = new Endorse(); this.endorseRepo.CurrentUserName = HttpContext.User.Identity.Name; try { endorseRepo.DoNewRecord(endorse); UpdateModel(endorse); endorseRepo.DoSave(endorse, true); TempData.AddInfo(Resources.Messages.SaveSuccess); if (!wantClose) { return(RedirectToAction("Edit", new { id = endorse.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(endorse)); }
public ActionResult Delete(int id) { Endorse endorse = endorseRepo.GetOne(id); if (endorse != null) { try { //Delete the record endorseRepo.DoDelete(endorse); new RecordDeletedEvent("Endorse", endorse.Id, 0, endorse.Code, endorse.Alien.Name.FullName, null).Raise(); TempData.AddInfo(Resources.Messages.DeleteSuccess + " (" + endorse.Code + "-" + endorse.Alien.Name.FullName + ")"); } catch (Exception ex) { TempData.AddError(ex.ExMessage()); return(RedirectToAction("Edit", new { id = id })); } } else { TempData.AddError(Resources.Messages.NotFoundData); } return(RedirectToAction("Index2")); }
public ActionResult _GetEndorseCodeDetail(int id, string code, string xdate) { Endorse endorse = null; try { DateTime requestdate = DateTime.ParseExact(xdate, Globals.DateFormat, CultureInfo.InvariantCulture); endorse = endorseRepo.GetOneByCode(code, requestdate, id); if (endorse != null) { return(new JsonResult { Data = new { dupcode = true, code = code, rdate = endorse.RequestDate.ToString(Globals.DateFormat), id = endorse.Id, name = endorse.Alien.Name.FullName } }); } } catch (FormatException) { } return(new JsonResult { Data = new { dupcode = false } }); }
private ActionResult doInsert(Endorse endorse) { ToolbarMenuHelpers.SetToolBar(ViewData, new { Save = "btnSave", New = "Insert", Close = "Index2" }, "Endorse"); //makeReferenceViewData(); return(View(endorse)); }
private ActionResult doEdit(Endorse endorse) { ToolbarMenuHelpers.SetToolBar(ViewData, new { Save = "btnSave", New = "Insert", GiveUp = "btnDelete", Close = "Index2" }, "Endorse"); //ส่งผ่านตัวแปรเพื่อทำ combobox //makeReferenceViewData(); if (endorse != null) { return(View(endorse)); } else { TempData.AddError(Resources.Messages.NotFoundData); return(RedirectToAction("Index2")); } }