public ActionResult GetList() { int status = WebUtil.GetFormValue <int>("Status", 0); string orderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); string supName = WebUtil.GetFormValue <string>("SupName", string.Empty); string beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty); string endTime = WebUtil.GetFormValue <string>("endTime", string.Empty); int pageSize = WebUtil.GetFormValue <int>("PageSize", 10); int pageIndex = WebUtil.GetFormValue <int>("PageIndex", 1); int InType = WebUtil.GetFormValue <int>("InType", 0); string planNum = WebUtil.GetFormValue <string>("planNum", string.Empty); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; InStorageEntity entity = new InStorageEntity(); if (status > 0) { entity.Where(a => a.Status == status); } if (!orderNum.IsEmpty()) { entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%"); } if (!supName.IsEmpty()) { entity.AndBegin <InStorageEntity>() .And <InStorageEntity>("SupNum", ECondition.Like, "%" + supName + "%") .Or <InStorageEntity>("SupName", ECondition.Like, "%" + supName + "%") .End <InStorageEntity>() ; } if (!beginTime.IsEmpty() && !endTime.IsEmpty()) { entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime)); } entity.And(a => a.StorageNum == this.DefaultStore); if (InType > 0) { entity.And(a => a.InType == InType); } if (!planNum.IsEmpty()) { entity.And("ContractOrder", ECondition.Like, "%" + planNum + "%"); } Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); List <InStorageEntity> listResult = bill.GetList(entity, ref pageInfo); listResult = listResult == null ? new List <InStorageEntity>() : listResult; string json = ConvertJson.ListToJson <InStorageEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", json); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 导出Excel /// </summary> /// <returns></returns> public ActionResult ToExcel() { int status = WebUtil.GetFormValue <int>("Status", 0); string orderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); string supName = WebUtil.GetFormValue <string>("SupName", string.Empty); string beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty); string endTime = WebUtil.GetFormValue <string>("endTime", string.Empty); int pageSize = Int32.MaxValue; int pageIndex = 1; PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; InStorageEntity entity = new InStorageEntity(); if (status > 0) { entity.Where(a => a.Status == status); } if (!orderNum.IsEmpty()) { entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%"); } if (!supName.IsEmpty()) { entity.AndBegin <InStorageEntity>() .And <InStorageEntity>("SupNum", ECondition.Like, "%" + supName + "%") .Or <InStorageEntity>("SupName", ECondition.Like, "%" + supName + "%") .End <InStorageEntity>() ; } if (!beginTime.IsEmpty() && !endTime.IsEmpty()) { entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime)); } Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); List <InStorageEntity> listResult = bill.GetList(entity, ref pageInfo); listResult = listResult == null ? new List <InStorageEntity>() : listResult; 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("创建时间")); foreach (InStorageEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = t.OrderNum; row[1] = EnumHelper.GetEnumDesc <EInType>(t.InType); row[2] = t.SupName; row[3] = t.ContractOrder; row[4] = t.Num; row[5] = t.Amount.ToString("0.00") + " 元"; row[6] = EnumHelper.GetEnumDesc <EAudite>(t.Status); row[7] = t.CreateUserName; row[8] = EnumHelper.GetEnumDesc <EOpType>(t.OperateType); row[9] = t.OrderTime.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()); return(Content(this.ReturnJson.ToString())); }