public GenDataTable ( String tableName ) : |
||
tableName | String | Table name to be retrieved |
return |
/// <summary> /// Select one table(work sheet) and display its data to DataGridView control. /// after selection, generate data table from data source /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tablesComboBox_SelectedIndexChanged(object sender, EventArgs e) { // update spread sheet based rooms sheetDataGridView.DataSource = null; m_roomTableName = tablesComboBox.SelectedValue as String; XlsDBConnector xlsCon = null; try { if (null != m_spreadRoomsTable) { m_spreadRoomsTable.Clear(); } // get all rooms table then close this connection immediately xlsCon = new XlsDBConnector(m_dataBaseName); // generate room data table from room work sheet. m_spreadRoomsTable = xlsCon.GenDataTable(m_roomTableName); newRoomButton.Enabled = (0 == m_spreadRoomsTable.Rows.Count) ? false : true; // close connection xlsCon.Dispose(); // update data source of DataGridView sheetDataGridView.DataSource = new DataView(m_spreadRoomsTable); } catch (Exception ex) { // close connection and update data source xlsCon.Dispose(); sheetDataGridView.DataSource = null; MyMessageBox(ex.Message, MessageBoxIcon.Warning); return; } // update the static s_DocMapDict variable when user changes the Excel and room table int hashCode = m_document.GetHashCode(); if (CrtlApplication.EventReactor.DocMonitored(hashCode)) { // update spread sheet to which document is being mapped. CrtlApplication.EventReactor.UpdateSheeInfo(hashCode, new SheetInfo(m_dataBaseName, m_roomTableName)); // update current mapped room sheet information, only show this when Revit rooms were mapped to Excel sheet. UpdateRoomMapSheetInfo(); } }
/// <summary> /// Select one table(work sheet) and display its data to DataGridView control. /// after selection, generate data table from data source /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tablesComboBox_SelectedIndexChanged(object sender, EventArgs e) { // update spread sheet based rooms sheetDataGridView.DataSource = null; m_roomTableName = tablesComboBox.SelectedValue as String; XlsDBConnector xlsCon = null; try { if (null != m_spreadRoomsTable) { m_spreadRoomsTable.Clear(); } // get all rooms table then close this connection immediately xlsCon = new XlsDBConnector(m_dataBaseName); // generate room data table from room work sheet. m_spreadRoomsTable = xlsCon.GenDataTable(m_roomTableName); newRoomButton.Enabled = (0 == m_spreadRoomsTable.Rows.Count) ? false : true; // close connection xlsCon.Dispose(); // update data source of DataGridView sheetDataGridView.DataSource = new DataView(m_spreadRoomsTable); } catch (Exception ex) { // close connection and update data source xlsCon.Dispose(); sheetDataGridView.DataSource = null; MyMessageBox(ex.Message, MessageBoxIcon.Warning); return; } // update the static s_DocMapDict variable when user changes the Excel and room table int hashCode = m_document.GetHashCode(); if (CrtlApplication.EventReactor.DocMonitored(hashCode)) { // update spread sheet to which document is being mapped. CrtlApplication.EventReactor.UpdateSheeInfo(hashCode, new SheetInfo(m_dataBaseName, m_roomTableName)); // update current mapped room sheet information, only show this when Revit rooms were mapped to Excel sheet. UpdateRoomMapSheetInfo(); } }