示例#1
0
        // Datagrid Employés Menu Click-droit/Supprimer
        private void menuSuppEmp_Click(object sender, RoutedEventArgs e)
        {
            if (dgEmployes.SelectedItem == null)
            {
                return;
            }
            if (empEdit != null && (dgEmployes.SelectedItem as EmpView).ID == empEdit.ID)
            {
                addMode();
            }
            EmpView          empViewSelection = dgEmployes.SelectedItem as EmpView;
            Employe          delEmp           = mgr.BDD.Employes.Where(x => x.ID == empViewSelection.ID).FirstOrDefault();
            MessageBoxResult confirmer        = MessageBox.Show(
                "Êtes-vous sûr de vouloir supprimer l'employé " + delEmp.Prenom + " " + delEmp.Nom + "?",
                "Confirmez",
                MessageBoxButton.YesNo,
                MessageBoxImage.Hand);

            if (confirmer == MessageBoxResult.Yes)
            {
                mgr.BDD.Employes.Remove(delEmp);
                mgr.SaveChanges();
                actualiser();
            }
        }
示例#2
0
        // Datagrid Employés Menu Click-droit/Edit
        private void menuEditEmp_Click(object sender, RoutedEventArgs e)
        {
            if (dgEmployes.SelectedItem == null)
            {
                return;
            }
            editMode();

            EmpView empViewSelection = dgEmployes.SelectedItem as EmpView;

            empEdit = mgr.BDD.Employes.Where(x => x.ID == empViewSelection.ID).FirstOrDefault();

            txtNom.Text          = empEdit.Nom;
            txtPrenom.Text       = empEdit.Prenom;
            txtUsr.Text          = empEdit.USR;
            txtPsw.Password      = empEdit.PSW;
            cbDepts.SelectedItem = empEdit.Departement;
        }