public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rptInternalMarks rpt = new rptInternalMarks(); rpt.Site = this.Site; return(rpt); }
private void btnGetData_Click(object sender, EventArgs e) { if (cmbCourse.Text == "") { MessageBox.Show("Please select course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbCourse.Focus(); return; } if (cmbBranch.Text == "") { MessageBox.Show("Please select branch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbBranch.Focus(); return; } if (cmbSemester.Text == "") { MessageBox.Show("Please select semester", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbSemester.Focus(); return; } if (cmbSession.Text == "") { MessageBox.Show("Please select session", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbSession.Focus(); return; } if (cmbSection.Text == "") { MessageBox.Show("Please select section", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbSection.Focus(); return; } try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptInternalMarks rpt = new rptInternalMarks(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); DataSet myDS = new DataSet(); //The DataSet you created. myConnection = new SqlConnection("Data Source=GHAFFARI\\ALIGHAFFARI;Initial Catalog=CMS;Integrated Security=True;"); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from InternalMarksEntry,Student where Student.ScholarNo=InternalMarksEntry.ScholarNo and InternalMarksEntry.Course= '" + cmbCourse.Text + "'and InternalMarksEntry.branch='" + cmbBranch.Text + "'and Student.Session='" + cmbSession.Text + "' and InternalMarksEntry.Semester = '" + cmbSemester.Text + "' and Student.Section = '" + cmbSection.Text + "' order by Student.Student_name "; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "InternalMarksEntry"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }