Beispiel #1
0
 private void classBType(int caseNumber)
 {
     try
     {
         if (caseNumber == 1)
         {
             sda = new SqlDataAdapter("SELECT * From [tblStudentB]", con);
         }
         else if (caseNumber == 2)
         {
             sda = new SqlDataAdapter("SELECT * From [tblStudentB] Where [Gender] = 'Male'", con);
         }
         else if (caseNumber == 3)
         {
             sda = new SqlDataAdapter("SELECT * From [tblStudentB] Where [Gender] = 'Female'", con);
         }
         else if (caseNumber == 4)
         {
             sda = new SqlDataAdapter("SELECT * From [tblStudentB] Where [EAL?] = 'Y'", con);
         }
         else
         {
             sda = new SqlDataAdapter("SELECT * From [tblStudentB] Where [Disadvantaged?] = 'Y'", con);
         }
     }
     catch (Exception e)
     {
         errorTracking et = new errorTracking();
         et.outputErrorToText(e.Message);
     }
 }
Beispiel #2
0
 //displays retrieved items required from the database (class A and B)
 public void queryDatabase(int caseNumber, StudentDataForm sdf)
 {
     try
     {
         if (sdf.cmbClass.Text == "Class A")
         {
             ConnectToDB();
             con.Open();
             //call method to set the query data.
             classAType(caseNumber);
             dt = new DataTable();
             sda.Fill(dt);
             sdf.dgvStudentProgress.DataSource = dt;
             con.Close();
         }
         else if (sdf.cmbClass.Text == "Class B")
         {
             ConnectToDB();
             con.Open();
             //call method to set the query data.
             classBType(caseNumber);
             dt = new DataTable();
             sda.Fill(dt);
             sdf.dgvStudentProgress.DataSource = dt;
             con.Close();
         }
     }
     catch (Exception e)
     {
         errorTracking et = new errorTracking();
         et.outputErrorToText(e.Message);
     }
 }
Beispiel #3
0
 //clear the Form, DataTable and closes the connection.
 public void clearDT(StudentDataForm sdf)
 {
     try
     {
         con.Open();
         dt.Clear();
         con.Close();
     }
     catch (Exception e)
     {
         errorTracking et = new errorTracking();
         et.outputErrorToText(e.Message);
     }
 }
Beispiel #4
0
 //updates the database with any changes (selected cells can be modified)
 public void update(StudentDataForm sdf)
 {
     try
     {
         con.Open();
         scb = new SqlCommandBuilder(sda);
         sda.Update(dt);
         con.Close();
     }
     catch (Exception e)
     {
         errorTracking et = new errorTracking();
         et.outputErrorToText(e.Message);
     }
 }