Ejemplo n.º 1
0
 /// <summary>
 /// 移库管理获得库存信息
 /// 
 /// </summary>
 /// <param name="barCode"></param>
 /// <returns></returns>
 public List<LocalProductEntity> GetList(string barCode)
 {
     LocalProductEntity entity = new LocalProductEntity();
     entity.IncludeAll();
     entity.OrderBy(a => a.ID, EOrderBy.DESC);
     entity.Where(a => a.BarCode == barCode).Or(a => a.ProductNum == barCode);
     List<LocalProductEntity> listResult = this.LocalProduct.GetList(entity);
     return listResult;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 获得库存信息
        /// </summary>
        /// <param name="barCode"></param>
        /// <returns></returns>
        public List<LocalProductEntity> GetList(string barCode)
        {
            LocalProductEntity entity = new LocalProductEntity();
            entity.IncludeAll();
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            entity.Where(a => a.BarCode == barCode).Or(a => a.ProductNum == barCode);

            LocationEntity location = new LocationEntity();
            entity.Left<LocationEntity>(location, new Params<string, string>() { Item1 = "LocalNum", Item2 = "LocalNum" });
            location.Where(a => a.LocalType == (int)ELocalType.Normal);
            List<LocalProductEntity> listResult = this.LocalProduct.GetList(entity);
            return listResult;
        }
Ejemplo n.º 3
0
 /// <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;
 }
Ejemplo n.º 4
0
        public ActionResult StockBillList()
        {
            string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty);
            string localName = WebUtil.GetFormValue<string>("LocalName", string.Empty);
            string localType = WebUtil.GetFormValue<string>("LocalType", string.Empty);
            int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0);
            int pageSize = WebUtil.GetFormValue<int>("pageSize", 0);
            string storageNum = this.DefaultStore;

            LocalProductProvider provider = new LocalProductProvider();
            LocalProductEntity entity = new LocalProductEntity();

            if (!localType.IsEmpty())
            {
                entity.Where("LocalType", ECondition.Eth, localType);
            }
            if (storageNum.IsNotNull())
            {
                entity.Where("StorageNum", ECondition.Eth, storageNum);
            }
            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>();
            }
            PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
            List<LocalProductEntity> listResult = provider.GetList(entity, ref pageInfo);
            int allNum = provider.GetAllNum(localName, localType, searchKey, storageNum);
            double allTotalPrice = provider.GetAllTotalPrice(localName, localType, searchKey, storageNum);
            if (!listResult.IsNullOrEmpty())
            {
                listResult.ForEach(a =>
                {
                    a.TotalPrice = a.Num * a.AvgPrice;
                });
            }
            string json = ConvertJson.ListToJson<LocalProductEntity>(listResult, "List");
            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            this.ReturnJson.AddProperty("AllNum", allNum);
            this.ReturnJson.AddProperty("AllTotalPrice", allTotalPrice);
            return Content(this.ReturnJson.ToString());
        }
Ejemplo n.º 5
0
        public ActionResult ToStockBilReportExcel()
        {
            string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty);
            string localName = WebUtil.GetFormValue<string>("LocalName", string.Empty);
            string localType = WebUtil.GetFormValue<string>("LocalType", string.Empty);
            string storageNum = this.DefaultStore;

            LocalProductProvider provider = new LocalProductProvider();
            LocalProductEntity entity = new LocalProductEntity();
            if (!localType.IsEmpty())
            {
                entity.Where("LocalType", ECondition.Eth, localType);
            }
            if (storageNum.IsNotNull())
            {
                entity.Where("StorageNum", ECondition.Eth, storageNum);
            }
            if (!localName.IsEmpty())
            {
                entity.Where("LocalName", 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>();
            }

            PageInfo pageInfo = new PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
            List<LocalProductEntity> listResult = provider.GetList(entity, ref pageInfo);
            int allNum = provider.GetAllNum(localName, localType, searchKey, storageNum);
            double allTotalPrice = provider.GetAllTotalPrice(localName, localType, searchKey, storageNum);
            if (!listResult.IsNullOrEmpty())
            {
                listResult.ForEach(a =>
                {
                    a.TotalPrice = a.Num * a.AvgPrice;
                });
                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("库存数"));
                dt.Columns.Add(new DataColumn("价格"));
                dt.Columns.Add(new DataColumn("总价"));

                int count = 1;
                foreach (LocalProductEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.LocalName;
                    row[2] = EnumHelper.GetEnumDesc<ELocalType>(t.LocalType);
                    row[3] = t.ProductNum;
                    row[4] = t.BarCode;
                    row[5] = t.ProductName;
                    row[6] = t.CateName;
                    row[7] = t.Size;
                    row[8] = t.MinNum;
                    row[9] = t.MaxNum;
                    row[10] = t.Num;
                    row[11] = t.AvgPrice;
                    row[12] = t.TotalPrice;
                    dt.Rows.Add(row);
                    count++;
                }
                DataRow rowTemp = dt.NewRow();
                rowTemp[0] = count;
                rowTemp[1] = "";
                rowTemp[2] = "";
                rowTemp[3] = "";
                rowTemp[4] = "";
                rowTemp[5] = "";
                rowTemp[6] = "";
                rowTemp[7] = "";
                rowTemp[8] = "";
                rowTemp[9] = "总计";
                rowTemp[10] = allNum;
                rowTemp[11] = "";
                rowTemp[12] = allTotalPrice;
                dt.Rows.Add(rowTemp);
                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"));
                AsposeExcel excel = new AsposeExcel(System.IO.Path.Combine(filePath, filename), "");
                excel.DatatableToExcel(dt, "库存清单报表", "库存清单报表");
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return Content(this.ReturnJson.ToString());
        }
