public static Boolean CreateSupply(SupplyMaster supply) { Boolean flag = false; try { Icontext objtext = new BALSupply(); flag = objtext.CreateRecord(supply); } catch (Exception ex) { throw; } return flag; }
public ActionResult Create(SupplyMaster 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 (String.IsNullOrEmpty(model.EnergyID.ToString())) { ModelState.AddModelError("Energy", "Please Select Energy"); } if (String.IsNullOrEmpty(model.UnitID.ToString())) { ModelState.AddModelError("Unit", "Please Select Unit"); } if (ModelState.IsValid) { try { model.CreateBy = Convert.ToInt64(loginsession.UserID); if (SupplyModel.CreateSupply(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(SupplyMaster model) { if (Session["Login"] != null) { 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 (String.IsNullOrEmpty(model.EnergyID.ToString())) { ModelState.AddModelError("Energy", "Please Select Energy"); } if (String.IsNullOrEmpty(model.UnitID.ToString())) { ModelState.AddModelError("Unit", "Please Select Unit"); } if (ModelState.IsValid) { try { LoginSession loginsession = (LoginSession)Session["Login"]; model.ModifyBy = Convert.ToInt64(loginsession.UserID); if (SupplyModel.UpdateSupply(model)) { return RedirectToAction("Index", "Supplier"); } else { // return Json(new { result = 0, message = "Duplicate Currency Name " }); return Content("Unable to save , try again"); } } catch (Exception ex) { return Content("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 Content("ErrorMessage" + ":" + exception); } } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Edit(String SupID) { 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 (SupID != null) { String DecSupID = BAL.Security.URLDecrypt(SupID); if ((DecSupID != "0") && (DecSupID != null)) { SupplyMaster supply = new SupplyMaster(); try { supply = BAL.SupplyModel.EditSupply(DecSupID); ViewBag.SuppID = supply.ID; if ((loginsession.ClientID != null)&&(supply.ClientID != null)) { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text", supply.ClientID.ToString()); ViewBag.ClientID = supply.ClientID; } else { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text"); } if (supply.EnergyID != null) { ViewBag.Energy = new SelectList(BAL.EnergyModel.EnergyDropDownList(), "Value", "Text", supply.EnergyID); } else { ViewBag.Energy = new SelectList(BAL.EnergyModel.EnergyDropDownList(), "Value", "Text"); } if (supply.UnitID != null) { ViewBag.Unit = new SelectList(BAL.UnitModel.UnitDropDownList(), "Value", "Text", supply.UnitID); } else { ViewBag.Unit = new SelectList(BAL.UnitModel.UnitDropDownList(), "Value", "Text"); } if ((supply.SiteID != null) && (supply.ClientID != null)) { ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Convert.ToInt64(supply.ClientID), loginsession.UserType, loginsession.RoleName), "Value", "Text", supply.SiteID); ViewBag.SiteID = supply.SiteID; } else { ViewBag.Site = new SelectList(BAL.Common.Default_DDR(), "Value", "Text"); } } catch (Exception ex) { return Content(ex.Message); } return View(supply); } else { return RedirectToAction("Index", "Supplier"); } } else { return RedirectToAction("Index", "Supplier"); } } else { return RedirectToAction("Index", "Home"); } }
public Object EditRecord(Int64 SupplyID) { SupplyMaster _supply = new SupplyMaster(); try { Supplier supply = DAL.DALSupplier.EditSupply(Convert.ToInt64(SupplyID)); _supply.ID = supply.ID; if (supply.ClientID != null) { _supply.ClientID = supply.ClientID; } if (supply.SiteID != null) { _supply.SiteID = supply.SiteID; } if (supply.EnergyID != null) { _supply.EnergyID = supply.EnergyID; } if (supply.UnitID != null) { _supply.UnitID = supply.UnitID; } if (supply.Volume != null) { _supply.Multiplier = supply.Volume.ToString(); } } catch (Exception ex) { throw; } return _supply; }