Beispiel #1
0
        public override void Update()
        {
            if (Selected != null)
            {
                RoleEmployeItemViewModel itemToUpate = Selected;
                RoleEmployeItemWindow    window      = new RoleEmployeItemWindow(itemToUpate);
                window.ShowDialog();

                if (window.DialogResult.HasValue && window.DialogResult == true)
                {
                    try
                    {
                        RoleEmploye toUpdate = itemToUpate.ToEntity();
                        MyDb.SaveChanges();
                        ReloadDatas();
                        return;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message);
                    }
                }
                MyDb = new MegaProductionBDDEntities();
            }
        }
Beispiel #2
0
 public override void Delete()
 {
     if (Selected != null)
     {
         if (MessageBox.Show("Souhaitez-vous réellement supprimer cet élément ?",
                             "Suppression",
                             MessageBoxButton.YesNo,
                             MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             try
             {
                 RoleEmploye toRemove = Selected.ToEntity();
                 MyDb.RoleEmploye.Remove(toRemove);
                 MyDb.SaveChanges();
                 ReloadDatas();
                 return;
             }
             catch (Exception e)
             {
                 MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message);
             }
         }
         MyDb = new MegaProductionBDDEntities();
     }
 }
Beispiel #3
0
        public RoleEmploye ToEntity()
        {
            RoleEmploye toReturn = associated_entity;

            toReturn.Libelle = Libelle;

            return(toReturn);
        }
Beispiel #4
0
        public RoleEmployeItemViewModel(RoleEmploye roleEmploye, MegaProductionBDDEntities MyDb)
        {
            if (roleEmploye == null)
            {
                roleEmploye = new RoleEmploye();
            }

            this.associated_entity = roleEmploye;

            this.Identifiant = roleEmploye?.Identifiant ?? 0;
            this.Libelle     = roleEmploye?.Libelle;

            ValiderCommand = new RelayCommand(Valider);
            CancelCommand  = new RelayCommand(Annuler);
        }
Beispiel #5
0
        public override void Add()
        {
            RoleEmployeItemViewModel itemToAdd = new RoleEmployeItemViewModel(null, MyDb);
            RoleEmployeItemWindow    window    = new RoleEmployeItemWindow(itemToAdd);

            window.ShowDialog();

            if (window.DialogResult.HasValue && window.DialogResult == true)
            {
                try
                {
                    RoleEmploye toAdd = itemToAdd.ToEntity();
                    MyDb.RoleEmploye.Add(toAdd);
                    MyDb.SaveChanges();
                    ReloadDatas();
                    return;
                }
                catch (Exception e)
                {
                    MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message);
                }
            }
            MyDb = new MegaProductionBDDEntities();
        }