예제 #1
0
 private void ReportValidationCheckbox_Checked(object sender, RoutedEventArgs e)
 {
     if (pageIsLoad && userSesion.Kind != "Student")
     {
         reportSelected = ((FrameworkElement)sender).DataContext as Reporte;
         try
         {
             if (reportSelected != null)
             {
                 using (SCPPContext context = new SCPPContext())
                 {
                     var fileInDB = context.Archivo.Find(reportSelected.ArchivoID);
                     if (fileInDB.Validado == 1)
                     {
                         fileInDB.Validado = 0;
                     }
                     else
                     {
                         fileInDB.Validado = 1;
                     }
                     context.SaveChanges();
                 }
             }
         }
         catch (EntityException)
         {
             Restarter.RestarSCPP();
         }
     }
 }
예제 #2
0
        private object UpdateProfesor()
        {
            Profesor profesor;

            using (SCPPContext context = new SCPPContext())
            {
                profesor = context.Profesor.FirstOrDefault(s => s.Numtrabajador == actualProfesor.Numtrabajador);

                profesor.Nombre          = TextBoxName.Text;
                profesor.Apellidopaterno = TextBoxApellidoPaterno.Text;
                profesor.Apellidomaterno = TextBoxApellidoMaterno.Text;
                profesor.Telefono        = TextBoxPhone.Text;
                profesor.Correopersonal  = TextBoxEmail.Text;
                if (ComboBoxState.Text.Equals("Activo"))
                {
                    profesor.Activo = 1;
                }
                else
                {
                    profesor.Activo = 0;
                }


                context.SaveChanges();
            }
            actualProfesor = profesor;
            return(profesor);
        }
예제 #3
0
 private void RegisterButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (SCPPContext context = new SCPPContext())
         {
             var proyecto = context.Proyecto.FirstOrDefault(s => s.Nombre == TextBoxNombre.Text);
             if (proyecto == null)
             {
                 var proyectRegistered         = RegisterNewProyect();
                 MessageBoxResult confirmation = CustomMessageBox.ShowYesNo("El registro se ha realizado con éxito", "Registro exitoso", "Gestionar proyecto", "Finalizar");
                 if (confirmation == MessageBoxResult.Yes)
                 {
                     var mainWindow = (MainWindow)Application.Current.MainWindow;
                     mainWindow?.ChangeView(new GestionarProyecto(proyecto));
                 }
                 else
                 {
                     CancelButton_Click(new object(), new RoutedEventArgs());
                 }
             }
             else
             {
                 CustomMessageBox.ShowOK("Ya existe un proyecto registrado con el nombre ingresado con clave: " + proyecto.Clave, "Proyecto ya registrado", "Aceptar");
             }
         }
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #4
0
 private void GetStudentActualExpediente()
 {
     using (SCPPContext context = new SCPPContext())
     {
         expediente = context.Expediente.FirstOrDefault(i => i.InscripciónID == inscription.InscripciónID);
     }
 }
예제 #5
0
        private void GetGroups()
        {
            try
            {
                using (SCPPContext context = new SCPPContext())
                {
                    var profesor = context.Profesor.FirstOrDefault(c => c.Numtrabajador.Equals(_user));

                    if (profesor != null)
                    {
                        isCoordinator = false;
                    }
                    else
                    {
                        isCoordinator = true;
                    }
                    groupsCollection = GetList(isCoordinator, profesor);
                }

                GroupList.ItemsSource = groupsCollection;
                DataContext           = groupsCollection;
            }
            catch (Exception)
            {
                Restarter.RestarSCPP();
            }
        }
예제 #6
0
        private void SpecificSearch(string searchText)
        {
            organizationCollection.Clear();
            using (SCPPContext context = new SCPPContext())
            {
                var organizationBySearch = context.Organización.Where(
                    o => o.Nombre.Contains(searchText) ||
                    o.Correo.Contains(searchText) ||
                    o.Telefono.Contains(searchText) ||
                    o.Sector.Contains(searchText) ||
                    o.Calle.Contains(searchText));

                if (organizationBySearch != null)
                {
                    foreach (Organización organization in organizationBySearch)
                    {
                        if (organization != null)
                        {
                            organizationCollection.Add(organization);
                        }
                    }
                }
                SetFilter();
            }
        }
