public ActionResult _AjaxList(GridCommand command, PlanBillSearchModel searchModel)
 {
     //int pageSize = command.PageSize;
     //int page = command.Page;
     command.PageSize = int.MaxValue;
     command.Page = 1;
     SearchStatementModel searchStatementModel = PrepareSearchStatement(command, searchModel);
     var gridData = GetAjaxPageData<PlanBill>(searchStatementModel, command);
     //command.PageSize = pageSize;
     //command.Page = page;
     gridData.Data = gridData.Data.GroupBy(p => new
         {
             p.Party,
             p.Item,
             p.Uom,
         }, (k, g) => new PlanBill
         {
             Party = k.Party,
             Item = k.Item,
             ItemDescription = g.First().ItemDescription,
             Uom = k.Uom,
             CurrentActingQty = g.Sum(q => q.PlanQty) - g.Sum(q => q.ActingQty),
         });
     return PartialView(gridData);
 }
        public ActionResult List(GridCommand command, PlanBillSearchModel searchModel)
        {
            TempData["PlanBillSearchModel"] = searchModel;
            ViewBag.PageSize = base.ProcessPageSize(command.PageSize);

            return View();
        }
Example #3
0
 public ActionResult InventoryList(GridCommand command, PlanBillSearchModel searchModel)
 {
     TempData["PlanBillSearchModel"] = searchModel;
     if (this.CheckSearchModelIsNull(searchModel))
     {
         TempData["_AjaxMessage"] = "";
     }
     else
     {
         SaveWarningMessage(Resources.ErrorMessage.Errors_NoConditions);
     }
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     return View();
 }
        private SearchStatementModel PrepareSearchStatement(GridCommand command, PlanBillSearchModel searchModel)
        {
            string whereStatement = string.Empty;
            IList<object> param = new List<object>();

            SecurityHelper.AddBillPermissionStatement(ref whereStatement, "p", "Party", com.Sconit.CodeMaster.BillType.Procurement);

            HqlStatementHelper.AddLikeStatement("OrderNo", searchModel.OrderNo, HqlStatementHelper.LikeMatchMode.Start, "p", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("ReceiptNo", searchModel.ReceiptNo, HqlStatementHelper.LikeMatchMode.Start, "p", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Item", searchModel.Item, "p", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Party", searchModel.Party, "p", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Type", com.Sconit.CodeMaster.BillType.Procurement, "p", ref whereStatement, param);

            if (searchModel.CreateDate_start != null & searchModel.CreateDate_End != null)
            {
                HqlStatementHelper.AddBetweenStatement("CreateDate", searchModel.CreateDate_start, searchModel.CreateDate_End, "p", ref whereStatement, param);
            }
            else if (searchModel.CreateDate_start != null & searchModel.CreateDate_End == null)
            {
                HqlStatementHelper.AddGeStatement("CreateDate", searchModel.CreateDate_start, "p", ref whereStatement, param);
            }
            else if (searchModel.CreateDate_start == null & searchModel.CreateDate_End != null)
            {
                HqlStatementHelper.AddLeStatement("CreateDate", searchModel.CreateDate_End, "p", ref whereStatement, param);
            }
            if (whereStatement == string.Empty)
            {
                whereStatement += " where p.PlanQty>p.ActingQty";
            }
            else
            {
                whereStatement += " and p.PlanQty>p.ActingQty";
            }
            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement = selectStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }
        private GridModel<PlanBill> GetPlanBillGridModel(GridCommand command, PlanBillSearchModel searchModel)
        {
            command.PageSize = int.MaxValue;
            command.Page = 1;
            string whereStatement = string.Empty;
            IList<object> param = new List<object>();
            SecurityHelper.AddBillPermissionStatement(ref whereStatement, "b", "Party", com.Sconit.CodeMaster.BillType.Distribution);
            HqlStatementHelper.AddEqStatement("Party", searchModel.Party, "b", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Flow", searchModel.Flow, "b", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Currency", searchModel.Currency, "b", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Item", searchModel.Item, "b", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Type", com.Sconit.CodeMaster.BillType.Distribution, "b", ref whereStatement, param);
            if (searchModel.StartTime != null & searchModel.EndTime != null)
            {
                HqlStatementHelper.AddBetweenStatement("CreateDate", searchModel.StartTime, searchModel.EndTime, "b", ref whereStatement, param);
            }
            else if (searchModel.StartTime != null & searchModel.EndTime == null)
            {
                HqlStatementHelper.AddGeStatement("CreateDate", searchModel.StartTime, "b", ref whereStatement, param);
            }
            else if (searchModel.StartTime == null & searchModel.EndTime != null)
            {
                HqlStatementHelper.AddLeStatement("CreateDate", searchModel.EndTime, "b", ref whereStatement, param);
            }
            if (whereStatement == string.Empty)
            {
                whereStatement += " where b.PlanQty > b.ActingQty";
            }
            else
            {
                whereStatement += " and b.PlanQty > b.ActingQty";
            }
            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = "select count(*) from PlanBill as b";
            searchStatementModel.SelectStatement = "from PlanBill as b";
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return GetAjaxPageData<PlanBill>(searchStatementModel, command);
        }
        public JsonResult SettlePlanBill(PlanBillSearchModel searchModel, string itemStr, string uomStr, string currencyStr, string qtyStr)
        {
            try
            {
                var planBillList = GetPlanBillGridModel(new GridCommand(), searchModel).Data.OrderBy(p => p.CreateDate);
                string[] itemArray = itemStr.Split(',');
                string[] uomArray = uomStr.Split(',');
                string[] currencyArray = currencyStr.Split(',');
                string[] qtyArray = qtyStr.Split(',');

                for (int i = 0; i < itemArray.Length; i++)
                {
                    decimal currentSettleQty = Convert.ToDecimal(qtyArray[i]);
                    string item = itemArray[i];
                    string uom = uomArray[i];
                    string currency = currencyArray[i];
                    var planBills = planBillList.Where(p => p.Item == itemArray[i]
                        && p.Uom == uomArray[i] && p.Currency == currencyArray[i]);
                    foreach (var planBill in planBills)
                    {
                        //负数应该会自动结算,不考虑负数 todo 测试
                        var currentQty = planBill.PlanQty - planBill.ActingQty;
                        if (currentQty >= currentSettleQty)
                        {
                            planBill.CurrentActingQty = currentSettleQty;
                            currentSettleQty = 0;
                            break;
                        }
                        else
                        {
                            planBill.CurrentActingQty = currentQty;
                            currentSettleQty -= currentQty;
                        }
                    }
                }
                billMgr.SettleBillList(planBillList.Where(p => p.CurrentActingQty != 0).ToList());
                return Json(new object());
            }
            catch (BusinessException ex)
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode = 500;
                Response.Write(ex.GetMessages()[0].GetMessageString());
                return Json(null);
            }
        }
        public void ExportXLPlanBill(PlanBillSearchModel searchModel)
        {
            int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.MaxRowSizeOnPage));
            GridCommand command = new GridCommand();
            command.Page = 1;
            command.PageSize = !string.IsNullOrEmpty(searchModel.Party) ? 0 : value;
            var gridModel = new GridModel<PlanBill>(new List<PlanBill>());
            if (!string.IsNullOrEmpty(searchModel.Party))
            {
                gridModel = GetPlanBillGridModel(command, searchModel);
                gridModel.Data = gridModel.Data.GroupBy(p => new
                {
                    p.Item,
                    p.Currency,
                    p.Uom,
                }, (k, g) => new PlanBill
                {
                    Item = k.Item,
                    ItemDescription = g.First().ItemDescription,
                    ReferenceItemCode = g.First().ReferenceItemCode,
                    Uom = k.Uom,
                    Currency = k.Currency,
                    PlanQty = g.Sum(q => q.PlanQty),
                    ActingQty = g.Sum(q => q.ActingQty),
                    CurrentActingQty = g.Sum(q => q.PlanQty) - g.Sum(q => q.ActingQty)
                });
            }

            IList<PlanBill> PlanBillList = gridModel.Data.ToList();
            ExportToXLS<PlanBill>("PlanBill.xls", PlanBillList);
        }
 public ActionResult _AjaxPlanBillList(GridCommand command, PlanBillSearchModel searchModel)
 {
     var gridModel = new GridModel<PlanBill>(new List<PlanBill>());
     if (!string.IsNullOrEmpty(searchModel.Party))
     {
         gridModel = GetPlanBillGridModel(command, searchModel);
         gridModel.Data = gridModel.Data.GroupBy(p => new
         {
             p.Item,
             p.Currency,
             p.Uom,
         }, (k, g) => new PlanBill
         {
             Item = k.Item,
             ItemDescription = g.First().ItemDescription,
             ReferenceItemCode = g.First().ReferenceItemCode,
             Uom = k.Uom,
             Currency = k.Currency,
             PlanQty = g.Sum(q => q.PlanQty),
             ActingQty = g.Sum(q => q.ActingQty),
             CurrentActingQty = g.Sum(q => q.PlanQty) - g.Sum(q => q.ActingQty)
         });
     }
     return PartialView(gridModel);
 }
 public ActionResult _PlanBillList(GridCommand command, PlanBillSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     if (!string.IsNullOrEmpty(searchModel.Party))
     {
         TempData["_AjaxMessage"] = "";
     }
     else
     {
         SaveWarningMessage(Resources.EXT.ControllerLan.Con_SupplierCanNotBeEmpty);
     }
     ViewBag.Party = searchModel.Party;
     ViewBag.Flow = searchModel.Flow;
     ViewBag.Item = searchModel.Item;
     ViewBag.StartTime = searchModel.StartTime;
     ViewBag.EndTime = searchModel.EndTime;
     ViewBag.EndTime = searchModel.Currency;
     return PartialView();
 }
 public ActionResult _AjaxList(GridCommand command, PlanBillSearchModel searchModel)
 {
     SearchStatementModel searchStatementModel = PrepareSearchStatement(command, searchModel);
     return PartialView(GetAjaxPageData<PlanBill>(searchStatementModel, command));
 }
