/// <summary> /// 获得满足条件的所有产品的总价格 /// </summary> /// <param name="localName"></param> /// <param name="localType"></param> /// <param name="searchKey"></param> /// <param name="storageNum"></param> /// <returns></returns> public double GetAllTotalPrice(string localName, string localType, string searchKey, string storageNum) { LocalProductEntity entity = new LocalProductEntity(); double allTotalPrice = 0; if (!storageNum.IsEmpty()) { entity.Where("StorageNum", ECondition.Eth, storageNum); } if (!localType.IsEmpty()) { entity.Where("LocalType", ECondition.Eth, localType); } if (!localName.IsEmpty()) { entity.Where("LocalName", ECondition.Like, "%" + localName + "%"); entity.Or("LocalNum", ECondition.Like, "%" + localName + "%"); } if (!searchKey.IsEmpty()) { entity.Begin <LocalProductEntity>() .Where <LocalProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%") .Or <LocalProductEntity>("ProductNum", ECondition.Like, "%" + searchKey + "%") .Or <LocalProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%") .End <LocalProductEntity>(); } entity.IncludeNum(true); ProductEntity ProEntity = new ProductEntity(); ProEntity.Include(a => new { AvgPrice = a.AvgPrice }); entity.Left <ProductEntity>(ProEntity, new Params <string, string>() { Item1 = "ProductNum", Item2 = "SnNum" }); entity.OrderBy(a => a.ID, EOrderBy.DESC); List <LocalProductEntity> listResult = this.LocalProduct.GetList(entity); if (!listResult.IsNullOrEmpty()) { listResult.ForEach(a => { a.TotalPrice = a.Num * a.AvgPrice; allTotalPrice += a.TotalPrice; }); } return(allTotalPrice); }
/// <summary> /// 获得满足条件的所有产品的库存 /// </summary> /// <param name="localName"></param> /// <param name="localType"></param> /// <param name="searchKey"></param> /// <param name="storageNum"></param> /// <returns></returns> public int GetAllNum(string localName, string localType, string searchKey, string storageNum) { LocalProductEntity entity = new LocalProductEntity(); if (!storageNum.IsEmpty()) { entity.Where("StorageNum", ECondition.Eth, storageNum); } if (!localType.IsEmpty()) { entity.Where("LocalType", ECondition.Eth, localType); } if (!localName.IsEmpty()) { entity.Where("LocalName", ECondition.Like, "%" + localName + "%"); entity.Or("LocalNum", ECondition.Like, "%" + localName + "%"); } if (!searchKey.IsEmpty()) { entity.Begin <LocalProductEntity>() .Where <LocalProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%") .Or <LocalProductEntity>("ProductNum", ECondition.Like, "%" + searchKey + "%") .Or <LocalProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%") .End <LocalProductEntity>(); } entity.IncludeNum(true); int allNum = 0; try { allNum = this.LocalProduct.Sum <int>(entity); } catch (Exception e) { allNum = 0; log.Info(e.Message); } return(allNum); }