/// <summary>
        /// 修改出库单的数量
        /// </summary>
        /// <param name="snNum"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public int EditInOrderNum(string snNum, double num)
        {
            OutStoDetailEntity detail = new OutStoDetailEntity();
            detail = new OutStoDetailEntity();
            detail.Include(a => new { a.OrderNum, a.Num,a.OutPrice,a.Amount });
            detail.Where(a => a.SnNum == snNum);
            detail = this.OutStoDetail.GetSingle(detail);

            int line = 0;
            if (detail != null)
            {
                string orderNum = detail.OrderNum;
                OutStoDetailEntity editDetail = new OutStoDetailEntity();
                editDetail.Num = num;
                editDetail.Amount = editDetail.Num * editDetail.OutPrice;
                editDetail.IncludeNum(true).IncludeAmount(true);
                editDetail.Where(a => a.SnNum == snNum);
                line = this.OutStoDetail.Update(editDetail);

                OutStoDetailEntity orderDetail = new OutStoDetailEntity();
                orderDetail.Include(a => new { a.Num, a.Amount });
                orderDetail.Where(a => a.OrderNum == orderNum);
                List<OutStoDetailEntity> list = this.OutStoDetail.GetList(orderDetail);

                OutStorageEntity entity = new OutStorageEntity();
                entity.Num = list.Sum(a=>a.Num);
                entity.Amount = list.Sum(a => a.Amount);
                entity.IncludeNum(true).IncludeAmount(true);
                entity.Where(a => a.OrderNum == orderNum);
                line += this.OutStorage.Update(entity);
            }
            return line;
        }
