来自两个DateTimePickers的Crystal Reports

时间:2015-10-30 18:28:56

标签: c# crystal-reports

我有一个包含CrystalReportViewer的表单,顶部有两个DateTimePickersbutton1,当我运行此代码并选择日期并点击按钮时,没有数据仅在查看器上显示列名称。

private void button1_Click(object sender, EventArgs e)
{
     ByName cryrpt = new ByName();
     cryrpt.Load(@"C:*******************ByName.rpt");
     ParameterFields pfields = new ParameterFields();
     ParameterField pfield = new ParameterField();
     ParameterDiscreteValue pdisc = new ParameterDiscreteValue();
     ParameterField pfield1 = new ParameterField();
     ParameterDiscreteValue pdisc1 = new ParameterDiscreteValue();

     pfield.Name = "start_Date";
     pdisc.Value = FirstDate;
     pfield.CurrentValues.Add(pdisc);
     pfields.Add(pfield);

     pfield1.Name = "End_Date";
     pdisc1.Value = SecondDate;
     pfield1.CurrentValues.Add(pdisc1);
     pfields.Add(pfield1);
     crystalReportViewer1.ReportSource = cryrpt;
     crystalReportViewer1.ParameterFieldInfo = pfields;
     FirstDate = dateTimePicker1.Value;
     SecondDate = dateTimePicker2.Value;
     crystalReportViewer1.ReportSource = cryrpt;
     crystalReportViewer1.Refresh();
}

0 个答案:

没有答案