private void SaveBtn_Click(object sender, EventArgs e) { if (Emailtxt.Text != "") { try { var eMailValidator = new System.Net.Mail.MailAddress(Emailtxt.Text); var result = FormOperations.ValidateFields(Nametxt.Text, Surnametext.Text, GenderCmb.SelectedItem.ToString(), Celltxt.Text); if (result) { DTO.Teacher teacher = new DTO.Teacher(); teacher.Name = Nametxt.Text; teacher.Surname = Surnametext.Text; teacher.Gender = GenderCmb.SelectedItem.ToString(); teacher.Cell = Celltxt.Text; teacher.Email = Emailtxt.Text; teacher.PIN = PINTxt.Text; DataAccess.InsertTeacher(teacher); DialogResult dl = MessageBox.Show("Teacer Saved Successfully. Do You want to Proceesd with another Registration?", "Success", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dl == DialogResult.Yes) { TeacherRegtxt.Clear(); Nametxt.Clear(); Surnametext.Clear(); GenderCmb.ResetText(); Celltxt.Clear(); PINTxt.Clear(); Emailtxt.Clear(); } else { FormOperations.OpenMenu(); this.Close(); } } else { MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (FormatException ex) { MessageBox.Show("The Email entered is not a valid email address", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (Exception ee) { MessageBox.Show(ee.Message); } } else { MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void SaveBtn_Click(object sender, EventArgs e) { int studentid = int.Parse(Studenttxt.Text); if (Emailtxt.Text != "") { try { var eMailValidator = new System.Net.Mail.MailAddress(Emailtxt.Text); var result = FormOperations.ValidateFields(Nametxt.Text, Surnametxt.Text, GenderCmb.SelectedItem.ToString(), CellTxt.Text, studentid); if (result) { Gaurdian gaurdian = new Gaurdian(); gaurdian.Name = Nametxt.Text; gaurdian.Surname = Surnametxt.Text; gaurdian.Gender = GenderCmb.SelectedItem.ToString(); gaurdian.Cell = CellTxt.Text; gaurdian.Email = Emailtxt.Text; gaurdian.StudentId = studentid; DataAccess.InsertGaurdian(gaurdian); DialogResult dl = MessageBox.Show("Gaudian Saved Successfully. Do You want to Proceesd to Payment Information?", "Success", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dl == DialogResult.Yes) { FormOperations._ID = FormOperations.student.ID; FormOperations.OpenPayment(); this.Close(); } else { //FormOperations.student = null; FormOperations._ID = 0; FormOperations.OpenMenu(); this.Close(); } } else { MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (FormatException ex) { MessageBox.Show("The Email entered is not a valid email address", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (Exception ee) { MessageBox.Show(ee.Message); } } else { MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void UpdateBtn_Click(object sender, EventArgs e) { int value = 0; int semester = 0; if (CourseCmb.Text.ToString() != null & SemesterCmb.SelectedItem != null) { value = DataAccess.GetCourseID(CourseCmb.Text.ToString()); semester = int.Parse(SemesterCmb.SelectedItem.ToString()); } if (EmailTxt.Text != "") { try { var eMailValidator = new System.Net.Mail.MailAddress(EmailTxt.Text); var result = FormOperations.ValidateFields(NameTxt.Text, SurnameTxt.Text, GenderCmb.SelectedItem, CellNTxt.Text, value, semester); if (result) { Student stud = new Student { ID = int.Parse(StudentRegTxt.Text), Name = NameTxt.Text, Surname = SurnameTxt.Text, Gender = GenderCmb.SelectedItem.ToString(), Cell = CellNTxt.Text, Email = EmailTxt.Text, PostalAddress = Postaltxt.Text, Semester = semester, CourseId = value, StatusId = DataAccess.GetSatusID(Statuscmb.Text.ToString()) }; //FormOperations.student.StatusId = int.Parse(StatusCmb.SelectedValue.ToString()); DataAccess.EditStudent(stud); MessageBox.Show("Student Update Successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); //FormOperations.OpenGaurdian(); //this.Close(); Refresh(); } else { MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (FormatException ex) { MessageBox.Show("The Email entered is not a valid email address", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void SaveBtn_Click(object sender, EventArgs e) { int value = 0; int semester = 0; if (CourseCmb.SelectedValue.ToString() != null & SemesterCmb.SelectedItem != null) { value = int.Parse(CourseCmb.SelectedValue.ToString()); semester = int.Parse(SemesterCmb.SelectedItem.ToString()); } if (EmailTxt.Text != "") { try { var eMailValidator = new System.Net.Mail.MailAddress(EmailTxt.Text); var result = FormOperations.ValidateFields(NameTxt.Text, SurnameTxt.Text, GenderCmb.SelectedItem, CellNTxt.Text, value, semester); if (result) { FormOperations.student.Name = NameTxt.Text; FormOperations.student.Surname = SurnameTxt.Text; FormOperations.student.Gender = GenderCmb.SelectedItem.ToString(); FormOperations.student.Cell = CellNTxt.Text; FormOperations.student.Email = EmailTxt.Text; FormOperations.student.PostalAddress = Postaltxt.Text; FormOperations.student.Semester = semester; FormOperations.student.CourseId = value; //FormOperations.student.StatusId = int.Parse(StatusCmb.SelectedValue.ToString()); FormOperations.student.ID = DataAccess.InsertStudent(FormOperations.student); MessageBox.Show("Student Saved Successfully. Please Proceesd to Gaurdian Information", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); FormOperations.OpenGaurdian(); this.Close(); } else { MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (FormatException ex) { MessageBox.Show("The Email entered is not a valid email address", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("Please fill in all fields", "Empty Fields Detected", MessageBoxButtons.OK, MessageBoxIcon.Error); } }