public ActionResult Create(int?LedgerAccountGroupId, int?LedgerAccountId, int ProductTypeId, string ControllerName, string Route) { //if (LedgerAccountGroupId.HasValue && LedgerAccountGroupId.Value > 0) // System.Web.HttpContext.Current.Session["LedgerAccountGroupId"] = LedgerAccountGroupId.Value; //if (LedgerAccountId.HasValue && LedgerAccountId.Value > 0) // System.Web.HttpContext.Current.Session["LedgerAccountId"] = LedgerAccountId.Value; ViewBag.id = ProductTypeId; System.Web.HttpContext.Current.Session["ProductTypeId"] = ProductTypeId; System.Web.HttpContext.Current.Session["Route"] = Route; System.Web.HttpContext.Current.Session["ControllerName"] = ControllerName.ToString(); string UserName = User.Identity.Name; var Settings = _StockInHandSettingService.GetTrailBalanceSetting(UserName, ProductTypeId, Route); PrepareViewBag(ProductTypeId, Route); if (Settings == null) { StockInHandSetting settings = new StockInHandSetting(); settings.UserName = UserName; settings.SiteIds = Convert.ToString((int)System.Web.HttpContext.Current.Session["SiteId"]); settings.ToDate = DateTime.Now; settings.FromDate = new DocumentTypeService(_unitOfWork).GetFinYearStart(); settings.GroupOn = StockInHandGroupOnConstants.Product; settings.ShowBalance = StockInHandShowBalanceConstants.All; settings.ProductTypeId = ProductTypeId; settings.TableName = Route; settings.ShowOpening = false; return(View("Create", settings)); } else { return(View("Create", Settings)); } }
public StockInHandSetting Add(StockInHandSetting pt) { _unitOfWork.Repository <StockInHandSetting>().Insert(pt); return(pt); }
public void Update(StockInHandSetting pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <StockInHandSetting>().Update(pt); }
public void Delete(StockInHandSetting pt) { _unitOfWork.Repository <StockInHandSetting>().Delete(pt); }
public StockInHandSetting Create(StockInHandSetting pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <StockInHandSetting>().Insert(pt); return(pt); }
public ActionResult CreatePost(StockInHandSetting vm) { int?LedgerAccountGroupId = null; int?LedgerAccountId = null; //if(System.Web.HttpContext.Current.Session["LedgerAccountGroupId"] != null) //LedgerAccountGroupId=(int)System.Web.HttpContext.Current.Session["LedgerAccountGroupId"]; //if (System.Web.HttpContext.Current.Session["LedgerAccountId"] != null) //LedgerAccountId=(int)System.Web.HttpContext.Current.Session["LedgerAccountId"]; int ProductTypeId = (int)System.Web.HttpContext.Current.Session["ProductTypeId"]; string ControllerName = (string)System.Web.HttpContext.Current.Session["ControllerName"]; string Routeid = (string)System.Web.HttpContext.Current.Session["Route"]; ViewBag.id = ProductTypeId; if (!vm.FromDate.HasValue) { ModelState.AddModelError("FromDate", "The From date field is required."); } if (!vm.ToDate.HasValue) { ModelState.AddModelError("ToDate", "The To date field is required."); } if (string.IsNullOrEmpty(vm.GroupOn)) { ModelState.AddModelError("GroupOn", "The GroupOn field is required."); } if (ModelState.IsValid) { if (vm.StockInHandSettingId <= 0) { vm.ObjectState = Model.ObjectState.Added; _StockInHandSettingService.Create(vm); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); PrepareViewBag(ProductTypeId, Routeid); return(View("Create", vm)); } //System.Web.HttpContext.Current.Session.Remove("LedgerAccountGroupId"); //System.Web.HttpContext.Current.Session.Remove("LedgerAccountId"); //if (LedgerAccountGroupId.HasValue && LedgerAccountGroupId.Value > 0) // return RedirectToAction("GetSubStockInHand", "StockInHand", new { id = LedgerAccountGroupId }).Success("Data saved successfully"); //else if (LedgerAccountId.HasValue && LedgerAccountId.Value > 0) // return RedirectToAction("GetLedgerBalance", "StockInHand", new { id = LedgerAccountId }).Success("Data saved successfully"); //else System.Web.HttpContext.Current.Session.Remove("ProductTypeId"); System.Web.HttpContext.Current.Session.Remove("ControllerName"); if (ControllerName == "StockProcessDisplay") { return(RedirectToAction("GetStockInHand", "StockProcessDisplay", new { id = ProductTypeId }).Success("Data saved successfully")); } else if (ControllerName == "StockInHandDisplay") { return(RedirectToAction("GetStockInHand", "StockInHandDisplay", new { id = ProductTypeId, Routeid = Routeid }).Success("Data saved successfully")); } else { return(RedirectToAction("GetStockInHand", "StockInHand", new { id = ProductTypeId }).Success("Data saved successfully")); } } else { vm.ObjectState = Model.ObjectState.Modified; _StockInHandSettingService.Update(vm); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); PrepareViewBag(ProductTypeId, Routeid); return(View("Create", vm)); } //System.Web.HttpContext.Current.Session.Remove("LedgerAccountGroupId"); //System.Web.HttpContext.Current.Session.Remove("LedgerAccountId"); //if (LedgerAccountGroupId.HasValue && LedgerAccountGroupId.Value > 0) // return RedirectToAction("GetSubStockInHand", "StockInHand", new { id = LedgerAccountGroupId }).Success("Data saved successfully"); //else if (LedgerAccountId.HasValue && LedgerAccountId.Value > 0) // return RedirectToAction("GetLedgerBalance", "StockInHand", new { id = LedgerAccountId }).Success("Data saved successfully"); //else System.Web.HttpContext.Current.Session.Remove("ProductTypeId"); System.Web.HttpContext.Current.Session.Remove("ControllerName"); if (ControllerName == "StockProcessDisplay") { return(RedirectToAction("GetStockInHand", "StockProcessDisplay", new { id = ProductTypeId }).Success("Data saved successfully")); } else if (ControllerName == "StockInHandDisplay") { return(RedirectToAction("GetStockInHand", "StockInHandDisplay", new { id = ProductTypeId, Routeid = Routeid }).Success("Data saved successfully")); } else { return(RedirectToAction("GetStockInHand", "StockInHand", new { id = ProductTypeId }).Success("Data saved successfully")); } // return RedirectToAction("GetStockInHand", "StockInHand", new { id = ProductTypeId }).Success("Data saved successfully"); } } else { PrepareViewBag(ProductTypeId, Routeid); return(View("Create", vm)); } }