2

我将类详细信息作为我的数据源附加到报告中;

class Detail
{ 
public string Name { get; set; }
public string State { get; set; }
public string City { get; set;}
public List<Transaction> tran { get; set; }
}
class Transaction
{
public string TransactionDate { get; set; }
public string TransactionDescription { get; set; } 
}

在我的查询中,我将其作为列表发送。

public List GetAccount(string account) {
List detail = new List();
sql ....
foreach (DataRow dr in dt.Rows)
{
detail.Add(new Detail()
{
  Name= dr["name"].Equals(DBNull.Value) ? string.Empty : dr["name"].ToString(),
 .....
  tran = GetTransactionDetail(account)// calling a list

 }); 
}
return detail;
}

public List<Transaction> GetTransactionDetail(string account)
{
....
}

在 Form1.cs

XtraReport1 rep = new XtraReport1();
printControl1.PrintingSystem = rep.PrintingSystem;
var ls = query.GetAccount(accountNo);
rep.DataSource = ls;
rep.CreateDocument();

在报告中我应该得到一个交易细节列表,但我只得到第一行。谢谢,

4

2 回答 2

0

这取决于您的报告是如何设计的。通常,您需要一个单独的波段 (DetailReport) 才能显示所有详细信息(如果您使用的是 XRTable)。

于 2013-12-27T10:48:39.727 回答
0

先生,您应该使用DataSetquery.GetAccount(accountNo)返回DataTable 然后尝试这样。这个对我有用。

XtraReport1 rep = new XtraReport1();
printControl1.PrintingSystem = rep.PrintingSystem;
var ds = new ds("TestDataSet");
var ls = query.GetAccount(accountNo);
ds.Tables.Add(ls);
rep.DataSource = ds;
rep.DataMember = ls.TableName;
rep.CreateDocument();
于 2015-10-29T05:45:41.043 回答