public DataTable displayClients()
        {
            dt = new DataTable();
            try
            {
                maConnexion1.OpenConnection();
                String reqSelectClients = "SELECT * FROM client";
                cmd    = maConnexion1.reqExec(reqSelectClients);
                reader = cmd.ExecuteReader();

                for (int i = 0; i <= reader.FieldCount - 1; i++)
                {
                    dt.Columns.Add(reader.GetName(i));
                }
                while (reader.Read())

                {
                    DataRow dr = dt.NewRow();

                    for (int i = 0; i <= reader.FieldCount - 1; i++)
                    {
                        dr[i] = reader.GetValue(i);
                    }

                    dt.Rows.Add(dr);
                }
                reader.Close();
                return(dt);
            }
            catch (Exception exp)
            {
                throw (exp);
            }
            finally
            {
                maConnexion1.CloseConnection();
            }
        }
Esempio n. 2
0
        public DataTable displayComptes()
        {
            dt = new DataTable();
            try
            {
                maConnexion.OpenConnection();
                String reqSelectClients = "SELECT c.num as numCompte, cli.num as numClient, cli.nom, cli.prenom, cli.adresse, c.solde, c.decouvert FROM COMPTE c JOIN CLIENT cli ON cli.num = c.numClient";
                cmd    = maConnexion.reqExec(reqSelectClients);
                reader = cmd.ExecuteReader();

                for (int i = 0; i <= reader.FieldCount - 1; i++)
                {
                    dt.Columns.Add(reader.GetName(i));
                }
                while (reader.Read())

                {
                    DataRow dr = dt.NewRow();

                    for (int i = 0; i <= reader.FieldCount - 1; i++)
                    {
                        dr[i] = reader.GetValue(i);
                    }

                    dt.Rows.Add(dr);
                }
                reader.Close();
                return(dt);
            }
            catch (Exception exp)
            {
                throw(exp);
            }
            finally
            {
                maConnexion.CloseConnection();
            }
        }