例如,我当前有出库单如下:
我当前代码如下:
- public async Task<DataTable> LoadData(LocateDataSourceArgs args)
- {
- //取值,URL传参,多个参数需要使用&进行分割
- var urlParamStr = (object[])args.ReportParameters[0].Value;
- var dic = ReportHelper.StringToDictionary(urlParamStr[0].ToString());
- string id = dic["id"].ToString();
- DataTable dt = new DataTable();
- var _context = _outboundOrderRepository.DbContext;
- if (args.DataSet.Query.DataSourceName == "DataSource1")
- {
- if (args.DataSet.Name == "DataSet1")
- {
- dt.Columns.Add("出库开单单号");
- dt.Columns.Add("开单日期");
- dt.Columns.Add("制单人");
- dt.Columns.Add("制单日期");
- dt.Columns.Add("出库人");
- dt.Columns.Add("出库部门");
- dt.Columns.Add("备注");
- dt.Columns.Add("审核人");
- dt.Columns.Add("审核时间");
- var orderInfo = await _context.Queryable<Xb_OutboundOrder>().Where(x => x.OutboundOrderId == Convert.ToInt64(id)).FirstOrDefaultAsync();
- if (orderInfo == null) return dt;
- var lxUserInfo = await _context.Queryable<Sys_UserInfo>().Where(x => x.User_Id == orderInfo.AuditId).FirstOrDefaultAsync();
- var zdUserInfo = await _context.Queryable<Sys_UserInfo>().Where(x => x.User_Id == orderInfo.CreateID).FirstOrDefaultAsync();
- string deptmentName = string.Empty;
- if (orderInfo.DepartmentId.HasValue)
- {
- var deptmentInfo = await _context.Queryable<Sys_Department>().Where(x => x.DepartmentId.ToString() == orderInfo.DepartmentId.Value.ToString()).FirstOrDefaultAsync();
- deptmentName = deptmentInfo?.DepartmentName;
- }
- var ckUserInfo = await _context.Queryable<Sys_UserInfo>().Where(x => x.User_Id == orderInfo.WarehouseKeeper).FirstOrDefaultAsync();
- dt.Rows.Add(orderInfo.Number, orderInfo.InvoiceDate,
- zdUserInfo?.UserTrueName, orderInfo.CreateDate, ckUserInfo?.UserTrueName, deptmentName, orderInfo.Remarks,
- lxUserInfo?.UserTrueName, orderInfo.AuditDate);
- }
- else if (args.DataSet.Name == "DataSet2")
- {
- dt.Columns.Add("货品名称");
- dt.Columns.Add("货品编号");
- dt.Columns.Add("型号");
- dt.Columns.Add("规格");
- dt.Columns.Add("单位");
- dt.Columns.Add("仓库");
- dt.Columns.Add("库位");
- dt.Columns.Add("批次");
- dt.Columns.Add("数量");
- dt.Columns.Add("单价");
- dt.Columns.Add("总金额");
- dt.Columns.Add("自定义1");
- dt.Columns.Add("自定义2");
- dt.Columns.Add("自定义3");
- dt.Columns.Add("品牌");
- dt.Columns.Add("生产日期");
- dt.Columns.Add("过期日期");
- dt.Columns.Add("仓库编号");
- dt.Columns.Add("库位编号");
- dt.Columns.Add("备注");
- var orderItemList = await _context.Queryable<Xb_OutboundOrderItem>().Where(x => x.OutboundOrderId == Convert.ToInt64(id)).OrderByDescending(x => x.Id).ToListAsync();
- if (!orderItemList.Any()) return dt;
- foreach (var orderItem in orderItemList)
- {
- var productInfo = await _context.Queryable<Xb_Product>().Where(x => x.Id == orderItem.ProductId).FirstOrDefaultAsync();
- var warehouseInfo = await _context.Queryable<Xb_Warehouse>().Where(x => x.Id == orderItem.WarehouseId).FirstOrDefaultAsync();
- var warehouseLocationInfo = await _context.Queryable<Xb_WarehouseLocation>().Where(x => x.Id == orderItem.WarehouseLocationId).FirstOrDefaultAsync();
- dt.Rows.Add(productInfo?.Name, productInfo?.Number, productInfo?.Model,
- productInfo?.Specifications, productInfo?.Unit, warehouseInfo?.Name, warehouseLocationInfo?.Name,
- orderItem.Batch, orderItem.Quantity, orderItem.Price, orderItem.Quantity * orderItem.Price,
- productInfo?.Custom1, productInfo?.Custom2, productInfo?.Custom3, productInfo?.Brand,
- orderItem.ProductionDate, orderItem.ExpirationDate, warehouseInfo?.Number, warehouseLocationInfo?.Number, orderItem?.Remarks);
- }
- }
- }
- return dt;
- }
复制代码
现在我需要打印多页,要如何实现? |