예제 #7
0
 private void RegisterButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (VerificateFields())
         {
             using (SCPPContext context = new SCPPContext())
             {
                 var student = context.Estudiante.Find(TextBoxMatricula.Text);
                 if (student == null)
                 {
                     var studentRegistered = RegisterNewStudent();
                     SendEmail();
                     StudentRegisteredMessage(studentRegistered);
                 }
                 else
                 {
                     CustomMessageBox.ShowOK("Ya existe un estudiante registrado con la matrícula ingresada con nombre: " + student.Nombre, "Estudiante ya registrado", "Aceptar");
                 }
             }
         }
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #8
0
        private void ChangeStudentStatus()
        {
            ObservableCollection <Estudiante> studentList = new ObservableCollection <Estudiante>();

            try
            {
                using (SCPPContext context = new SCPPContext())
                {
                    foreach (var student in selectedStudents)
                    {
                        var foundStudent = context.Estudiante.Where(s => s.Matricula.Equals(student.Matricula)).
                                           FirstOrDefault();

                        if (foundStudent != null)
                        {
                            foundStudent.Estado = "Inscrito";
                            context.SaveChanges();
                        }

                        studentList.Add(student);
                    }
                }

                foreach (var student in studentList)
                {
                    studentsCollection.Remove(student);
                }

                ConfirmedRegistrationMessage();
            }
            catch (EntityException)
            {
                Restarter.RestarSCPP();
            }
        }
예제 #9
0
 private void GetStudentActualInscription()
 {
     using (SCPPContext context = new SCPPContext())
     {
         inscription = context.Inscripción.FirstOrDefault(i => i.Matriculaestudiante == student.Matricula && i.Estatus.Equals("Cursando"));
     }
 }
예제 #10
0
 private void RegisterButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (VerificateFields())
         {
             using (SCPPContext context = new SCPPContext())
             {
                 var organization = context.Organización.FirstOrDefault(s => s.Nombre == NameTextBox.Text);
                 if (organization == null)
                 {
                     Organización organizationRegistered = (Organización)RegisterNewOrganization();
                     OrganizationRegisteredMessage(organizationRegistered);
                 }
                 else
                 {
                     CustomMessageBox.ShowOK("Organización ya registrada", "Registro repetido", "Aceptar");
                 }
             }
         }
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
        private bool VerificateGroupCapacity()
        {
            var  selectedGroup = (Grupo)GroupComboBox.SelectedItem;
            bool isAvailable;

            using (SCPPContext context = new SCPPContext())
            {
                var studentsAlreadyInTheGroup = context.Estudiante.Join(
                    context.Inscripción,
                    e => e.Matricula,
                    i => i.Matriculaestudiante,
                    (e, i) => new { e, i })
                                                .Where(x => x.i.GrupoID == selectedGroup.GrupoID);

                int totalStudents = studentsAlreadyInTheGroup.Count() + selectedStudents.Count();
                if (totalStudents <= selectedGroup.Cupo)
                {
                    isAvailable = true;
                }
                else
                {
                    isAvailable = false;
                }
            }
            return(isAvailable);
        }