Beispiel #2
0
 public static OutStorage_CE ToCE(OutStorageEntity item)
 {
     OutStorage_CE target = new OutStorage_CE();
     target.ID=item.ID;
     target.OrderNum=item.OrderNum;
     target.OutType=item.OutType;
     target.ProductType=item.ProductType;
     target.CusNum=item.CusNum;
     target.CusName=item.CusName;
     target.Contact=item.Contact;
     target.Phone=item.Phone;
     target.Address=item.Address;
     target.ContractOrder=item.ContractOrder;
     target.Num=item.Num;
     target.Amount=item.Amount;
     target.Weight=item.Weight;
     target.SendDate=item.SendDate;
     target.Status=item.Status;
     target.IsDelete=item.IsDelete;
     target.CreateTime=item.CreateTime;
     target.CreateUser=item.CreateUser;
     target.AuditUser=item.AuditUser;
     target.AuditeTime=item.AuditeTime;
     target.PrintUser=item.PrintUser;
     target.PrintTime=item.PrintTime;
     target.Reason=item.Reason;
     target.OperateType=item.OperateType;
     target.EquipmentNum=item.EquipmentNum;
     target.EquipmentCode=item.EquipmentCode;
     target.Remark=item.Remark;
     return target;
 }
 public ActionResult Delete()
 {
     string OrderNum = WebUtil.GetFormValue<string>("OrderNum", string.Empty);
     OutStorageEntity entity = new OutStorageEntity();
     entity.OrderNum = OrderNum;
     Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
     string returnValue = bill.Delete(entity);
     this.ReturnJson.AddProperty("d", returnValue);
     return Content(this.ReturnJson.ToString());
 }
 public ActionResult DeleteBatch([ModelBinder(typeof(JsonBinder<List<string>>))] List<string> list)
 {
     if (!list.IsNullOrEmpty())
     {
         foreach (string orderNum in list)
         {
             OutStorageEntity entity = new OutStorageEntity();
             entity.OrderNum = orderNum;
             Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
             string returnValue = bill.Delete(entity);
             this.ReturnJson.AddProperty("d", returnValue);
         }
     }
     return Content(this.ReturnJson.ToString());
 }
        public ActionResult Detail()
        {
            string orderNum = WebUtil.GetQueryStringValue<string>("orderNum", string.Empty);
            string flag = WebUtil.GetQueryStringValue<string>("flag", string.Empty);
            Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            OutStorageEntity entity = new OutStorageEntity();
            entity.OrderNum = orderNum;
            entity = bill.GetOrder(entity);
            entity = entity.IsNull() ? new OutStorageEntity() : entity;
            ViewBag.Entity = entity;
            ViewBag.OutType = EnumHelper.GetEnumDesc<EOutType>(entity.OutType);
            ViewBag.Status = EnumHelper.GetEnumDesc<EAudite>(entity.Status);

            OutStoDetailEntity detail = new OutStoDetailEntity();
            detail.OrderNum = orderNum;
            List<OutStoDetailEntity> listResult = bill.GetOrderDetail(detail);
            listResult = listResult.IsNull() ? new List<OutStoDetailEntity>() : listResult;

            ProductProvider provider = new ProductProvider();
            List<ProductEntity> list = provider.GetListByCache();
            list = list.IsNull() ? new List<ProductEntity>() : list;
            listResult.ForEach(a =>
            {
                ProductEntity product = null;
                if (a.BarCode.IsEmpty())
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum);
                }
                else
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum && b.BarCode == a.BarCode);
                }
                if (product.IsNotNull())
                {
                    a.Size = product.Size.IsEmpty() ? "" : product.Size;
                }
                else
                {
                    a.Size = "";
                }
            });
            ViewBag.Detail = listResult;
            ViewBag.Flag = flag;
            return View();
        }
 public ActionResult Audit()
 {
     string OrderNum = WebUtil.GetFormValue<string>("OrderNum", string.Empty);
     int Status = WebUtil.GetFormValue<int>("Status");
     string Reason = WebUtil.GetFormValue<string>("Reason", string.Empty);
     OutStorageEntity entity = new OutStorageEntity();
     entity.Status = Status;
     entity.OrderNum = OrderNum;
     entity.AuditUser = this.LoginUserCode;
     entity.OperateType = (int)EOpType.PC;
     entity.EquipmentCode = string.Empty;
     entity.EquipmentNum = string.Empty;
     entity.Remark = string.Empty;
     entity.Reason = Reason;
     Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
     string returnValue = bill.Audite(entity);
     this.ReturnJson.AddProperty("d", returnValue);
     return Content(this.ReturnJson.ToString());
 }
        public ActionResult OutStorageReport()
        {
            int queryTime = WebUtil.GetFormValue<int>("QueryTime", 0);
            int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0);
            int pageSize = WebUtil.GetFormValue<int>("pageSize", 0);
            string storageNum = this.DefaultStore;

            ProductProvider provider = new ProductProvider();
            OutStorageEntity entity = new OutStorageEntity();
            PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
            if (queryTime > 0)
            {
                entity.Where("CreateTime", ECondition.Between, DateTime.Now.AddDays(-queryTime), DateTime.Now);
            }
            if (storageNum.IsNotNull())
            {
                entity.Where("StorageNum", ECondition.Eth, storageNum);
            }
            Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            List<OutStorageEntity> listResult = bill.GetList(entity, ref pageInfo);
            listResult = listResult == null ? new List<OutStorageEntity>() : listResult;
            string json = ConvertJson.ListToJson<OutStorageEntity>(listResult, "List");
            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return Content(this.ReturnJson.ToString());
        }
        public ActionResult CustomerReportTOP10()
        {
            int queryTime = WebUtil.GetFormValue<int>("QueryTime", 0);
            int pageIndex = 1;
            int pageSize = 10;
            string storageNum = this.DefaultStore;

            OutStorageProvider provider = new OutStorageProvider();
            OutStorageEntity entity = new OutStorageEntity();
            PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };

            List<OutStorageEntity> listResult = provider.GetListTOP10(queryTime, storageNum);
            listResult = listResult.IsNull() ? new List<OutStorageEntity>() : listResult;
            CustomerProvider cusProvider = new CustomerProvider();
            foreach (OutStorageEntity item in listResult)
            {
                CustomerEntity tempItem = cusProvider.GetSingleCustomer(item.CusNum);
                item.CusName = tempItem.CusName;
                item.CusType = tempItem.CusType;
            }
            /*******************************************订单数量排名前十的客户饼图数据****************************************************/
            StringBuilder sb = new StringBuilder();
            sb.Append("<pie>");
            listResult.ForEach(a =>
            {
                if (a.Num > 0)
                {
                    sb.AppendFormat("<slice title=\"{0}\">{1}</slice>", a.CusName, a.Num.ToString());
                }
            });
            sb.Append("</pie>");
            this.ReturnJson.AddProperty("InStorageData", sb.ToString());
            string json = ConvertJson.ListToJson<OutStorageEntity>(listResult, "List");
            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return Content(this.ReturnJson.ToString());
        }
 public ActionResult Load()
 {
     string OrderNum = WebUtil.GetFormValue<string>("OrderNum", string.Empty);
     if (!OrderNum.IsEmpty())
     {
         ReturnProvider provider = new ReturnProvider();
         ReturnOrderEntity backEntity = provider.CheckOrder(OrderNum);
         if (backEntity != null && backEntity.Status == (int)EAudite.Wait)
         {
             this.ReturnJson.AddProperty("d", "1001");
             return Content(this.ReturnJson.ToString());
         }
         Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
         OutStorageEntity entity = new OutStorageEntity();
         entity.OrderNum = OrderNum;
         entity = bill.GetOrder(entity);
         if (entity.IsNotNull())
         {
             if (entity.Status != (int)EAudite.Pass)
             {
                 this.ReturnJson.AddProperty("d", "1002");
                 return Content(this.ReturnJson.ToString());
             }
             this.ReturnJson.AddProperty("CusNum", entity.CusNum);
             this.ReturnJson.AddProperty("CusName", entity.CusName);
             this.ReturnJson.AddProperty("Address", entity.Address);
             this.ReturnJson.AddProperty("Contact", entity.Contact);
             this.ReturnJson.AddProperty("Phone", entity.Phone);
             //加载详细内容
             OutStoDetailEntity detail = new OutStoDetailEntity();
             detail.OrderNum = OrderNum;
             List<OutStoDetailEntity> list = bill.GetOrderDetail(detail);
             list = list.IsNull() ? new List<OutStoDetailEntity>() : list;
             //获得已经退货的数量
             List<ReturnDetailEntity> listResult = provider.GetDetailByOrder(OrderNum);
             if (!listResult.IsNullOrEmpty())
             {
                 list.ForEach(a =>
                 {
                     double qty = listResult.Where(b => b.BarCode == a.BarCode && b.ProductNum == a.ProductNum && b.LocalNum == a.LocalNum && b.StorageNum == a.StorageNum && b.BatchNum==a.BatchNum).Sum(b => b.BackNum);
                     a.BackNum = qty;
                 });
             }
             Session[CacheKey.TEMPDATE_CACHE_RETURNPRODUCTDETAIL] = list;
             string json = ConvertJson.ListToJson<OutStoDetailEntity>(list, "List");
             this.ReturnJson.AddProperty("data", json);
         }
     }
     return Content(this.ReturnJson.ToString());
 }
 public ActionResult GetList()
 {
     int Status = WebUtil.GetFormValue<int>("Status", 0);
     string OrderNum = WebUtil.GetFormValue<string>("OrderNum", string.Empty);
     string CusName = WebUtil.GetFormValue<string>("CusName", string.Empty);
     string beginTime = WebUtil.GetFormValue<string>("beginTime", string.Empty);
     string endTime = WebUtil.GetFormValue<string>("endTime", string.Empty);
     string order = WebUtil.GetFormValue<string>("order", string.Empty);
     int OutType = WebUtil.GetFormValue<int>("OutType", 0);
     string planNum = WebUtil.GetFormValue<string>("planNum");
     int pageSize = WebUtil.GetFormValue<int>("PageSize", 10);
     int pageIndex = WebUtil.GetFormValue<int>("PageIndex", 1);
     PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
     OutStorageEntity entity = new OutStorageEntity();
     if (Status > 0)
     {
         entity.Where(a => a.Status == Status);
     }
     if (!OrderNum.IsEmpty())
     {
         entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%");
     }
     if (!CusName.IsEmpty())
     {
         entity.Begin<OutStorageEntity>()
             .And<OutStorageEntity>("CusNum", ECondition.Like, "%" + CusName + "%")
             .Or<OutStorageEntity>("CusName", ECondition.Like, "%" + CusName + "%")
             .End<OutStorageEntity>()
             ;
     }
     if (!beginTime.IsEmpty() && !endTime.IsEmpty())
     {
         entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType<DateTime>(beginTime), ConvertHelper.ToType<DateTime>(endTime));
     }
     entity.And(a => a.StorageNum == this.DefaultStore);
     if (!order.IsEmpty())
     {
         OrderProvider orderProvider = new OrderProvider();
         List<string> listContractOrder = orderProvider.GetOrderPlan(order);
         listContractOrder = listContractOrder.IsNull() ? new List<string>() : listContractOrder;
         if (listContractOrder.Count == 0)
         {
             listContractOrder.Add(order);
         }
         entity.And("ContractOrder", ECondition.In, listContractOrder.ToArray());
     }
     if (OutType > 0)
     {
         entity.And(a => a.OutType == OutType);
     }
     if (!planNum.IsEmpty())
     {
         OutStoDetailEntity detail = new OutStoDetailEntity();
         detail.Where("ContractOrder", ECondition.Like, "%" + planNum + "%");
         entity.Left<OutStoDetailEntity>(detail, new Params<string, string>() { Item1 = "OrderNum", Item2 = "OrderNum" });
     }
     Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
     List<OutStorageEntity> listResult = bill.GetList(entity, ref pageInfo);
     listResult = listResult == null ? new List<OutStorageEntity>() : listResult;
     string json = ConvertJson.ListToJson<OutStorageEntity>(listResult, "List");
     this.ReturnJson.AddProperty("Data", json);
     this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
     return Content(this.ReturnJson.ToString());
 }
        public ActionResult ToExcel()
        {
            int Status = WebUtil.GetFormValue<int>("Status", 0);
            string OrderNum = WebUtil.GetFormValue<string>("OrderNum", string.Empty);
            string CusName = WebUtil.GetFormValue<string>("CusName", string.Empty);
            string beginTime = WebUtil.GetFormValue<string>("beginTime", string.Empty);
            string endTime = WebUtil.GetFormValue<string>("endTime", string.Empty);

            PageInfo pageInfo = new PageInfo() { PageIndex = 1, PageSize = int.MaxValue };
            OutStorageEntity entity = new OutStorageEntity();
            if (Status > 0)
            {
                entity.Where(a => a.Status == Status);
            }
            if (!OrderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%");
            }
            if (!CusName.IsEmpty())
            {
                entity.Begin<OutStorageEntity>()
                    .And<OutStorageEntity>("CusNum", ECondition.Like, "%" + CusName + "%")
                    .Or<OutStorageEntity>("CusName", ECondition.Like, "%" + CusName + "%")
                    .End<OutStorageEntity>()
                    ;
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType<DateTime>(beginTime), ConvertHelper.ToType<DateTime>(endTime));
            }
            entity.And(a => a.StorageNum == this.DefaultStore);
            Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            List<OutStorageEntity> listResult = bill.GetList(entity, ref pageInfo);
            listResult = listResult == null ? new List<OutStorageEntity>() : listResult;
            if (listResult.IsNotNull())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("出库单编号 "));
                dt.Columns.Add(new DataColumn("出库类型"));
                dt.Columns.Add(new DataColumn("客户名称"));
                dt.Columns.Add(new DataColumn("关联单号"));
                dt.Columns.Add(new DataColumn("总数量"));
                dt.Columns.Add(new DataColumn("总金额"));
                dt.Columns.Add(new DataColumn("状态"));
                dt.Columns.Add(new DataColumn("制单人"));
                dt.Columns.Add(new DataColumn("操作方式"));
                dt.Columns.Add(new DataColumn("创建时间"));
                int count = 1;
                foreach (OutStorageEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.OrderNum;
                    row[2] = EnumHelper.GetEnumDesc<EOutType>(t.OutType);
                    row[3] = t.CusName;
                    row[4] = t.ContractOrder;
                    row[5] = t.Num;
                    row[6] = t.Amount;
                    row[7] = EnumHelper.GetEnumDesc<EAudite>(t.Status);
                    row[8] = t.CreateUserName;
                    row[9] = EnumHelper.GetEnumDesc<EOpType>(t.OperateType);
                    row[10] = t.CreateTime.ToString("yyyy-MM-dd");
                    dt.Rows.Add(row);
                    count++;
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string filename = string.Format("出库管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel = new NPOIExcel("出库管理", "出库单", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return Content(this.ReturnJson.ToString());
        }
        public ActionResult Create()
        {
            string OrderNum = WebUtil.GetFormValue<string>("OrderNum", string.Empty);
            int OutType = WebUtil.GetFormValue<int>("OutType", 0);
            int ProductType = WebUtil.GetFormValue<int>("ProductType", 0);
            string ContractOrder = WebUtil.GetFormValue<string>("ContractOrder", string.Empty);
            string CusNum = WebUtil.GetFormValue<string>("CusNum", string.Empty);
            string CusName = WebUtil.GetFormValue<string>("CusName", string.Empty);
            string Address = WebUtil.GetFormValue<string>("Address", string.Empty);
            string ContactName = WebUtil.GetFormValue<string>("ContactName", string.Empty);
            string Phone = WebUtil.GetFormValue<string>("Phone", string.Empty);
            DateTime SendDate = WebUtil.GetFormValue<DateTime>("SendDate", DateTime.Now);
            string Remark = WebUtil.GetFormValue<string>("Remark", string.Empty);

            OutStorageEntity entity = new OutStorageEntity();
            entity.OrderNum = OrderNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(OutStorageEntity)) : OrderNum;
            entity.OutType = OutType;
            entity.ProductType = ProductType;
            entity.CusNum = CusNum;
            entity.CusName = CusName;
            entity.Contact = ContactName;
            entity.Phone = Phone;
            entity.Address = Address;
            entity.ContractOrder = ContractOrder;
            entity.Status = (int)EAudite.Wait;
            entity.IsDelete = (int)EIsDelete.NotDelete;
            entity.SendDate = SendDate;
            entity.CreateTime = DateTime.Now;
            entity.CreateUser = this.LoginUserCode;
            entity.AuditUser = string.Empty;
            entity.AuditeTime = DateTime.MinValue;
            entity.PrintUser = string.Empty;
            entity.PrintTime = DateTime.MinValue;
            entity.Reason = string.Empty;
            entity.OperateType = (int)EOpType.PC;
            entity.EquipmentNum = string.Empty;
            entity.EquipmentCode = string.Empty;
            entity.Remark = Remark;
            entity.StorageNum = this.DefaultStore;

            List<OutStoDetailEntity> list = Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] as List<OutStoDetailEntity>;
            if (list.IsNullOrEmpty())
            {
                this.ReturnJson.AddProperty("Key", "1001");
                this.ReturnJson.AddProperty("Value", "请选择要出库的产品以及数量");
                return Content(this.ReturnJson.ToString());
            }
            list.ForEach(a => { a.OrderNum = entity.OrderNum; });
            Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            if (OrderNum.IsEmpty())
            {
                string returnValue = bill.Create(entity, list);
                if (returnValue == EnumHelper.GetEnumDesc<EReturnStatus>(EReturnStatus.Success))
                {
                    Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] = null;
                    this.ReturnJson.AddProperty("Key", "1000");
                    this.ReturnJson.AddProperty("Value", "出库单创建成功");
                }
            }
            else
            {
                string returnValue = bill.EditOrder(entity, list);
                if (returnValue == EnumHelper.GetEnumDesc<EReturnStatus>(EReturnStatus.Success))
                {
                    Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] = null;
                    this.ReturnJson.AddProperty("Key", "1000");
                    this.ReturnJson.AddProperty("Value", "出库单编辑成功");
                }
            }
            return Content(this.ReturnJson.ToString());
        }
 /// <summary>
 /// 获得某个客户的所有订购产品数量
 /// </summary>
 /// <param name="cusNum"></param>
 /// <param name="queryTime"></param>
 /// <returns></returns>
 public double GetNumByCusNum(string cusNum, int queryTime, string storageNum)
 {
     OutStorageEntity entity = new OutStorageEntity();
     entity.IncludeNum(true);
     entity.Where("CreateTime", ECondition.Between, DateTime.Now.AddDays(-queryTime), DateTime.Now);
     entity.And("StorageNum", ECondition.Eth, storageNum);
     entity.And("CusNum", ECondition.Eth, cusNum);
     entity.And("Status", ECondition.Eth, (int)EAudite.Pass);
     entity.And("IsDelete", ECondition.Eth, (int)EIsDelete.NotDelete);
     double allNum = 0;
     try
     {
         allNum = this.OutStorage.Sum<double>(entity);
     }
     catch (Exception e)
     {
         allNum = 0;
         log.Info(e.Message);
     }
     return allNum;
 }
        public ActionResult Print()
        {
            string orderNum = WebUtil.GetQueryStringValue<string>("orderNum", string.Empty);
            Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            OutStorageEntity entity = new OutStorageEntity();
            entity.OrderNum = orderNum;
            entity = bill.GetOrder(entity);
            entity = entity.IsNull() ? new OutStorageEntity() : entity;
            ViewBag.Entity = entity;

            OutStoDetailEntity detail = new OutStoDetailEntity();
            detail.OrderNum = orderNum;
            List<OutStoDetailEntity> listResult = bill.GetOrderDetail(detail);
            listResult = listResult.IsNull() ? new List<OutStoDetailEntity>() : listResult;
            OrderProvider orderProvider = new OrderProvider();
            foreach (OutStoDetailEntity item in listResult)
            {
                OrderDetailEntity orderDetail = new OrderDetailEntity();
                orderDetail.Where(a => a.SnNum == item.ContractSn).And(a => a.OrderNum == item.ContractOrder);
                orderDetail = orderProvider.GetOrderDetail(orderDetail);
                if (orderDetail != null)
                {
                    item.Qty = orderDetail.Num;
                }
            }
            ViewBag.Detail = listResult;
            return View();
        }
        public ActionResult Edit()
        {
            string orderNum = WebUtil.GetQueryStringValue<string>("orderNum", string.Empty);
            Bill<OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            OutStorageEntity entity = new OutStorageEntity();
            entity.OrderNum = orderNum;
            entity = bill.GetOrder(entity);
            entity = entity.IsNull() ? new OutStorageEntity() : entity;
            ViewBag.Entity = entity;
            ViewBag.OutType = EnumHelper.GetOptions<EInType>(entity.OutType, "请选择入库单类型");
            ViewBag.ProductType = EnumHelper.GetOptions<EProductType>(entity.ProductType, "请选择入库产品类型");

            OutStoDetailEntity detail = new OutStoDetailEntity();
            detail.OrderNum = orderNum;
            List<OutStoDetailEntity> listResult = bill.GetOrderDetail(detail);
            listResult = listResult.IsNull() ? new List<OutStoDetailEntity>() : listResult;

            ProductProvider provider = new ProductProvider();
            List<ProductEntity> list = provider.GetListByCache();
            list = list.IsNull() ? new List<ProductEntity>() : list;
            listResult.ForEach(a =>
            {
                ProductEntity product = null;
                if (a.BarCode.IsEmpty())
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum);
                }
                else
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum && b.BarCode == a.BarCode);
                }
                a.OutPrice = product != null ? product.OutPrice : 0;
                if (product != null)
                {
                    a.Size = product.Size.IsEmpty() ? "" : product.Size;
                }
                else
                {
                    a.Size = "";
                }
            });
            Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] = listResult;
            return View();
        }