private void textBox1_TextChanged(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptStudentRegistration rpt = new rptStudentRegistration(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); StudentDataSet myDS = new StudentDataSet(); //The DataSet you created. myConnection = new SqlConnection("Data Source=GHAFFARI\\ALIGHAFFARI;Initial Catalog=CMS;Integrated Security=True;"); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from studentRegistration where Student_name like '" + StudentName.Text + "%' order by DateOfAdmission"; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "StudentRegistration"); rpt.SetDataSource(myDS); crystalReportViewer3.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button4_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptStudentRegistration rpt = new rptStudentRegistration(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); StudentDataSet myDS = new StudentDataSet(); //The DataSet you created. myConnection = new SqlConnection("Data Source=GHAFFARI\\ALIGHAFFARI;Initial Catalog=CMS;Integrated Security=True;"); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from studentRegistration where DateOfAdmission between @date1 and @date2 order by DateOfAdmission"; MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, " DateOfAdmission").Value = DateFrom.Value.Date; MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, " DateOfAdmission").Value = DateTo.Value.Date; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "StudentRegistration"); rpt.SetDataSource(myDS); crystalReportViewer2.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void StudentName_SelectedIndexChanged(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptStudentRegistration rpt = new rptStudentRegistration(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); CMS_DBDataSet myDS = new CMS_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBConn); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from studentRegistration where Student_name='" + cmbStudentName.Text + "' order by DateOfAdmission"; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "StudentRegistration"); rpt.SetDataSource(myDS); crystalReportViewer3.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rptStudentRegistration rpt = new rptStudentRegistration(); rpt.Site = this.Site; return(rpt); }
private void Button1_Click(object sender, EventArgs e) { try { if (Course.Text == "") { MessageBox.Show("Please select course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Course.Focus(); return; } if (Branch.Text == "") { MessageBox.Show("Please select branch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Branch.Focus(); return; } if (Session.Text == "") { MessageBox.Show("Please select session", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Session.Focus(); return; } Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptStudentRegistration rpt = new rptStudentRegistration(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); StudentDataSet myDS = new StudentDataSet(); //The DataSet you created. myConnection = new SqlConnection("Data Source=GHAFFARI\\ALIGHAFFARI;Initial Catalog=CMS;Integrated Security=True;"); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from studentRegistration where Course= '" + Course.Text + "'and branch='" + Branch.Text + "'and Session='" + Session.Text + "'order by DateOfAdmission"; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "StudentRegistration"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }