Ejemplo n.º 1
0
 private void btnSearch_Click(object sender, RoutedEventArgs e)
 {
     //Teacher Id validation
     if (clsValidation.ValidateForEmptiness(TxtTeacherId.Text) == false)
     {
         MessageBox.Show("Teacher id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtTeacherId.Text) == false)
     {
         MessageBox.Show("Teacher id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtTeacherId.Text, 5) == false)
     {
         MessageBox.Show("Teacher id is not 5 digits");
     }
     else
     {
         clsTeacher ObjTeacher = new clsTeacher();
         ObjTeacher.TeacherId = int.Parse(TxtTeacherId.Text);
         bool found = ObjTeacher.SearchTeacher();
         if (found)
         {
             MessageBox.Show("Success to search this teacher");
             TxtTeacherId.Text        = ObjTeacher.TeacherId.ToString();
             TxtPassword.Password     = ObjTeacher.Password.ToString();
             TxtTeacherName.Text      = ObjTeacher.TeacherName.ToString();
             LabTeacherGender.Content = ObjTeacher.TeacherGender.ToString();
             if ("Male".Equals(ObjTeacher.TeacherGender))
             {
                 RadioMale.IsChecked = true;
             }
             else
             {
                 RadioFemale.IsChecked = true;
             }
             TxtTeacherMobile.Text  = ObjTeacher.TeacherMobile.ToString();
             TxtTeacherEmail.Text   = ObjTeacher.TeacherEmail.ToString();
             TxtTeacherAddress.Text = ObjTeacher.TeacherAddress.ToString();
             //LabTeacherDOB.Content = objTeacher.TeacherDOB.Year + "-" + objTeacher.TeacherDOB.Month + "-" + objTeacher.TeacherDOB.Day;
             LabTeacherDOB.Content     = ObjTeacher.TeacherDOB.ToString("dddd, dd MMMM yyyy");
             DatePickerTeacherDOB.Text = ObjTeacher.TeacherDOB.ToString("dd-MMMM-yyyy");
         }
         else
         {
             MessageBox.Show("This teacher id does not exist");
             TxtTeacherId.Text        = "";
             TxtPassword.Password     = "";
             TxtTeacherName.Text      = "";
             RadioMale.IsChecked      = true;
             RadioMale.IsChecked      = false;
             LabTeacherGender.Content = "";
             TxtTeacherMobile.Text    = "";
             TxtTeacherEmail.Text     = "";
             TxtTeacherAddress.Text   = "";
             LabTeacherDOB.Content    = "This teacher id does not exist";
             //DatePickerTeacherDOB.Text = objTeacher.TeacherDOB.ToString("dd-MMMM-yyyy");
         }
     }
 }
Ejemplo n.º 2
0
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     //Teacher Id validation
     if (clsValidation.ValidateForEmptiness(TxtTeacherId.Text) == false)
     {
         MessageBox.Show("Teacher id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtTeacherId.Text) == false)
     {
         MessageBox.Show("Teacher id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtTeacherId.Text, 5) == false)
     {
         MessageBox.Show("Teacher id is not 5 digits");
     }
     else
     {
         clsTeacher ObjTeacher = new clsTeacher();
         ObjTeacher.TeacherId = int.Parse(TxtTeacherId.Text);
         ObjTeacher.DeleteTeacher();
     }
 }
Ejemplo n.º 3
0
 private void btnLogin_Click(object sender, RoutedEventArgs e)
 {
     //Course Id validation
     if (clsValidation.ValidateForEmptiness(TxtUserId.Text) == false)
     {
         MessageBox.Show("User id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtUserId.Text) == false)
     {
         MessageBox.Show("User id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtUserId.Text, 5) == false)
     {
         MessageBox.Show("User id is not correct");
     }
     else if (clsValidation.ValidateForEmptiness(TxtPassWord.Password) == false)
     {
         MessageBox.Show("Password is required");
     }
     else
     {
         if (RadioTeacher.IsChecked == true)
         {
             clsTeacher Teacher = new clsTeacher();
             Teacher.TeacherId = int.Parse(TxtUserId.Text);
             Teacher.Password  = TxtPassWord.Password;
             bool FlagT = Teacher.Login();
             if (FlagT)
             {
                 var tForm = new TeacherNavigation(Teacher.TeacherId);
                 tForm.Show();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("User Id or password not correct!");
             }
         }
         else if (RadioStudent.IsChecked == true)
         {
             clsTeacher Teacher = new clsTeacher();
             Teacher.TeacherId = int.Parse(TxtUserId.Text);
             Teacher.Password  = TxtPassWord.Password;
             bool FlagS = Teacher.Login();
             if (FlagS)
             {
                 var tForm = new TeacherNavigation(Teacher.TeacherId);
                 tForm.Show();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("User Id or password not correct!");
             }
         }
         else
         {
             MessageBox.Show("Problem to login this system!");
         }
     }
 }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            //Teacher Id validation
            if (clsValidation.ValidateForEmptiness(TxtTeacherId.Text) == false)
            {
                MessageBox.Show("Teacher id is required");
            }
            else if (clsValidation.ValidateForNumeric(TxtTeacherId.Text) == false)
            {
                MessageBox.Show("Teacher id is not a number");
            }
            else if (clsValidation.ValidateForLength(TxtTeacherId.Text, 5) == false)
            {
                MessageBox.Show("Teacher id is not 5 digits");
            }
            //Teacher Name validation
            else if (clsValidation.ValidateForEmptiness(TxtTeacherName.Text) == false)
            {
                MessageBox.Show("Teacher name is required");
            }
            //Teacher Password validation
            else if (clsValidation.ValidateForEmptiness(TxtPassword.Password) == false)
            {
                MessageBox.Show("Teacher password is required");
            }
            //Teacher Mobile validation
            else if (clsValidation.ValidateForEmptiness(TxtTeacherMobile.Text) == false)
            {
                MessageBox.Show("Teacher mobile is required");
            }
            //Teacher Email validation
            else if (clsValidation.ValidateForEmptiness(TxtTeacherEmail.Text) == false)
            {
                MessageBox.Show("Teacher email is required");
            }
            //Teacher Address validation
            else if (clsValidation.ValidateForEmptiness(TxtTeacherAddress.Text) == false)
            {
                MessageBox.Show("Teacher address is required");
            }
            //Teacher DOB validation
            else if (clsValidation.ValidateForEmptiness(DatePickerTeacherDOB.Text) == false)
            {
                MessageBox.Show("Teacher DOB is required");
            }
            else
            {
                String TeacherGender = "";
                if (RadioMale.IsChecked == true)
                {
                    TeacherGender = "Male";
                }
                else
                {
                    TeacherGender = "Female";
                }

                int        Year       = DatePickerTeacherDOB.SelectedDate.Value.Year;
                int        Month      = DatePickerTeacherDOB.SelectedDate.Value.Month;
                int        Day        = DatePickerTeacherDOB.SelectedDate.Value.Day;
                DateTime   TeacherDOB = new DateTime(Year, Month, Day);
                clsTeacher ObjTeacher = new clsTeacher(int.Parse(TxtTeacherId.Text), TxtPassword.Password, TxtTeacherName.Text, TeacherGender, TxtTeacherMobile.Text, TxtTeacherEmail.Text, TxtTeacherAddress.Text, TeacherDOB);
                int        teacherid  = ObjTeacher.AddTeacher();
                if (teacherid == -1)
                {
                    MessageBox.Show("Can't add this teacher");
                }
                else
                {
                    TxtTeacherId.Text = teacherid.ToString();
                }
            }
        }