public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { RptStudents rpt = new RptStudents(); rpt.Site = this.Site; return(rpt); }
private void Button1_Click(object sender, EventArgs e) { try { if (txtSchool.Text == "") { MessageBox.Show("Please select school", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSchool.Focus(); return; } if (txtSession.Text == "") { MessageBox.Show("Please Enter Session", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSession.Focus(); return; } if (txtClass.Text == "") { MessageBox.Show("Please Enter Class", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtClass.Focus(); return; } if (txtSection.Text == "") { MessageBox.Show("Please Enter Section", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSection.Focus(); return; } try { Cursor = Cursors.WaitCursor; Timer1.Enabled = true; con = new SqlConnection(cs.DBcon); ds.WriteXmlSchema("Student.xml"); RptStudents rpt = new RptStudents(); rpt.SetDataSource(ds); frm.crystalReportViewer1.ReportSource = rpt; frm.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Button1_Click(object sender, EventArgs e) { try { if (txtSchool.Text == "") { MessageBox.Show("Please select school", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSchool.Focus(); return; } if (txtSession.Text == "") { MessageBox.Show("Please Enter Session", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSession.Focus(); return; } if (txtClass.Text == "") { MessageBox.Show("Please Enter Class", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtClass.Focus(); return; } if (txtSection.Text == "") { MessageBox.Show("Please Enter Section", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSection.Focus(); return; } try { Cursor = Cursors.WaitCursor; Timer1.Enabled = true; con = new SqlConnection(cs.DBcon); con.Open(); cmd = new SqlCommand("SELECT Student.AdmissionNo,Student.Status, Student.EnrollmentNo, Student.StudentName, Student.FatherName, Student.MotherName, Student.ParentContact, Student.PermanentAddress, Student.ContactNo, Student.DOB,Student.Gender, Student.AdmissionDate, Student.Religion, Student.Nationality, Sessions.Session, School.SchoolName, School.Photo, Class.ClassName, Section.SectionName FROM Student INNER JOIN Sessions ON Student.Session_ID = Sessions.SessionID INNER JOIN School ON Student.School_ID = School.SchoolID INNER JOIN ClassSection ON Student.ClassSection_ID = ClassSection.ClassSectionID INNER JOIN Class ON ClassSection.Class_ID = Class.ClassID INNER JOIN Section ON ClassSection.Section_ID = Section.SectionID where SchoolName=@d1 and Session=@d2 and ClassName=@d3 and SectionName=@d4 order by StudentName", con); cmd.Parameters.AddWithValue("@d1", txtSchool.Text); cmd.Parameters.AddWithValue("@d2", txtSession.Text); cmd.Parameters.AddWithValue("@d3", txtClass.Text); cmd.Parameters.AddWithValue("@d4", txtSection.Text); adp = new SqlDataAdapter(cmd); DataTable table = new DataTable(); adp.Fill(table); ds = new DataSet(); con.Close(); ds.Tables.Add(table); ds.WriteXmlSchema("Student.xml"); RptStudents rpt = new RptStudents(); rpt.SetDataSource(ds); frm.crystalReportViewer1.ReportSource = rpt; frm.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }