コード例 #1
0
        public StockOutViewModel GetIndexListStockItemForSold(IOwinContext owinContext,
                                                              ExtendedIdentityDbContext db, ContractListCondition condition)
        {
            var saleItemQuery = db.SaleProductItems.Include("SaleContract").Include("StockItem")
                                .Include("OrderProductItem").Where(si => si.StockItem != null &&
                                                                   si.StockItem.StockStatus == StockStatus.InStock)
                                .Select(SaleItem => new
            {
                SaleItem,
                SaleItem.SaleContract.SaleContractKey,
                SaleItem.SaleContract.SaleCreateTime,
                SaleItem.StockItem
            });

            StockOutViewModel resultViewModel = new StockOutViewModel();

            AggregationsViewModel aggregation = new AggregationsViewModel();

            if (condition != null && condition.IsEnable.GetValueOrDefault())
            {
                if (condition.OrderType.HasValue)
                {
                    saleItemQuery = saleItemQuery.Where(m => condition.OrderType.Value
                                                        == m.SaleItem.SaleContract.OrderType);
                }

                if (ContractListInclude.WithAggregations ==
                    (condition.ListInclude & ContractListInclude.WithAggregations))
                {
                    aggregation.IsEnable         = true;
                    aggregation.Count            = saleItemQuery.Count();
                    resultViewModel.Aggregations = aggregation;
                }

                if (condition.OrderField == ContractOrderField.CONTRACT_KEY_ASC)
                {
                    saleItemQuery = saleItemQuery.OrderBy(m => m.SaleContractKey);
                }
                else if (condition.OrderField == ContractOrderField.CONTRACT_KEY_DESC)
                {
                    saleItemQuery = saleItemQuery.OrderByDescending(m => m.SaleContractKey);
                }
                else if (condition.OrderField == ContractOrderField.CTIME_DESC)
                {
                    saleItemQuery = saleItemQuery.OrderByDescending(
                        m => m.SaleCreateTime);
                }
                else
                {
                    saleItemQuery = saleItemQuery.OrderBy(
                        m => m.SaleCreateTime);
                }

                if (condition.Page.HasValue && condition.Rows.HasValue)
                {
                    saleItemQuery = saleItemQuery.Skip(
                        (condition.Page.Value - 1) * condition.Rows.Value)
                                    .Take(condition.Rows.Value);
                }

                resultViewModel.IsEnable = true;

                List <SaleProductItemInfo> saleItemInfos = new List <SaleProductItemInfo>();
                List <StockItemInfo>       stockInfos    = new List <StockItemInfo>();
                resultViewModel.StockViewModel = new StockViewModel()
                {
                    IsEnable = true
                };



                var list = saleItemQuery.ToList();
                foreach (var one in list)
                {
                    SaleProductItemInfo info = new SaleProductItemInfo(one.SaleItem);
                    saleItemInfos.Add(info);
                    StockItemInfo stInfo = new StockItemInfo(one.StockItem);
                    stockInfos.Add(stInfo);
                }

                resultViewModel.SaleProductItems          = saleItemInfos;
                resultViewModel.StockViewModel.StockItems = stockInfos;
            }

            return(resultViewModel);
        }
コード例 #2
0
 internal static void AssignValues(YuShang.ERP.Entities.Stocks.StockItem source, StockItemInfo target)
 {
     target.IsAllSold             = source.IsAllSold;
     target.OrderContractKey      = source.OrderContractKey;
     target.ProductItemId         = source.ProductItemId;
     target.ProductKey            = source.ProductKey;
     target.ProductName           = source.ProductName;
     target.Quantity              = source.Quantity;
     target.StockInDate           = source.StockInDate;
     target.StockItemId           = source.StockItemId;
     target.StockStatus           = source.StockStatus;
     target.StockWeight           = source.StockWeight;
     target.StoreHouseId          = source.StoreHouseId;
     target.StoreHouseMountNumber = source.StoreHouseMountNumber;
 }