Beispiel #1
0
        public void setPassword(int passwortId)
        {
            passwort = BLL.Passwort.LesenID(passwortId);

            login.Text = passwort.Login;

            ComboboxItem selectedItem = new ComboboxItem
            {
                Text  = passwort.Kategorie.Name,
                Value = passwort.Kategorie.KategorieId
            };

            kategorie.Text = passwort.Kategorie.Name;

            zielsystem.Text = passwort.Zielsystem;

            ablaufdatum.SelectedDate = passwort.Ablaufdatum;

            erstelldatum.Content = passwort.Eingabedatum.ToString("dd.MM.yyyy");

            password_buttons.Visibility = Visibility.Visible;
            set_new_password.Visibility = Visibility.Hidden;
            save_button.IsEnabled       = false;
            delete_button.Visibility    = Visibility.Visible;
        }
 private void BTNSave_Click(object sender, RoutedEventArgs e)
 {
     if (IsSelectionValid())
     {
         if (entityStatus == EntityStatus.MODIFIED)
         {
             BLL.Passwort.Aktualisieren(currentPassword);
             MessageBox.Show("The password has been update", "Updated", MessageBoxButton.OK, MessageBoxImage.Information);
             currentPassword = BLL.Passwort.LesenID(currentPassword.PasswortId);
         }
         if (entityStatus == EntityStatus.UNATTACHED)
         {
             long id = BLL.Passwort.Erstellen(currentPassword);
             if (id > 0)
             {
                 MessageBox.Show("The password has been created", "Created", MessageBoxButton.OK, MessageBoxImage.Information);
                 currentPassword = BLL.Passwort.LesenID(id);
                 LoadValues(currentPassword);
                 entityStatus       = EntityStatus.MODIFIED;
                 BTNBack.Visibility = Visibility.Visible;
             }
         }
     }
     else
     {
         MessageBox.Show("Please check the data", "Incorrect values", MessageBoxButton.OK, MessageBoxImage.Stop);
     }
 }
