public ActionResult Create(TemperatureClass 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.TemperatureModel.CreateTemperatureDifference(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(TemperatureClass model) { if (Session["Login"] != null) { try { LoginSession loginsession = (LoginSession)Session["Login"]; model.ModifyBy = Convert.ToInt64(loginsession.UserID); if (BAL.TemperatureModel.UpdateTemperatureDifference(model)) { return RedirectToAction("Index", "Temperature"); } 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 TemperatureId) { TemperatureClass _Temperature = new TemperatureClass(); try { DAL.TemperatureDifference Temperature = DAL.DALTemperature.EditTemperatureDifference(Convert.ToInt64(TemperatureId)); _Temperature.ID = Convert.ToInt64(Temperature.ID); if (Temperature.ClientID != null) { _Temperature.ClientID = Convert.ToInt64(Temperature.ClientID); } if (Temperature.SiteID != null) { _Temperature.SiteID = Convert.ToInt64(Temperature.SiteID); } if (Temperature.Variance != null) { _Temperature.Variance = Temperature.Variance.ToString(); } if (Temperature.FormDate != null) { _Temperature.FromDate = BAL.Common.DateGBString(Temperature.FormDate.ToString()); } if (Temperature.ToDate != null) { _Temperature.ToDate = BAL.Common.DateGBString(Temperature.ToDate.ToString()); } else { _Temperature.ToDate = null; } } catch (Exception ex) { throw; } return _Temperature; }
public ActionResult Edit(String TemperatureID) { 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 (TemperatureID != null) { String DtempID = BAL.Security.URLDecrypt(TemperatureID); if ((DtempID != "0") && (DtempID != null)) { TemperatureClass Temperature = new TemperatureClass(); try { Temperature = BAL.TemperatureModel.EditTemperatureDifferencey(DtempID); ViewBag.SID = Temperature.ID; ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text", Temperature.ClientID); ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Temperature.ClientID, loginsession.UserType.ToString(), loginsession.RoleName), "Value", "Text", Temperature.SiteID); } catch (Exception ex) { return Content(ex.Message); } return View(Temperature); } } { return RedirectToAction("Index", "Temperature"); } } else { return RedirectToAction("Index", "Home"); } }
public static Boolean UpdateTemperatureDifference(TemperatureClass Temperature) { Boolean flag = false; try { Icontext objtext = new BALTemperature(); flag = objtext.UpdateRecord(Temperature); } catch (Exception ex) { throw; } return flag; }