public ActionResult Create(FlowTemperaturesClass model) { if (Session["Login"] != null) { LoginSession loginsession = (LoginSession)Session["Login"]; ViewBag.CompanyLogo = loginsession.CompanyLogo; ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType); String actionName = this.ControllerContext.RouteData.Values["action"].ToString(); String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType)); ViewBag.RoleName = loginsession.RoleName; if (String.IsNullOrEmpty(model.ClientID.ToString())) { ModelState.AddModelError("Client", "Please Select Client"); } if (String.IsNullOrEmpty(model.SiteID.ToString())) { ModelState.AddModelError("Site", "Please Select Site"); } if (ModelState.IsValid) { try { model.CreateBy = Convert.ToInt64(loginsession.UserID); if (BAL.FlowTemperaturesModel.CreateFlowTemperatures(model)) { return Json(new { result = 1, message = "Record was successfully Saved!" }); } else { return Json(new { result = 0, message = "Duplicate Energy Supplier " }); } } catch (Exception ex) { return Json(new { result = 0, message = "ErrorMessage" + ":" + ex.StackTrace.ToString() }); } } else { String errorMessage = String.Empty; String exception = String.Empty; foreach (var modelStateVal in ViewData.ModelState.Values) { foreach (var error in modelStateVal.Errors) { errorMessage = error.ErrorMessage; exception = error.Exception.ToString(); } } return Json(new { result = 0, message = "ErrorMessage" + ":" + exception }); } } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Update(FlowTemperaturesClass model) { if (Session["Login"] != null) { try { LoginSession loginsession = (LoginSession)Session["Login"]; model.ModifyBy = Convert.ToInt64(loginsession.UserID); if (BAL.FlowTemperaturesModel.UpdateFlowTemperatures(model)) { return RedirectToAction("Index", "Flow"); } else { return Content("Unable to save ,Plz Try again"); } } catch (Exception ex) { return Content("ErrorMessage" + ":" + ex.StackTrace.ToString()); } } else { return RedirectToAction("Index", "Home"); } }
public Object EditRecord(Int64 FlowId) { FlowTemperaturesClass _Flow = new FlowTemperaturesClass(); try { DAL.FlowTemperature Flow = DAL.DALFlowTemperatures.EditFlowTemperature(Convert.ToInt64(FlowId)); _Flow.ID = Convert.ToInt64(Flow.ID); if (Flow.ClientID != null) { _Flow.ClientID = Convert.ToInt64(Flow.ClientID); } if (Flow.SiteID != null) { _Flow.SiteID = Convert.ToInt64(Flow.SiteID); } if (Flow.LowestFlowTemperature != null) { _Flow.LowestFlowTemperature = Flow.LowestFlowTemperature.ToString(); } if (Flow.FormDate != null) { _Flow.FromDate = BAL.Common.DateGBString(Flow.FormDate.ToString()); } else { _Flow.FromDate = null; } if (Flow.ToDate != null) { _Flow.ToDate = BAL.Common.DateGBString(Flow.ToDate.ToString()); } else { _Flow.ToDate = null; } } catch (Exception ex) { throw; } return _Flow; }
public ActionResult Edit(String FlowID) { if (Session["Login"] != null) { LoginSession loginsession = (LoginSession)Session["Login"]; ViewBag.CompanyLogo = loginsession.CompanyLogo; ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType); String actionName = this.ControllerContext.RouteData.Values["action"].ToString(); String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType)); ViewBag.RoleName = loginsession.RoleName; if (FlowID != null) { String DFlowID = BAL.Security.URLDecrypt(FlowID); if ((DFlowID != "0") && (DFlowID != null)) { FlowTemperaturesClass Flow = new FlowTemperaturesClass(); try { Flow = BAL.FlowTemperaturesModel.EditFlowTemperatures(DFlowID); ViewBag.SID = Flow.ID; ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text", Flow.ClientID); ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Flow.ClientID, loginsession.UserType.ToString(), loginsession.RoleName), "Value", "Text", Flow.SiteID); } catch (Exception ex) { return Content(ex.Message); } return View(Flow); } } { return RedirectToAction("Index", "Flow"); } } else { return RedirectToAction("Index", "Home"); } }
public static Boolean UpdateFlowTemperatures(FlowTemperaturesClass Flow) { Boolean flag = false; try { Icontext objtext = new BALFlowTemperatures(); flag = objtext.UpdateRecord(Flow); } catch (Exception ex) { throw; } return flag; }