访问XtraReport中的存储过程值

时间:2018-11-25 18:54:01

标签: c# winforms devexpress

在我的表单中,我具有以下代码,只需单击一下按钮即可打开报告:

private void btnGroupOther_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
    LayoutControl lc = new LayoutControl();
    lc.Dock = DockStyle.Fill;
    DateEdit FirstDate = new DateEdit();
    DateEdit LastDate = new DateEdit();
    lc.AddItem(Resources.firstdate, FirstDate).TextVisible = true;
    lc.AddItem(Resources.seconddate, LastDate).TextVisible = true;
    lc.Height = 70;
    this.Controls.Add(lc);
    this.Dock = DockStyle.Top;
    if (DevExpress.XtraEditors.XtraDialog.Show(lc, " ", MessageBoxButtons.OKCancel) == DialogResult.OK)
    {
        RepProductionGroupOther report = new RepProductionGroupOther();
        report.DataSource = paint.RepProductionGroupOther(Convert.ToDateTime(FirstDate.EditValue).ToString("MM/dd/yyyy"),
            Convert.ToDateTime(LastDate.EditValue).ToString("MM/dd/yyyy"));

        report.ShowRibbonPreviewDialog();
    }
}

在标题报告中,我有两个xrLabel;第一个txtFirstDate和第二个txtLastDate。我想在FirstDate中显示DateEdit txtFirstDate控件的值,在LastDate中显示DateEdit txtLastDate控件的值。

我该怎么做,报表的数据源是sql存储过程。
它具有两个参数:@FirstDate@LastDate

预先感谢

1 个答案:

答案 0 :(得分:0)

我建议您阅读XtraReport文档:
Request and Pass Report Parameter Values

private void button1_Click(object sender, EventArgs e) {
    // Create a report instance. 
    XtraReport1 report = new XtraReport1();

    // Obtain a parameter and set its value. 
    report.Parameters["parameter1"].Value = 30;

    // Hide the Parameters' UI from end-users (if you did not hide it at design time). 
    report.Parameters["parameter1"].Visible = false;

    // Show the report's print preview depending on your target platform. 
    // ... 
}

检查上述文档中的“自定义参数编辑器”部分 参数的自定义编辑器实现取决于您的应用程序平台:

下面是与您尝试执行的类似的实现。请检查这些内容,希望这将帮助您解决问题。
How to pass parameters to devexpress XtraReport from combobox
DevExpress XtraReport Setting a DateTime Parameter to Today

Passing parameters to Xtrareports repx file