private void OpenListeCompteClient()
 {
     Models.Compte           compte            = DBContext.Comptes.Where(c => (c.CompteId.Equals(this.Panier.CompteId))).FirstOrDefault();
     Models.Utilisateur      client            = DBContext.Utilisateurs.Where(c => (c.Id.Equals(compte.ClientId))).FirstOrDefault();
     Views.ListeCompteClient listeCompteClient = new Views.ListeCompteClient(client);
     listeCompteClient.Show();
     _window.Close();
 }
        /* Navigation */
        private void OpenAccueil()
        {
            Models.Compte      compte = DBContext.Comptes.Where(c => (c.CompteId.Equals(this.Panier.CompteId))).FirstOrDefault();
            Models.Utilisateur client = DBContext.Utilisateurs.Where(c => (c.Id.Equals(compte.ClientId))).FirstOrDefault();
            client.Deconnexion();
            DBContext.SaveChanges();

            Views.Accueil accueil = new Views.Accueil();
            accueil.Show();
            _window.Close();
        }
Пример #3
0
        private void AddCompte()
        {
            if (Comptes.Any(c => c.NomCompte == _addedCompte.NomCompte))
            {
                MessageBox.Show("Le compte existe déjà", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                int nbComptes = DBContext.Comptes.Count();


                Models.Compte compteToAdd = new Models.Compte()
                {
                    //CompteId = nbComptes+2, // Oon doit trouver tout les comptes pour affecter le bon id au niveau du modèle (+2 parce qu'il ne faut incrémenter (+1) et que ça ne commence pas à 0 (+1)
                    ClientId     = this.Client.Id,
                    DateCreation = System.DateTime.Now,
                    NomCompte    = this._addedCompte.NomCompte
                };

                //MessageBox.Show("CompteId à affecter :" + (nbComptes + 2));
                DBContext.Add(compteToAdd);
                DBContext.SaveChanges();



                Models.Panier panierToAdd = new Models.Panier()
                {
                    Compte = compteToAdd
                };
                DBContext.Add(panierToAdd);
                DBContext.SaveChanges();


                OpenListeCompteClient(Client);

                /*compteToAdd.CompteId = nbComptes + 2;
                 * this.Comptes.Add(compteToAdd);*/



                // On ne peut pas ajouter le Compte au Client dans le modèle vu qu'on se balade avec un Utilisateur et pas un client à cause de ce satané Table per Type

                /*DBContext.Comptes.Add(new Models.Compte()
                 * {
                 *  ClientId = this.Client.Id,
                 *  DateCreation = System.DateTime.Now,
                 *  NomCompte = this._addedCompte.NomCompte
                 * });
                 * DBContext.SaveChanges();*/

                //MessageBox.Show("Le compte " + _addedCompte.NomCompte + " a été ajouté");
            }
        }
Пример #4
0
        public ListeComptesViewModel(Window window, Models.Utilisateur client)
        {
            this._window = window;
            DBContext    = new DatabaseContext.GestionRelationClient_DBContext();

            this.Client    = client;
            this.nomClient = this.Client.Login;

            this._addedCompte = new Models.Compte();



            // Initialisation du compte
            ObservableCollection <Models.Compte> comptesATrouver = Models.Utilitaire.ToObservableCollection <Models.Compte>(DBContext.Comptes.Where(c => c.ClientId.Equals(Client.Id)));

            if (comptesATrouver == null)
            {
                this.Comptes = new ObservableCollection <Models.Compte>();
            }
            else
            {
                this.Comptes = comptesATrouver;
            }



            // Inscription
            AjoutCompteCommand = new RelayCommand(
                o => _isValid_addedCompte,
                o => AddCompte()
                );

            // Sélection compte
            SelectionnerCompteCommand = new RelayCommand(
                o => (p_SelectedItem != null),
                o => SelectionnerCompte()
                );

            // Navigation
            GoToAccueilCommand = new RelayCommand(
                o => true,
                o => OpenAccueil()
                );
            GoToModificationClientCommand = new RelayCommand(
                o => true,
                o => OpenModificationClient()
                );
            GoToListeCompteClientCommand = new RelayCommand(
                o => true,
                o => OpenListeCompteClient(this.Client)
                );
        }
Пример #5
0
        public PageCompteClientViewModel(Window window, int idCompte)
        {
            this._window = window;
            DBContext    = new DatabaseContext.GestionRelationClient_DBContext();


            this.Compte = DBContext.Comptes.Where(c => (c.CompteId.Equals(idCompte))).FirstOrDefault();

            this.Client = DBContext.Utilisateurs.Where(c => (c.Id.Equals(this.Compte.ClientId))).FirstOrDefault();


            this.NomClient = this.Client.Login;
            this.NomCompte = this.Compte.NomCompte;



            // Modification nom Compte
            ModificationNomCompteCommand = new RelayCommand(
                o => InformationsModificationNomCompteValides(),
                o => ModifieNomClient(LoginModificationCompte, MotDePasseModificationCompte, NouveauNomModificationCompte)
                );

            // Navigation
            GoToAccueilCommand = new RelayCommand(
                o => true,
                o => OpenAccueil()
                );
            GoToModificationCompteCommand = new RelayCommand(
                o => true,
                o => OpenModificationCompte()
                );
            GoToListeCompteClientCommand = new RelayCommand(
                o => true,
                o => OpenListeCompteClient()
                );
            GoToListArticleCommand = new RelayCommand(
                o => true,
                o => OpenListeArticle()
                );
            GoToPanierCommand = new RelayCommand(
                o => true,
                o => OpenPanier()
                );
        }
        public AchatArticleViewModel(Window window, int idCompte)
        {
            this._window = window;
            DBContext    = new DatabaseContext.GestionRelationClient_DBContext();

            this.Compte = DBContext.Comptes.Where(c => (c.CompteId.Equals(idCompte))).FirstOrDefault();

            // Pour l'instant, on ne s'embète pas à ne pas afficher les article qu'à déjà l'utilisateur


            this.Articles = Models.Utilitaire.ToObservableCollection(DBContext.Articles);



            // Navigation
            GoToAccueilCommand = new RelayCommand(
                o => true,
                o => OpenAccueil()
                );
            GoToModificationCompteCommand = new RelayCommand(
                o => true,
                o => OpenModificationCompte()
                );
            GoToListeComptesClientCommand = new RelayCommand(
                o => true,
                o => OpenListeCompteClient()
                );
            SelectionnerCompteCommand = new RelayCommand(
                o => true,
                o => OpenDetailsArticle()
                );
            GoToPageCompteCommand = new RelayCommand(
                o => true,
                o => OpenPageClient()
                );
            GoToPanierCommand = new RelayCommand(
                o => true,
                o => OpenPanier()
                );
        }