private ActionResult ViewDetail(TblPile ob, string msg, AlertMsgType?msgType) { try { if (ob == null) { throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง"); } if (!string.IsNullOrWhiteSpace(msg)) { WidgetAlertModel alert = new WidgetAlertModel() { Message = msg }; if (msgType.HasValue) { alert.Type = msgType.Value; } ViewBag.Alert = alert; } ViewData["optSeries"] = db.TblPileSeries.OrderBy(x => x.SeriesOrder).ToList(); return(View(ob)); } catch (Exception ex) { return(RedirectToAction("Index", MVCController, new { area = MVCArea, msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); } }
public ActionResult Delete() { try { int id = Request.Form["PileId"].ParseInt(); TblPile ob = db.TblPile.Find(id); if (ob == null) { return(RedirectToAction("Index", MVCController, new { msg = "ไม่พบข้อมูลที่ต้องการ", msgType = AlertMsgType.Warning })); } db.TblPile.Remove(ob); db.SaveChanges(); return(RedirectToAction("Index", MVCController, new { msg = "ลบข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); } catch (Exception ex) { return(RedirectToAction("Index", MVCController, new { msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); } }
public ActionResult SetDetail() { int id = Request.Form["PileId"].ParseInt(); TblPile ob = db.TblPile.Find(id) ?? new TblPile(); ob.PileName = Request.Form["PileName"]; ob.SeriesId = Request.Form["SeriesId"].ParseInt(); //ob.Series = db.TblPileSeries.Find(ob.SeriesId.Value); ob.PileLength = Request.Form["PileLength"].ParseInt(); ob.PileDia = Request.Form["PileDia"].ParseDecimal(); ob.PileBlade = Request.Form["PileBlade"].ParseDecimal(); ob.PileSpiralDepth = Request.Form["PileSpiralDepth"].ParseDecimal(); ob.PileSpiralLength = Request.Form["PileSpiralLength"].ParseDecimal(); ob.PileFlangeLength = Request.Form["PileFlangeLength"].ParseDecimal(); ob.PileFlangeWidth = Request.Form["PileFlangeWidth"].ParseDecimal(); ob.PileSeriesOrder = Request.Form["PileSeriesOrder"].ParseInt(); try { //Validate model b4 save if (ob.PileId <= 0) { db.TblPile.Add(ob); } else { db.Entry(ob).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); return(RedirectToAction("Index", new { area = "", controller = MVCController, msg = "บันทึกข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); } catch (Exception ex) { string msg = ex.GetMessage(true); return(ViewDetail(ob, msg, AlertMsgType.Danger)); } }
public ActionResult SetDetail() { int id = Request.Form["PileId"].ParseInt(); TblPile ob = uow.Modules.Pile.Get(id); ob.PileName = Request.Form["PileName"]; ob.SeriesId = Request.Form["SeriesId"].ParseInt(); ob.Series = uow.Modules.PileSeries.Get(ob.SeriesId.Value); ob.PileLength = Request.Form["PileLength"].ParseInt(); ob.PileDia = Request.Form["PileDia"].ParseDecimal(); ob.PileBlade = Request.Form["PileBlade"].ParseDecimal(); ob.PileSpiralDepth = Request.Form["PileSpiralDepth"].ParseDecimal(); ob.PileSpiralLength = Request.Form["PileSpiralLength"].ParseDecimal(); ob.PileFlangeLength = Request.Form["PileFlangeLength"].ParseDecimal(); ob.PileFlangeWidth = Request.Form["PileFlangeWidth"].ParseDecimal(); ob.PileSeriesOrder = Request.Form["PileSeriesOrder"].ParseInt(); try { //Validate model b4 save uow.Modules.Pile.Set(ob); uow.SaveChanges(); return(RedirectToAction("Index", new { area = "", controller = MVCController, msg = "บันทึกข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); } catch (Exception ex) { string msg = ex.GetMessage(true); return(ViewDetail(ob, msg, AlertMsgType.Danger)); } }
public ActionResult Detail(int?id, string msg, AlertMsgType?msgType) { TblPile ob = db.TblPile.Find(id ?? 0) ?? new TblPile(); return(ViewDetail(ob, msg, msgType)); }
public ActionResult Detail(int?id, string msg, AlertMsgType?msgType) { TblPile ob = uow.Modules.Pile.Get(id ?? 0); return(ViewDetail(ob, msg, msgType)); }