public static void AddResultatLabo(Hospitalisation hospit, ResultatLabo resultLabo, int numEmp)
        {
            resultLabo.DateEvenement   = DateTime.Now;
            resultLabo.EmployeImplique = DataModelEmploye.GetEmploye(numEmp);

            if (ConnexionBD.Instance().EstConnecte())
            {
                string requete = string.Format("INSERT INTO evenements " +
                                               "(idHospitalisation, idEmploye, dateHeure, estNotifier) " +
                                               "VALUES (" +
                                               "(SELECT idHospitalisation FROM hospitalisations WHERE dateDebut = '{0}')," +
                                               "{1}," +
                                               "'{2}'," +
                                               "{3})", hospit.DateDebut.ToString(), numEmp, resultLabo.DateEvenement.ToString(), resultLabo.EstNotifier);


                ConnexionBD.Instance().ExecuterRequete(requete);

                requete = string.Format("INSERT INTO resultatsLabo " +
                                        "(idEvenement, lienImage, nomAnalyse) " +
                                        "VALUES (" +
                                        "(SELECT idEvenement FROM evenements WHERE dateHeure = '{0}')," +
                                        "'{1}'," +
                                        "'{2}')"
                                        , resultLabo.DateEvenement.ToString(), resultLabo.LienImage, resultLabo.NomAnalyse);

                ConnexionBD.Instance().ExecuterRequete(requete);
                ControlModel.ControlModelDossierPatientResultatsLabo.LstResultsLabo.Add(resultLabo);
            }
        }
Ejemplo n.º 2
0
        public static void AddPrescription(Hospitalisation hospit, Prescription prescript, int numEmp)
        {
            prescript.DateEvenement   = DateTime.Now;
            prescript.EmployeImplique = DataModelEmploye.GetEmploye(numEmp);

            if (ConnexionBD.Instance().EstConnecte())
            {
                string requete = string.Format("INSERT INTO evenements " +
                                               "(idHospitalisation, idEmploye, dateHeure, estNotifier) " +
                                               "VALUES (" +
                                               "(SELECT idHospitalisation FROM hospitalisations WHERE dateDebut = '{0}')," +
                                               "{1}," +
                                               "'{2}'," +
                                               "{3})", hospit.DateDebut.ToString(), numEmp, prescript.DateEvenement.ToString(), prescript.EstNotifier);


                ConnexionBD.Instance().ExecuterRequete(requete);

                requete = string.Format("INSERT INTO Prescriptions " +
                                        "(idEvenement, produit, posologie, dateDebut, nbJour) " +
                                        "VALUES (" +
                                        "(SELECT idEvenement FROM evenements WHERE dateHeure = '{0}')," +
                                        "'{1}'," +
                                        "'{2}'," +
                                        "'{3}'," +
                                        "{4})"
                                        , prescript.DateEvenement.ToString(), prescript.Produit, prescript.Posologie, prescript.DateDebut.ToString(), prescript.NbJour);

                ConnexionBD.Instance().ExecuterRequete(requete);
                ControlModel.ControlModelDossierPatientPrescriptions.LstPrescriptions.Add(prescript);
            }
        }
Ejemplo n.º 3
0
        public static void AddNoteInf(Hospitalisation hospit, NoteInfirmiere noteInf, int numEmp)
        {
            noteInf.DateEvenement   = DateTime.Now;
            noteInf.EmployeImplique = DataModelEmploye.GetEmploye(numEmp);

            if (ConnexionBD.Instance().EstConnecte())
            {
                string requete = string.Format("INSERT INTO evenements " +
                                               "(idHospitalisation, idEmploye, dateHeure, estNotifier) " +
                                               "VALUES (" +
                                               "(SELECT idHospitalisation FROM hospitalisations WHERE dateDebut = '{0}')," +
                                               "{1}," +
                                               "'{2}'," +
                                               "{3})", hospit.DateDebut.ToString(), numEmp, noteInf.DateEvenement.ToString(), noteInf.EstNotifier);


                ConnexionBD.Instance().ExecuterRequete(requete);

                requete = string.Format("INSERT INTO NotesInfirmiere " +
                                        "(idEvenement, note) " +
                                        "VALUES (" +
                                        "(SELECT idEvenement FROM evenements WHERE dateHeure = '{0}')," +
                                        "'{1}')"
                                        , noteInf.DateEvenement.ToString(), noteInf.NotesInf);

                ConnexionBD.Instance().ExecuterRequete(requete);
                ControlModel.ControlModelDossierPatientNotesInf.LstNotesInf.Add(noteInf);
            }
        }
Ejemplo n.º 4
0
 public static void Delete(Usager usager)
 {
     if (ConnexionBD.Instance().EstConnecte())
     {
         ConnexionBD.Instance().ExecuterRequete(
             string.Format("DELETE FROM Usagers WHERE nomUtilisateur = '{0}'", usager.NomUtilisateur));
         DataModelEmploye.Delete(usager as Employe);
     }
 }
Ejemplo n.º 5
0
        public static void AddUsager(Usager usager, string motDePasseHash)
        {
            EtatAvecMessage retour = new EtatAvecMessage();

            if (ConnexionBD.Instance().EstConnecte())
            {
                string requete = string.Format("INSERT INTO Usagers " +
                                               "(idRole, idEmploye, nomUtilisateur, motDePasse) " +
                                               "VALUES (" +
                                               "(SELECT idEmploye FROM Employes WHERE numEmploye = '{0}'," +
                                               "(SELECT idRole FROM Roles WHERE role = '{1}'," +
                                               "'{2}'," +
                                               "'{3}'"
                                               , usager.NumEmploye, usager.RoleUsager.ToString(), usager.NomUtilisateur, motDePasseHash);

                DataModelEmploye.AddEmploye(usager);
                ConnexionBD.Instance().ExecuterRequete(requete);
                // TODO : Recevoir code erreur BD dans cas d'erreur (duplicata)
            }
        }
