Ejemplo n.º 1
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            StudentInterface studentInterface = new StudentInterface();

            studentInterface.Show();
            Close();
        }
        private void submitBtn_Click(object sender, EventArgs e)
        {
            //Validates collection of textboxes on form to ensure they are not empty
            var textBoxCollection = new[] { textBoxStudentId, textBoxEmail, textBoxPhone,
                                            textBoxAddressL1, textBoxAddressL2, textBoxCity, textBoxLevel };

            bool atleastOneTextboxEmpty = textBoxCollection
                                          .Any(t => string.IsNullOrWhiteSpace(t.Text));

            //If one is empty, form will not submit
            if (atleastOneTextboxEmpty)
            {
                MessageBox.Show("No fields can be left empty.");
                DialogResult = DialogResult.None;
            }
            //Email validation
            else if (!IsValidEmail(textBoxEmail.Text))
            {
                MessageBox.Show("Email address must be valid format");
                DialogResult = DialogResult.None;
            }
            else
            {
                Student.editStudent(int.Parse(textBoxStudentId.Text),
                                    textBoxEmail.Text, textBoxPhone.Text,
                                    textBoxAddressL1.Text, textBoxAddressL2.Text,
                                    textBoxCity.Text, cBoxCounty.Text,
                                    textBoxLevel.Text);

                StudentInterface studentInterface = new StudentInterface();
                studentInterface.Show();
                Close();
            }
        }
Ejemplo n.º 3
0
        //Form buttons
        private void btnDeleteStudent_Click(object sender, EventArgs e)
        {
            Student.deleteStudent(int.Parse(textBoxStudentId.Text));
            StudentInterface studentInterface = new StudentInterface();

            studentInterface.Show();
            Close();
        }
Ejemplo n.º 4
0
 public StudentService(StudentInterface studentInterface)
 {
     _studentInterface = studentInterface;
 }