예제 #1
0
파일: Form1.cs 프로젝트: adhdtech/uctools
        private unsafe void tvDBList_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node = tvDBList.SelectedNode;

            if ((string)node.Tag == "Table")
            {
                //MessageBox.Show(string.Format("You selected table: {0}", node.Text));
                dataGridView1.Columns.Clear();

                OntapeReader.DBTableDetails thisTable = new OntapeReader.DBTableDetails();

                for (int i = 0; i < MyTapeReader._DBSpaces.Count(); i++)
                {
                    // Loop over Tables - look for all "systables"
                    for (int j = 0; j < MyTapeReader._DBSpaces[i].TableCount; j++)
                    {
                        //string wantedTable = "devicenumplanmap";
                        if (MyTapeReader._DBSpaces[i].Tables[j].TableName == node.Text)
                        {
                            thisTable = MyTapeReader._DBSpaces[i].Tables[j];
                        }
                    }
                }

                if (thisTable.TableName != "")
                {
                    for (int i = 0; i < thisTable.NumCols; i++)
                    {
                        string newColName = thisTable.DBColumns[i].colname;
                        DataGridViewTextBoxColumn newCol = new DataGridViewTextBoxColumn();
                        newCol.DataPropertyName = newColName;
                        newCol.HeaderText       = newColName;
                        newCol.Name             = newColName;
                        dataGridView1.Columns.Add(newCol);
                    }

                    // Callback
                    OntapeReader.DBTableDetails.RecHandlerCallBack recHandler = new OntapeReader.DBTableDetails.RecHandlerCallBack(ProcessRow);
                    thisTable.GetRecords(10, 0, recHandler);
                    if (dataGridView1.SelectedCells.Count > 0)
                    {
                        dataGridView1.ContextMenuStrip = contextMenuStrip1;
                    }
                } // End if found table
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: adhdtech/uctools
 public void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     foreach (OntapeReader.DBSpace dbProfile in MyTapeReader._DBSpaces)
     {
         if (dbProfile.Name != null)
         {
             TreeNode tvDBItem = new TreeNode(dbProfile.Name);
             //foreach (ADHDTech.OntapeReader.DBTableDetails thisTable in dbProfile.Tables)
             foreach (KeyValuePair <String, OntapeReader.DBTableDetails> keyValPair in dbProfile.TableDictionary)
             {
                 OntapeReader.DBTableDetails thisTable = keyValPair.Value;
                 if ((thisTable.TableType == 0x0A || thisTable.TableType == 0x02) && thisTable.NumCols > 0)
                 {
                     TreeNode tvTableItem = new TreeNode(thisTable.TableName);
                     tvTableItem.Tag = "Table";
                     // Add Columns to table
                     if (thisTable.DBColumns != null)
                     {
                         foreach (OntapeReader.DBColumnRecord thisCol in thisTable.DBColumns)
                         {
                             string colName = "<MISSING>";
                             if (thisCol.colname != null)
                             {
                                 colName = thisCol.colname + '(' + thisCol.coldetails.coltype.ToString("X") + "|" + thisCol.coldetails.collength.ToString("X") + ')';
                             }
                             TreeNode tvColItem = new TreeNode(colName);
                             tvTableItem.Nodes.Add(tvColItem);
                         }
                     }
                     tvDBItem.Nodes.Add(tvTableItem);
                 }
             }
             tvDBList.Nodes.Add(tvDBItem);
         }
     }
     toolStripProgressBar1.Value   = 0;
     toolStripProgressBar1.Visible = false;
 }