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();
            }
        }
Esempio n. 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);
        }
 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();
         }
     }
 }
Esempio n. 4
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);
        }
        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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
        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());
            }
        }
        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();
                }
            }
        }
Esempio n. 10
0
 public void AddNullRangeProfesors_DoesNotAffectDatabase()
 {
     using (SCPPContext context = new SCPPContext())
     {
         context.Profesor.AddRange(null);
         context.SaveChanges();
     }
 }
Esempio n. 11
0
 public void AddNullInscription_DoesNotAffectDatabase()
 {
     using (SCPPContext context = new SCPPContext())
     {
         context.Expediente.Add(null);
         context.SaveChanges();
     }
 }
Esempio n. 12
0
 public void AddNullStudent_DoesNotAffectDatabase()
 {
     using (SCPPContext context = new SCPPContext())
     {
         context.Organización.Add(null);
         context.SaveChanges();
     }
 }
Esempio n. 13
0
 public void AddNullRangeGroups_DoesNotAffectDatabase()
 {
     using (SCPPContext context = new SCPPContext())
     {
         context.Grupo.AddRange(null);
         context.SaveChanges();
     }
 }
Esempio n. 14
0
 public void AddNullRangeInscriptions_DoesNotAffectDatabase()
 {
     using (SCPPContext context = new SCPPContext())
     {
         context.Inscripción.AddRange(null);
         context.SaveChanges();
     }
 }
Esempio n. 15
0
 public void AddNullGroup_DoesNotAffectDatabase()
 {
     using (SCPPContext context = new SCPPContext())
     {
         context.Selecciónproyecto.Add(null);
         context.SaveChanges();
     }
 }
Esempio n. 16
0
 public void AddNullRangeStudents_DoesNotAffectDatabase()
 {
     using (SCPPContext context = new SCPPContext())
     {
         context.Estudiante.AddRange(null);
         context.SaveChanges();
     }
 }
Esempio n. 17
0
 public void DeleteInscription()
 {
     using (SCPPContext context = new SCPPContext())
     {
         var inscriptionRemoved = context.Inscripción.FirstOrDefault(i => i.Estatus.Equals("TestExpediente"));
         context.Inscripción.Remove(inscriptionRemoved);
         context.SaveChanges();
     }
 }
Esempio n. 18
0
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            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
                            };

                            Reporte oReport = new Reporte
                            {
                                Horasreportadas = int.Parse(TextBoxHours.Text),
                                Tiporeporte     = ComboBoxKind.Text
                            };

                            context.Archivo.Add(oDocument);

                            oReport.Archivo = oDocument;

                            context.Reporte.Add(oReport);
                            context.SaveChanges();
                        }
                        CustomMessageBox.ShowOK("Reporte agregado con éxito.", "Éxito.", "Aceptar");
                        CancelButton_Click(new object(), new RoutedEventArgs());
                    }
                }
                catch (EntityException)
                {
                    Restarter.RestarSCPP();
                }
            }
        }
Esempio n. 19
0
 public void AddNewGroup_Success()
 {
     using (SCPPContext context = new SCPPContext())
     {
         expectedInDB = context.Grupo.ToList().Count();
         context.Grupo.Add(testGroup);
         context.SaveChanges();
         soloID = testGroup.GrupoID;
         var expected = context.Grupo.Find(testGroup.GrupoID);
         Assert.AreEqual(expected.GrupoID, testGroup.GrupoID);
     }
 }
Esempio n. 20
0
 public void AddNewProyect_Success()
 {
     using (SCPPContext context = new SCPPContext())
     {
         expectedInDB = context.Proyecto.ToList().Count();
         context.Proyecto.Add(testProyect);
         context.SaveChanges();
         soloID = testProyect.Clave;
         var expected = context.Proyecto.Find(testProyect.Clave);
         Assert.AreEqual(expected.Clave, testProyect.Clave);
     }
 }
Esempio n. 21
0
 public void AddNewExpediente_Success()
 {
     using (SCPPContext context = new SCPPContext())
     {
         expectedInDB = context.Expediente.ToList().Count();
         context.Expediente.Add(testExpediente);
         context.SaveChanges();
         soloID = testExpediente.ExpedienteID;
         var expected = context.Expediente.Find(testExpediente.ExpedienteID);
         Assert.AreEqual(expected.ExpedienteID, testExpediente.ExpedienteID);
     }
 }