예제 #12
0
 private void ComboBoxOrganization_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         var organization = (Organización)ComboBoxOrganization.SelectedItem;
         responsablesCollection = new ObservableCollection <Responsableproyecto>();
         using (SCPPContext context = new SCPPContext())
         {
             var responsablesList = context.Responsableproyecto.Where(r => r.OrganizaciónID == organization.OrganizaciónID);
             if (responsablesList != null)
             {
                 foreach (Responsableproyecto responsableProyecto in responsablesList)
                 {
                     if (responsableProyecto != null)
                     {
                         responsablesCollection.Add(responsableProyecto);
                     }
                 }
             }
         }
         ComboBoxResponsable.ItemsSource = responsablesCollection;
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #13
0
        private void SpecificSearch(string searchText)
        {
            profesorsCollection.Clear();
            using (SCPPContext context = new SCPPContext())
            {
                var profesorsBySearch = context.Profesor.Where(
                    s => s.Numtrabajador.Contains(searchText) ||
                    s.Nombre.Contains(searchText) ||
                    s.Apellidomaterno.Contains(searchText) ||
                    s.Apellidopaterno.Contains(searchText) ||
                    s.Correopersonal.Contains(searchText));

                if (profesorsBySearch != null)
                {
                    foreach (Profesor profesor in profesorsBySearch)
                    {
                        if (profesor != null)
                        {
                            profesorsCollection.Add(profesor);
                        }
                    }
                }
                SetFilter();
            }
        }
예제 #14
0
 private void GetStudents()
 {
     studentsCollection = new ObservableCollection <Estudiante>();
     using (SCPPContext context = new SCPPContext())
     {
         var students = context.Estudiante.Join(
             context.Inscripción,
             e => e.Matricula,
             i => i.Matriculaestudiante,
             (e, i) => new { e, i })
                        .Where(x => x.i.Claveproyecto == actualProject.Clave)
                        .Select(x => x.e);
         if (students != null)
         {
             foreach (Estudiante estudiante in students)
             {
                 if (estudiante != null)
                 {
                     studentsCollection.Add(estudiante);
                 }
             }
         }
     }
     StudentsList.ItemsSource = studentsCollection;
     DataContext = studentsCollection;
 }
예제 #15
0
        private object UpdateProject()
        {
            Proyecto project;

            using (SCPPContext context = new SCPPContext())
            {
                var organization = (Organización)ComboBoxOrganization.SelectedItem;
                Responsableproyecto responsable;
                if (ComboBoxResponsable.SelectedItem == null)
                {
                    responsable = actualResponsableProyecto;
                }
                else
                {
                    responsable = (Responsableproyecto)ComboBoxResponsable.SelectedItem;
                }

                project = context.Proyecto.FirstOrDefault(p => p.Clave == actualProject.Clave);

                project.Actividades           = TextBoxActividades.Text;
                project.Descripcion           = TextBoxDescription.Text;
                project.Noestudiantes         = Int32.Parse(ComboBoxCapacidad.Text);
                project.Nombre                = TextBoxName.Text;
                project.OrganizaciónID        = organization.OrganizaciónID;
                project.ResponsableproyectoID = responsable.ResponsableproyectoID;

                context.SaveChanges();
            }
            actualProject = project;
            return(project);
        }
예제 #16
0
        private void Search(string searchText)
        {
            studentsCollection.Clear();
            using (SCPPContext context = new SCPPContext())
            {
                var studentsBySearch = context.Estudiante.Where(
                    s => s.Matricula.Contains(searchText) ||
                    s.Nombre.Contains(searchText) ||
                    s.Apellidomaterno.Contains(searchText) ||
                    s.Apellidopaterno.Contains(searchText) ||
                    s.Correopersonal.Contains(searchText) ||
                    s.Telefono.Contains(searchText));

                if (studentsBySearch != null)
                {
                    foreach (Estudiante student in studentsBySearch)
                    {
                        if (student != null)
                        {
                            studentsCollection.Add(student);
                        }
                    }
                }
            }
        }
예제 #17
0
        private void GetStudents()
        {
            studentsCollection = new ObservableCollection <Estudiante>();
            IQueryable <Estudiante> studentsInDB = null;

            using (SCPPContext context = new SCPPContext())
            {
                studentsInDB = context.Estudiante.Join(
                    context.Inscripción,
                    s => s.Matricula,
                    i => i.Matriculaestudiante,
                    (s, i) => new { student = s, inscription = i })
                               .Where(j => j.inscription.Periodo.Equals(period) && j.student.Estado.Equals("Inscrito"))
                               .Select(j => j.student);

                if (studentsInDB != null)
                {
                    foreach (Estudiante student in studentsInDB)
                    {
                        if (student != null)
                        {
                            studentsCollection.Add(student);
                        }
                    }
                }
            }
            StudentList.ItemsSource = studentsCollection;
            DataContext             = studentsCollection;
        }
