상속: MonoBehaviour
예제 #1
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();
     }
 }
예제 #2
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);
        }
예제 #3
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();
     }
 }
예제 #4
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();
     }
 }
예제 #5
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);
        }
예제 #6
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();
            }
        }
예제 #7
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();
     }
 }
예제 #8
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();
     }
 }
예제 #9
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();
            }
        }
예제 #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();
     }
 }
예제 #11
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);
        }
예제 #12
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();
         }
     }
 }
예제 #13
0
 private void AgreeButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (CheckChoosenProjects())
         {
             MessageBoxResult confirmation = CustomMessageBox.ShowYesNo("¿Seguro que desea escoger estos proyectos?", "Confirmacion", "Si", "No");
             if (confirmation == MessageBoxResult.Yes)
             {
                 CreateProjectsSelection();
                 ConfirmedChoosenProjectsMessage();
             }
             else
             {
                 return;
             }
         }
         else
         {
             CustomMessageBox.ShowOK("Debes elegir 3 proyectos", "Error", "Aceptar");
         }
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #14
0
        private void DeleteStudentButton_Click(object sender, RoutedEventArgs e)
        {
            bool unasingDone = false;

            try
            {
                MessageBoxResult confirmation = CustomMessageBox.ShowYesNo("¿Seguro que desea desasignar al alumno con nombre: "
                                                                           + studentSelected.Nombre
                                                                           + " del grupo?", "Confirmación", "Si", "No");

                if (confirmation == MessageBoxResult.Yes)
                {
                    UnasingStudent();
                    unasingDone = true;
                }
                else
                {
                    return;
                }

                if (unasingDone)
                {
                    MessageBoxResult result = CustomMessageBox.ShowOK("El estudiante se ha quitado del grupo.", "Alumno desasignado", "Finalizar");
                    ReturnToPreviousList(new object(), new RoutedEventArgs());
                }
            }
            catch (EntityException)
            {
                Restarter.RestarSCPP();
            }
        }
예제 #15
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();
                }
            }
        }
예제 #16
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            Restarter.CheckRestart(e.Args);

            Restarter.Start(Settings.Port - 1);
            new NeoPlayerWindow().Show();
        }
예제 #17
0
 private void Awake()
 {
     if (me != null)
     {
         Destroy(gameObject);
     }
     me = this;
     DontDestroyOnLoad(gameObject);
 }
예제 #18
0
        public static IEnumerable <string> GenerateCommandLineExecution(IAbsoluteFilePath location, string executable,
                                                                        params string[] desiredParams)
        {
            var updateExe = GetUpdateExe(location);

            return(updateExe != null && updateExe.Exists
                ? new[] { updateExe.ToString() }.Concat(Restarter.BuildUpdateExeArguments(executable, desiredParams))
                : new[] { location.ToString() }.Concat(desiredParams));
        }
예제 #19
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();
                }
            }
        }
        private void RegisterButton_Clicked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (VerificateFields())
                {
                    OrganizationUserApi organizationtUserApi = new OrganizationUserApi();
                    OrganizationUser    organizationUser     = new OrganizationUser(name: NameTextBox.Text, contactEmail: AgentEmailTextBox.Text);
                    User  generalUser = new User(email: EmailTextBox.Text);
                    Media perfilImage = new Media();

                    generalUser.City     = CityTextBox.Text;
                    generalUser.Country  = CountryTextBox.Text;
                    generalUser.Password = Encrypt.GetSHA256(PasswordTextBox.Password);

                    if (myStream != null)
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            myStream.CopyTo(ms);
                            byte[] imageFile = ms.ToArray();
                            perfilImage.File         = imageFile;
                            generalUser.ProfilePhoto = perfilImage;
                        }
                    }

                    organizationUser.About        = DescripctionTextBox.Text;
                    organizationUser.ContactPhone = PhoneTextBox.Text;
                    organizationUser.ContactName  = AgentTextBox.Text;
                    organizationUser.ZipCode      = Convert.ToInt32(PostalCodeTextBox.Text);
                    organizationUser.WebSite      = WebSiteTextBox.Text;
                    organizationUser.WorkSector   = (Sector)SectorComboBox.SelectedItem;
                    organizationUser.User         = generalUser;

                    var response = organizationtUserApi.RegisterOrganizationUserWithHttpInfo(organizationUser);
                    CustomMessageBox.ShowOK("El usuario ha sido registrado con éxito.", "Registro exitoso", "Aceptar");

                    var mainWindow = (MainWindow)Application.Current.MainWindow;
                    mainWindow?.ChangeView(new ValidateUser(organizationUser.User.Email, organizationUser.Name));
                    return;
                }
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 401)
                {
                    CustomMessageBox.ShowOK("Ya existe un usuario con el correo " + EmailTextBox.Text, "Usuario existente", "Aceptar");
                }
                if (ex.ErrorCode == 500)
                {
                    CustomMessageBox.ShowOK("Ocurrió un error en la conexión con la base de datos. Por favor intentelo más tarde", "Error de conexión", "Aceptar");
                    Restarter.RestarEmployex();
                }
            }
        }
