public FrmExportMessageBox(DB338 db, IntSchTable currentTable) { InitializeComponent(); this.db = db; this.currentTable = currentTable; InitializeComboBox(db, currentTable); SetUpButtons(); }
private void SubmitQuery() { string[] trimmedLines = GetTrimmedLines(); string[] queries = String.Join(" ", trimmedLines).Split(';').Where(x => !string.IsNullOrWhiteSpace(x)) .ToArray(); for (int i = 0; i < queries.Length; ++i) { QueryResult queryResult = db.SubmitQuery(queries[i]); IntSchTable queryResults = queryResult.Results; if (queryResult.Error.ErrorType != "none") { ShowError(queryResult.Error); } else { Output(queryResults); } } }
private void InitializeComboBox(DB338 db, IntSchTable currentTable) { List <IntSchTable> tablesToExport = new List <IntSchTable>(); if (currentTable != null) { tablesToExport.Add(currentTable); } List <IntSchTable> dbTables = db.GetTables(); foreach (IntSchTable table in dbTables) { tablesToExport.Add(table); } comboBox_ExportTables.DataSource = tablesToExport; comboBox_ExportTables.DisplayMember = "Name"; comboBox_ExportTables.DropDownStyle = ComboBoxStyle.DropDownList; }
public void Output(IntSchTable results) { dataGridView1.Rows.Clear(); dataGridView1.Columns.Clear(); dataGridView1.Refresh(); currentTable = results; if (results == null) { return; } List <string> columns = results.columnNames; dataGridView1.ColumnCount = columns.Count; for (int i = 0; i < columns.Count; i++) { dataGridView1.Columns[i].Name = columns[i]; } for (int i = 0; i < results.numRows; i++) { string[] emptyRow = new string[columns.Count]; dataGridView1.Rows.Add(emptyRow); } for (int col = 0; col < columns.Count; ++col) { string columnName = columns[col]; IntSchColumn columnEntries = results.GetColumn(columnName); for (int row = 0; row < results.numRows; row++) { dataGridView1.Rows[row].Cells[col].Value = columnEntries.Get(row); } } }
private void BtnExport_Click(object sender, EventArgs e) { IntSchTable tableToExport = (IntSchTable)comboBox_ExportTables.SelectedItem; SaveFileDialog savefile = new SaveFileDialog(); savefile.FileName = tableToExport.Name; savefile.Filter = "Excel Files|*.xls;*.xlsx;*.xlsm;*.csv"; savefile.DefaultExt = "csv"; savefile.CheckPathExists = true; if (savefile.ShowDialog() == DialogResult.OK) { StreamWriter streamWriter = new StreamWriter(savefile.FileName); tableToExport.WriteToStreamWriter(ref streamWriter); streamWriter.Close(); this.Close(); } else { MessageBox.Show("Failed to export table " + tableToExport.Name); } }