예제 #18
0
        private Estudiante RegisterNewStudent()
        {
            var student = new Estudiante
            {
                Matricula       = TextBoxEnrrollment.Text,
                Nombre          = TextBoxName.Text,
                Apellidopaterno = TextBoxLastName.Text,
                Apellidomaterno = TextBoxMothersLastName.Text,
                Telefono        = TextBoxPhone.Text,
                Correopersonal  = TextBoxEMail.Text,
                Promedio        = Convert.ToDouble(TextBoxAverage.Text),
                Estado          = "Preinscrito",
                Genero          = ComboBoxGender.Text,
                Activo          = 1,
                Contraseña      = Encrypt.GetSHA256(TextBoxPassword.Password)
            };

            try
            {
                using (SCPPContext context = new SCPPContext())
                {
                    context.Estudiante.Add(student);
                    context.SaveChanges();
                }
            }
            catch (EntityException)
            {
                Restarter.RestarSCPP();
            }

            return(student);
        }
예제 #19
0
        private void CoordinatorSearch(string searchText)
        {
            groupsCollection.Clear();
            using (SCPPContext context = new SCPPContext())
            {
                var groupsBySearch = context.Grupo.Where(s => (s.Nrc.ToString().Contains(searchText) ||
                                                               s.Cupo.ToString().Contains(searchText) ||
                                                               s.Bloque.Contains(searchText) ||
                                                               s.Seccion.Contains(searchText) ||
                                                               s.Periodo.Contains(searchText))
                                                         );

                if (groupsBySearch != null)
                {
                    foreach (Grupo group in groupsBySearch)
                    {
                        if (group != null)
                        {
                            groupsCollection.Add(group);
                        }
                    }
                }
            }
            SetFilter();
        }
예제 #20
0
 private void RegisterButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (SCPPContext context = new SCPPContext())
         {
             var foundResposable = context.Responsableproyecto.Where(s => s.Correopersonal.Equals(TextBoxEMail.Text)).FirstOrDefault();
             if (foundResposable == null)
             {
                 if (VerificateFields())
                 {
                     var resposableRegistered = RegisterNewResposable();
                     ResposableRegisteredMessage(resposableRegistered);
                 }
             }
             else
             {
                 CustomMessageBox.ShowOK("Ya existe un resposable registrado con el correo ingresado: " +
                                         foundResposable.Nombre, "Resposable ya registrado", "Aceptar");
             }
         }
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #21
0
        private void GetInscriptions()
        {
            inscriptionsCollection = new ObservableCollection <Inscripción>();
            using (SCPPContext context = new SCPPContext())
            {
                var inscriptionsList = context.Inscripción.Where(i => i.Matriculaestudiante == actualStudent.Matricula)
                                       .Include(i => i.Proyecto)
                                       .Include(i => i.Proyecto.Organización)
                                       .Include(i => i.Expediente)
                                       .Include(i => i.Grupo);
                if (inscriptionsList != null)
                {
                    foreach (Inscripción inscription in inscriptionsList)
                    {
                        if (inscription != null)
                        {
                            inscriptionsCollection.Add(inscription);
                        }
                    }
                }
            }

            if (userSesion.Kind == "Coordinator")
            {
                DeleteStudentButton.Visibility = Visibility.Visible;
            }

            ProyectColumn.Binding      = new Binding("Proyecto.Nombre");
            OrganizationColumn.Binding = new Binding("Proyecto.Organización.Nombre");

            InscriptionList.ItemsSource = inscriptionsCollection;
            DataContext = inscriptionsCollection;
        }
