public Object EditRecord(Int64 UnitID) { Unit _unit = new Unit(); try { UnitMaster unit = DAL.DALUnit.EditUnit(Convert.ToInt32(UnitID)); _unit.ID = unit.ID; if (unit.UnitCode != null) { _unit.UnitCode = unit.UnitCode; } if (unit.UnitName != null) { _unit.UnitName = unit.UnitName; } if (unit.Volume != null) { _unit.Multiplier = unit.Volume.ToString(); } } catch (Exception ex) { throw; } return _unit; }
public ActionResult Create(Unit model) { if (Session["Login"] != null) { if (String.IsNullOrEmpty(model.UnitCode)) { ModelState.AddModelError("Unit Code", "Please Enter Unit Code"); } if (ModelState.IsValid) { try { LoginSession loginsession = (LoginSession)Session["Login"]; model.CreateBy = Convert.ToInt64(loginsession.UserID); if (UnitModel.CreateUnit(model)) { return Json(new { result = 1, message = "Record was successfully Saved!" }); } else { return Json(new { result = 0, message = "Duplicate Unit Code " }); } } 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 Edit(String UnitID) { 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 (UnitID != null) { String DecUnitID = BAL.Security.URLDecrypt(UnitID); if ((DecUnitID != "0") && (DecUnitID != null)) { Unit unit = new Unit(); try { unit = BAL.UnitModel.EditUnit(DecUnitID); ViewBag.UnitID = unit.ID; } catch (Exception ex) { return Content(ex.Message); } return View(unit); } } { return RedirectToAction("Index", "Unit"); } } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Update(Unit model) { if (Session["Login"] != null) { if (ModelState.IsValid) { try { LoginSession loginsession = (LoginSession)Session["Login"]; model.ModifyBy = Convert.ToInt64(loginsession.UserID); if (UnitModel.UpdateUnit(model)) { return RedirectToAction("Index", "Unit"); } else { return Content("Unable to save , try again"); } } catch (Exception ex) { return Content("ErrorMessage" + ":" + ex.StackTrace.ToString()); } } else { return RedirectToAction("Index", "Unit"); } } else { return RedirectToAction("Index", "Home"); } }
public static bool UpdateUnit(Unit unit) { Boolean flag = false; try { Icontext objinter = new BALUnit(); flag = objinter.UpdateRecord(unit); } catch (Exception ex) { throw; } return flag; }
public static Boolean CreateUnit(Unit unit) { Boolean flag = false; try { Icontext objtext = new BALUnit(); flag = objtext.CreateRecord(unit); } catch (Exception ex) { throw; } return flag; }