Example #11
0
 public ActionResult _InventoryAjaxList(GridCommand command, PlanBillSearchModel searchModel)
 {
     if (!this.CheckSearchModelIsNull(searchModel))
     {
         return PartialView(new GridModel(new List<PlanBill>()));
     }
     SearchStatementModel searchStatementModel = PrepareSearchInventoryStatement(command, searchModel);
     return PartialView(GetAjaxPageData<PlanBill>(searchStatementModel, command));
 }
        public ActionResult _ConsignmentAjaxList(GridCommand command, PlanBillSearchModel searchModel)
        {
            command.PageSize = int.MaxValue;
            command.Page = 1;

            //if (!this.CheckSearchModelIsNull(searchModel))
            //{
            //    return PartialView(new GridModel(new List<PlanBill>()));
            //}
            SearchStatementModel searchStatementModel = PrepareSearchConsignmentInventoryStatement(command, searchModel);
            var gridData = GetAjaxPageData<PlanBill>(searchStatementModel, command);
            var itemCategoryList = this.genericMgr.FindAll<ItemCategory>();
            foreach (var listdata in gridData.Data)
            {
                listdata.ItemDescription = itemMgr.GetCacheItem(listdata.Item).FullDescription;
                listdata.MaterialsGroup = itemMgr.GetCacheItem(listdata.Item).MaterialsGroup;
                listdata.MaterialsGroupDesc = GetItemCategory(listdata.MaterialsGroup, Sconit.CodeMaster.SubCategory.MaterialsGroup, itemCategoryList).Description;
            }
            gridData.Data = gridData.Data.GroupBy(p => new
            {
                p.Party,
                p.Item,
                p.Uom,
            }, (k, g) => new PlanBill
            {
                Party = k.Party,
                Item = k.Item,
                ItemDescription = g.First().ItemDescription,
                MaterialsGroup = g.First().MaterialsGroup,
                MaterialsGroupDesc = g.First().MaterialsGroupDesc,
                Uom = k.Uom,
                CurrentActingQty = g.Sum(q => q.PlanQty) - g.Sum(q => q.ActingQty),
            });
            return PartialView(gridData);
        }
 public ActionResult CustomerConsignmentList(GridCommand command, PlanBillSearchModel searchModel)
 {
     TempData["PlanBillSearchModel"] = searchModel;
     //if (this.CheckSearchModelIsNull(searchModel))
     //{
     //    TempData["_AjaxMessage"] = "";
     //}
     //else
     //{
     //    SaveWarningMessage(Resources.SYS.ErrorMessage.Errors_NoConditions);
     //}
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     return View();
 }