/// <summary> /// 查询单据分页 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <param name="storageNum"></param> /// <returns></returns> public List <BadReportEntity> GetList(BadReportEntity entity, ref PageInfo pageInfo, string storageNum) { entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); entity.And("Status", ECondition.Eth, (int)EAudite.Pass); entity.OrderBy(a => a.ID, EOrderBy.DESC); BadReportDetailEntity badDetail = new BadReportDetailEntity(); badDetail.Include(a => new { ProductName = a.ProductName, BarCode = a.BarCode, ProductNum = a.ProductNum }); badDetail.Where(a => a.StorageNum == storageNum); entity.Left <BadReportDetailEntity>(badDetail, new Params <string, string>() { Item1 = "OrderNum", Item2 = "OrderNum" }); int rowCount = 0; List <BadReportEntity> listResult = this.BadReport.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); int allNum = GetAllNum(); if (!listResult.IsNullOrEmpty()) { foreach (BadReportEntity item in listResult) { item.NumPCT = (item.Num * 100.00f) / allNum; } } pageInfo.RowCount = rowCount; return(listResult); }
public ActionResult GetList() { int Status = WebUtil.GetFormValue <int>("Status", 0); string OrderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); string BadType = WebUtil.GetFormValue <string>("BadType", string.Empty); string ProductType = WebUtil.GetFormValue <string>("ProductType", 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); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; BadReportEntity entity = new BadReportEntity(); if (Status > 0) { entity.Where(a => a.Status == Status); } if (!OrderNum.IsEmpty()) { entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%"); } if (!ProductType.IsEmpty()) { entity.Where("ProductType", ECondition.Eth, ProductType); } if (!BadType.IsEmpty()) { entity.Where("BadType", ECondition.Eth, BadType); } if (!beginTime.IsEmpty() && !endTime.IsEmpty()) { entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime)); } entity.And(a => a.StorageNum == this.DefaultStore); Bill <BadReportEntity, BadReportDetailEntity> bill = new BadOrder(); List <BadReportEntity> listResult = bill.GetList(entity, ref pageInfo); listResult = listResult == null ? new List <BadReportEntity>() : listResult; string json = ConvertJson.ListToJson <BadReportEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", json); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 获得所有报损数量 /// </summary> /// <returns></returns> public int GetAllNum() { BadReportEntity entity = new BadReportEntity(); entity.IncludeNum(true); entity.Where("Status", ECondition.Eth, (int)EAudite.Pass); entity.And("IsDelete", ECondition.Eth, (int)EIsDelete.NotDelete); int allNum = 0; try { allNum = this.BadReport.Sum <int>(entity); } catch (Exception e) { allNum = 0; log.Info(e.Message); } return(allNum); }
public ActionResult ToExcel() { int Status = WebUtil.GetFormValue <int>("Status", 0); string OrderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); string BadType = WebUtil.GetFormValue <string>("BadType", string.Empty); string ProductType = WebUtil.GetFormValue <string>("ProductType", 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); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; BadReportEntity entity = new BadReportEntity(); if (Status > 0) { entity.Where(a => a.Status == Status); } if (!OrderNum.IsEmpty()) { entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%"); } if (!ProductType.IsEmpty()) { entity.Where("ProductType", ECondition.Eth, ProductType); } if (!BadType.IsEmpty()) { entity.Where("BadType", ECondition.Eth, BadType); } if (!beginTime.IsEmpty() && !endTime.IsEmpty()) { entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime)); } entity.And(a => a.StorageNum == this.DefaultStore); Bill <BadReportEntity, BadReportDetailEntity> bill = new BadOrder(); List <BadReportEntity> listResult = bill.GetList(entity, ref pageInfo); 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("创建时间")); int count = 1; foreach (BadReportEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = count; row[1] = t.OrderNum; row[2] = EnumHelper.GetEnumDesc <EBadType>(t.BadType); row[3] = t.ContractOrder; row[4] = t.Num; row[5] = EnumHelper.GetEnumDesc <EAudite>(t.Status); row[6] = EnumHelper.GetEnumDesc <EOpType>(t.OperateType); row[7] = t.CreateUser; row[8] = t.CreateTime.ToString("yyyy-MM-dd"); 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())); }