예제 #21
0
        private void invokeUpdate()
        {
            Directory.CreateDirectory("temp");
            ConfigXML.writeLocal <UpdateXML>(update, "temp\\update.xml");
            foreach (string newPath in Directory.GetFiles("libs", "*.*"))
            {
                File.Copy(newPath, newPath.Replace("libs", "temp"), true);
            }

            Restarter.restart("update");
        }
예제 #22
0
 private void TextBoxSearch_KeyUp(object sender, KeyEventArgs e)
 {
     try
     {
         string searchText = TextBoxSearch.Text;
         SpecificSearch(searchText);
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #23
0
 private void TextBoxSearch_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
 {
     try
     {
         string searchText = TextBoxSearch.Text;
         Search(searchText);
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #24
0
        private void RegistButton_Clicked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (VerificateFields())
                {
                    IndependientUserApi independientUserApi = new IndependientUserApi();
                    IndependientUser    independientUser    = new IndependientUser(name: NameTextBox.Text);
                    User  generalUser = new User(email: EmailTextBox.Text);
                    Media perfilImage = new Media();

                    generalUser.City     = CityTextBox.Text;
                    generalUser.Country  = CountryTextBox.Text;
                    generalUser.Password = Encrypt.GetSHA256(PasswordTextBox.Password);

                    if (myStream != null)
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            myStream.CopyTo(ms);
                            byte[] imageFile = ms.ToArray();
                            perfilImage.File         = imageFile;
                            generalUser.ProfilePhoto = perfilImage;
                        }
                    }

                    independientUser.Surnames            = LastNameTextBox.Text;
                    independientUser.Ocupation           = OcupationTextBox.Text;
                    independientUser.PersoanlDescription = GeneralDescripctionTextBox.Text;
                    independientUser.User = generalUser;

                    var response = independientUserApi.RegisterIndpendientUserWithHttpInfo(independientUser);
                    CustomMessageBox.ShowOK("El usuario ha sido registrado con éxito.", "Registro exitoso", "Aceptar");

                    string fullName   = independientUser.Name + " " + independientUser.Surnames;
                    var    mainWindow = (MainWindow)Application.Current.MainWindow;
                    mainWindow?.ChangeView(new ValidateUser(independientUser.User.Email, fullName));
                    return;
                }
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 401)
                {
                    CustomMessageBox.ShowOK("Ya existe un usuario con el correo " + EmailTextBox.Text, "Usuario existente", "Aceptar");
                }
                if (ex.ErrorCode == 500)
                {
                    CustomMessageBox.ShowOK("Ocurrió un error en la conexión con la base de datos. Por favor intentelo más tarde", "Error de conexión", "Aceptar");
                    Restarter.RestarEmployex();
                }
            }
        }
예제 #25
0
 private void NavigationService_Navigated(object sender, NavigationEventArgs e)
 {
     try
     {
         pageIsLoad = false;
         GetDocuments();
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #26
0
 public ValidarInscripcion()
 {
     try
     {
         InitializeComponent();
         AddInformationToLabels();
         GetStudents();
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #27
0
 public GenerarOficioAsignacion()
 {
     try
     {
         InitializeComponent();
         GetSesion();
         GetStudents();
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #28
0
 public RegistrarProyecto()
 {
     try
     {
         InitializeComponent();
         ComboBoxCapacidad.ItemsSource = numOfStudents;
         FillComboBoxOrganizations();
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #29
0
 public EscogerProyecto()
 {
     try
     {
         InitializeComponent();
         GetSesion();
         GetProyects();
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }
예제 #30
0
 public DesasignarProfesorGrupo()
 {
     try
     {
         InitializeComponent();
         GetProfesors();
         _period = Period.GetPeriod();
     }
     catch (EntityException)
     {
         Restarter.RestarSCPP();
     }
 }