Ejemplo n.º 1
0
        public static Magasinier Create(Magasinier m)
        {
            using (SqlConnection conn = Database.GetConnection())
            {
                conn.Open();

                SqlCommand command = new SqlCommand(CREATE, conn);
                command.Parameters.AddWithValue("@username", m.Username);
                command.Parameters.AddWithValue("@password", m.Password);
                command.Parameters.AddWithValue("@tel", m.Tel);
                command.Parameters.AddWithValue("@email", m.Email);


                m.Id = (int)command.ExecuteScalar();                 //Revnoyer la valeur de l'intersection de la première ligne première colonne
            }
            return(m);
        }
Ejemplo n.º 2
0
        public static Magasinier Get(int id)
        {
            Magasinier m = null;

            using (SqlConnection conn = Database.GetConnection())
            {
                conn.Open();
                SqlCommand command = new SqlCommand(GET, conn);
                command.Parameters.AddWithValue("@id", id);
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    m = new Magasinier(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4));
                }
            }

            return(m);
        }
Ejemplo n.º 3
0
        public static Magasinier getMag(string username, string password)
        {
            Magasinier mag = null;

            using (SqlConnection connection = Database.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(GETCONENCTION, connection);
                command.Parameters.AddWithValue("@username", username);
                command.Parameters.AddWithValue("@password", password);
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    mag = new Magasinier(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4));
                }
            }
            return(mag);
        }
Ejemplo n.º 4
0
        public static Boolean Update(Magasinier m)
        {
            bool aEteModifie = false;

            using (SqlConnection conn = Database.GetConnection())
            {
                conn.Open();

                SqlCommand command = new SqlCommand(UPDATE, conn);
                command.Parameters.AddWithValue("@username", m.Username);
                command.Parameters.AddWithValue("@password", m.Password);
                command.Parameters.AddWithValue("@tel", m.Tel);
                command.Parameters.AddWithValue("@email", m.Email);

                command.Parameters.AddWithValue("@id", m.Id);

                aEteModifie = command.ExecuteNonQuery() != 0;
            }
            return(aEteModifie);
        }