private void button1_Click(object sender, EventArgs e) { ParameterFields paramFields = new ParameterFields(); ParameterField paramField1 = new ParameterField(); paramField1.Name = "@starttime"; pdv1.Value = dateTimePicker1.Value.Date; paramField1.CurrentValues.Add(pdv1); paramFields.Add(paramField1); ParameterField paramField2 = new ParameterField(); paramField2.Name = "@endtime"; pdv2.Value = new DateTime(dateTimePicker2.Value.Year, dateTimePicker2.Value.Month, dateTimePicker2.Value.Day, 23, 59, 59); paramField2.CurrentValues.Add(pdv2); paramFields.Add(paramField2); switch (comboBox1.SelectedIndex) { case 0: { Form9 f9 = new Form9(); f9.ShowDialog(); break; } case 1: { initdb(); break; } case 2: if (dateTimePicker1.Value == dateTimePicker2.Value) { CrystalReport5 CrystalReport = new CrystalReport5(); crystalReportViewer1.ParameterFieldInfo = paramFields; crystalReportViewer1.ReportSource = CrystalReport; } else { CrystalReport1 CrystalReport = new CrystalReport1(); crystalReportViewer1.ParameterFieldInfo = paramFields; crystalReportViewer1.ReportSource = CrystalReport; } break; case 3: CrystalReport2 CrystalReport1 = new CrystalReport2(); //crystalReportViewer1.ParameterFieldInfo = paramFields; crystalReportViewer1.ReportSource = CrystalReport1; break; case 4: CrystalReport3 CrystalReport2 = new CrystalReport3(); crystalReportViewer1.ParameterFieldInfo = paramFields; crystalReportViewer1.ReportSource = CrystalReport2; break; case 5: CrystalReport4 CrystalReport3 = new CrystalReport4(); crystalReportViewer1.ParameterFieldInfo = paramFields; crystalReportViewer1.ReportSource = CrystalReport3; break; } }