예제 #1
0
 public void UpdateValue(dao.Field aField, string strValue)
 {
     dao.Recordset rs = Document;
     rs.Edit();
     aField.Value = strValue;
     rs.Update((int)dao.UpdateTypeEnum.dbUpdateRegular, false);
 }
예제 #2
0
 public AccessDocument(dao.Recordset doc, string strFieldName)
     : base(doc)
 {
     m_strFieldName = strFieldName;
 }
예제 #3
0
        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);
            }
        }