예제 #1
0
        public ActionResult ListItemDailyConsume(GridCommand command, ItemDailyConsumeSearchModel searchModel)
        {
            ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
            //if (string.IsNullOrEmpty(searchModel.Region))
            //{
            //    SaveWarningMessage("区域不能为空");
            //    return View();
            //}

            SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);

            ViewBag.SearchModel = searchModel;
            return View();
        }
예제 #2
0
        private ItemDailyConsumeView PrepareItemDailyConsumePrdView(ItemDailyConsumeSearchModel searchModel, int days)
        {
            ItemDailyConsumeView view = new ItemDailyConsumeView();
            ItemDailyConsumeHead head = new ItemDailyConsumeHead();
            view.ItemDailyConsumeHead = head;

            List<object> paras = new List<object>();
            paras.Add((int)com.Sconit.CodeMaster.FlowStrategy.KB);
            paras.Add((int)com.Sconit.CodeMaster.KBCalculation.CatItem);
            paras.Add(searchModel.StartDate);
            paras.Add(searchModel.EndDate);

            string where = string.Empty;
            //if (!string.IsNullOrEmpty(searchModel.Region))
            //{
            //    where += " and fm.PartyTo = ?";
            //    paras.Add(searchModel.Region);
            //}
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (!string.IsNullOrEmpty(searchModel.Region))
            {
                sb.Append(" and fm.PartyTo in (");
                string[] regions = searchModel.Region.Split(',');
                for (int ir = 0; ir < regions.Length; ir++)
                {
                    sb.Append("?,");
                    paras.Add(regions[ir]);
                }
                sb = sb.Remove(sb.Length - 1, 1);
                where += sb.ToString() + ")";
            }
            if (!string.IsNullOrEmpty(searchModel.Location))
            {
                where += " and fm.LocTo = ?";
                paras.Add(searchModel.Location);
            }
            if (!string.IsNullOrEmpty(searchModel.Item))
            {
                where += " and ic.Item = ?";
                paras.Add(searchModel.Item);
            }

            IList<ItemDailyConsume> idcs = this.genericMgr.FindEntityWithNativeSql<ItemDailyConsume>(@"select ic.* from cust_itemdailyconsume ic 
                    inner join scm_flowdet fd on ic.item = fd.item 
                    inner join scm_flowmstr fm on fd.flow = fm.code 
                    inner join scm_flowstrategy fg on fm.code = fg.flow
                    where fm.isactive=1 and fm.FlowStrategy = ? and fg.kbcalc = ? and ic.ConsumeDate >= ? and ic.ConsumeDate <= ? " + where, paras.ToArray());

            IList<ColumnCell> columnCellList = new List<ColumnCell>();

            for (int i = 0; i < days; i++)
            {
                ColumnCell c = new ColumnCell();
                c.ConsumeDate = searchModel.StartDate.Value.AddDays(i);
                columnCellList.Add(c);
            }
            head.ColumnCellList = columnCellList;

            var s = from idc in idcs
                    group idc by new
                    {
                        Item = idc.Item,
                        ItemDesc = idc.ItemDesc,
                        Location = idc.Location,
                        MultiSupplyGroup = idc.MultiSupplyGroup
                    } into g
                    select new ItemDailyConsumeBody
                    {
                        Item = g.Key.Item,
                        ItemDesc = g.Key.ItemDesc,
                        Location = g.Key.Location,
                        MultiSupplyGroup = g.Key.MultiSupplyGroup
                    };

            IList<ItemDailyConsumeBody> bodylist = s.ToList();
            if (bodylist != null && bodylist.Count > 0)
            {
                if (head.ColumnCellList != null && head.ColumnCellList.Count > 0)
                {
                    foreach (ItemDailyConsumeBody idcBody in bodylist)
                    {
                        Decimal maxConsumeQty = 0;
                        List<RowCell> rcs = new List<RowCell>();
                        for (int i = 0; i < days; i++)
                        {
                            RowCell rc = new RowCell();
                            rc.ConsumeDate = searchModel.StartDate.Value.AddDays(i);

                            var r = from idc in idcs
                                    where (idc.Item == idcBody.Item
                                        && idc.Location == idcBody.Location
                                        && idc.MultiSupplyGroup == idcBody.MultiSupplyGroup
                                        && idc.ConsumeDate == rc.ConsumeDate)
                                    select idc;
                            if (r != null && r.ToList().Count > 0)
                            {
                                rc.Qty = r.ToList()[0].OriginalQty;
                                rc.MaxQty = r.ToList()[0].Qty;
                            }
                            else
                            {
                                rc.Qty = 0;
                            }
                            rcs.Add(rc);

                            if (rc.MaxQty > maxConsumeQty)
                            {
                                maxConsumeQty = rc.MaxQty;
                            }
                        }

                        idcBody.MaxConsumeQty = maxConsumeQty;
                        idcBody.RowCellList = rcs;
                    }
                }
            }
            view.ItemDailyConsumeBodyList = bodylist;

            return view;
        }
예제 #3
0
        public ActionResult ListItemDailyConsumePrd(GridCommand command, ItemDailyConsumeSearchModel searchModel)
        {
            this.ProcessSearchModel(command, searchModel);
            ViewBag.ReadOnly = false;
            if (string.IsNullOrEmpty(searchModel.Region) && string.IsNullOrEmpty(searchModel.Item))
            {
                SaveWarningMessage("区域跟物料不能同时为空");
                ViewData["Columns"] = new List<GridColumnSettings>().ToArray();
                ViewBag.ReadOnly = true;
                return View();
            }

            if (searchModel.StartDate == null)
            {
                SaveWarningMessage("开始日期不能为空");
                ViewData["Columns"] = new List<GridColumnSettings>().ToArray();
                ViewBag.ReadOnly = true;
                return View();
            }

            if (searchModel.EndDate == null)
            {
                SaveWarningMessage("结束日期不能为空");
                ViewData["Columns"] = new List<GridColumnSettings>().ToArray();
                ViewBag.ReadOnly = true;
                return View();
            }
            //第二次刷新值没了,先放这里
            TempData["ItemDailyConsumeSearchModel"] = searchModel;
            ViewBag.SearchModel = searchModel;
            int days = (int)searchModel.EndDate.Value.Subtract(searchModel.StartDate.Value).TotalDays + 1;

            ItemDailyConsumeView itemDailyConsumeView = this.PrepareItemDailyConsumePrdView(searchModel, days);

            IList<GridColumnSettings> columns = new List<GridColumnSettings>();
            columns.Add(new GridColumnSettings
            {
                Member = itemDailyConsumeView.ItemDailyConsumeHead.Item,
                Title = Resources.KB.KanbanCard.KanbanCard_Item,
                Sortable = false
            });
            columns.Add(new GridColumnSettings
            {
                Member = itemDailyConsumeView.ItemDailyConsumeHead.ItemDesc,
                Title = Resources.CUST.ItemDailyConsume.ItemDailyConsume_ItemDesc,
                Sortable = false
            });
            columns.Add(new GridColumnSettings
            {
                Member = itemDailyConsumeView.ItemDailyConsumeHead.Location,
                Title = Resources.KB.KanbanCard.KanbanCard_Location,
                Sortable = false
            });
            columns.Add(new GridColumnSettings
            {
                Member = itemDailyConsumeView.ItemDailyConsumeHead.MultiSupplyGroup,
                Title = Resources.KB.KanbanCard.KanbanCard_MultiSupplyGroup,
                Sortable = false
            });
            columns.Add(new GridColumnSettings
            {
                Member = itemDailyConsumeView.ItemDailyConsumeHead.MaxConsumeQty,
                Title = Resources.KB.KanbanCard.KanbanCard_MaxConsumeQty,
                Sortable = false
            });
            columns.Add(new GridColumnSettings
            {
                Member = itemDailyConsumeView.ItemDailyConsumeHead.NewMaxConsumeQty,
                Title = Resources.KB.KanbanCard.KanbanCard_NewMaxConsumeQty,
                Sortable = false
            });

            if (itemDailyConsumeView.ItemDailyConsumeHead.ColumnCellList != null
                && itemDailyConsumeView.ItemDailyConsumeHead.ColumnCellList.Count > 0)
            {
                for (int i = 0; i < days; i++)
                {
                    columns.Add(new GridColumnSettings
                    {
                        Member = "RowCellList[" + i + "].Qty",
                        MemberType = typeof(Decimal),
                        Title = (itemDailyConsumeView.ItemDailyConsumeHead.ColumnCellList[i].ConsumeDate.Value.Date.ToShortDateString()),
                        Sortable = false
                    });
                }
            }

            ViewData["Columns"] = columns.ToArray();
            TempData["ExportListItemDailyConsumePrdColumns"] = columns;
            TempData["ExportListItemDailyConsumePrdBodyList"] = itemDailyConsumeView.ItemDailyConsumeBodyList;
            return View(itemDailyConsumeView.ItemDailyConsumeBodyList);
        }
예제 #4
0
        private SearchStatementModel ItemDailyConsumePrepareSearchStatement(GridCommand command, ItemDailyConsumeSearchModel searchModel)
        {
            string whereStatement = string.Empty;

            IList<object> param = new List<object>();
            if (!string.IsNullOrEmpty(searchModel.Region))
            {
                if (string.IsNullOrEmpty(searchModel.Location))
                {
                    //all loc of the region
                    IList<Location> locs = genericMgr.FindAll<Location>("from Location where Region = ? and IsActive = ? ", new object[] { searchModel.Region, true });
                    IList<string> locCodes = new List<string>();
                    if (locs != null)
                    {
                        foreach (Location loc in locs)
                        {
                            locCodes.Add(loc.Code);
                        }
                    }
                    HqlStatementHelper.AddInStatement("Location", locCodes.ToArray(), "u", ref whereStatement, param);
                }
                else
                {
                    HqlStatementHelper.AddEqStatement("Location", searchModel.Location, "u", ref whereStatement, param);
                }
            }
            HqlStatementHelper.AddEqStatement("Item", searchModel.Item, "u", ref whereStatement, param);
            if (searchModel.StartDate != null && searchModel.StartDate > DateTime.MinValue)
            {
                HqlStatementHelper.AddGeStatement("ConsumeDate", searchModel.StartDate, "u", ref whereStatement, param);
            }
            if (searchModel.EndDate != null && searchModel.EndDate > DateTime.MinValue)
            {
                HqlStatementHelper.AddLeStatement("ConsumeDate", searchModel.EndDate, "u", ref whereStatement, param);
            }

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

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

            return searchStatementModel;
        }
예제 #5
0
        public ActionResult _ItemDailyConsumeSaveBatch([Bind(Prefix = "updated")]IEnumerable<ItemDailyConsume> updates,
            ItemDailyConsumeSearchModel searchModel)
        {
            if (updates != null)
            {
                foreach (ItemDailyConsume idc in updates)
                {
                    this.genericMgr.Update(idc);
                }
            }

            GridCommand command = new GridCommand();
            SearchStatementModel searchStatementModel = this.ItemDailyConsumePrepareSearchStatement(command, searchModel);
            return PartialView(GetAjaxPageData<ItemDailyConsume>(searchStatementModel, command));
        }
예제 #6
0
 public ActionResult _ItemDailyConsumeAjaxList(GridCommand command, ItemDailyConsumeSearchModel searchModel)
 {
     SearchStatementModel searchStatementModel = this.ItemDailyConsumePrepareSearchStatement(command, searchModel);
     return PartialView(GetAjaxPageData<ItemDailyConsume>(searchStatementModel, command));
 }