Exemplo n.º 1
0
        public Utilisateur GetUtilisateurByIdentifiant(string identifiants)
        {
            Utilisateur     reponse   = new Utilisateur();
            Connexion       connexion = new Connexion();
            string          sql       = "select * from utilisateur where IDENTIFIANTS='" + identifiants + "'";
            MySqlCommand    command   = new MySqlCommand(sql, connexion.GetConnection());
            MySqlDataReader dataReader;

            connexion.GetConnection().Open();
            dataReader = command.ExecuteReader();
            PosteDAO posteDAO = new PosteDAO();

            try
            {
                if (dataReader.Read().ToString() == "True")
                {
                    Poste poste = posteDAO.GetPosteById(dataReader["ID_POSTE"].ToString());
                    reponse = new Utilisateur(dataReader["ID_UTILISATEUR"].ToString(), poste, dataReader["NOM_UTILISATEUR"].ToString(), dataReader["PRENOMS"].ToString(), dataReader["IDENTIFIANTS"].ToString(), dataReader["MDP"].ToString());
                }
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
Exemplo n.º 2
0
        public Utilisateur GetMagasinier(string mdp)
        {
            Utilisateur     reponse   = new Utilisateur();
            Connexion       connexion = new Connexion();
            string          sql       = "select * from utilisateur where MDP = '" + mdp + "' and id_poste='2'";
            MySqlCommand    command   = new MySqlCommand(sql, connexion.GetConnection());
            MySqlDataReader dataReader;

            connexion.GetConnection().Open();
            dataReader = command.ExecuteReader();
            PosteDAO posteDAO = new PosteDAO();

            try
            {
                while (dataReader.Read())
                {
                    Poste poste = posteDAO.GetPosteById(dataReader["ID_POSTE"].ToString());
                    reponse = new Utilisateur(dataReader["ID_UTILISATEUR"].ToString(), poste, dataReader["NOM_UTILISATEUR"].ToString(), dataReader["PRENOMS"].ToString(), dataReader["IDENTIFIANTS"].ToString(), dataReader["MDP"].ToString());
                }
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
Exemplo n.º 3
0
        public List <Utilisateur> GetUtilisateurValidation(string etat)
        {
            List <Utilisateur> reponse   = new List <Utilisateur>();
            Connexion          connexion = new Connexion();
            string             sql       = "select * from utilisateur where etat='" + etat + "'";
            MySqlCommand       command   = new MySqlCommand(sql, connexion.GetConnection());
            MySqlDataReader    dataReader;

            connexion.GetConnection().Open();
            dataReader = command.ExecuteReader();
            PosteDAO posteDAO = new PosteDAO();

            try
            {
                while (dataReader.Read())
                {
                    Poste poste = posteDAO.GetPosteById(dataReader["ID_POSTE"].ToString());
                    reponse.Add(new Utilisateur(dataReader["ID_UTILISATEUR"].ToString(), poste, dataReader["NOM_UTILISATEUR"].ToString(), dataReader["PRENOMS"].ToString(), dataReader["IDENTIFIANTS"].ToString(), dataReader["MDP"].ToString()));
                }
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
Exemplo n.º 4
0
        public Utilisateur GetUtilisateurByLogin(LoginUsers loginUsers)
        {
            Utilisateur     reponse   = new Utilisateur();
            Connexion       connexion = new Connexion();
            string          sql       = "select * from utilisateur where IDENTIFIANTS='" + loginUsers.Identifiant + "' and MDP = '" + loginUsers.Mdp + "' and ETAT='1'";
            MySqlCommand    command   = new MySqlCommand(sql, connexion.GetConnection());
            MySqlDataReader dataReader;

            connexion.GetConnection().Open();
            dataReader = command.ExecuteReader();
            PosteDAO posteDAO = new PosteDAO();

            try
            {
                if (dataReader.Read().ToString() == "True")
                {
                    Poste poste = posteDAO.GetPosteById(dataReader["ID_POSTE"].ToString());
                    reponse         = new Utilisateur(dataReader["ID_UTILISATEUR"].ToString(), poste, dataReader["NOM_UTILISATEUR"].ToString(), dataReader["PRENOMS"].ToString(), dataReader["IDENTIFIANTS"].ToString(), dataReader["MDP"].ToString());
                    reponse.EtatMdp = dataReader["etatmdp"].ToString();
                }
                else
                {
                    throw new Exception("Identifiants / mot de passe invalide");
                }
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
Exemplo n.º 5
0
        public List <string> GetListeIdentifiant(string identifiant)
        {
            List <String>   reponse   = new List <String>();
            Connexion       connexion = new Connexion();
            string          sql       = "select identifiants from utilisateur where identifiants like '" + identifiant + "%'";
            MySqlCommand    command   = new MySqlCommand(sql, connexion.GetConnection());
            MySqlDataReader dataReader;

            connexion.GetConnection().Open();
            dataReader = command.ExecuteReader();
            PosteDAO posteDAO = new PosteDAO();

            try
            {
                while (dataReader.Read())
                {
                    reponse.Add(dataReader["IDENTIFIANTS"].ToString());
                }
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }