同一报表查看器中的多个表。 [英] Multiple Tables in same Report Viewer.
本文介绍了同一报表查看器中的多个表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个结算应用程序。在那里,我需要向客户打印账单。我为此创建了一个自定义表单。然后我发现这个 MSDN演练 [ ^ ]。它有效。但它只创建一个表的详细信息并显示完整的表格详细信息。
我需要自定义这个。我需要添加3个不同表格的详细信息并过滤掉最后输入的OrderID的详细信息。
Hi,
I am creating a billing application. In there i need to print the bill to customers. I created a custom form for that. Then i found this MSDN Walkthrough[^] . And it works. But it only creates details about one table and displays full table details.
I need to customize this. I need to add details from 3 different tables and filter out the details of only the last entered OrderID.
public PrintPreview()
{
InitializeComponent();
_reportViewer.Load += ReportViewer_Load;
}
private bool _isReportViewerLoaded;
private void ReportViewer_Load(object sender, EventArgs e)
{
if (!_isReportViewerLoaded)
{
Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
BillingDatabaseDataSet1 dataset = new BillingDatabaseDataSet1();
dataset.BeginInit();
reportDataSource1.Name = "DataSet1"; //Name of the report dataset in our .RDLC file
reportDataSource1.Value = dataset.Order_Products;
this._reportViewer.LocalReport.DataSources.Add(reportDataSource1);
this._reportViewer.LocalReport.ReportEmbeddedResource = "Billing.Report1.rdlc";
dataset.EndInit();
//fill data into Order_ProductsDataSet
BillingDatabaseDataSet1TableAdapters.Order_ProductsTableAdapter salesOrderDetailTableAdapter = new BillingDatabaseDataSet1TableAdapters.Order_ProductsTableAdapter();
salesOrderDetailTableAdapter.ClearBeforeFill = true;
salesOrderDetailTableAdapter.Fill(dataset.Order_Products);
_reportViewer.RefreshReport();
_isReportViewerLoaded = true;
}
}
推荐答案
为什么不创建一个select查询语句来绑定三个不同的表。并在.rpt文件中访问此查询。
示例:select query
Why dont you create a select query statement for binding three different tables and access this query in .rpt file.
Example:select query
Select
[MobNo]
,[Name]
,[WhomToMeet]
,[CheckInTime]
,[CheckOutTime]
,[CheckInItems]
,[CheckOutItems]
,[PendingItems]
,[PurPoseOfVisit]
,[ShiftName]
,[DeptName]
,[CompName] from Visitor
JOIN EmpMaster on EmpMaster.EmpMNo = Visitor.VisitorMobNo
JOIN ShiftMaster on ShiftMaster.ShiftCode=Visitor.VCompCode
JOIN DeptMaster on DeptMaster.DeptCode=Visitor.VisitorType
where IsBlackList=0
AND EmpCode =1
现在你可以根据逻辑编写自己的选择查询。
Now you can write your own select query as per logic.
这篇关于同一报表查看器中的多个表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文