public ActionResult ToExcel()
 {
     int status = WebUtil.GetFormValue<int>("Status", 0);
     string orderNum = WebUtil.GetFormValue<string>("OrderNum", string.Empty);
     string beginTime = WebUtil.GetFormValue<string>("BeginTime", string.Empty);
     string endTime = WebUtil.GetFormValue<string>("EndTime", string.Empty);
     CheckStockEntity entity = new CheckStockEntity();
     if (status > 0)
     {
         entity.Where(a => a.Status == status);
     }
     if (!orderNum.IsEmpty())
     {
         entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
     }
     if (!beginTime.IsEmpty() && !endTime.IsEmpty())
     {
         entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType<DateTime>(beginTime, DateTime.Now.AddDays(-1)), ConvertHelper.ToType<DateTime>(endTime, DateTime.Now));
     }
     entity.And(a => a.StorageNum == this.DefaultStore);
     PageInfo pageInfo = new PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
     Bill<CheckStockEntity, CheckStockInfoEntity> bill = new CheckOrder();
     List<CheckStockEntity> listResult = bill.GetList(entity, ref pageInfo);
     listResult = listResult.IsNull() ? new List<CheckStockEntity>() : 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("创建时间"));
         foreach (CheckStockEntity t in listResult)
         {
             DataRow row = dt.NewRow();
             row[0] = t.OrderNum;
             row[1] = EnumHelper.GetEnumDesc<ECheckType>(t.Type);
             row[2] = t.ContractOrder;
             row[3] = EnumHelper.GetEnumDesc<EAudite>(t.Status);
             row[4] = t.CreateUserName;
             row[5] = EnumHelper.GetEnumDesc<EOpType>(t.OperateType);
             row[6] = t.CreateTime.ToString("yyyy-MM-dd");
             dt.Rows.Add(row);
         }
         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 GetList()
 {
     int status = WebUtil.GetFormValue<int>("Status", 0);
     string orderNum = WebUtil.GetFormValue<string>("OrderNum", string.Empty);
     string beginTime = WebUtil.GetFormValue<string>("BeginTime", string.Empty);
     string endTime = WebUtil.GetFormValue<string>("EndTime", string.Empty);
     CheckStockEntity entity = new CheckStockEntity();
     if (status > 0)
     {
         entity.Where(a => a.Status == status);
     }
     if (!orderNum.IsEmpty())
     {
         entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
     }
     if (!beginTime.IsEmpty() && !endTime.IsEmpty())
     {
         entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType<DateTime>(beginTime, DateTime.Now.AddDays(-1)), ConvertHelper.ToType<DateTime>(endTime, DateTime.Now));
     }
     entity.And(a => a.StorageNum == this.DefaultStore);
     int pageIndex = WebUtil.GetFormValue<int>("PageIndex", 1);
     int pageSize = WebUtil.GetFormValue<int>("PageSize", 10);
     PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
     Bill<CheckStockEntity, CheckStockInfoEntity> bill = new CheckOrder();
     List<CheckStockEntity> listResult = bill.GetList(entity, ref pageInfo);
     listResult = listResult.IsNull() ? new List<CheckStockEntity>() : listResult;
     string json = ConvertJson.ListToJson(listResult, "List");
     this.ReturnJson.AddProperty("Data", json);
     this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
     return Content(this.ReturnJson.ToString());
 }