public ActionResult Detail(string snNum)
 {
     ProductEntity entity = null;
     if (!snNum.IsEmpty())
     {
         ProductProvider provider = new ProductProvider();
         entity = provider.GetProductBySn(snNum);
         ViewBag.Category = BaseHelper.GetProductCategory(entity.CateNum);
         ViewBag.Storage = LocalHelper.GetStorageNumList(entity.StorageNum);
         ViewBag.Local = LocalHelper.GetLocalNumList(entity.StorageNum, entity.DefaultLocal);
         ViewBag.Customer = BaseHelper.GetCustomerList(entity.CusNum);
         ViewBag.Goods = entity;
         ViewBag.Unit = BaseHelper.GetMeasureNameList(entity.UnitNum);
     }
     else
     {
         ViewBag.Goods = new ProductEntity();
         ViewBag.Category = BaseHelper.GetProductCategory(string.Empty);
         ViewBag.Storage = LocalHelper.GetStorageNumList(string.Empty);
         ViewBag.Local = LocalHelper.GetLocalNumList(string.Empty, string.Empty);
         ViewBag.Customer = BaseHelper.GetCustomerList(string.Empty);
         ViewBag.Unit = BaseHelper.GetMeasureNameList(string.Empty);
     }
     return View();
 }
 public ActionResult GoodsDetail(string snNum)
 {
     ProductEntity entity = new ProductEntity();
     ProductProvider provider = new ProductProvider();
     entity = provider.GetProductBySn(snNum);
     ViewBag.Category = BaseHelper.GetProductCategory(entity.CateNum);
     ViewBag.Storage = LocalHelper.GetStorageNumList(entity.StorageNum);
     ViewBag.Local = LocalHelper.GetLocalNumList(entity.StorageNum, entity.DefaultLocal);
     ViewBag.Customer = BaseHelper.GetCustomerList(entity.CusNum);
     ViewBag.Goods = entity;
     //ViewBag.Unit = EnumHelper.GetOptions<EUnit>(entity.Unit, "请选择单位");
     ViewBag.Unit = BaseHelper.GetMeasureNameList(entity.UnitNum);
     return View();
 }
 public ActionResult LoadProduct([ModelBinder(typeof(JsonBinder<List<LocalProductEntity>>))]List<LocalProductEntity> list)
 {
     List<BadReportDetailEntity> ListProducts = Session[CacheKey.TEMPDATA_CACHE_BADPRODUCTDETAIL] as List<BadReportDetailEntity>;
     ListProducts = ListProducts.IsNull() ? new List<BadReportDetailEntity>() : ListProducts;
     if (!list.IsNullOrEmpty())
     {
         LocationProvider localProvider = new LocationProvider();
         foreach (LocalProductEntity item in list)
         {
             string BarCode = item.BarCode;
             string ProductNum = item.ProductNum;
             string StorageNum = item.StorageNum;
             string FromLocalNum = item.LocalNum;
             string BatchNum = item.BatchNum;
             if (ListProducts.Exists(a => a.BarCode == BarCode && a.ProductNum == ProductNum && a.BatchNum == BatchNum && a.StorageNum == StorageNum && a.FromLocalNum == FromLocalNum))
             {
                 BadReportDetailEntity entity = ListProducts.FirstOrDefault(a => a.BarCode == BarCode && a.ProductNum == ProductNum && a.BatchNum == BatchNum && a.StorageNum == StorageNum && a.FromLocalNum == FromLocalNum);
                 entity.Num += item.Num;
             }
             else
             {
                 BadReportDetailEntity entity = new BadReportDetailEntity();
                 entity.SnNum = SequenceProvider.GetSequence(typeof(BadReportDetailEntity));
                 ProductProvider provider = new ProductProvider();
                 ProductEntity product = provider.GetProductBySn(ProductNum);
                 entity.ProductName = product.ProductName;
                 entity.BarCode = product.BarCode;
                 entity.ProductNum = product.SnNum;
                 entity.BatchNum = item.BatchNum;
                 entity.LocalNum = item.Num;
                 entity.Num = item.Qty;
                 entity.Amount = product.InPrice * item.Num;
                 entity.InPrice = product.InPrice;
                 entity.CreateTime = DateTime.Now;
                 entity.StorageNum = StorageNum;
                 entity.FromLocalNum = item.LocalNum;
                 LocationEntity fromLocal = localProvider.GetSingleByNumCache(item.LocalNum);
                 if (fromLocal != null)
                 {
                     entity.FromLocalName = fromLocal.LocalName;
                 }
                 LocationEntity localtion = localProvider.GetDefaultLocal(StorageNum, ELocalType.Bad);
                 if (localtion != null)
                 {
                     entity.ToLocalNum = localtion.LocalNum;
                 }
                 ListProducts.Add(entity);
             }
         }
         Session[CacheKey.TEMPDATA_CACHE_BADPRODUCTDETAIL] = ListProducts;
     }
     return Content(string.Empty);
 }
 /// <summary>
 /// 根据产品SN号码查询产品的详细信息
 /// SNNum为产品的唯一编号
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public Product_CE GetProductBySn(string snNum)
 {
     if (snNum.IsEmpty())
     {
         return null;
     }
     ProductProvider provider = new ProductProvider();
     ProductEntity entity = provider.GetProductBySn(snNum);
     if (entity != null)
     {
         Product_CE productCe = Product_To.ToCE(entity);
         return productCe;
     }
     return null;
 }