public AccessRange(dao.Field basedOnRange, AccessDocument rsDoc) { m_doc = rsDoc; m_field = basedOnRange; }
void ConvertTableFieldDialog_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault) #endif { #if DEBUG MessageBox.Show("ConvertTableFieldDialog_Click"); #endif dao.Database aDb = Application.CurrentDb(); if (aDb == null) { return; } dao.TableDefs aTableDefs = null; dao.TableDef aTableDef = null; dao.Recordset aRecordSet = null; try { aTableDefs = aDb.TableDefs; DbFieldSelect dlg = new DbFieldSelect(aTableDefs); if (dlg.ShowDialog() == DialogResult.OK) { aTableDef = aTableDefs[dlg.TableName]; aRecordSet = aTableDef.OpenRecordset(dao.RecordsetTypeEnum.dbOpenTable, 0); // dao.RecordsetOptionEnum.); if (!aRecordSet.Updatable) { throw new ApplicationException("Can't edit this table? Is it opened? If so, then close it and try again."); } string strTitle = String.Format("Select the Converter for the {0}.{1} field", dlg.TableName, dlg.FieldName); EncConverters aECs = GetEncConverters; if (aECs != null) { IEncConverter aIEC = aECs.AutoSelectWithTitle(ConvType.Unknown, strTitle); FontConverter aFC = new FontConverter(new DirectableEncConverter(aIEC)); OfficeDocumentProcessor aTableProcessor = new OfficeDocumentProcessor(aFC, new SILConverterProcessorForm()); AccessDocument rsDoc = new AccessDocument(aRecordSet, dlg.FieldName); // do a transaction just in case we throw an exception trying to update and the user // wants to rollback. aDb.BeginTrans(); rsDoc.ProcessWordByWord(aTableProcessor); aDb.CommitTrans((int)dao.CommitTransOptionsEnum.dbForceOSFlush); } } } catch (Exception ex) { DisplayException(ex); if (ex.Message != cstrAbortMessage) { if (MessageBox.Show("Would you like to rollback the transaction?", OfficeApp.cstrCaption, MessageBoxButtons.YesNo) == DialogResult.Yes) { aDb.Rollback(); } else { aDb.CommitTrans((int)dao.CommitTransOptionsEnum.dbForceOSFlush); } } } finally { if (aRecordSet != null) { aRecordSet.Close(); } ReleaseComObject(aRecordSet); ReleaseComObject(aTableDef); ReleaseComObject(aTableDefs); ReleaseComObject(aDb); } }
void ConvertTableFieldDialog_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault) { dao.Database aDb = (dao.Database)Application.CurrentDb(); if (aDb == null) return; dao.TableDefs aTableDefs = null; dao.TableDef aTableDef = null; dao.Recordset aRecordSet = null; try { aTableDefs = aDb.TableDefs; DbFieldSelect dlg = new DbFieldSelect(aTableDefs); if (dlg.ShowDialog() == DialogResult.OK) { aTableDef = aTableDefs[dlg.TableName]; aRecordSet = aTableDef.OpenRecordset(dao.RecordsetTypeEnum.dbOpenTable, 0); // dao.RecordsetOptionEnum.); if (!aRecordSet.Updatable) throw new ApplicationException("Can't edit this table? Is it opened? If so, then close it and try again."); string strTitle = String.Format("Select the Converter for the {0}.{1} field", dlg.TableName, dlg.FieldName); EncConverters aECs = GetEncConverters; if (aECs != null) { IEncConverter aIEC = aECs.AutoSelectWithTitle(ConvType.Unknown, strTitle); FontConverter aFC = new FontConverter(new DirectableEncConverter(aIEC)); OfficeDocumentProcessor aTableProcessor = new OfficeDocumentProcessor(aFC, new SILConverterProcessorForm()); AccessDocument rsDoc = new AccessDocument(aRecordSet, dlg.FieldName); // do a transaction just in case we throw an exception trying to update and the user // wants to rollback. aDb.BeginTrans(); rsDoc.ProcessWordByWord(aTableProcessor); aDb.CommitTrans((int)dao.CommitTransOptionsEnum.dbForceOSFlush); } } } catch (Exception ex) { DisplayException(ex); if (ex.Message != Connect.cstrAbortMessage) { if (MessageBox.Show("Would you like to rollback the transaction?", Connect.cstrCaption, MessageBoxButtons.YesNo) == DialogResult.Yes) aDb.Rollback(); else aDb.CommitTrans((int)dao.CommitTransOptionsEnum.dbForceOSFlush); } } finally { if( aRecordSet != null ) aRecordSet.Close(); ReleaseComObject(aRecordSet); ReleaseComObject(aTableDef); ReleaseComObject(aTableDefs); ReleaseComObject(aDb); } }