コード例 #1
0
        private void btnAddStudent_Click(object sender, EventArgs e)
        {
            string firstName    = txtAddFname.Text;
            string lastName     = txtAddSname.Text;
            string email        = txtAddEmail.Text;
            string phone        = txtAddPhone.Text;
            string addressLine1 = txtAddAddress1.Text;
            string addressLine2 = txtAddAddress2.Text;
            string city         = txtAddCity.Text;
            string county       = cboAddCounty.SelectedItem.ToString();
            string courseTitle  = cboAddCourse.SelectedItem.ToString();
            string level        = LevelChoice();

            int courseId = sd.GetCourseID(level, courseTitle);

            if (Validation() == 0)
            {
                errorProvider1.Clear();
                AddNewStudent addStu = new AddNewStudent(firstName, lastName, email, phone, addressLine1, addressLine2, city, county, courseId);
                addStu.AddStudentToDb();
                MessageBox.Show("Student added to database");
                CancelItems();

                Program.SHOW_STUDENTS.RefreshGrid();

                this.Close();
            }
        }