示例#1
0
        public ActionResult GetListProductStockOut(ManageWarehouseModel model)
        {
            int currentPage = 1;
            int pageSize    = SystemSettings.DefaultPageSize;

            if (string.IsNullOrEmpty(model.SearchExec))
            {
                model.SearchExec = "Y";
                if (!ModelState.IsValid)
                {
                    ModelState.Clear();
                }
            }

            currentPage = model.CurrentPage;
            if (currentPage == 0)
            {
                currentPage = 1;
            }

            if (model.PageSize > 0)
            {
                pageSize = model.PageSize;
            }

            if (pageSize <= 0 || pageSize > 100)
            {
                pageSize = SystemSettings.DefaultPageSize;
            }

            var filter = new IdentityWarehouse
            {
                //ProductCode = !string.IsNullOrEmpty(model.Code) ? model.Code.Trim() : null,
                //Keyword = !string.IsNullOrEmpty(model.Name) ? model.Name.Trim() : null,
            };

            try
            {
                model.Units = CommonHelpers.GetListUnit();
                var warehouseStore = GlobalContainer.IocContainer.Resolve <IStoreWarehouse>();
                model.SearchResults = warehouseStore.GetProductStockOutByPage(filter, currentPage, SystemSettings.DefaultPageSize);
                if (model.SearchResults != null && model.SearchResults.Count > 0)
                {
                    model.TotalCount  = model.SearchResults[0].TotalCount;
                    model.CurrentPage = currentPage;
                    model.PageSize    = pageSize;
                }
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed to get GetProductStockOutByPage because: " + ex.ToString());
            }

            return(PartialView("Partials/_ProductStockOutList", model));
        }
示例#2
0
        public ActionResult Index(ManageWarehouseModel model)
        {
            int currentPage = 1;
            int pageSize    = SystemSettings.DefaultPageSize;

            if (string.IsNullOrEmpty(model.SearchExec))
            {
                model.SearchExec = "Y";
                if (!ModelState.IsValid)
                {
                    ModelState.Clear();
                }
            }

            if (Request["Page"] != null)
            {
                currentPage = Utils.ConvertToInt32(Request["Page"], 1);
            }

            var filter = new IdentityWarehouse
            {
                ProductCode    = !string.IsNullOrEmpty(model.Code) ? model.Code.Trim() : null,
                Keyword        = !string.IsNullOrEmpty(model.Name) ? model.Name.Trim() : null,
                IsStockTakeQTY = model.IsConfirmStockTakeQTY == null ? -1 : (int)model.IsConfirmStockTakeQTY,
                IsStockOut     = model.IsStockOut == null ? -1 : (int)model.IsStockOut
            };

            try
            {
                model.Units = CommonHelpers.GetListUnit();

                model.SearchResults = _mainStore.GetByPage(filter, currentPage, SystemSettings.DefaultPageSize);
                if (model.SearchResults != null && model.SearchResults.Count > 0)
                {
                    model.TotalCount  = model.SearchResults[0].TotalCount;
                    model.CurrentPage = currentPage;
                    model.PageSize    = pageSize;
                }
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed to get data because: " + ex.ToString());

                return(View(model));
            }

            return(View(model));
        }