Beispiel #3
0
        private void DemoErstellen()
        {
            // Kategorie (kurze Syntax)
            DAL.Kategorie kategorie1 = new DAL.Kategorie {
                Name = "Kategorie 1"
            };
            Int64 kategorie1Id = BLL.Kategorie.Erstellen(kategorie1);

            Debug.Print("Kategorie erstellt mit Id:" + kategorie1Id);
            DAL.Kategorie kategorie2 = new DAL.Kategorie {
                Name = "Kategorie 2"
            };
            Int64 kategorie2Id = BLL.Kategorie.Erstellen(kategorie2);

            Debug.Print("Kategorie erstellt mit Id:" + kategorie2Id);
            // Passwort (detaillierte Syntax)
            DAL.Passwort passwort1 = new DAL.Passwort();
            passwort1.Login        = "******";
            passwort1.PSW          = "gibbiX12345";
            passwort1.Eingabedatum = DateTime.Today;
            passwort1.Ablaufdatum  = DateTime.Today.AddMonths(1);
            passwort1.Kategorie    = kategorie1;
            Int64 passwort1Id = BLL.Passwort.Erstellen(passwort1);

            Debug.Print("Passwort erstellt mit Id:" + passwort1Id);
        }
 private void LoadValues(DAL.Passwort pw)
 {
     TXTName.Text = pw.Zielsystem;
     DATECreationDate.SelectedDate   = pw.Eingabedatum;
     DATEExpirationDate.SelectedDate = pw.Ablaufdatum;
     CMBCategory.SelectedValue       = pw.Kategorie.KategorieId;
     TXTPasswordClear.Text           = pw.PSW;
     TXTUsername.Text = pw.Login;
 }
 public UC_Password(MainWindow parent, DAL.Passwort password, WorkingStatus workingStatus)
 {
     InitializeComponent();
     BTNBack.Visibility   = Visibility.Hidden;
     this.parent          = parent;
     this.workingStatus   = password == null ? WorkingStatus.NEW : workingStatus;
     this.entityStatus    = password == null ? EntityStatus.UNATTACHED : EntityStatus.MODIFIED;
     this.currentPassword = password;
     if (password == null)
     {
         Initialize();
         LoadValues(currentPassword);
     }
     else
     {
         LoadValues(currentPassword);
         Initialize();
     }
 }
 private void BTNDelete_Click(object sender, RoutedEventArgs e)
 {
     if (entityStatus == EntityStatus.MODIFIED)
     {
         MessageBoxResult mbr = MessageBox.Show("Do you realy want to delete the password", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning);
         if (mbr == MessageBoxResult.Yes)
         {
             BLL.Passwort.LoeschenById(currentPassword.PasswortId);
             MessageBox.Show("Password has been deleted", "Deleted", MessageBoxButton.OK, MessageBoxImage.Information);
             parent.LoadView(new UC_Password(parent, Additonal.WorkingStatus.NEW), "New password");
         }
     }
     else
     {
         currentPassword = EmptyPassword();
         LoadValues(currentPassword);
         MessageBox.Show("Content has been cleared", "Cleared", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
Beispiel #7
0
 private void ListExpiredPassword_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     currentPassword = (DAL.Passwort)(((DataGrid)sender).SelectedItem);
 }
Beispiel #8
0
        private void save_button_Click(object sender, RoutedEventArgs e)
        {
            if (passwort != null)
            {
                Boolean passwortValidation = true;
                if (set_new_password.Visibility == Visibility.Visible)
                {
                    if (String.IsNullOrWhiteSpace(new_passwort.Password))
                    {
                        MessageBox.Show("Geben sie ein Passwort ein!");
                        passwortValidation = false;
                    }
                    else if (new_passwort.Password != repeat_password.Password)
                    {
                        MessageBox.Show("Passwörter stimmen nicht überein!");
                        passwortValidation = false;
                    }
                    else
                    {
                        passwort.PSW = new_passwort.Password;
                    }
                }
                if (passwortValidation)
                {
                    passwort.Zielsystem  = zielsystem.Text;
                    passwort.Login       = login.Text;
                    passwort.Ablaufdatum = ablaufdatum.SelectedDate.Value;
                    var selectedItem = (ComboboxItem)kategorie.SelectedItem;
                    passwort.Kategorie = BLL.Kategorie.LesenID(selectedItem.Value);

                    BLL.Passwort.Aktualisieren(passwort);
                    MainWindow parentWindow = (MainWindow)Window.GetWindow(this);
                    parentWindow.showDefault();
                }
            }
            else
            {
                if (String.IsNullOrWhiteSpace(new_passwort.Password))
                {
                    MessageBox.Show("Geben sie ein Passwort ein!");
                }
                else if (new_passwort.Password != repeat_password.Password)
                {
                    MessageBox.Show("Passwörter stimmen nicht überein!");
                }
                else
                {
                    passwort = new DAL.Passwort();
                    var selectedKategorie = (ComboboxItem)kategorie.SelectedItem;
                    passwort.Kategorie    = BLL.Kategorie.LesenID(selectedKategorie.Value);
                    passwort.Zielsystem   = zielsystem.Text;
                    passwort.Login        = login.Text;
                    passwort.Ablaufdatum  = ablaufdatum.SelectedDate.Value;
                    passwort.Eingabedatum = DateTime.Now;
                    passwort.PSW          = new_passwort.Password;

                    BLL.Passwort.Erstellen(passwort);

                    MainWindow parentWindow = (MainWindow)Window.GetWindow(this);
                    parentWindow.content.Children.Clear();
                }
            }
        }
 public UC_Password(MainWindow parent, DAL.Passwort passwort)
 {
     this.parent = parent;
 }
        private void InitalizeNewStatus()
        {
            currentPassword = EmptyPassword();

            DATECreationDate.IsEnabled = false;
        }