Пример #1
0
 private void ConsultTeacherButtonClicked(object sender, RoutedEventArgs routedEventArgs)
 {
     ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
     UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);
     try
     {
         IEnumerable<Teacher> thereAreTeachers = unitOfWork.Teachers.GetAll();
         if (IENumerableHasTeachers(thereAreTeachers))
         {
             TeacherConsultation teacherConsultation = new TeacherConsultation();
             teacherConsultation.Show();
             Close();
         }
         else
         {
             MessageBox.Show("No hay profesores registrados. Por favor registre uno");
         }
     }
     catch (SqlException)
     {
         MessageBox.Show("No hay conexión a la base de datos. Intente más tarde");
     }
     catch (EntityException)
     {
         MessageBox.Show("No hay conexión a la base de datos. Intente más tarde");
     }
     finally
     {
         unitOfWork.Dispose();
     }
     
 }
Пример #2
0
        private void DeleteButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("¿Seguro desea eliminar el profesor?", "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                try
                {
                    ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
                    UnitOfWork unitOfWork    = new UnitOfWork(professionalPracticesContext);
                    Teacher    deleteTeacher = unitOfWork.Teachers.Get(teacher.StaffNumber);
                    deleteTeacher.User.UserStatus = UserStatus.INACTIVE;
                    int rowsAffected = unitOfWork.Complete();
                    unitOfWork.Dispose();
                    if (rowsAffected == 1)
                    {
                        MessageBox.Show("El Profesor se eliminó exitosamente", "Elimiación Exitosa", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("El Profesor no pudo eliminarse", "Eliminación Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                catch (EntityException)
                {
                    MessageBox.Show("El Profesor no pudo eliminarse", "Eliminación Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                TeacherConsultation teacherConsultation = new TeacherConsultation();
                teacherConsultation.Show();
                Close();
            }
        }
Пример #3
0
        private void BehindButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            TeacherConsultation teacherConsultation = new TeacherConsultation();

            teacherConsultation.Show();
            Close();
        }
Пример #4
0
 private void ModifyButtonClicked(object sender, RoutedEventArgs routedEventArgs)
 {
     CreateTeacherFromInputData();
     Console.WriteLine(ValidateData());
     if (ValidateData())
     {
         try
         {
             bool teacherrWithSameData = _unitOfWork.Teachers.TeacherIsAlreadyRegistered(_teacher, true);
             if (teacherrWithSameData)
             {
                 MessageBox.Show("El correo, correo alternativo o número de teléfono ingresado ya está ocupado por otro usuario");
             }
             else
             {
                 bool userConfirmedAction = AskForConfirmation();
                 if (userConfirmedAction)
                 {
                     _unitOfWork.Complete();
                     _unitOfWork.Dispose();
                     MessageBox.Show("Profesor modificado exitosamente.");
                     TeacherConsultation teacherConsult = new TeacherConsultation();
                     teacherConsult.Show();
                     Close();
                 }
             }
         }
         catch (SqlException)
         {
             ShowException();
         }
     }
 }
Пример #5
0
        private void CancelButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("¿Seguro desea cancelar?", "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                TeacherConsultation teacherConsultation = new TeacherConsultation();
                teacherConsultation.Show();
                Close();
            }
        }