Exemplo n.º 1
0
        // Datagrid Medecins Menu Click-droit/Supprimer
        private void menuSuppMed_Click(object sender, RoutedEventArgs e)
        {
            if (dgMedecins.SelectedItem == null)
            {
                return;
            }
            if (empEdit != null && (dgMedecins.SelectedItem as MedView).ID == empEdit.ID)
            {
                addMode();
            }
            MedView          medViewSelection = dgMedecins.SelectedItem as MedView;
            Employe          delEmp           = mgr.BDD.Employes.Where(x => x.ID == medViewSelection.ID).FirstOrDefault();
            Medecin          delMed           = mgr.BDD.Medecins.Where(x => x.MedID == medViewSelection.MedID).FirstOrDefault();
            MessageBoxResult confirmer        = MessageBox.Show(
                "Êtes-vous sûr de vouloir supprimer le médecin " + delEmp.Prenom + " " + delEmp.Nom + "?",
                "Confirmez",
                MessageBoxButton.YesNo,
                MessageBoxImage.Hand);

            if (confirmer == MessageBoxResult.Yes)
            {
                mgr.BDD.Medecins.Remove(delMed);
                mgr.BDD.Employes.Remove(delEmp);
                mgr.SaveChanges();
                actualiser();
            }
        }
Exemplo n.º 2
0
        // Button Ajouter/Enregistrer
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (checkFields())
            {
                if (!editing)
                {
                    // Ajout
                    Employe emp = new Employe();
                    emp.Nom    = txtNom.Text;
                    emp.Prenom = txtPrenom.Text;
                    emp.USR    = txtUsr.Text;
                    emp.PSW    = txtPsw.Password;
                    emp.DepID  = (cbDepts.SelectedItem as Departement).ID;

                    mgr.BDD.Employes.Add(emp);
                    mgr.SaveChanges();

                    if ((cbDepts.SelectedItem as Departement).NomDept == "Medical")
                    {
                        // Ajout Medecin
                        mgr.BDD.Entry(emp).GetDatabaseValues();
                        Medecin med = new Medecin();
                        med.EmpID    = emp.ID;
                        med.DepMedID = (cbDeptsMed.SelectedItem as DepartementMedical).ID;

                        mgr.BDD.Medecins.Add(med);
                        mgr.SaveChanges();
                    }
                    actualiser();
                    MessageBox.Show("Employé Ajouté!", "Succès!", MessageBoxButton.OK);
                }
                else
                {
                    // Edition Employé
                    empEdit.Nom    = txtNom.Text;
                    empEdit.Prenom = txtPrenom.Text;
                    empEdit.USR    = txtUsr.Text;
                    empEdit.PSW    = txtPsw.Password;
                    empEdit.DepID  = (cbDepts.SelectedItem as Departement).ID;

                    if (editingMed)
                    {
                        // Edition Medecin
                        medEdit.DepMedID = (cbDeptsMed.SelectedItem as DepartementMedical).ID;
                    }

                    mgr.SaveChanges();
                    actualiser();
                    addMode();
                    MessageBox.Show("Modification(s) effectuée(s)!", "Succès!", MessageBoxButton.OK);
                }
            }
            else
            {
                // En cas d'erreur
                MessageBox.Show(message, "Erreur d'entrée", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                message = String.Empty;
            }
        }
Exemplo n.º 3
0
        public void actualiser()
        {
            string  term    = txtSearch.Text;
            Medecin userMed = mgr.BDD.Medecins.Where(x => x.EmpID == mgr.User.ID).SingleOrDefault();

            if (term != String.Empty)
            {
                dgSejours.DataContext = mgr.BDD.SejMedViews.Where(x => x.MedID == userMed.MedID && x.DateFin == null && (x.Nom.Contains(term) || x.Prenom.Contains(term))).ToList();
            }
            else
            {
                dgSejours.DataContext = mgr.BDD.SejMedViews.Where(x => x.MedID == userMed.MedID && x.DateFin == null).ToList();
            }
        }
Exemplo n.º 4
0
        // Datagrid Medecins Menu Click-droit/Edit
        private void menuEditMed_Click(object sender, RoutedEventArgs e)
        {
            if (dgMedecins.SelectedItem == null)
            {
                return;
            }
            editMode();
            editingMed        = true;
            cbDepts.IsEnabled = false;

            MedView medViewSelection = dgMedecins.SelectedItem as MedView;

            empEdit = mgr.BDD.Employes.Where(x => x.ID == medViewSelection.ID).FirstOrDefault();
            medEdit = mgr.BDD.Medecins.Where(x => x.MedID == medViewSelection.MedID).FirstOrDefault();

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