예제 #22
0
        private Responsableproyecto RegisterNewResposable()
        {
            var organization = (Organización)ComboBoxOrganizacion.SelectedItem;

            Responsableproyecto responsable = new Responsableproyecto
            {
                Nombre          = TextBoxName.Text,
                Apellidopaterno = TextBoxLastName.Text,
                Apellidomaterno = TextBoxMothersLastName.Text,
                Correopersonal  = TextBoxEMail.Text,
                Telefono        = TextBoxPhone.Text,
                Activo          = 1,
                OrganizaciónID  = organization.OrganizaciónID
            };

            try
            {
                using (SCPPContext context = new SCPPContext())
                {
                    context.Responsableproyecto.Add(responsable);
                    context.SaveChanges();
                }
            }
            catch (EntityException)
            {
                Restarter.RestarSCPP();
            }

            return(responsable);
        }
 private void GetStudents()
 {
     studentsCollection = new ObservableCollection <Estudiante>();
     using (SCPPContext context = new SCPPContext())
     {
         var studentsWithoutGroupList = context.Estudiante.Join(
             context.Inscripción,
             e => e.Matricula,
             i => i.Matriculaestudiante,
             (e, i) => new { e, i })
                                        .Where(x => x.i.GrupoID == null)
                                        .Select(x => x.e);
         if (studentsWithoutGroupList != null)
         {
             foreach (Estudiante estudiante in studentsWithoutGroupList)
             {
                 if (estudiante != null)
                 {
                     studentsCollection.Add(estudiante);
                 }
             }
         }
     }
     StudentList.ItemsSource = studentsCollection;
     DataContext             = studentsCollection;
 }
