private void btnAddStudent_Click(object sender, RoutedEventArgs e) { try { AddStudentWindow addStudentWindow = new AddStudentWindow(); if (addStudentWindow.ShowDialog() == true) { Student student = new Student() { Username = addStudentWindow.Username, FirstName = addStudentWindow.FirstName, MiddleName = addStudentWindow.MiddleName, LastName = addStudentWindow.LastName, EGN = addStudentWindow.EGN, ClassId = addStudentWindow.ClassId }; string secret = Crypto.GenerateRandomSecret(); student.Username = Crypto.EncryptStringAES(student.Username, secret); string password = Crypto.EncryptStringAES(addStudentWindow.Password, secret); if (client.RegisterStudent(student, password, secret)) { UpdateStudentViews(); MessageBox.Show("Ученикът беше добавен успешно"); } else { MessageBox.Show("Ученикът не е валиден или вече съществува"); } } } catch (Exception ex) { MessageBox.Show(Application.Current.Resources["defaultErrorMessage"].ToString(), "Грешка", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnAddStudent_Click(object sender, RoutedEventArgs e) { try { AddStudentWindow addStudentWindow = new AddStudentWindow(); if (addStudentWindow.ShowDialog() == true) { Student student = new Student() { Username = addStudentWindow.Username, FirstName = addStudentWindow.FirstName, MiddleName = addStudentWindow.MiddleName, LastName = addStudentWindow.LastName, EGN = addStudentWindow.EGN, ClassId = addStudentWindow.ClassId }; string secret = Crypto.GenerateRandomSecret(); student.Username = Crypto.EncryptStringAES(student.Username, secret); string password = Crypto.EncryptStringAES(addStudentWindow.Password, secret); if(client.RegisterStudent(student, password, secret)) { UpdateStudentViews(); MessageBox.Show("Ученикът беше добавен успешно"); } else { MessageBox.Show("Ученикът не е валиден или вече съществува"); } } } catch (Exception ex) { MessageBox.Show(Application.Current.Resources["defaultErrorMessage"].ToString(), "Грешка", MessageBoxButton.OK, MessageBoxImage.Error); } }