Example #1
0
 private void AddNewStudent(object sender, EventArgs e)
 {
     EditStudentForm addStudent = new EditStudentForm();
     addStudent.Text = "Add New Student";
     addStudent.status = 0;
     addStudent.ShowDialog();
     //if the dialog is closed with a status of 1 the student needs to be added
     if (addStudent.status == 1)
     {
         if (dbConnention.IsConnected())
         {
             //update the class table in the database
             dbConnention.AddStudent(addStudent.PublicStudent);
             dbConnention.GetStudents();
         }
         else
         {
             MessageBox.Show("No connection exists, unable to save student data.");
         }
     }
 }
Example #2
0
        private void EditStudent(object sender, EventArgs e)
        {
            EditStudentForm editStudent = new EditStudentForm();
            editStudent.FormStatus = 1;
            editStudent.PublicStudent = (Student)studentComboBox.SelectedItem;
            editStudent.populateForm();
            //TODO load the right student into the public student of the form
            //editStudent.PublicStudent. = studentComboBox.SelectedItem
            editStudent.ShowDialog();

            //if the dialog is closed with a status of 1 the student needs to be updated
            if (editStudent.FormStatus == 1)
            {
                //check to make sure a connection exisists
                if (dbConnention.IsConnected())
                {
                    //update the class table in the database
                    dbConnention.UpdateStudent(editStudent.PublicStudent);
                    //dbConnention.GetStudents();
                    loadStudents(dbConnention);
                }
                else
                {
                    MessageBox.Show("No connection exists, unable to save student data.");
                }
            }
        }