【问题标题】:Access stored procedure value within XtraReport访问 XtraReport 中的存储过程值
【发布时间】:2018-11-25 18:54:00
【问题描述】:

在我的表单中,我有这个代码可以通过单击按钮打开我的报告:

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。我想在txtFirstDate 中显示FirstDate DateEdit 控件的值,在txtLastDate 中显示LastDate DateEdit 控件的值。

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

提前致谢

【问题讨论】:

    标签: c# winforms devexpress


    【解决方案1】:

    我建议您阅读 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

    【讨论】:

    猜你喜欢
    • 2011-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-08
    • 2014-11-26
    • 1970-01-01
    相关资源
    最近更新 更多