Esempio n. 1
0
 internal static SqlCeDataReader ExecuteReader(string req)
 {
     try
     {
         var con = new Connexion();
         SqlCeConnection conne = con.OpenConnection();
         var sqlCommand = new SqlCeCommand(req, conne);
         SqlCeDataReader myReader = sqlCommand.ExecuteReader();
         return myReader;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         return null;
     }
 }
Esempio n. 2
0
        internal static int ExecuteUpdate(string requête)
        {
            // on gère les éventuelles exceptions
            try
            {
                var con = new Connexion();
                // ouverture connexion
                SqlCeConnection conne = con.OpenConnection();
                // exécute sqlCommand avec requête de mise à jour
                var sqlCommand = new SqlCeCommand(requête, conne);
                int nbLignes = sqlCommand.ExecuteNonQuery();
                return nbLignes;

            }
            catch (Exception)
            {
                return -1;
            }
        }
Esempio n. 3
0
 internal static DataSet ExecuteSelect(string requête)
 {
     // on gère les éventuelles exceptions
     try
     {
         var con = new Connexion();
         SqlCeConnection connexion = con.OpenConnection();
         SqlCeCommand cmd = connexion.CreateCommand();
         cmd.CommandText = requête;
         var da = new SqlCeDataAdapter(cmd);
         var ds = new DataSet();
         da.Fill(ds);
         return ds;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         return null;
     }
 }
Esempio n. 4
0
        public static int LogExiste(string log)
        {
            int id = 0;

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                String          req = "SELECT id FROM profile WHERE login = '******' ; ";
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    id = dt.GetInt16(0);
                }
                con.CloseConnection();
                return(id);
            }
            catch (Exception e) {
                MessageBox.Show("" + e.Message);
                return(-1);
            }
        }
Esempio n. 5
0
        public static int IdExisteJournal(int idd)
        {
            int id = 0;

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                String          req = " SELECT id FROM journalatelier WHERE idatelier= " + idd + " ";
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    id = dt.GetInt16(0);
                }
                con.CloseConnection();
                return(id);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(-1);
            }
        }
Esempio n. 6
0
        public static List <Injoignable> GetAllRappelInjoignablefiltre(String champ, String texte)
        {
            List <Injoignable> list = new List <Injoignable>();

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                string          req = " SELECT id, identreprise, date, heure, numtel, nom, prenom, poste, reponse, note  FROM 	injoignable WHERE "+ champ + " like '%" + texte + "%'";
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    list.Add(new Injoignable
                    {
                        ID           = dt.GetInt16(0),
                        IDENTREPRISE = dt.GetInt16(1),
                        DATE         = dt.GetString(2),
                        HEURE        = dt.GetString(3),
                        NUMTEL       = dt.GetString(4),
                        NOM          = dt.GetString(5),
                        PRENOM       = dt.GetString(6),
                        POSTE        = dt.GetString(7),
                        REPONSE      = dt.GetString(8),
                        NOTE         = dt.GetString(9)
                    });
                }
                con.CloseConnection();
                return(list);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(null);
            }
        }
Esempio n. 7
0
        public static List <fauxnumero> GetAllrappelFauxnumero()
        {
            List <fauxnumero> list = new List <fauxnumero>();

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                string          req = "SELECT id, identreprise, date, heure, numtel, nom, prenom, poste, reponse, note FROM 	fauxnumero";
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    list.Add(new fauxnumero
                    {
                        ID           = dt.GetInt16(0),
                        IDENTREPRISE = dt.GetInt16(1),
                        DATE         = dt.GetString(2),
                        HEURE        = dt.GetString(3),
                        NUMTEL       = dt.GetString(4),
                        NOM          = dt.GetString(5),
                        PRENOM       = dt.GetString(6),
                        POSTE        = dt.GetString(7),
                        REPONSE      = dt.GetString(8),
                        NOTE         = dt.GetString(9)
                    });
                }
                con.CloseConnection();
                return(list);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "azerty");
                return(null);
            }
        }
Esempio n. 8
0
        //statistique
        public static List <String> getAllChampFromTableST(String champ, String tab)
        {
            List <String> V = new List <String>();

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                string          req = " SELECT " + champ + " FROM " + tab;
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    V.Add(dt.GetString(0));
                }
                con.CloseConnection();
                return(V);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(null);
            }
        }
Esempio n. 9
0
        public static int MaxId()
        {
            int id = 0;

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                String          req = "SELECT MAX(id) FROM article ; ";
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    id = dt.GetInt16(0);
                }
                con.CloseConnection();
                return(id);
            }
            catch (Exception e)
            {
                MessageBox.Show("" + e.Message);
                return(-1);
            }
        }
Esempio n. 10
0
        public static String GetNomFromId(int id)
        {
            String nom = "";

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                string          req = " SELECT nom FROM article WHERE id = " + id + ";";
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    nom = dt.GetString(0);
                }
                con.CloseConnection();
                return(nom);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(null);
            }
        }
Esempio n. 11
0
        public static int getQuantite(int idd)
        {
            int id = 0;

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                String          req = " SELECT quant FROM article WHERE id= " + idd + " ";
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    id = dt.GetInt16(0);
                }
                con.CloseConnection();
                return(id);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(-1);
            }
        }
Esempio n. 12
0
        public static int GetSuivi(int idd)
        {
            int id = 0;

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                string          req = "SELECT suivi FROM suivibonprod WHERE id = " + idd;
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    id = dt.GetInt16(0);
                }
                con.CloseConnection();
                return(id);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(-1);
            }
        }
Esempio n. 13
0
        public static String GetEmailFromLogin(String log)
        {
            string mail = "";

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                string          req        = "SELECT mail FROM profile WHERE login='******';";
                MySqlCommand    cmd        = new MySqlCommand(req, con.connexion);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                while (dataReader.Read())
                {
                    mail = dataReader.GetString(0);
                }
                con.CloseConnection();
                return(mail);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(null);
            }
        }
Esempio n. 14
0
        public static int NomExiste(string nom)
        {
            int id = 0;

            try
            {
                Connexion con = new Connexion();
                con.OpenConnection();
                String          req = "SELECT id FROM groupedetravail WHERE nom = '" + nom + "' ; ";
                MySqlCommand    cmd = new MySqlCommand(req, con.connexion);
                MySqlDataReader dt  = cmd.ExecuteReader();
                while (dt.Read())
                {
                    id = dt.GetInt16(0);
                }
                con.CloseConnection();
                return(id);
            }
            catch (Exception e)
            {
                MessageBox.Show("" + e.Message);
                return(-1);
            }
        }