Exemplo n.º 1
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();

        string connectionString = "Server=localhost;Database=dbprueba;User Id=dbprueba;Password=sistemas";

        ApplicationContext.Instance.DbConnection = new NpgsqlConnection(connectionString);
        dbConnection = ApplicationContext.Instance.DbConnection;
        dbConnection.Open();

        IDbCommand dbCommand = dbConnection.CreateCommand();

        dbCommand.CommandText =
            "select a.id, a.nombre, a.precio, c.nombre as categoria " +
            "from articulo a left join categoria c " +
            "on a.categoria = c.id";

        IDataReader dataReader = dbCommand.ExecuteReader();

        TreeViewExtensions.Fill(treeView, dataReader);
        dataReader.Close();

        dataReader = dbCommand.ExecuteReader();
        TreeViewExtensions.Fill(treeView, dataReader);
        dataReader.Close();
    }