Example #1
0
        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 Refresh()
        {
            StudentRegTxt.Clear();
            NameTxt.Clear();
            SurnameTxt.Clear();
            GenderCmb.ResetText();
            CellNTxt.Clear();
            EmailTxt.Clear();
            Postaltxt.ResetText();
            CourseCmb.ResetText();
            Statuscmb.ResetText();
            SemesterCmb.ResetText();
            dataGridView1.DataSource = DataAccess.GetStudents();

            dataGridView1.Columns["ID"].DisplayIndex            = 0;
            dataGridView1.Columns["Name"].DisplayIndex          = 1;
            dataGridView1.Columns["Surname"].DisplayIndex       = 2;
            dataGridView1.Columns["Gender"].DisplayIndex        = 3;
            dataGridView1.Columns["Cell"].DisplayIndex          = 4;
            dataGridView1.Columns["Email"].DisplayIndex         = 5;
            dataGridView1.Columns["PostalAddress"].DisplayIndex = 6;
            dataGridView1.Columns["CourseId"].DisplayIndex      = 7;
            dataGridView1.Columns["Semester"].DisplayIndex      = 8;
            dataGridView1.Columns["StatusId"].DisplayIndex      = 9;
        }
Example #3
0
 private void Refresh()
 {
     TeacherRegtxt.Clear();
     Nametxt.Clear();
     Surnametext.Clear();
     GenderCmb.ResetText();
     Celltxt.Clear();
     PINTxt.Clear();
     Emailtxt.Clear();
     Statuscmb.ResetText();
     dataGridView1.DataSource = DataAccess.GetTeachers();
 }