Exemplo n.º 1
0
        public static Pos_Gd Get(Int32 Identifiant)
        {
            Pos_Gd pos_Gd = new Pos_Gd();

            //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())
                {
                    pos_Gd.Identifiant = dataReader.GetInt32(0);
                    pos_Gd.Position = dataReader.GetString(1);
                }

                dataReader.Close();

            }
            catch (Exception)
            {
                pos_Gd = null;
            }
            finally
            {
                connection.Close();
            }
            return pos_Gd;
        }
Exemplo n.º 2
0
        public static Boolean Insert(Pos_Gd pos_Gd)
        {
            //Connection
            SqlConnection connection = DataBase.Connection();

            //Requete
            String requete = @"INSERT INTO Pos_Gd ("+champs+") VALUES (@Position);";

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

            //Parametres
            commande.Parameters.AddWithValue("Position", pos_Gd.Position);
            //Execution
            try
            {
                connection.Open();
                commande.ExecuteNonQuery();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                connection.Close();
            }
        }
Exemplo n.º 3
0
        public static Boolean Update(Pos_Gd pos_Gd)
        {
            //Connection
            SqlConnection connection = DataBase.Connection();

            //Requete
            String requete = @"UPDATE Pos_Gd
                               SET Position=@Position
                               WHERE Identifiant=@Identifiant ;";

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

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

            //Execution
            try
            {
                connection.Open();
                commande.ExecuteNonQuery();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                connection.Close();
            }
        }
Exemplo n.º 4
0
        public static List<Pos_Gd> List()
        {
            List<Pos_Gd> listePos_Gd = new List<Pos_Gd>();

            //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())
                {
                   Pos_Gd pos_Gd = new Pos_Gd();
                   pos_Gd.Identifiant = dataReader.GetInt32(0);
                   pos_Gd.Position         = dataReader.GetString(1);
                   listePos_Gd.Add(pos_Gd);
                }

                dataReader.Close();

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

            return listePos_Gd;
        }