예제 #24
0
        private int countStudentsByGender(string sector, string gender)
        {
            int totalStudents = 0;

            using (SCPPContext context = new SCPPContext())
            {
                var studentsList = context.Estudiante.Join(
                    context.Inscripción,
                    s => s.Matricula,
                    i => i.Matriculaestudiante,
                    (s, i) => new { student = s, inscription = i })
                                   .Join(
                    context.Proyecto,
                    j => j.inscription.Claveproyecto,
                    p => p.Clave,
                    (j, p) => new { join = j, project = p })
                                   .Join(
                    context.Organización,
                    j2 => j2.project.OrganizaciónID,
                    o => o.OrganizaciónID,
                    (j2, o) => new { join2 = j2, organization = o })
                                   .Where(q => q.organization.Sector.Equals(sector))
                                   .Where(q => q.join2.join.student.Genero.Equals(gender))
                                   .Select(q => q.join2.join.student);

                totalStudents = studentsList.Count();
            }
            return(totalStudents);
        }
        private void ChangeStudentsGroups()
        {
            ObservableCollection <Estudiante> studentList = new ObservableCollection <Estudiante>();

            try
            {
                using (SCPPContext context = new SCPPContext())
                {
                    foreach (var student in selectedStudents)
                    {
                        var foundInscription = context.Inscripción.Where(i => i.Matriculaestudiante.Equals(student.Matricula)).FirstOrDefault();
                        if (foundInscription != null)
                        {
                            foundInscription.GrupoID = _groupID;
                            context.SaveChanges();
                        }
                        studentList.Add(student);
                    }
                }

                foreach (var student in studentList)
                {
                    studentsCollection.Remove(student);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #26
0
 private void RegisterButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (SCPPContext context = new SCPPContext())
         {
             var foundProfessor = context.Profesor.Find(TextBoxWorkerNumber.Text);
             if (foundProfessor == null)
             {
                 if (VerificateFields())
                 {
                     var professorRegistered = RegisterNewProfessor();
                     SendEmail();
                     ProfessorRegisteredMessage(professorRegistered);
                 }
             }
             else
             {
                 CustomMessageBox.ShowOK("Ya existe un profesor registrado con la matrícula ingresada con nombre: " +
                                         foundProfessor.Nombre, "Profesor ya registrado", "Aceptar");
             }
         }
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #27
0
        private void GetStudents()
        {
            studentsCollection = new ObservableCollection <Estudiante>();
            using (SCPPContext context = new SCPPContext())
            {
                var studentsListWithLessThan2Periods = context.Estudiante.Where(s => s.Inscripción.Count < 2);
                studentsListWithLessThan2Periods = studentsListWithLessThan2Periods.Where(s => s.Estado == "Inscrito");

                var studentsListAlreadyAttending =
                    context.Estudiante.Join(
                        context.Inscripción,
                        s => s.Matricula,
                        i => i.Matriculaestudiante,
                        (s, i) => new { student = s, inscription = i })
                    .Where(s2 => s2.inscription.Periodo == periodo)
                    .Select(s2 => s2.student);

                var studentsList = studentsListWithLessThan2Periods.Except(studentsListAlreadyAttending);

                if (studentsList != null)
                {
                    foreach (Estudiante student in studentsList)
                    {
                        if (student != null)
                        {
                            studentsCollection.Add(student);
                        }
                    }
                }
            }
            StudentsList.ItemsSource = studentsCollection;
            DataContext = studentsCollection;
        }
예제 #28
0
        private Profesor RegisterNewProfessor()
        {
            Profesor professor = new Profesor
            {
                Nombre          = TextBoxName.Text,
                Apellidopaterno = TextBoxLastName.Text,
                Apellidomaterno = TextBoxMothersLastName.Text,
                Numtrabajador   = TextBoxWorkerNumber.Text,
                Correopersonal  = TextBoxEMail.Text,
                Telefono        = TextBoxPhone.Text,
                Contraseña      = Encrypt.GetSHA256(TextBoxPassword.Password),
                Activo          = 1
            };

            try
            {
                using (SCPPContext context = new SCPPContext())
                {
                    context.Profesor.Add(professor);
                    context.SaveChanges();
                }
            }
            catch (EntityException)
            {
                Restarter.RestarSCPP();
            }

            return(professor);
        }
예제 #29
0
        private void GetOrganization()
        {
            using (SCPPContext context = new SCPPContext())
            {
                //recupera el id del responsable
                var resposable = context.Responsableproyecto.FirstOrDefault(a => a.Correopersonal.Equals(actualResposable.Correopersonal));

                var proyectsList = context.Proyecto.Where(p => p.ResponsableproyectoID == resposable.ResponsableproyectoID);

                if (proyectsList != null)
                {
                    foreach (var proyects in proyectsList)
                    {
                        if (proyects != null)
                        {
                            proyectsCollection.Add(proyects);
                        }
                    }
                }

                ProyectsList.ItemsSource = proyectsCollection;
                DataContext = ProyectsList;

                if (proyectsCollection.Count == 0)
                {
                    Label.Content = "El resposable aun no cuenta con proyectos";
                }
            }
        }
예제 #30
0
        private void UploadFileButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter           = "Report files | *.pdf; *.doc; *.docs; *.docx",
                FilterIndex      = 1,
                InitialDirectory = new KnownFolder(KnownFolderType.Documents).Path,
                RestoreDirectory = true
            };

            dialog.ShowDialog();
            string filePath = dialog.FileName;

            Console.WriteLine(filePath);
            Stream myStream = null;

            try
            {
                myStream = dialog.OpenFile();
            }
            catch (InvalidOperationException)
            {
                // Por si cancela el dialogo
            }

            if (myStream != null)
            {
                try
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        myStream.CopyTo(ms);
                        byte[] file = ms.ToArray();

                        using (SCPPContext context = new SCPPContext())
                        {
                            Archivo oDocument = new Archivo
                            {
                                ExpedienteID = inscription.Expediente.First().ExpedienteID,
                                Archivo1     = file,
                                Fechaentrega = DateTime.Today,
                                Titulo       = dialog.SafeFileName,
                                Validado     = 0
                            };

                            context.Archivo.Add(oDocument);
                            context.SaveChanges();

                            filesCollection.Add(oDocument);
                        }
                        CustomMessageBox.ShowOK("Archivo agregado con éxito.", "Éxito.", "Aceptar");
                    }
                }
                catch (EntityException)
                {
                    Restarter.RestarSCPP();
                }
            }
        }