예제 #1
0
        /// <summary>
        /// 数据源:申请单
        /// </summary>
        /// <param name="PRContents"></param>
        /// <param name="PurchaseItemRepository"></param>
        /// <param name="CostCenterRepository"></param>
        /// <param name="PartRepository"></param>
        public PurchaseContentGridViewModel(List <PRContent> PRContents,
                                            IPurchaseItemRepository PurchaseItemRepository,
                                            ICostCenterRepository CostCenterRepository,
                                            IPartRepository PartRepository,
                                            ITaskHourRepository TaskHourRepository)
        {
            rows = new List <PurchaseContentGridRowModel>();

            string state = "";

            foreach (PRContent _content in PRContents)
            {
                PurchaseItem _purchaseItem = PurchaseItemRepository.QueryByID(_content.PurchaseItemID);
                try
                {
                    state = Enum.GetName(typeof(PurchaseItemStatus), _purchaseItem.State);
                }
                catch
                {
                    state = "";
                }

                String     _costcenter;
                CostCenter _centerObj = CostCenterRepository.QueryByID(_purchaseItem.CostCenterID);
                if (_centerObj != null)
                {
                    _costcenter = _centerObj.Name;
                }
                else
                {
                    _costcenter = "";
                }
                string ERPNo = string.Empty;
                //if (_purchaseItem.PartID > 0)
                //{
                //    Part _part = PartRepository.QueryByID(_purchaseItem.PartID);
                //    ERPNo = _part.ERPPartID;
                //}
                ERPNo = _content.ERPPartID;
                SetupTaskStart _setupTask = new SetupTaskStart();
                #region 外发内容
                if (_content.TaskID > 0)
                {
                    TaskHour _taskhour = TaskHourRepository.TaskHours.Where(h => h.TaskID == _content.TaskID).OrderByDescending(h => h.TaskHourID).FirstOrDefault();
                    if (_taskhour != null)
                    {
                        _setupTask.TaskID       = _taskhour.TaskID;
                        _setupTask.MachinesName = TaskHourRepository.GetMachineByTask(_taskhour.TaskID) ?? "";
                        _setupTask.TotalTime    = TaskHourRepository.GetTotalHourByTaskID(_taskhour.TaskID);
                        _setupTask.UserName     = _taskhour.Operater;
                        _setupTask.MachinesCode = _taskhour.MachineCode;
                    }
                }
                #endregion
                rows.Add(new PurchaseContentGridRowModel(_content, state, _costcenter, ERPNo, _setupTask));
            }
            Page    = 1;
            Total   = PRContents.Count();
            Records = 500;
        }
예제 #2
0
 public ReturnItemGridViewModel(List <ReturnItem> ReturnItems,
                                IPurchaseItemRepository POItemRepository,
                                IWHStockRepository StockRepository,
                                int RequestState)
 {
     rows = new List <ReturnItemGridRowModel>();
     foreach (ReturnItem _item in ReturnItems)
     {
         WHStock      _stock  = StockRepository.QueryByID(_item.WarehouseItemID);
         PurchaseItem _poItem = POItemRepository.QueryByID(_item.PurchaseItemID);
         rows.Add(new ReturnItemGridRowModel(_item, _poItem, _stock, RequestState));
     }
     Page    = 1;
     Total   = ReturnItems.Count();
     Records = ReturnItems.Count();
 }