Beispiel #1
0
        private void OnAddCommand(object obj)
        {
            AddView add = new AddView();

            add.Name = "Ajout";
            add.ShowDialog();

            ListeJoueur.Add(add.ViewModel.JoueurToAdd);
            NotifyPropertyChanged("ListeJoueur");
        }
Beispiel #2
0
        public void Add()
        {
            var addWindow = new AddView()
            {
                Owner = Application.Current.MainWindow
            };

            addWindow.ShowDialog();

            SelectedEntry = _addWindowViewModel.AddedEntry;

            RefreshEntriesList();
        }
Beispiel #3
0
 /// <summary>
 /// Method to execute add song command, opens the add view for adding new song
 /// </summary>
 public void AddSongExecute()
 {
     try
     {
         AddView addView = new AddView(User);
         addView.ShowDialog();
         SongList = service.GetUsersSongs(User);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Beispiel #4
0
        private void OnAddCommand(object o)
        {
            ButtonPressedEvent.GetEvent().Handler += CloseAddView;

            _fenetreAjoutPerso      = new AddView();
            _fenetreAjoutPerso.Name = "Ajout";
            _fenetreAjoutPerso.ShowDialog(); //actif tant que la fenetre est ouverte.

            if (_fenetreAjoutPerso.ViewModel.IsSaisieValid)
            {
                ListePersonnages.Add(_fenetreAjoutPerso.ViewModel.Personnage);
                ListePersonnages      = TrierListe(ListePersonnages); // Supprimable ? (la liste qui n'est pas affichée n'a techniquement pas besoin d'être triée)
                ListePersonnageAffich = ListePersonnages;
            }
        }
Beispiel #5
0
        private void OnAddCommand(object o)
        {
            AudioControl = MediaState.Stop;
            ButtonPressedEvent.GetEvent().Handler += CloseAddView;

            Add      = new AddView();
            Add.Name = "Ajout";

            Add.ShowDialog();

            if (Add.AddViewVM.ClickOnFin)
            {
                ListeVoiture.Add(Add.AddViewVM.NewVoiture);
            }
        }
Beispiel #6
0
 private void OnAddCommand(object o)
 {
     try
     {
         AddView      ajouter = new AddView();
         AddViewModel modele  = new AddViewModel(ajouter);
         ajouter.DataContext = modele;
         ajouter.ShowDialog();
         if (!modele.NormalEnd)
         {
             return;
         }
         if (modele.Nom == " ")
         {
             throw (new ArgumentException("Vous n'avez pas rentrez de nom. Erreur: \n"));
         }
         if (!modele.TestI)
         {
             if (modele.Intervention == " ")
             {
                 throw (new ArgumentException("Vous n'avez pas rentrez d'intervention. Erreur: \n"));
             }
             List <Intervenant> tmp = Event.Intervenants;
             tmp.Add(new Intervenant(modele.Nom, modele.Intervention));
             Event.Intervenants = tmp;
             UpdateListeSpeaker();
         }
         else
         {
             List <Internaute> tmp = Event.Inscrits;
             tmp.Add(new Internaute(modele.Nom));
             Event.Inscrits = tmp;
             UpdateListeSpectator();
         }
         NotifyPropertyChanged("ListeSpectator");
         NotifyPropertyChanged("ListeSpeaker");
     }
     catch (Exception E)
     {
         ExceptionViewModel v = new ExceptionViewModel(E);
         ExceptionView      ExceptionWindow = new ExceptionView();
         ExceptionWindow.DataContext = v;
         ExceptionWindow.ShowDialog();
     }
 }
Beispiel #7
0
 private void OnAddCommand(object obj)
 {
     if (u == null)
     {
         MessageBoxResult conf = MessageBox.Show("Veuillez vous authentifier avant de commencer", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     else
     {
         if (u.IsAdmin())
         {
             AddView add = new AddView();
             add.Name = "Ajout";
             add.ShowDialog();
             ListeJoueur.Add(add.ViewModel.JoueurToAdd);
             NotifyPropertyChanged("ListeJoueur");
         }
         else
         {
             MessageBoxResult conf = MessageBox.Show("Vous n'avez pas l'accès Administrateur", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
Beispiel #8
0
        private void OnAddCommand(object o)
        {
            CommandChangedEvent.GetEvent().Handler += CloseAddWindows;

            _addView      = new AddView();
            _addView.Name = "Ajouter";
            _addView.ShowDialog();



            if (_addView.FilmViewModel.Valid == true)
            {
                ListFilm.Add(_addView.FilmViewModel.Film);
                ListFilm  = ListSort(ListFilm);
                ToDisplay = ListFilm;
                NotifyPropertyChanged("ToDisplay");
                System.Windows.Forms.MessageBox.Show("Ajout effectué.");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Ajout annulé.");
            }
        }
Beispiel #9
0
        public MainViewModel()
        {
            Messenger.Default.Register <Customer>(this, "refresh", (customer) =>
            {
                selectedCustomer = customer;
                GetCustomer(selectedCustomer.CustomerID);
            });

            Messenger.Default.Register <Customer>(this, "clear controls", (customer) =>
            {
                ClearControls();
            });

            //Message receivers to accept messages from EditViewModel and AddViewModel
            //The sender also sends a token as the second parameter and only receivers with the same token will accept it.
            Messenger.Default.Register <Customer>(this, "add", (customer) =>
            {
                try
                {
                    // Code a query to retrieve the selected customer
                    // and store the Customer object in the class variable.
                    selectedCustomer = customer;
                    this.DisplayCustomer();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            });

            //register for messenger from editView
            Messenger.Default.Register <Customer>(this, "edit", (customer) =>
            {
                try
                {
                    // Code a query to retrieve the selected customer
                    // and store the Customer object in the class variable.
                    selectedCustomer = customer;
                    this.DisplayCustomer();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            });

            //open add window
            AddCommand = new RelayCommand(() =>
            {
                //call and display addview
                AddView addView = new AddView();
                addView.ShowDialog();
            });

            //open edit window and send customer info to edit view
            EditCommand = new RelayCommand(() =>
            {
                //call and display the edit view
                EditView editView = new EditView();
                //send message to edit view before window pops out
                Messenger.Default.Send(selectedCustomer, "CustomerToEdit");
                editView.ShowDialog();
            });

            //get the customer information with customer ID
            GetCommand = new RelayCommand(() =>
            {
                if (Validator.IsInt32(CustomerID) && Validator.IsPresent(CustomerID))
                {
                    int customerID = int.Parse(CustomerID);
                    GetCustomer(customerID);
                }
            });

            //close window command
            ExitCommand = new RelayCommand <Window>((window) =>
            {
                if (window != null)
                {
                    window.Close();
                }
            });

            //command to remove customer
            DeleteCommand = new RelayCommand(() =>
            {
                try
                {
                    // Mark the row for deletion.
                    // Update the database.
                    MMABooksEntity.mmaBooks.Customers.Remove(selectedCustomer);
                    //MMABooksEntity.mmaBooks.Entry(selectedCustomer).State = System.Data.EntityState.Detached;
                    MMABooksEntity.mmaBooks.SaveChanges();
                    Messenger.Default.Send(new NotificationMessage("Customer " + CustomerID + " Removed!"));

                    CustomerID = "";
                    this.ClearControls();
                }
                // Add concurrency error handling.
                // Place the catch block before the one for a generic exception.
                catch (DbUpdateConcurrencyException ex)
                {
                    ex.Entries.Single().Reload();
                    if (MMABooksEntity.mmaBooks.Entry(selectedCustomer).State == EntityState.Detached)
                    {
                        MessageBox.Show("Another user has deleted " + "that customer.", "Concurrency Error");
                        this.ClearControls();
                    }
                    else
                    {
                        MessageBox.Show("Another user has updated " + "that customer.", "Concurrency Error");
                        DisplayCustomer();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            });
        }
Beispiel #10
0
        public void addUsers()
        {
            AddView addview = new AddView();

            addview.ShowDialog();
        }