public ActionResult ProductReportList()
        {
            string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty);
            string beginTime = WebUtil.GetFormValue<string>("BeginTime", string.Empty);
            string endTime = WebUtil.GetFormValue<string>("EndTime", string.Empty);
            int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0);
            int pageSize = WebUtil.GetFormValue<int>("pageSize", 0);
            string storageNum = this.DefaultStore;
            ProductProvider provider = new ProductProvider();
            ProductEntity entity = new ProductEntity();
            entity.StorageNum = storageNum;
            if (!searchKey.IsEmpty())
            {
                entity.Begin<ProductEntity>()
                 .Where<ProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%")
                 .Or<ProductEntity>("SnNum", ECondition.Like, "%" + searchKey + "%")
                 .Or<ProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%")
                 .End<ProductEntity>();
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType<DateTime>(beginTime), ConvertHelper.ToType<DateTime>(endTime));
            }

            PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
            List<ProductEntity> listResult = provider.GetList(entity, ref pageInfo, searchKey, beginTime, endTime);
            string json = ConvertJson.ListToJson<ProductEntity>(listResult, "List");
            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return Content(this.ReturnJson.ToString());
        }
        public ActionResult ToExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
            string ProductName = WebUtil.GetFormValue<string>("ProductName", string.Empty);
            int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0);
            int pageSize = WebUtil.GetFormValue<int>("pageSize", 0);
            string CateNum = WebUtil.GetFormValue<string>("CateNum", string.Empty);
            ProductProvider provider = new ProductProvider();
            ProductEntity entity = new ProductEntity();
            if (!ProductName.IsEmpty())
            {
                entity.Where<ProductEntity>("ProductName", ECondition.Like, "%" + ProductName + "%");
            }
            if (!CateNum.IsEmpty())
            {
                entity.Where<ProductEntity>("CateNum", ECondition.Eth, CateNum);
            }
            List<ProductEntity> listResult = provider.GetList(entity, ref pageInfo);

            listResult = listResult.IsNull() ? new List<ProductEntity>() : 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("进口价格"));
                dt.Columns.Add(new DataColumn("出口价格"));
                dt.Columns.Add(new DataColumn("净重"));
                dt.Columns.Add(new DataColumn("毛重"));
                dt.Columns.Add(new DataColumn("备注"));
                int count = 1;
                foreach (ProductEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.SnNum;
                    row[2] = t.BarCode;
                    row[3] = t.ProductName;
                    row[4] = t.CateName;
                    row[5] = t.Num;
                    row[6] = t.MinNum;
                    row[7] = t.MaxNum;
                    row[8] = t.UnitName;
                    row[9] = t.AvgPrice;
                    row[10] = t.InPrice;
                    row[11] = t.OutPrice;
                    row[12] = t.NetWeight.ToString();
                    row[13] = t.GrossWeight.ToString();
                    row[14] = t.Remark;
                    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 ToProductReportExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
            string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty);
            string beginTime = WebUtil.GetFormValue<string>("BeginTime", string.Empty);
            string endTime = WebUtil.GetFormValue<string>("EndTime", string.Empty);
            string storageNum = this.DefaultStore;

            ProductProvider provider = new ProductProvider();
            ProductEntity entity = new ProductEntity();
            if (!searchKey.IsEmpty())
            {
                entity.Begin<ProductEntity>()
                 .Where<ProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%")
                 .Or<ProductEntity>("SnNum", ECondition.Like, "%" + searchKey + "%")
                 .Or<ProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%")
                 .End<ProductEntity>();
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType<DateTime>(beginTime), ConvertHelper.ToType<DateTime>(endTime));
            }
            if (storageNum.IsNotNull())
            {
                entity.Where("StorageNum", ECondition.Eth, storageNum);
            }
            List<ProductEntity> listResult = provider.GetList(entity, ref pageInfo, searchKey, beginTime, endTime);
            listResult = listResult.IsNull() ? new List<ProductEntity>() : listResult;
            if (!listResult.IsNullOrEmpty())
            {
                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 (ProductEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.SnNum;
                    row[2] = t.BarCode;
                    row[3] = t.ProductName;
                    row[4] = t.CateName;
                    row[5] = t.MinNum;
                    row[6] = t.MaxNum;
                    row[7] = t.Size;
                    row[8] = t.AvgPrice;
                    row[9] = t.LocalProductNum;
                    row[10] = t.InStorageNum;
                    row[11] = t.OutStorageNum;
                    row[12] = t.BadReportNum;
                    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] = listResult[0].TotalLocalProductNum;
                rowTemp[10] = listResult[0].TotalInStorageNum;
                rowTemp[11] = listResult[0].TotalOutStorageNum;
                rowTemp[12] = listResult[0].TotalBadReportNum;
                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());
        }
 public ActionResult GetList()
 {
     string ProductName = WebUtil.GetFormValue<string>("ProductName", string.Empty);
     int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0);
     int pageSize = WebUtil.GetFormValue<int>("pageSize", 0);
     string CateNum = WebUtil.GetFormValue<string>("CateNum", string.Empty);
     ProductProvider provider = new ProductProvider();
     ProductEntity entity = new ProductEntity();
     if (!ProductName.IsEmpty())
     {
         entity.Begin<ProductEntity>()
          .Where<ProductEntity>("ProductName", ECondition.Like, "%" + ProductName + "%")
          .Or<ProductEntity>("SnNum", ECondition.Like, "%" + ProductName + "%")
          .Or<ProductEntity>("BarCode", ECondition.Like, "%" + ProductName + "%")
          .End<ProductEntity>();
     }
     if (!CateNum.IsEmpty())
     {
         entity.Where<ProductEntity>("CateNum", ECondition.Eth, CateNum);
     }
     PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
     List<ProductEntity> listResult = provider.GetList(entity, ref pageInfo);
     string json = ConvertJson.ListToJson<ProductEntity>(listResult, "List");
     this.ReturnJson.AddProperty("Data", new JsonObject(json));
     this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
     return Content(this.ReturnJson.ToString());
 }