public void GetSortOrderTest()
        {
            SortingDownService target = new SortingDownService(); // TODO: 初始化为适当的值

            SortOrder[] expected = null;                          // TODO: 初始化为适当的值
            SortOrder[] actual;
            actual = target.GetSortOrder("", "", "");

            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #2
0
        public bool DownSortOrder(string beginDate, string endDate, out string errorInfo)
        {
            errorInfo = string.Empty;
            bool   result        = false;
            string sortOrderStrs = "";
            string sortOrderList = "";

            try
            {
                var sortOrderIds = SortOrderRepository.GetQueryable().Where(s => s.OrderID == s.OrderID).Select(s => new { s.OrderID }).ToArray();

                for (int i = 0; i < sortOrderIds.Length; i++)
                {
                    sortOrderStrs += sortOrderIds[i].OrderID + ",";
                }

                SortOrder[] SortOrders = SortingDownService.GetSortOrder(beginDate, endDate, sortOrderStrs);

                foreach (var item in SortOrders)
                {
                    var sortOrder = new SortOrder();
                    sortOrder.OrderID         = item.OrderID;
                    sortOrder.CompanyCode     = item.CompanyCode;
                    sortOrder.SaleRegionCode  = item.SaleRegionCode;
                    sortOrder.OrderDate       = item.OrderDate;
                    sortOrder.OrderType       = item.OrderType;
                    sortOrder.CustomerCode    = item.CustomerCode;
                    sortOrder.CustomerName    = item.CustomerName;
                    sortOrder.DeliverLineCode = item.DeliverLineCode;
                    sortOrder.QuantitySum     = item.QuantitySum;
                    sortOrder.AmountSum       = item.AmountSum;
                    sortOrder.DetailNum       = item.DetailNum;
                    sortOrder.DeliverOrder    = item.DeliverOrder;
                    sortOrder.DeliverDate     = item.DeliverDate;
                    sortOrder.Description     = item.Description;
                    sortOrder.IsActive        = item.IsActive;
                    sortOrder.UpdateTime      = item.UpdateTime;
                    SortOrderRepository.Add(sortOrder);
                    sortOrderList += item.OrderID + ",";
                }
                if (sortOrderList != string.Empty)
                {
                    SortOrderDetail[] SortOrderDetails = null; //SortingDownService.GetSortOrderDetail(sortOrderList);
                    foreach (var detail in SortOrderDetails)
                    {
                        var sortOrderDetail = new SortOrderDetail();
                        var product         = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == detail.ProductCode);
                        sortOrderDetail.OrderDetailID  = detail.OrderDetailID;
                        sortOrderDetail.OrderID        = detail.OrderID;
                        sortOrderDetail.ProductCode    = detail.ProductCode;
                        sortOrderDetail.ProductName    = detail.ProductName;
                        sortOrderDetail.UnitCode       = detail.UnitCode;
                        sortOrderDetail.UnitName       = detail.UnitName;
                        sortOrderDetail.DemandQuantity = detail.DemandQuantity * product.UnitList.Unit02.Count;
                        sortOrderDetail.RealQuantity   = detail.RealQuantity * product.UnitList.Unit02.Count;
                        sortOrderDetail.Price          = detail.Price;
                        sortOrderDetail.Amount         = detail.Amount;
                        sortOrderDetail.UnitQuantity   = product.UnitList.Quantity02;
                        SortOrderDetailRepository.Add(sortOrderDetail);
                    }
                }
                SortOrderRepository.SaveChanges();
                result = true;
            }
            catch (Exception e)
            {
                errorInfo = "出错,原因:" + e.Message;
            }
            return(result);
        }