我如何在devexpress报告图表栏中表示存储过程

时间:2018-11-23 10:58:10

标签: c# winforms devexpress

我有这个存储过程

USE [SIM]
GO

CREATE PROCEDURE RepSumLigne
    @Date DATE
AS
    SELECT
        SUM(AssemblyWeight) AS 'Ligne Assemblage',
        SUM(WeldingWeight)  AS 'Ligne Soudage',
        SUM(PaintWeight)    AS 'Ligne Peinture' 
    FROM
        DailyProduction
    WHERE
        CreationDate = @Date

并且我创建了一个包含表格和图表栏的报告,该表格显示的结果正确,但是图表栏什么也不显示,为此图表栏我创建了三个系列(Ligne Assemblage,Ligne Soudage和Ligne Peinture),在数据部分,我设置每个值。但是当我运行报告时,它显示为空

enter image description here

点击按钮即可打开重排

private void btnLigneProduSumry_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
    {
        DateEdit ProducationDay = new DateEdit();
        ProducationDay.Properties.HighlightHolidays = false;
        ProducationDay.Properties.FirstDayOfWeek = DayOfWeek.Saturday;

        XtraInputBoxArgs args = new XtraInputBoxArgs();
        args.Caption = Resources.date;
        args.Prompt = Resources.chooseDate;
        args.DefaultButtonIndex = 0;
        args.DefaultResponse = DateTime.Today;
        args.Editor = ProducationDay;
        var result = XtraInputBox.Show(args);

        RepLigneProductionSumm report = new RepLigneProductionSumm();
        report.DataSource = paint.LigneProductionSummRep(Convert.ToDateTime(ProducationDay.EditValue).ToString("MM/dd/yyyy"));
        report.ShowRibbonPreviewDialog();
    }

以及LigneProductionSummRep背后的代码

public DataTable LigneProductionSummRep(string DateProduction)
    {
        DAL.DataAccessLayer DAL = new DAL.DataAccessLayer();
        DataTable dt = new DataTable();
        SqlParameter[] param = new SqlParameter[1];
        param[0] = new SqlParameter("@Date", SqlDbType.NVarChar, 50);
        param[0].Value = DateProduction;

        dt = DAL.SelectData("LigneProductionSummRep", param);
        DAL.Close();
        return dt;

    }

如何解决此问题?在此先感谢您的更新:我已将Ligne组合放在参数和值上

enter image description here

和无数据源 enter image description here

图表栏看起来像这样 enter image description here

1 个答案:

答案 0 :(得分:0)

我在youtube上找到了这个灵魂,我创建了没有任何数据源的图表栏,并且我在图表设计器中添加了三个栏系列,在我的报告中输入了这段代码

        private void xrChart1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
    {
        xrChart1.Series["Ligne Assemblage"].Points.Add(new DevExpress.XtraCharts.SeriesPoint("Ligne Assemblage", txtAssembly.Text));
        xrChart1.Series["Ligne Soudage"].Points.Add(new DevExpress.XtraCharts.SeriesPoint("Ligne Soudage", txtWelding.Text));
        xrChart1.Series["Ligne Peinture"].Points.Add(new DevExpress.XtraCharts.SeriesPoint("Ligne Peinture", txtPaint.Text));
    }