Ejemplo n.º 6
0
 public static void Post(Usager usager, string motDePasseEncrypte)
 {
     if (ConnexionBD.Instance().EstConnecte())
     {
         DataModelEmploye.Post(usager as Employe);
         ConnexionBD.Instance().ExecuterRequete(
             string.Format(
                 "INSERT INTO Usagers (nomUtilisateur, motDePasse, idEmploye, idRole) " +
                 "VALUES ( " +
                 "   '{0}', " +
                 "   '{1}', " +
                 "   (SELECT idEmploye FROM Employes WHERE NumEmploye = '{2}'), " +
                 "   (SELECT idRole FROM Roles WHERE role = '{3}') " +
                 ")",
                 usager.NomUtilisateur, motDePasseEncrypte,
                 usager.NumEmploye, usager.RoleUsager
                 )
             );
     }
 }
        public static Departement GetDepartementInfChef(Employe employe)
        {
            Departement departement = new Departement();

            int idEmployeRecherche = DataModelEmploye.GetidEmploye(employe);

            // On vérifie si la BD est connecté
            if (ConnexionBD.Instance().EstConnecte())
            {
                ConnexionBD.Instance().ExecuterRequete(
                    "SELECT d.idDepartement _id, d.nom depNom, d.abreviation depAbrev " +
                    "FROM departements d " +
                    "WHERE d.idEmploye = " + idEmployeRecherche + " "
                    , SqlDR => {
                    departement._identifiant = int.Parse(SqlDR.GetString("_id"));
                    departement.Nom          = SqlDR.GetString("depNom");
                    departement.Abreviation  = SqlDR.GetString("depAbrev");
                }
                    );
            }

            return(departement);
        }
        public static Departement GetDepartement(string abreviation, string expand = "")
        {
            Departement departement = null;

            if (ConnexionBD.Instance().EstConnecte())
            {
                int idEmployeChef = -1;
                ConnexionBD.Instance().ExecuterRequete(
                    string.Format(
                        "SELECT idDepartement _id, nom, abreviation, idEmploye " +
                        "FROM Departements " +
                        "WHERE abreviation = '{0}'",
                        abreviation
                        ), lecteur =>
                {
                    departement = new Departement
                    {
                        _identifiant = int.Parse(lecteur.GetString("_id")),
                        Nom          = lecteur.GetString("nom"),
                        Abreviation  = lecteur.GetString("abreviation")
                    };
                    if (!lecteur.IsDBNull(lecteur.GetOrdinal("idEmploye")))
                    {
                        idEmployeChef = int.Parse(lecteur.GetString("idEmploye"));
                    }
                }
                    );

                if (departement != null)
                {
                    departement.PersonnelMedicalEnChef = (idEmployeChef >= 0 ? null : DataModelEmploye.GetEmploye(idEmployeChef));
                    if (expand.Contains("chambres"))
                    {
                        StringBuilder expandPropagation = new StringBuilder();
                        if (expand.Contains("lits"))
                        {
                            expandPropagation.Append("lits ");
                        }
                        if (expand.Contains("equipements"))
                        {
                            expandPropagation.Append("equipements ");
                        }
                        departement.Chambres = new ObservableCollection <Chambre>(
                            DataModelChambre.GetChambres(
                                departement._identifiant.ToString(),
                                expandPropagation.ToString()
                                )
                            );
                    }
                }
            }
            return(departement);
        }
        public static List <Departement> GetDepartements()
        {
            List <Departement> lstDepartement = new List <Departement>();

            // On vérifie si la BD est connecté
            if (ConnexionBD.Instance().EstConnecte())
            {
                List <int> idEmployesChefs = new List <int>();

                // Si oui, on execute la requête que l'on veut effectuer
                // SqlDR (MySqlDataReader) emmagasine une liste des citoyens de la BD
                ConnexionBD.Instance().ExecuterRequete(
                    "SELECT * " +
                    "FROM departements"
                    , SqlDR => {
                    lstDepartement.Add(new Departement
                    {
                        _identifiant = int.Parse(SqlDR.GetString("idDepartement")),
                        Nom          = SqlDR.GetString("nom"),
                        Abreviation  = SqlDR.GetString("abreviation")
                    });
                    idEmployesChefs.Add(SqlDR.IsDBNull(SqlDR.GetOrdinal("idEmploye")) ? -1 : int.Parse(SqlDR.GetString("idEmploye")));
                }
                    );

                for (int i = 0; i < lstDepartement.Count; i++)
                {
                    lstDepartement[i].PersonnelMedicalEnChef = (idEmployesChefs[i] == -1 ? null : DataModelEmploye.GetEmploye(idEmployesChefs[i]));
                }

                for (int i = 0; i < lstDepartement.Count; i++)
                {
                    lstDepartement[i].Chambres = new ObservableCollection <Chambre>(DataModelChambre.GetChambres(lstDepartement[i]._identifiant.ToString(), "lits, equipements"));
                }
            }

            return(lstDepartement);
        }