Ejemplo n.º 1
0
 public void SetupEdit()
 {
     btn_deleteStorageRoom.Visibility = Visibility.Visible;
     output_StorageID.Text            = storageRoomToEdit.ID.ToString();
     textBox_Name.Text      = storageRoomToEdit.Name;
     textBox_descr.Text     = storageRoomToEdit.Description;
     btn_JustQuit.Click    += delegate { this.Close(); };
     btn_SaveAndQuit.Click += delegate
     {
         if (textBox_Name.Text == "" || textBox_descr.Text == "")
         {
             textBox_Name.BorderBrush  = Brushes.DarkGray;
             textBox_descr.BorderBrush = Brushes.DarkGray;
             if (textBox_Name.Text == "")
             {
                 textBox_Name.BorderBrush = Brushes.Red;
             }
             if (textBox_descr.Text == "")
             {
                 textBox_descr.BorderBrush = Brushes.Red;
             }
         }
         else
         {
             string storageRoomName  = textBox_Name.Text;
             string storageRoomDescr = textBox_descr.Text;
             ControllerSto.EditStorageRoom(storageRoomToEdit.ID, storageRoomName, storageRoomDescr);
             this.Close();
         }
     };
     btn_deleteStorageRoom.Click += delegate
     {
         MessageBoxResult results = MessageBox.Show($"Er du sikker på at du vil slette dette lagerrum: {storageRoomToEdit.Name} ?", "Slet lagerrum:", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (results == MessageBoxResult.Yes)
         {
             ControllerSto.DeleteStorageRoom(storageRoomToEdit.ID);
             this.Close();
         }
     };
 }