Ejemplo n.º 6
0
        /// <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;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 获得产品的当前库存信息
 /// </summary>
 /// <param name="localNum"></param>
 /// <param name="productNum"></param>
 /// <returns></returns>
 public LocalProductEntity GetSingle(string localNum, string productNum)
 {
     LocalProductEntity entity = new LocalProductEntity();
     entity.IncludeAll();
     entity.Where(a => a.LocalNum == localNum).And(a => a.ProductNum == productNum)
         .And(a => a.LocalType == (int)ELocalType.Normal);
     entity = this.LocalProduct.GetSingle(entity);
     return entity;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 根据库存唯一编码号获取该位置的库存信息以及产品信息
 /// </summary>
 /// <param name="sn"></param>
 /// <returns></returns>
 public LocalProductEntity GetLocalProductBySn(string sn, string productNum = null)
 {
     LocalProductEntity entity = new LocalProductEntity();
     entity.IncludeAll();
     ProductEntity ProEntity = new ProductEntity();
     ProEntity.Include(a => new { Size = a.Size, InPrice = a.InPrice });
     entity.Left<ProductEntity>(ProEntity, new Params<string, string>() { Item1 = "ProductNum", Item2 = "SnNum" });
     entity.Where(a => a.Sn == sn);
     if (!productNum.IsEmpty())
     {
         entity.Where(a => a.ProductNum == productNum);
     }
     entity = this.LocalProduct.GetSingle(entity);
     return entity;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 获得产品的当前库存
 /// </summary>
 /// <param name="storageNum"></param>
 /// <param name="productNum"></param>
 /// <returns></returns>
 public double GetLocalNum(string storageNum, string productNum)
 {
     LocalProductEntity entity = new LocalProductEntity();
     entity.IncludeNum(true);
     entity.Where(a => a.StorageNum == storageNum).And(a => a.ProductNum == productNum)
         .And(a => a.LocalType == (int)ELocalType.Normal);
     try
     {
         double sum = this.LocalProduct.Sum<double>(entity);
         return sum;
     }
     catch (Exception e)
     {
         log.Info(e.Message);
     }
     return 0;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 根据产品条码或者产品编号或者产品名称搜索库存产品数量以及库存位置
 /// 主要用于选择产品的界面中搜索功能。在搜索到相应产品之后查询库存信息
 /// </summary>
 /// <returns></returns>
 public List<LocalProductEntity> GetList(string barCode)
 {
     LocalProductEntity entity = new LocalProductEntity();
     entity.IncludeAll();
     ProductEntity ProEntity = new ProductEntity();
     ProEntity.Include(a => new { Size = a.Size, InPrice = a.InPrice });
     entity.Left<ProductEntity>(ProEntity, new Params<string, string>() { Item1 = "ProductNum", Item2 = "SnNum" });
     entity.Where(a => a.BarCode == barCode);
     entity.OrderBy(a => a.ID, EOrderBy.DESC);
     List<LocalProductEntity> listResult = this.LocalProduct.GetList(entity);
     return listResult;
 }