Exemplo n.º 1
0
 public static QueryResult Get(string selectText)
 {
     IDbConnection dbConnection = App.Instance.DbConnection;
     IDbCommand dbCommand = dbConnection.CreateCommand ();
     dbCommand.CommandText = selectText;
     IDataReader dataReader = dbCommand.ExecuteReader ();
     QueryResult queryResult = new QueryResult ();
     queryResult.ColumnNames = getColumnNames (dataReader);
     List<IList> rows = new List<IList> ();
     while (dataReader.Read()) {
         IList row = getRow (dataReader);
         rows.Add (row);
     }
     queryResult.Rows = rows;
     dataReader.Close ();
     return queryResult;
 }
Exemplo n.º 2
0
 public static void Fill(TreeView treeView, QueryResult queryResult)
 {
     removeAllColumns (treeView);
     string[] columnNames = queryResult.ColumnNames;
     CellRendererText cellRendererText = new CellRendererText ();
     for (int index = 0; index < columnNames.Length; index++) {
         int column = index;
         treeView.AppendColumn (columnNames [index], cellRendererText,
                                delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
             IList row = (IList)tree_model.GetValue(iter, 0);
             cellRendererText.Text = row[column].ToString();
         });
     }
     ListStore listStore = new ListStore (typeof(IList));
     foreach (IList row in queryResult.Rows)
         listStore.AppendValues (row);
     treeView.Model = listStore;
 }
Exemplo n.º 3
0
        public static void Fill(ComboBox comboBox, QueryResult queryResult, object id)
        {
            CellRendererText cellRendererText = new CellRendererText ();
            comboBox.PackStart (cellRendererText, false);
            comboBox.SetCellDataFunc (cellRendererText,
                                      delegate(CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                IList row = (IList)tree_model.GetValue(iter, 0);
                cellRendererText.Text = row[1].ToString();
            });
            ListStore listStore = new ListStore (typeof(IList));
            //TODO localización de "sin asignar"
            IList first = new object[]{null, "<sin asignar>"};
            TreeIter treeIterId = listStore.AppendValues (first);
            foreach (IList row in queryResult.Rows){
                TreeIter treeIter = listStore.AppendValues (row);
                if (row[0].Equals(id))
                    treeIterId = treeIter;

            }
            comboBox.Model = listStore;
            comboBox.SetActiveIter (treeIterId);
        }