/// <summary> /// Display current Room sheet information: Excel path /// </summary> private void UpdateRoomMapSheetInfo() { int hashCode = m_document.GetHashCode(); SheetInfo xlsAndTable = new SheetInfo("", ""); if (CrtlApplication.EventReactor.DocMappedSheetInfo(hashCode, ref xlsAndTable)) { roomExcelTextBox.Text = "Mapped Sheet: " + xlsAndTable.FileName + ": " + xlsAndTable.SheetName; } }
/// <summary> /// Get the sheet information of document. /// </summary> /// <param name="hashCode">The hash code of document.</param> /// <param name="sheetInfo">The mapped spread file and sheet information.</param> /// <returns>Indicates whether find the spread sheet mapped by this document. /// True if mapped spreadsheet information found, else false.</returns> public bool DocMappedSheetInfo(int hashCode, ref SheetInfo sheetInfo) { if (!DocMonitored(hashCode)) { return(false); } else { return(m_docMapDict.TryGetValue(hashCode, out sheetInfo)); } }
/// <summary> /// Update or reset the sheet information to which document is being mapped. /// </summary> /// <param name="hashCode">Hash code of document used as key to find mapped spreadsheet.</param> /// <param name="newSheetInfo">New value for spreadsheet.</param> public void UpdateSheeInfo(int hashCode, SheetInfo newSheetInfo) { if (!DocMonitored(hashCode)) { m_docMapDict.Add(hashCode, newSheetInfo); } else { m_docMapDict.Remove(hashCode); m_docMapDict.Add(hashCode, newSheetInfo); } }
/// <summary> /// Import room spread sheet and display them in form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void importRoomButton_Click(object sender, EventArgs e) { using (OpenFileDialog sfdlg = new OpenFileDialog()) { // file dialog initialization sfdlg.Title = "Import Excel File"; sfdlg.Filter = "Excel File(*.xls)|*.xls"; sfdlg.RestoreDirectory = true; // // initialize the default file name int hashCode = m_document.GetHashCode(); SheetInfo xlsAndTable = new SheetInfo(String.Empty, String.Empty); if (CrtlApplication.EventReactor.DocMappedSheetInfo(hashCode, ref xlsAndTable)) { sfdlg.FileName = xlsAndTable.FileName; } // // import the select if (DialogResult.OK == sfdlg.ShowDialog()) { try { // create xls data source connector and retrieve data from it m_dataBaseName = sfdlg.FileName; XlsDBConnector xlsCon = new XlsDBConnector(m_dataBaseName); // bind table data to grid view and ComboBox control tablesComboBox.DataSource = xlsCon.RetrieveAllTables(); // close the connection xlsCon.Dispose(); } catch (Exception ex) { tablesComboBox.DataSource = null; MyMessageBox(ex.Message, MessageBoxIcon.Warning); } } } }
/// <summary> /// Update or reset the sheet information to which document is being mapped. /// </summary> /// <param name="hashCode">Hash code of document used as key to find mapped spreadsheet.</param> /// <param name="newSheetInfo">New value for spreadsheet.</param> public void UpdateSheeInfo(int hashCode, SheetInfo newSheetInfo) { if(!DocMonitored(hashCode)) { m_docMapDict.Add(hashCode, newSheetInfo); } else { m_docMapDict.Remove(hashCode); m_docMapDict.Add(hashCode, newSheetInfo); } }
/// <summary> /// Get the sheet information of document. /// </summary> /// <param name="hashCode">The hash code of document.</param> /// <param name="sheetInfo">The mapped spread file and sheet information.</param> /// <returns>Indicates whether find the spread sheet mapped by this document. /// True if mapped spreadsheet information found, else false.</returns> public bool DocMappedSheetInfo(int hashCode, ref SheetInfo sheetInfo) { if(!DocMonitored(hashCode)) { return false; } else { return m_docMapDict.TryGetValue(hashCode, out sheetInfo); } }