Esempio n. 22
0
 public void AddNewProfesor_Success()
 {
     using (SCPPContext context = new SCPPContext())
     {
         expectedInDB = context.Profesor.ToList().Count();
         context.Profesor.Add(testProfesor);
         context.SaveChanges();
         soloID = testProfesor.Numtrabajador;
         var expected = context.Profesor.Find(testProfesor.Numtrabajador);
         Assert.AreEqual(expected.Numtrabajador, testProfesor.Numtrabajador);
     }
 }
Esempio n. 23
0
 public void AddNewSelection_Success()
 {
     using (SCPPContext context = new SCPPContext())
     {
         expectedInDB = context.Selecciónproyecto.ToList().Count();
         context.Selecciónproyecto.Add(testSelection);
         context.SaveChanges();
         soloID = testSelection.SelecciónproyectoID;
         var expected = context.Selecciónproyecto.Find(testSelection.SelecciónproyectoID);
         Assert.AreEqual(expected.SelecciónproyectoID, testSelection.SelecciónproyectoID);
     }
 }
Esempio n. 24
0
 public void AddNewInscription_Success()
 {
     using (SCPPContext context = new SCPPContext())
     {
         expectedInDB = context.Inscripción.ToList().Count();
         context.Inscripción.Add(testInscription);
         context.SaveChanges();
         soloID = testInscription.InscripciónID;
         var expected = context.Inscripción.Find(testInscription.InscripciónID);
         Assert.AreEqual(expected.InscripciónID, testInscription.InscripciónID);
     }
 }
Esempio n. 25
0
 public void AddNewStudent_Success()
 {
     using (SCPPContext context = new SCPPContext())
     {
         expectedInDB = context.Estudiante.ToList().Count();
         context.Estudiante.Add(testStudent);
         context.SaveChanges();
         soloID = testStudent.Matricula;
         var expected = context.Estudiante.Find(testStudent.Matricula);
         Assert.AreEqual(expected.Matricula, testStudent.Matricula);
     }
 }
Esempio n. 26
0
        private void UpdateReport()
        {
            Reporte reporte;

            using (SCPPContext context = new SCPPContext())
            {
                reporte = context.Reporte.FirstOrDefault(s => s.ReporteID == actualReporte.ReporteID);
                reporte.Calificacion     = Convert.ToDouble(ScoreTextBox.Text);
                reporte.Comentario       = TextBoxComments.Text;
                reporte.Archivo.Validado = 1;
                context.SaveChanges();
            }
        }
Esempio n. 27
0
 public void AddRangeStudents_Success()
 {
     using (SCPPContext context = new SCPPContext())
     {
         context.Estudiante.AddRange(testStudentsList);
         context.SaveChanges();
         duoID[0] = testStudentsList[0].Matricula;
         duoID[1] = testStudentsList[1].Matricula;
         var expected = context.Estudiante.Find(testStudentsList[0].Matricula);
         Assert.IsNotNull(expected);
         Assert.AreEqual(expected.Nombre, testStudentsList[0].Nombre);
     }
 }
Esempio n. 28
0
        public void RemoveRange_Success()
        {
            using (SCPPContext context = new SCPPContext())
            {
                var tmp          = duoID[0];
                var studentsList = context.Estudiante.Where(p => p.Correopersonal.Equals("*****@*****.**"));
                context.Estudiante.RemoveRange(studentsList);
                context.SaveChanges();

                var studentRemoved = context.Estudiante.Find(duoID[0]);
                Assert.IsNull(studentRemoved);
            }
        }
Esempio n. 29
0
        public void Remove_Success()
        {
            using (SCPPContext context = new SCPPContext())
            {
                var studentRetrieved = context.Estudiante.Find(soloID);
                Assert.IsNotNull(studentRetrieved);

                context.Estudiante.Remove(studentRetrieved);
                context.SaveChanges();
                var studentRemoved = context.Estudiante.Find(soloID);
                Assert.IsNull(studentRemoved);
            }
        }
Esempio n. 30
0
 public void AddRangeGroup_Success()
 {
     using (SCPPContext context = new SCPPContext())
     {
         context.Grupo.AddRange(testGroupList);
         context.SaveChanges();
         duoID[0] = testGroupList[0].GrupoID;
         duoID[1] = testGroupList[1].GrupoID;
         var expected = context.Grupo.Find(testGroupList[1].GrupoID);
         Assert.IsNotNull(expected);
         Assert.AreEqual(expected.Nrc, testGroupList[1].Nrc);
     }
 }