예제 #1
0
        public static Alerte_Pro Get(Int32 Identifiant)
        {
            Alerte_Pro alerte_Pro = new Alerte_Pro();

            //Connection
            SqlConnection connection = DataBase.Connection();

            //Requete
            String requete = select+" WHERE Identifiant = @Identifiant;";

            //Commande
            SqlCommand commande = new SqlCommand(requete, connection);

            //Parametres
            commande.Parameters.AddWithValue("Identifiant", Identifiant);

            //Execution
            try
            {
                connection.Open();

                SqlDataReader dataReader = commande.ExecuteReader();

                while (dataReader.Read())
                {

                    alerte_Pro.Identifiant = dataReader.GetInt32(0);
                    alerte_Pro.Message = dataReader.GetString(1);
                    alerte_Pro.Date = dataReader.GetDateTime(2);
                    alerte_Pro.ID_Produit = dataReader.GetInt32(3);
                }

                dataReader.Close();

            }
            catch (Exception)
            {
                alerte_Pro = null;
            }
            finally
            {
                connection.Close();
            }

            return alerte_Pro;
        }
예제 #2
0
        public static Boolean Insert(Alerte_Pro alerte_Pro)
        {
            //Connection
            SqlConnection connection = DataBase.Connection();

            //Requete
            String requete = @"INSERT INTO Alerte_Pro (" + champs + ") VALUES (Message,Date,ID_Produit);";

            //Commande
            SqlCommand commande = new SqlCommand(requete, connection);

            //Parametres
            commande.Parameters.AddWithValue("Message", alerte_Pro.Message);
            commande.Parameters.AddWithValue("Date", alerte_Pro.Date);
            commande.Parameters.AddWithValue("ID_Produit", alerte_Pro.ID_Produit);
            //Execution
            try
            {
                connection.Open();
                commande.ExecuteNonQuery();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                connection.Close();
            }
        }
예제 #3
0
        public static Boolean Update(Alerte_Pro alerte_Pro)
        {
            //Connection
            SqlConnection connection = DataBase.Connection();

            //Requete
            String requete = @"UPDATE Alerte_Pro
                               SET Message=@Message,Date=@Date,ID_Produit=@ID_Produit
                               WHERE Identifiant=@Identifiant ;";

            //Commande
            SqlCommand commande = new SqlCommand(requete, connection);

            //Parametres
            commande.Parameters.AddWithValue("Identifiant",alerte_Pro.Identifiant);
            commande.Parameters.AddWithValue("Message", alerte_Pro.Message);
            commande.Parameters.AddWithValue("Date", alerte_Pro.Date);
            commande.Parameters.AddWithValue("ID_Produit", alerte_Pro.ID_Produit);

            //Execution
            try
            {
                connection.Open();
                commande.ExecuteNonQuery();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                connection.Close();
            }
        }
예제 #4
0
        public static List<Alerte_Pro> List()
        {
            List<Alerte_Pro> listeAlerte_Pro = new List<Alerte_Pro>();

            //Connection
            SqlConnection connection = DataBase.Connection();

            //Requete
            String requete = select+";";

            //Commande
            SqlCommand commande = new SqlCommand(requete, connection);

            //Parametres

            //Execution

            try
            {
                connection.Open();

                SqlDataReader dataReader = commande.ExecuteReader();

                while (dataReader.Read())
                {

                   Alerte_Pro alerte_Pro = new Alerte_Pro();
                   alerte_Pro.Identifiant = dataReader.GetInt32(0);
                   alerte_Pro.Message = dataReader.GetString(1);
                   alerte_Pro.Date = dataReader.GetDateTime(2);
                   alerte_Pro.ID_Produit = dataReader.GetInt32(3);
                   listeAlerte_Pro.Add(alerte_Pro);
                }

                dataReader.Close();

            }
            catch (Exception)
            {
                listeAlerte_Pro = null;
            }
            finally
            {
                connection.Close();
            }

            return listeAlerte_Pro;
        }