Exemple #1
0
 private void Button1_Click(System.Object sender, System.EventArgs e)
 {
     try {
         Cursor         = Cursors.WaitCursor;
         Timer1.Enabled = true;
         rptProject rpt = new rptProject();
         //The report you created.
         OleDbConnection  myConnection = null;
         OleDbCommand     MyCommand    = new OleDbCommand();
         OleDbDataAdapter myDA         = new OleDbDataAdapter();
         LMS_DBDataSet    myDS         = new LMS_DBDataSet();
         //The DataSet you created.
         myConnection          = new OleDbConnection(cs);
         MyCommand.Connection  = myConnection;
         MyCommand.CommandText = "SELECT * from Project where Projectname like '" + txtProjectTitle.Text + "%' order by Projectname";
         MyCommand.CommandType = CommandType.Text;
         myDA.SelectCommand    = MyCommand;
         myDA.Fill(myDS, "Project");
         rpt.SetDataSource(myDS);
         My.MyProject.Forms.frmProjectReport.CrystalReportViewer1.ReportSource = rpt;
         My.MyProject.Forms.frmProjectReport.Show();
     } catch (Exception ex) {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
 private void Button3_Click(System.Object sender, System.EventArgs e)
 {
     try {
         if (Strings.Len(Strings.Trim(cmbCourse.Text)) == 0)
         {
             MessageBox.Show("Please select course", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             cmbCourse.Focus();
             return;
         }
         if (Strings.Len(Strings.Trim(cmbYear.Text)) == 0)
         {
             MessageBox.Show("Please select year", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             cmbYear.Focus();
             return;
         }
         Cursor         = Cursors.WaitCursor;
         Timer1.Enabled = true;
         rptProject rpt = new rptProject();
         //The report you created.
         OleDbConnection  myConnection = null;
         OleDbCommand     MyCommand    = new OleDbCommand();
         OleDbDataAdapter myDA         = new OleDbDataAdapter();
         LMS_DBDataSet    myDS         = new LMS_DBDataSet();
         //The DataSet you created.
         myConnection          = new OleDbConnection(cs);
         MyCommand.Connection  = myConnection;
         MyCommand.CommandText = "SELECT * from Project where Course='" + cmbCourse.Text + "' and Proj_Year='" + cmbYear.Text + "' order by ProjectName";
         MyCommand.CommandType = CommandType.Text;
         myDA.SelectCommand    = MyCommand;
         myDA.Fill(myDS, "Project");
         rpt.SetDataSource(myDS);
         My.MyProject.Forms.frmProjectReport.CrystalReportViewer1.ReportSource = rpt;
         My.MyProject.Forms.frmProjectReport.Show();
     } catch (Exception ex) {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }