private void ImportHierarchy(object sender, EventArgs e) { // TODO: open file; only will work if there are no GLM records and transactions yet XmlDocument doc = TImportExportDialogs.ImportWithDialog(Catalog.GetString("Load Cost Centre Hierarchy from file")); if (doc == null) { // import was cancelled return; } TVerificationResultCollection VerificationResultCol; if (!TRemote.MFinance.Setup.WebConnectors.ImportCostCentreHierarchy(FLedgerNumber, TXMLParser.XmlToString(doc), out VerificationResultCol)) { MessageBox.Show(VerificationResultCol.BuildVerificationResultString(), Catalog.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // refresh the screen FMainDS = TRemote.MFinance.Setup.WebConnectors.LoadCostCentreHierarchy(FLedgerNumber); ucoCostCentreTree.PopulateTreeView(FMainDS); MessageBox.Show("Import of new Cost Centre Hierarchy has been successful", Catalog.GetString("Success"), MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// this function allows to store the content of the whole database /// as a text file, and import it somewhere else, across database types etc /// </summary> /// <param name="AParentForm"></param> public static void ExportAllData(Form AParentForm) { MessageBox.Show(Catalog.GetString("This may take a while. Please just wait!")); string zippedYml = TRemote.MSysMan.ImportExport.WebConnectors.ExportAllTables(); TImportExportDialogs.ExportWithDialogYMLGz(zippedYml, Catalog.GetString("Save Database into File")); }
private void ExportHierarchy(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); doc.LoadXml(TRemote.MFinance.Setup.WebConnectors.ExportAccountHierarchy(FLedgerNumber, FSelectedHierarchy)); TImportExportDialogs.ExportWithDialog(doc, Catalog.GetString("Save Account Hierarchy to file")); }
/// <summary> /// this will delete the current database, and reset it with the data selected /// </summary> /// <param name="AParentForm"></param> public static void RestoreDatabase(Form AParentForm) { string StrImportCancelledMsg = Catalog.GetString("Restoring of database got cancelled; no existing data has been deleted or modified!"); string StrImportCancelledTitle = Catalog.GetString("Restore Cancelled"); DialogResult r = MessageBox.Show( Catalog.GetString( "WARNING: This will THROW AWAY ALL CURRENT DATA that is held in the database (including the users and passwords!) and replace it with the data that was previously backed up and which you chose to restore!\r\n\r\nDo you REALLY want to restore that data?"), Catalog.GetString("WARNING: Replace All Data With Previously Backed Up Data?"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (r == DialogResult.Yes) { string zippedYml = TImportExportDialogs.ImportWithDialogYMLGz(Catalog.GetString("Select Backup File to Restore From")); if (zippedYml != null) { Thread ResetDBThread = new Thread(() => ResetDatabaseInThread(zippedYml)); using (TProgressDialog dialog = new TProgressDialog(ResetDBThread)) { if (dialog.ShowDialog() == DialogResult.Cancel) { MessageBox.Show(StrImportCancelledMsg, StrImportCancelledTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } // Ensure that WebConnectorResult got set in Method 'ResetDatabaseInThread' before we get to the if statement below... ResetDBThread.Join(); if (WebConnectorResult) { // TODO: reset all caches? for comboboxes etc MessageBox.Show(Catalog.GetString( "The data was successfully restored.\r\n\r\nPlease restart your OpenPetra Client immediately!"), Catalog.GetString("Restore Successful"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(Catalog.GetString("The restoring of the data FAILED. No existing data has been deleted or modified!\r\n\r\n" + "Please check the Server.log file on the server for errors!"), Catalog.GetString("Restore Failed"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(StrImportCancelledMsg, StrImportCancelledTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// Exports a single Partner. /// </summary> /// <param name="APartnerKey">Partner Key of the Partner.</param> /// <param name="APartnerClass">Class of partner for the specified key</param> /// <param name="ASiteKey">SiteKey of the Location.</param> /// <param name="ALocationKey">LocationKey of the Location.</param> /// <param name="AOldPetraFormat">Set to true if old format should be used.</param> public static void ExportSinglePartner(Int64 APartnerKey, String APartnerClass, Int64 ASiteKey, int ALocationKey, Boolean AOldPetraFormat) { bool Result = false; String ExtFormattedDocument; String PartnerShortName; TPartnerClass PartnerClass; // prepare suggestion for file name: Partner short name TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetPartnerShortName(APartnerKey, out PartnerShortName, out PartnerClass); PartnerShortName = "p_" + PartnerShortName; string FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File"), PartnerShortName); if (FileName.Length > 0) { if (FileName.EndsWith("ext")) { bool ExportFamiliesPersons = false; if (string.Compare(APartnerClass, TPartnerClass.FAMILY.ToString(), true) == 0) { if (MessageBox.Show( Catalog.GetString("Do you want to also export all PERSON records associated with this FAMILY?"), Catalog.GetString("Export Partner"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ExportFamiliesPersons = true; } } ExtFormattedDocument = TRemote.MPartner.ImportExport.WebConnectors.ExportSinglePartnerExt(APartnerKey, ExportFamiliesPersons, AOldPetraFormat); Result = TImportExportDialogs.ExportTofile(ExtFormattedDocument, FileName, AOldPetraFormat); if (!Result) { MessageBox.Show(Catalog.GetString("Export of Partner failed!"), Catalog.GetString( "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(Catalog.GetString("Export of Partner finished"), Catalog.GetString( "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString( "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void ExportHierarchy(object sender, EventArgs e) { if (FPetraUtilsObject.HasChanges) { MessageBox.Show(Catalog.GetString("Save changes before exporting."), Catalog.GetString( "Export Hierarchy"), MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } XmlDocument doc = new XmlDocument(); doc.LoadXml(TRemote.MFinance.Setup.WebConnectors.ExportCostCentreHierarchy(FLedgerNumber)); TImportExportDialogs.ExportWithDialog(doc, Catalog.GetString("Save Cost Centre Hierarchy to file")); }
/// export partners into file public static void ExportPartners(Form AParentForm) { String FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File")); if (FileName.Length > 0) { if (FileName.EndsWith("ext")) { String doc = TRemote.MPartner.ImportExport.WebConnectors.ExportAllPartnersExt(); TImportExportDialogs.ExportTofile(doc, FileName); } else { XmlDocument doc = new XmlDocument(); doc.LoadXml(TRemote.MPartner.ImportExport.WebConnectors.ExportPartners()); TImportExportDialogs.ExportTofile(doc, FileName); } } }
/// <summary> /// export all partners in selected extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> public bool ExportPartnersInExtract(System.Object sender, EventArgs e) { Boolean Result = false; if (!WarnIfNotSingleSelection(Catalog.GetString("Export Partners in Extract")) && (GetSelectedDetailRow() != null)) { String FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File")); if (FileName.Length > 0) { if (FileName.EndsWith("ext")) { String doc = TRemote.MPartner.ImportExport.WebConnectors.ExportExtractPartnersExt(GetSelectedDetailRow().ExtractId, false); Result = TImportExportDialogs.ExportTofile(doc, FileName); if (!Result) { MessageBox.Show(Catalog.GetString("Export of Partners in Extract failed!"), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(Catalog.GetString("Export of Partners in Extract finished"), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { // XmlDocument doc = new XmlDocument(); MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error); // doc.LoadXml(TRemote.MPartner.ImportExport.WebConnectors.ExportExtractPartners(GetSelectedDetailRow().ExtractId, false)); // Result = TImportExportDialogs.ExportTofile(doc, FileName); } } return(Result); } return(false); }
/// <summary> /// Exports a single Partner. /// </summary> /// <param name="APartnerKey">Partner Key of the Partner.</param> /// <param name="ASiteKey">SiteKey of the Location.</param> /// <param name="ALocationKey">LocationKey of the Location.</param> public static void ExportSinglePartner(Int64 APartnerKey, Int64 ASiteKey, int ALocationKey) { bool Result = false; StringCollection ASpecificBuildingInfo = null; String ExtFormattedDocument; string FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File")); if (FileName.Length > 0) { if (FileName.EndsWith("ext")) { ExtFormattedDocument = TRemote.MPartner.ImportExport.WebConnectors.GetExtFileHeader(); ExtFormattedDocument += TRemote.MPartner.ImportExport.WebConnectors.ExportPartnerExt( APartnerKey, ASiteKey, ALocationKey, false, ASpecificBuildingInfo); ExtFormattedDocument += TRemote.MPartner.ImportExport.WebConnectors.GetExtFileFooter(); Result = TImportExportDialogs.ExportTofile(ExtFormattedDocument, FileName); if (!Result) { MessageBox.Show(Catalog.GetString("Export of Partner failed!"), Catalog.GetString( "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(Catalog.GetString("Export of Partner finished"), Catalog.GetString( "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString( "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void ImportHierarchy(object sender, EventArgs e) { // TODO: open file; only will work if there are no GLM records and transactions yet XmlDocument doc; try { doc = TImportExportDialogs.ImportWithDialog(Catalog.GetString("Load Account Hierarchy from file")); } catch (Exception ex) { MessageBox.Show(ex.Message, Catalog.GetString("Load Account Hierarchy from file"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (doc == null) { // was cancelled return; } if (!TRemote.MFinance.Setup.WebConnectors.ImportAccountHierarchy(FLedgerNumber, FSelectedHierarchy, TXMLParser.XmlToString(doc))) { MessageBox.Show(Catalog.GetString( "Import of new Account Hierarchy failed; perhaps there were already balances? Try with a new ledger!"), Catalog.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // refresh the screen FMainDS.Clear(); FMainDS.Merge(TRemote.MFinance.Setup.WebConnectors.LoadAccountHierarchies(FLedgerNumber)); ucoAccountsTree.PopulateTreeView(FMainDS, FLedgerNumber, FSelectedHierarchy); MessageBox.Show("Import of new Account Hierarchy has been successful", Catalog.GetString("Success"), MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// this will delete the current database, and reset it with the data selected /// </summary> /// <param name="AParentForm"></param> public static void ImportAllData(Form AParentForm) { DialogResult r = MessageBox.Show( Catalog.GetString("WARNING: this will reset the database! Do you really want to delete the current database?"), Catalog.GetString("WARNING: this will reset the database!"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (r == DialogResult.Yes) { string zippedYml = TImportExportDialogs.ImportWithDialogYMLGz(Catalog.GetString("Please select the file to import from")); if (zippedYml != null) { Thread t = new Thread(() => ResetDatabaseInThread(zippedYml)); using (TProgressDialog dialog = new TProgressDialog(t)) { if (dialog.ShowDialog() == DialogResult.Cancel) { return; } } if (WebConnectorResult) { // TODO: reset all caches? for comboboxes etc MessageBox.Show(Catalog.GetString("Import of database was successful. Please restart your OpenPetra client")); } else { MessageBox.Show(Catalog.GetString("Failed import of database. Please check the Server.log file on the server")); } } } }
/// <summary> /// Import a transactions file or a clipboard equivalent /// </summary> /// <param name="ACurrentBatchRow">The batch to import to</param> /// <param name="AImportSource">The import source - eg File or Clipboard</param> /// <returns>True if the import was successful</returns> public bool ImportTransactions(AGiftBatchRow ACurrentBatchRow, TGiftImportDataSourceEnum AImportSource) { bool ok = false; bool RefreshGUIAfterImport = false; OpenFileDialog dialog = null; Boolean IsPlainText = false; if (FPetraUtilsObject.HasChanges) { // saving failed, therefore do not try to import MessageBox.Show(Catalog.GetString("Please save any changes before calling this function!"), Catalog.GetString( "Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if ((ACurrentBatchRow == null) || (ACurrentBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED)) { MessageBox.Show(Catalog.GetString("Please select an unposted batch to import transactions."), Catalog.GetString( "Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (ACurrentBatchRow.LastGiftNumber > 0) { if (MessageBox.Show(Catalog.GetString( "The current batch already contains some gift transactions. Do you really want to add more transactions to this batch?"), Catalog.GetString("Gift Transaction Import"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return(false); } } FdlgSeparator = new TDlgSelectCSVSeparator(false); FdlgSeparator.DateMayBeInteger = TUserDefaults.GetBooleanDefault(MCommonConstants.USERDEFAULT_IMPORTEDDATESMAYBEINTEGERS, false); if (AImportSource == TGiftImportDataSourceEnum.FromClipboard) { string importString = Clipboard.GetText(TextDataFormat.UnicodeText); if ((importString == null) || (importString.Length == 0)) { MessageBox.Show(Catalog.GetString("Please first copy data from your spreadsheet application!"), Catalog.GetString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } FdlgSeparator.CSVData = importString; } else if (AImportSource == TGiftImportDataSourceEnum.FromFile) { dialog = new OpenFileDialog(); string exportPath = TClientSettings.GetExportPath(); string fullPath = TUserDefaults.GetStringDefault("Imp Filename", exportPath + Path.DirectorySeparatorChar + "import.csv"); TImportExportDialogs.SetOpenFileDialogFilePathAndName(dialog, fullPath, exportPath); dialog.Title = Catalog.GetString("Import Transactions from CSV File"); dialog.Filter = Catalog.GetString("Gift Transactions files (*.csv)|*.csv|Text Files (*.txt)|*.txt"); // This call fixes Windows7 Open File Dialogs. It must be the line before ShowDialog() TWin7FileOpenSaveDialog.PrepareDialog(Path.GetFileName(fullPath)); if (dialog.ShowDialog() == DialogResult.OK) { Boolean fileCanOpen = FdlgSeparator.OpenCsvFile(dialog.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } IsPlainText = (Path.GetExtension(dialog.FileName).ToLower() == ".txt"); } else { return(false); } } else { // unknown source!! The following need a value... return(false); } String impOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator.DateFormat = dateFormatString; FdlgSeparator.NumberFormat = (impOptions.Length > 1) ? impOptions.Substring(1) : TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN; FdlgSeparator.SelectedSeparator = StringHelper.GetCSVSeparator(FdlgSeparator.FileContent) ?? ((impOptions.Length > 0) ? impOptions.Substring(0, 1) : ";"); if (IsPlainText || (FdlgSeparator.ShowDialog() == DialogResult.OK)) { Hashtable requestParams = new Hashtable(); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("Delimiter", FdlgSeparator.SelectedSeparator); requestParams.Add("DateFormatString", FdlgSeparator.DateFormat); requestParams.Add("NumberFormat", FdlgSeparator.NumberFormat); requestParams.Add("NewLine", Environment.NewLine); bool Repeat = true; while (Repeat) { Repeat = false; TVerificationResultCollection AMessages = new TVerificationResultCollection(); GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber = new GiftBatchTDSAGiftDetailTable(); Thread ImportThread = new Thread(() => ImportGiftTransactions( requestParams, FdlgSeparator.FileContent, ACurrentBatchRow.BatchNumber, out AMessages, out ok, out RefreshGUIAfterImport, out NeedRecipientLedgerNumber)); using (TProgressDialog ImportDialog = new TProgressDialog(ImportThread)) { ImportDialog.ShowDialog(); } // if the import contains gifts with Motivation Group 'GIFT' and that have a Family recipient with no Gift Destination // then the import will have failed and we need to alert the user int numberOfMissingGiftDestinations = NeedRecipientLedgerNumber.Rows.Count; if (numberOfMissingGiftDestinations == 0) { if (TVerificationHelper.ResultsContainErrorCode(AMessages, PetraErrorCodes.ERR_DB_SERIALIZATION_EXCEPTION)) { TConcurrentServerTransactions.ShowTransactionSerializationExceptionDialog(); } else { ShowMessages(AMessages); } } if (numberOfMissingGiftDestinations > 0) { bool offerToRunImportAgain = true; int currentMissingGiftDestinationNo = 1; // for each gift in which the recipient needs a Git Destination foreach (GiftBatchTDSAGiftDetailRow Row in NeedRecipientLedgerNumber.Rows) { //Lookup the partner shortname string partnerShortName = string.Empty; TPartnerClass partnerClass; if (TServerLookup.TMPartner.GetPartnerShortName(Row.RecipientKey, out partnerShortName, out partnerClass)) { Row.RecipientDescription = partnerShortName; } if (MessageBox.Show(string.Format( Catalog.GetString( "Error: {0:0000} of {1:0000} - Recipient '{2}' ({3}) has no Gift Destination assigned."), currentMissingGiftDestinationNo, numberOfMissingGiftDestinations, Row.RecipientDescription, Row.RecipientKey) + "\n\n" + Catalog.GetString("Do you want to assign a Gift Destination to this partner now?"), Catalog.GetString("Gift Import Cancelled"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { // allow the user to assign a Gift Destingation TFrmGiftDestination GiftDestinationForm = new TFrmGiftDestination(FPetraUtilsObject.GetForm(), Row.RecipientKey); GiftDestinationForm.ShowDialog(); } else { offerToRunImportAgain = false; } currentMissingGiftDestinationNo++; } // if the user has clicked yes to assigning Gift Destinations then offer to restart the import if (offerToRunImportAgain && (MessageBox.Show(Catalog.GetString("Would you like to import these Gift Transactions again?"), Catalog.GetString("Gift Import"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)) { Repeat = true; } } } } // We save the defaults even if ok is false - because the client will probably want to try and import // the same file again after correcting any errors if (!IsPlainText) { SaveUserDefaults(dialog); } if (ok) { MessageBox.Show(Catalog.GetString("Your data was imported successfully!"), Catalog.GetString("Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Information); } if (ok || RefreshGUIAfterImport) { FMyUserControl.LoadBatchesForCurrentYear(); FPetraUtilsObject.DisableSaveButton(); return(true); // This completes the refresh } return(false); }
/// <summary> /// this supports the batch export files from Petra 2.x. /// Each line starts with a type specifier, B for batch, J for journal, T for transaction /// </summary> public void ImportBatches(TGiftImportDataSourceEnum AImportSource) { bool ok = false; String importString; String impOptions; OpenFileDialog dialog = null; if (FPetraUtilsObject.HasChanges) { // saving failed, therefore do not try to post MessageBox.Show(Catalog.GetString("Please save before calling this function!"), Catalog.GetString( "Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FdlgSeparator = new TDlgSelectCSVSeparator(false); if (AImportSource == TGiftImportDataSourceEnum.FromClipboard) { importString = Clipboard.GetText(TextDataFormat.UnicodeText); if ((importString == null) || (importString.Length == 0)) { MessageBox.Show(Catalog.GetString("Please first copy data from your spreadsheet application!"), Catalog.GetString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } impOptions = TUserDefaults.GetStringDefault("Imp Options", ";American"); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator = new TDlgSelectCSVSeparator(false); FdlgSeparator.SelectedSeparator = "\t"; FdlgSeparator.CSVData = importString; FdlgSeparator.DateFormat = dateFormatString; if (impOptions.Length > 1) { FdlgSeparator.NumberFormat = impOptions.Substring(1); } } else if (AImportSource == TGiftImportDataSourceEnum.FromFile) { dialog = new OpenFileDialog(); string exportPath = TClientSettings.GetExportPath(); string fullPath = TUserDefaults.GetStringDefault("Imp Filename", exportPath + Path.DirectorySeparatorChar + "import.csv"); TImportExportDialogs.SetOpenFileDialogFilePathAndName(dialog, fullPath, exportPath); dialog.Title = Catalog.GetString("Import Batches from CSV File"); dialog.Filter = Catalog.GetString("Gift Batches files (*.csv)|*.csv"); impOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); // This call fixes Windows7 Open File Dialogs. It must be the line before ShowDialog() TWin7FileOpenSaveDialog.PrepareDialog(Path.GetFileName(fullPath)); if (dialog.ShowDialog() == DialogResult.OK) { Boolean fileCanOpen = FdlgSeparator.OpenCsvFile(dialog.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } importString = File.ReadAllText(dialog.FileName, Encoding.Default); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator.DateFormat = dateFormatString; if (impOptions.Length > 1) { FdlgSeparator.NumberFormat = impOptions.Substring(1); } FdlgSeparator.SelectedSeparator = impOptions.Substring(0, 1); } else { return; } } else { // unknown source!! The following need a value... impOptions = String.Empty; importString = String.Empty; } if (FdlgSeparator.ShowDialog() == DialogResult.OK) { Hashtable requestParams = new Hashtable(); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("Delimiter", FdlgSeparator.SelectedSeparator); requestParams.Add("DateFormatString", FdlgSeparator.DateFormat); requestParams.Add("NumberFormat", FdlgSeparator.NumberFormat); requestParams.Add("NewLine", Environment.NewLine); bool Repeat = true; while (Repeat) { Repeat = false; TVerificationResultCollection AMessages = new TVerificationResultCollection(); GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber = new GiftBatchTDSAGiftDetailTable(); Thread ImportThread = new Thread(() => ImportGiftBatches( requestParams, importString, out AMessages, out ok, out NeedRecipientLedgerNumber)); using (TProgressDialog ImportDialog = new TProgressDialog(ImportThread)) { ImportDialog.ShowDialog(); } // If NeedRecipientLedgerNumber contains data then AMessages will only ever contain // one message alerting the user that no data has been imported. // We do not want to show this as we will be displaying another more detailed message. if (NeedRecipientLedgerNumber.Rows.Count == 0) { ShowMessages(AMessages); } // if the import contains gifts with Motivation Group 'GIFT' and that have a Family recipient with no Gift Destination // then the import will have failed and we need to alert the user if (NeedRecipientLedgerNumber.Rows.Count > 0) { bool OfferToRunImportAgain = true; bool DoNotShowMessageBoxEverytime = false; TFrmExtendedMessageBox.TResult Result = TFrmExtendedMessageBox.TResult.embrUndefined; int count = 1; // for each gift in which the recipient needs a Git Destination foreach (GiftBatchTDSAGiftDetailRow Row in NeedRecipientLedgerNumber.Rows) { if (!DoNotShowMessageBoxEverytime) { string CheckboxText = string.Empty; // only show checkbox if there is at least one more occurance of this error if (NeedRecipientLedgerNumber.Rows.Count - count > 0) { CheckboxText = string.Format( Catalog.GetString("Do this for all further occurances ({0})?"), NeedRecipientLedgerNumber.Rows.Count - count); } TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(FPetraUtilsObject.GetForm()); extendedMessageBox.ShowDialog(string.Format( Catalog.GetString( "Gift Import has been cancelled as the recipient '{0}' ({1}) has no Gift Destination assigned."), Row.RecipientDescription, Row.RecipientKey) + "\n\r\n\r\n\r" + Catalog.GetString("Do you want to assign a Gift Destination to this partner now?"), Catalog.GetString("Import Errors"), CheckboxText, TFrmExtendedMessageBox.TButtons.embbYesNo, TFrmExtendedMessageBox.TIcon.embiWarning); Result = extendedMessageBox.GetResult(out DoNotShowMessageBoxEverytime); } if (Result == TFrmExtendedMessageBox.TResult.embrYes) { // allow the user to assign a Gift Destingation TFrmGiftDestination GiftDestinationForm = new TFrmGiftDestination(FPetraUtilsObject.GetForm(), Row.RecipientKey); GiftDestinationForm.ShowDialog(); } else { OfferToRunImportAgain = false; if (DoNotShowMessageBoxEverytime) { break; } } count++; } // if the user has clicked yes to assigning Gift Destinations then offer to restart the import if (OfferToRunImportAgain && (MessageBox.Show(Catalog.GetString("Would you like to import this Gift Batch again?"), Catalog.GetString("Gift Import"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)) { Repeat = true; } } } // We save the defaults even if ok is false - because the client will probably want to try and import // the same file again after correcting any errors SaveUserDefaults(dialog, impOptions); } if (ok) { MessageBox.Show(Catalog.GetString("Your data was imported successfully!"), Catalog.GetString("Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Information); FMyUserControl.LoadBatchesForCurrentYear(); FPetraUtilsObject.DisableSaveButton(); } }
/// <summary> /// this supports the batch export files from Petra 2.x. /// Each line starts with a type specifier, B for batch, J for journal, T for transaction /// The code handles importing from file or clipboard /// </summary> public void ImportBatches(TImportDataSourceEnum AImportDataSource) { bool ok = false; bool RefreshGUIAfterImport = false; OpenFileDialog dialog = null; if (FPetraUtilsObject.HasChanges) { // saving failed, therefore do not try to import MessageBox.Show(Catalog.GetString("Please save before calling this function!"), Catalog.GetString( "Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { FMyForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.IMPORTING; bool datesMayBeIntegers = TUserDefaults.GetBooleanDefault(MCommonConstants.USERDEFAULT_IMPORTEDDATESMAYBEINTEGERS, false); FdlgSeparator = new TDlgSelectCSVSeparator(false); FdlgSeparator.DateMayBeInteger = datesMayBeIntegers; if (AImportDataSource == TImportDataSourceEnum.FromClipboard) { string importString = Clipboard.GetText(TextDataFormat.UnicodeText); if ((importString == null) || (importString.Length == 0)) { MessageBox.Show(Catalog.GetString("Please first copy data from your spreadsheet application!"), Catalog.GetString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FdlgSeparator.CSVData = importString; } else if (AImportDataSource == TImportDataSourceEnum.FromFile) { dialog = new OpenFileDialog(); string exportPath = TClientSettings.GetExportPath(); string fullPath = TUserDefaults.GetStringDefault("Imp Filename", exportPath + Path.DirectorySeparatorChar + "import.csv"); TImportExportDialogs.SetOpenFileDialogFilePathAndName(dialog, fullPath, exportPath); dialog.Title = Catalog.GetString("Import Batches from CSV File"); dialog.Filter = Catalog.GetString("GL Batch Files (*.csv)|*.csv|Text Files (*.txt)|*.txt"); // This call fixes Windows7 Open File Dialogs. It must be the line before ShowDialog() TWin7FileOpenSaveDialog.PrepareDialog(Path.GetFileName(fullPath)); if (dialog.ShowDialog() == DialogResult.OK) { Boolean fileCanOpen = FdlgSeparator.OpenCsvFile(dialog.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Batch Import"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } else { return; } } else { // unknown source!! return; } String impOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator.DateFormat = dateFormatString; FdlgSeparator.NumberFormat = (impOptions.Length > 1) ? impOptions.Substring(1) : TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN; FdlgSeparator.SelectedSeparator = StringHelper.GetCSVSeparator(FdlgSeparator.FileContent) ?? ((impOptions.Length > 0) ? impOptions.Substring(0, 1) : ";"); if (FdlgSeparator.ShowDialog() == DialogResult.OK) { Hashtable requestParams = new Hashtable(); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("Delimiter", FdlgSeparator.SelectedSeparator); requestParams.Add("DateFormatString", FdlgSeparator.DateFormat); requestParams.Add("DatesMayBeIntegers", datesMayBeIntegers); requestParams.Add("NumberFormat", FdlgSeparator.NumberFormat); requestParams.Add("NewLine", Environment.NewLine); TVerificationResultCollection AMessages = new TVerificationResultCollection(); Thread ImportThread = new Thread(() => ImportGLBatches( requestParams, FdlgSeparator.FileContent, out AMessages, out ok, out RefreshGUIAfterImport)); using (TProgressDialog ImportDialog = new TProgressDialog(ImportThread)) { ImportDialog.ShowDialog(); } if (TVerificationHelper.ResultsContainErrorCode(AMessages, PetraErrorCodes.ERR_DB_SERIALIZATION_EXCEPTION)) { TConcurrentServerTransactions.ShowTransactionSerializationExceptionDialog(); } else { ShowMessages(AMessages); } } // We save the defaults even if ok is false - because the client will probably want to try and import // the same file again after correcting any errors SaveUserDefaults(dialog); if (ok) { MessageBox.Show(Catalog.GetString("Your data was imported successfully!"), Catalog.GetString("Batch Import"), MessageBoxButtons.OK, MessageBoxIcon.Information); } if (ok) { FMyUserControl.ReloadBatches(); FMyForm.GetBatchControl().SelectRowInGrid(1); FPetraUtilsObject.SetChangedFlag(); FMyForm.SaveChangesManual(FMyForm.FCurrentGLBatchAction); } else if (RefreshGUIAfterImport) { // The import failed and the server needs us to refresh the GUI FMyUserControl.ReloadBatches(true); FMyForm.GetBatchControl().SelectRowInGrid(1); } } finally { FMyForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE; } }
/// <summary> /// Import a transactions file or a clipboard equivalent /// </summary> /// <param name="ACurrentBatchRow">The batch to import to</param> /// <param name="AImportSource">The import source - eg File or Clipboard</param> /// <returns>True if the import was successful</returns> public bool ImportTransactions(AGiftBatchRow ACurrentBatchRow, TGiftImportDataSourceEnum AImportSource) { bool ok = false; String importString; String impOptions; OpenFileDialog dialog = null; Boolean IsPlainText = false; if (FPetraUtilsObject.HasChanges) { // saving failed, therefore do not try to import MessageBox.Show(Catalog.GetString("Please save before calling this function!"), Catalog.GetString( "Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if ((ACurrentBatchRow == null) || (ACurrentBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED)) { MessageBox.Show(Catalog.GetString("Please select an unposted batch to import transactions."), Catalog.GetString( "Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (ACurrentBatchRow.LastGiftNumber > 0) { if (MessageBox.Show(Catalog.GetString( "The current batch already contains some gift transactions. Do you really want to add more transactions to this batch?"), Catalog.GetString("Gift Transaction Import"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return(false); } } FdlgSeparator = new TDlgSelectCSVSeparator(false); if (AImportSource == TGiftImportDataSourceEnum.FromClipboard) { importString = Clipboard.GetText(TextDataFormat.UnicodeText); if ((importString == null) || (importString.Length == 0)) { MessageBox.Show(Catalog.GetString("Please first copy data from your spreadsheet application!"), Catalog.GetString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } impOptions = TUserDefaults.GetStringDefault("Imp Options", ";American"); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator = new TDlgSelectCSVSeparator(false); FdlgSeparator.SelectedSeparator = "\t"; FdlgSeparator.CSVData = importString; FdlgSeparator.DateFormat = dateFormatString; if (impOptions.Length > 1) { FdlgSeparator.NumberFormat = impOptions.Substring(1); } } else if (AImportSource == TGiftImportDataSourceEnum.FromFile) { dialog = new OpenFileDialog(); string exportPath = TClientSettings.GetExportPath(); string fullPath = TUserDefaults.GetStringDefault("Imp Filename", exportPath + Path.DirectorySeparatorChar + "import.csv"); TImportExportDialogs.SetOpenFileDialogFilePathAndName(dialog, fullPath, exportPath); dialog.Title = Catalog.GetString("Import Transactions from CSV File"); dialog.Filter = Catalog.GetString("Gift Transactions files (*.csv)|*.csv|Text Files (*.txt)|*.txt"); impOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); // This call fixes Windows7 Open File Dialogs. It must be the line before ShowDialog() TWin7FileOpenSaveDialog.PrepareDialog(Path.GetFileName(fullPath)); if (dialog.ShowDialog() == DialogResult.OK) { Boolean fileCanOpen = FdlgSeparator.OpenCsvFile(dialog.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } importString = File.ReadAllText(dialog.FileName, Encoding.Default); IsPlainText = (Path.GetExtension(dialog.FileName).ToLower() == ".txt"); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator.DateFormat = dateFormatString; if (impOptions.Length > 1) { FdlgSeparator.NumberFormat = impOptions.Substring(1); } FdlgSeparator.SelectedSeparator = impOptions.Substring(0, 1); } else { return(false); } } else { // unknown source!! The following need a value... impOptions = String.Empty; importString = String.Empty; } if (IsPlainText || (FdlgSeparator.ShowDialog() == DialogResult.OK)) { Hashtable requestParams = new Hashtable(); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("Delimiter", FdlgSeparator.SelectedSeparator); requestParams.Add("DateFormatString", FdlgSeparator.DateFormat); requestParams.Add("NumberFormat", FdlgSeparator.NumberFormat); requestParams.Add("NewLine", Environment.NewLine); bool Repeat = true; while (Repeat) { Repeat = false; TVerificationResultCollection AMessages = new TVerificationResultCollection(); GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber = new GiftBatchTDSAGiftDetailTable(); Thread ImportThread = new Thread(() => ImportGiftTransactions( requestParams, importString, ACurrentBatchRow.BatchNumber, out AMessages, out ok, out NeedRecipientLedgerNumber)); using (TProgressDialog ImportDialog = new TProgressDialog(ImportThread)) { ImportDialog.ShowDialog(); } ShowMessages(AMessages); // if the import contains gifts with Motivation Group 'GIFT' and that have a Family recipient with no Gift Destination // then the import will have failed and we need to alert the user if (NeedRecipientLedgerNumber.Rows.Count > 0) { bool OfferToRunImportAgain = true; // for each gift in which the recipient needs a Git Destination foreach (GiftBatchTDSAGiftDetailRow Row in NeedRecipientLedgerNumber.Rows) { if (MessageBox.Show(string.Format( Catalog.GetString( "Gift Import has been cancelled as the recipient '{0}' ({1}) has no Gift Destination assigned."), Row.RecipientDescription, Row.RecipientKey) + "\n\n" + Catalog.GetString("Do you want to assign a Gift Destination to this partner now?"), Catalog.GetString("Gift Import"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { // allow the user to assign a Gift Destingation TFrmGiftDestination GiftDestinationForm = new TFrmGiftDestination(FPetraUtilsObject.GetForm(), Row.RecipientKey); GiftDestinationForm.ShowDialog(); } else { OfferToRunImportAgain = false; } } // if the user has clicked yes to assigning Gift Destinations then offer to restart the import if (OfferToRunImportAgain && (MessageBox.Show(Catalog.GetString("Would you like to import these Gift Transactions again?"), Catalog.GetString("Gift Import"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)) { Repeat = true; } } } // We save the defaults even if ok is false - because the client will probably want to try and import // the same file again after correcting any errors SaveUserDefaults(dialog, impOptions); } if (ok) { MessageBox.Show(Catalog.GetString("Your data was imported successfully!"), Catalog.GetString("Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Information); //FMyUserControl.LoadBatchesForCurrentYear(); FPetraUtilsObject.DisableSaveButton(); } return(ok); }
/// <summary> /// export all partners in selected extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> public bool ExportPartnersInExtract(System.Object sender, EventArgs e) { Boolean Result = false; if (!WarnIfNotSingleSelection(Catalog.GetString("Export Partners in Extract")) && (GetSelectedDetailRow() != null)) { String FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File")); if (FileName.Length > 0) { bool ExportFamiliesPersons = false; bool ContainsFamily = TRemote.MPartner.ImportExport.WebConnectors.CheckExtractContainsFamily(GetSelectedDetailRow().ExtractId); if (ContainsFamily) { if (MessageBox.Show( Catalog.GetString("When exporting a FAMILY record do you want to also export all associated PERSON records?"), Catalog.GetString("Export Partners"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ExportFamiliesPersons = true; } } this.Cursor = Cursors.WaitCursor; if (FileName.EndsWith("ext")) { string Doc = string.Empty; // run in thread so we can have Progress Dialog Thread t = new Thread(() => ExportToFile(ExportFamiliesPersons, ref Doc)); using (TProgressDialog dialog = new TProgressDialog(t)) { dialog.ShowDialog(); } // null if the user cancelled the operation if (Doc == null) { MessageBox.Show(Catalog.GetString("Export cancelled."), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information); this.Cursor = Cursors.Default; return(false); } Result = TImportExportDialogs.ExportTofile(Doc, FileName); if (!Result) { MessageBox.Show(Catalog.GetString("Export of Partners in Extract failed!"), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(Catalog.GetString("Export of Partners in Extract finished"), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { // XmlDocument doc = new XmlDocument(); MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error); // doc.LoadXml(TRemote.MPartner.ImportExport.WebConnectors.ExportExtractPartners(GetSelectedDetailRow().ExtractId, false)); // Result = TImportExportDialogs.ExportTofile(doc, FileName); } this.Cursor = Cursors.Default; } return(Result); } return(false); }
/// <summary> /// this supports the transaction export files from Petra 2.x. /// Lines do NOT start with T for transaction /// </summary> public void ImportTransactions(ABatchRow ACurrentBatchRow, AJournalRow ACurrentJournalRow, TImportDataSourceEnum AImportDataSource) { bool ok = false; bool RefreshGUIAfterImport = false; OpenFileDialog dialog = null; if (FPetraUtilsObject.HasChanges && !FMyForm.SaveChanges()) { // saving failed, therefore do not try to import MessageBox.Show(Catalog.GetString("Please save your changes before Importing new transactions"), Catalog.GetString( "Import GL Transactions"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if ((ACurrentBatchRow == null) || (ACurrentJournalRow == null) || (ACurrentJournalRow.JournalStatus != MFinanceConstants.BATCH_UNPOSTED)) { MessageBox.Show(Catalog.GetString("Please select an unposted journal to import transactions."), Catalog.GetString("Import GL Transactions")); return; } if (ACurrentJournalRow.LastTransactionNumber > 0) { if (MessageBox.Show(Catalog.GetString( "The current journal already contains some transactions. Do you really want to add more transactions to this journal?"), Catalog.GetString("Import GL Transactions"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } bool datesMayBeIntegers = TUserDefaults.GetBooleanDefault(MCommonConstants.USERDEFAULT_IMPORTEDDATESMAYBEINTEGERS, false); FdlgSeparator = new TDlgSelectCSVSeparator(false); FdlgSeparator.DateMayBeInteger = datesMayBeIntegers; if (AImportDataSource == TImportDataSourceEnum.FromClipboard) { string importString = Clipboard.GetText(TextDataFormat.UnicodeText); if ((importString == null) || (importString.Length == 0)) { MessageBox.Show(Catalog.GetString("Please first copy data from your spreadsheet application!"), Catalog.GetString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FdlgSeparator.CSVData = importString; } else if (AImportDataSource == TImportDataSourceEnum.FromFile) { dialog = new OpenFileDialog(); string exportPath = TClientSettings.GetExportPath(); string fullPath = TUserDefaults.GetStringDefault("Imp Filename", exportPath + Path.DirectorySeparatorChar + "import.csv"); TImportExportDialogs.SetOpenFileDialogFilePathAndName(dialog, fullPath, exportPath); dialog.Title = Catalog.GetString("Import Transactions from CSV File"); dialog.Filter = Catalog.GetString("GL Transactions files (*.csv)|*.csv|Text Files (*.txt)|*.txt"); // This call fixes Windows7 Open File Dialogs. It must be the line before ShowDialog() TWin7FileOpenSaveDialog.PrepareDialog(Path.GetFileName(fullPath)); if (dialog.ShowDialog() == DialogResult.OK) { Boolean fileCanOpen = FdlgSeparator.OpenCsvFile(dialog.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Transaction Import"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } else { return; } } else { // unknown source!! return; } String impOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator.DateFormat = dateFormatString; FdlgSeparator.NumberFormat = (impOptions.Length > 1) ? impOptions.Substring(1) : TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN; FdlgSeparator.SelectedSeparator = StringHelper.GetCSVSeparator(FdlgSeparator.FileContent) ?? ((impOptions.Length > 0) ? impOptions.Substring(0, 1) : ";"); if (FdlgSeparator.ShowDialog() == DialogResult.OK) { Hashtable requestParams = new Hashtable(); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("Delimiter", FdlgSeparator.SelectedSeparator); requestParams.Add("DateFormatString", FdlgSeparator.DateFormat); requestParams.Add("DatesMayBeIntegers", datesMayBeIntegers); requestParams.Add("NumberFormat", FdlgSeparator.NumberFormat); requestParams.Add("NewLine", Environment.NewLine); requestParams.Add("LastTransactionNumber", ACurrentJournalRow.LastTransactionNumber); TVerificationResultCollection AMessages = new TVerificationResultCollection(); Thread ImportThread = new Thread(() => ImportGLTransactions(requestParams, FdlgSeparator.FileContent, ACurrentBatchRow.BatchNumber, ACurrentJournalRow.JournalNumber, out AMessages, out ok, out RefreshGUIAfterImport)); using (TProgressDialog ImportDialog = new TProgressDialog(ImportThread)) { ImportDialog.ShowDialog(); } ShowMessages(AMessages); } // It is important to save user defaults here, even if there were errors // because in that case the user will want to import the same file again after fixing it. SaveUserDefaults(dialog); if (ok || RefreshGUIAfterImport) { if (ok) { MessageBox.Show(Catalog.GetString("Your data was imported successfully!"), Catalog.GetString("Transactions Import"), MessageBoxButtons.OK, MessageBoxIcon.Information); } // Update the client side with new information from the server FMyForm.Cursor = Cursors.WaitCursor; FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadABatchAJournal(FLedgerNumber, ACurrentBatchRow.BatchNumber)); FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadATransactionAndRelatedTablesForJournal(FLedgerNumber, ACurrentBatchRow.BatchNumber, ACurrentJournalRow.JournalNumber)); FMainDS.AcceptChanges(); FMyForm.Cursor = Cursors.Default; FMyForm.GetTransactionsControl().SelectRow(1); } }
/// <summary> /// this supports the batch export files from Petra 2.x. /// Each line starts with a type specifier, B for batch, J for journal, T for transaction /// The code handles importing from file or clipboard /// </summary> public void ImportBatches(TImportDataSourceEnum AImportDataSource) { bool ok = false; String importString; String impOptions; OpenFileDialog dialog = null; if (FPetraUtilsObject.HasChanges) { // saving failed, therefore do not try to import MessageBox.Show(Catalog.GetString("Please save before calling this function!"), Catalog.GetString( "Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FdlgSeparator = new TDlgSelectCSVSeparator(false); if (AImportDataSource == TImportDataSourceEnum.FromClipboard) { importString = Clipboard.GetText(TextDataFormat.UnicodeText); if ((importString == null) || (importString.Length == 0)) { MessageBox.Show(Catalog.GetString("Please first copy data from your spreadsheet application!"), Catalog.GetString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } impOptions = TUserDefaults.GetStringDefault("Imp Options", ";American"); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator = new TDlgSelectCSVSeparator(false); FdlgSeparator.SelectedSeparator = "\t"; FdlgSeparator.CSVData = importString; FdlgSeparator.DateFormat = dateFormatString; if (impOptions.Length > 1) { FdlgSeparator.NumberFormat = impOptions.Substring(1); } } else if (AImportDataSource == TImportDataSourceEnum.FromFile) { dialog = new OpenFileDialog(); string exportPath = TClientSettings.GetExportPath(); string fullPath = TUserDefaults.GetStringDefault("Imp Filename", exportPath + Path.DirectorySeparatorChar + "import.csv"); TImportExportDialogs.SetOpenFileDialogFilePathAndName(dialog, fullPath, exportPath); dialog.Title = Catalog.GetString("Import Batches from CSV File"); dialog.Filter = Catalog.GetString("Text Files(*.txt) | *.txt | GL Batch Files(*.csv) | *.csv"); impOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); // This call fixes Windows7 Open File Dialogs. It must be the line before ShowDialog() TWin7FileOpenSaveDialog.PrepareDialog(Path.GetFileName(fullPath)); if (dialog.ShowDialog() == DialogResult.OK) { Boolean fileCanOpen = FdlgSeparator.OpenCsvFile(dialog.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Batch Import"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } importString = File.ReadAllText(dialog.FileName, Encoding.Default); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator.DateFormat = dateFormatString; if (impOptions.Length > 1) { FdlgSeparator.NumberFormat = impOptions.Substring(1); } FdlgSeparator.SelectedSeparator = impOptions.Substring(0, 1); } else { return; } } else { // unknown source!! The following need a value... impOptions = String.Empty; importString = String.Empty; } if (FdlgSeparator.ShowDialog() == DialogResult.OK) { Hashtable requestParams = new Hashtable(); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("Delimiter", FdlgSeparator.SelectedSeparator); requestParams.Add("DateFormatString", FdlgSeparator.DateFormat); requestParams.Add("NumberFormat", FdlgSeparator.NumberFormat); requestParams.Add("NewLine", Environment.NewLine); TVerificationResultCollection AMessages = new TVerificationResultCollection(); Thread ImportThread = new Thread(() => ImportGLBatches( requestParams, importString, out AMessages, out ok)); using (TProgressDialog ImportDialog = new TProgressDialog(ImportThread)) { ImportDialog.ShowDialog(); } // We save the defaults even if ok is false - because the client will probably want to try and import // the same file again after correcting any errors SaveUserDefaults(dialog, impOptions); ShowMessages(AMessages); } if (ok) { MessageBox.Show(Catalog.GetString("Your data was imported successfully!"), Catalog.GetString("Batch Import"), MessageBoxButtons.OK, MessageBoxIcon.Information); FMyUserControl.ReloadBatches(); FPetraUtilsObject.DisableSaveButton(); } }
/// <summary> /// Imports budgets from a file /// </summary> /// <param name="ASelectedBudgetYear"></param> /// <param name="AMainDS"></param> public void ImportBudget(int ASelectedBudgetYear, ref BudgetTDS AMainDS) { TVerificationResultCollection Messages = new TVerificationResultCollection(); int NumBudgetsToImport = 0; int NumRecsUpdated = 0; int NumRowsFailed = 0; if (FPetraUtilsObject.HasChanges) { // saving failed, therefore do not try to post MessageBox.Show(Catalog.GetString("Please save before trying to import!"), Catalog.GetString( "Failure"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } String DateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); OpenFileDialog OFDialog = new OpenFileDialog(); string ExportPath = TClientSettings.GetExportPath(); string FullPath = TUserDefaults.GetStringDefault("Imp Filename", ExportPath + Path.DirectorySeparatorChar + "import.csv"); TImportExportDialogs.SetOpenFileDialogFilePathAndName(OFDialog, FullPath, ExportPath); OFDialog.Title = Catalog.GetString("Import budget(s) from csv file"); OFDialog.Filter = Catalog.GetString("Budget files (*.csv)|*.csv"); String ImportOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); // This call fixes Windows7 Open File Dialogs. It must be the line before ShowDialog() TWin7FileOpenSaveDialog.PrepareDialog(Path.GetFileName(FullPath)); if (OFDialog.ShowDialog() == DialogResult.OK) { FdlgSeparator = new TDlgSelectCSVSeparator(false); try { FParentForm.UseWaitCursor = true; Boolean fileCanOpen = FdlgSeparator.OpenCsvFile(OFDialog.FileName); if (!fileCanOpen) { throw new Exception(String.Format(Catalog.GetString("File {0} cannot be opened."), OFDialog.FileName)); } FdlgSeparator.DateFormat = DateFormatString; if (ImportOptions.Length > 1) { FdlgSeparator.NumberFormat = ImportOptions.Substring(1); } FdlgSeparator.SelectedSeparator = ImportOptions.Substring(0, 1); if (FdlgSeparator.ShowDialog() == DialogResult.OK) { string[] FdlgSeparatorVal = new string[] { FdlgSeparator.SelectedSeparator, FdlgSeparator.DateFormat, FdlgSeparator.NumberFormat }; // read contents of file string ImportString = File.ReadAllText(OFDialog.FileName); //TODO return the budget from the year, and -99 for fail NumBudgetsToImport = TRemote.MFinance.Budget.WebConnectors.ImportBudgets(FLedgerNumber, ASelectedBudgetYear, ImportString, OFDialog.FileName, FdlgSeparatorVal, ref AMainDS, out NumRecsUpdated, out NumRowsFailed, out Messages); ShowMessages(Messages, NumBudgetsToImport, NumRecsUpdated, NumRowsFailed); } } catch (Exception ex) { NumBudgetsToImport = -1; MessageBox.Show(ex.Message, Catalog.GetString("Budget Import"), MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // We save the defaults even if ok is false - because the client will probably want to try and import // the same file again after correcting any errors SaveUserDefaults(OFDialog, ImportOptions); FParentForm.UseWaitCursor = false; } // update grid if (NumBudgetsToImport > 0) { FParentForm.UseWaitCursor = true; UpdateABudgetPeriodAmounts(AMainDS, ASelectedBudgetYear); FUserControl.SetBudgetDefaultView(); FParentForm.UseWaitCursor = false; FUserControl.SelectRowInGrid(1); FPetraUtilsObject.SetChangedFlag(); } else if (NumBudgetsToImport <= 0) { FUserControl.SelectRowInGrid(1); } } }
/// <summary> /// Imports budgets from a file /// </summary> /// <param name="ACurrentBudgetYear"></param> /// <param name="AMainDS"></param> public void ImportBudget(int ACurrentBudgetYear, ref BudgetTDS AMainDS) { TVerificationResultCollection Messages = new TVerificationResultCollection(); int BudgetsImported = 0; int BudgetsAdded = 0; int BudgetsUpdated = 0; int BudgetsFailed = 0; if (FPetraUtilsObject.HasChanges) { // saving failed, therefore do not try to post MessageBox.Show(Catalog.GetString("Please save before trying to import!"), Catalog.GetString( "Failure"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } String DateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); OpenFileDialog OFDialog = new OpenFileDialog(); string ExportPath = TClientSettings.GetExportPath(); string FullPath = TUserDefaults.GetStringDefault("Imp Filename", ExportPath + Path.DirectorySeparatorChar + "import.csv"); TImportExportDialogs.SetOpenFileDialogFilePathAndName(OFDialog, FullPath, ExportPath); OFDialog.Title = Catalog.GetString("Import budget(s) from CSV file"); OFDialog.Filter = Catalog.GetString("Text Files(*.txt) | *.txt | Delimited Files(*.csv) | *.csv"); String ImportOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); // This call fixes Windows7 Open File Dialogs. It must be the line before ShowDialog() TWin7FileOpenSaveDialog.PrepareDialog(Path.GetFileName(FullPath)); if (OFDialog.ShowDialog() == DialogResult.OK) { TFrmStatusDialog dlgStatus = new TFrmStatusDialog(FPetraUtilsObject.GetForm()); FdlgSeparator = new TDlgSelectCSVSeparator(false); try { string fileTitle = OFDialog.SafeFileName; Boolean fileCanOpen = FdlgSeparator.OpenCsvFile(OFDialog.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Budget Import"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } FdlgSeparator.DateFormat = DateFormatString; if (ImportOptions.Length > 1) { FdlgSeparator.NumberFormat = ImportOptions.Substring(1); } FdlgSeparator.SelectedSeparator = ImportOptions.Substring(0, 1); if (FdlgSeparator.ShowDialog() == DialogResult.OK) { string[] FdlgSeparatorVal = new string[] { FdlgSeparator.SelectedSeparator, FdlgSeparator.DateFormat, FdlgSeparator.NumberFormat }; Application.UseWaitCursor = true; //New set of budgets to be loaded dlgStatus.Show(); dlgStatus.Heading = Catalog.GetString("Budget Import"); dlgStatus.CurrentStatus = Catalog.GetString("Importing budgets from '" + fileTitle + "' ..."); // read contents of file string ImportString = File.ReadAllText(OFDialog.FileName); //TODO return the budget from the year, and -99 for fail BudgetsImported = TRemote.MFinance.Budget.WebConnectors.ImportBudgets(FLedgerNumber, ImportString, OFDialog.FileName, FdlgSeparatorVal, ref AMainDS, out BudgetsAdded, out BudgetsUpdated, out BudgetsFailed, out Messages); dlgStatus.Visible = false; Application.UseWaitCursor = false; ShowMessages(Messages, BudgetsImported, BudgetsAdded, BudgetsUpdated, BudgetsFailed); } // We save the defaults even if ok is false - because the client will probably want to try and import // the same file again after correcting any errors SaveUserDefaults(OFDialog, ImportOptions); } catch (Exception ex) { TLogging.LogException(ex, Utilities.GetMethodSignature()); throw; } finally { Application.UseWaitCursor = false; } // update grid if ((BudgetsAdded + BudgetsUpdated) > 0) { try { dlgStatus.CurrentStatus = Catalog.GetString("Updating budget period data..."); dlgStatus.Visible = true; Application.UseWaitCursor = true; UpdateABudgetPeriodAmounts(AMainDS, ACurrentBudgetYear); FUserControl.SetBudgetDefaultView(AMainDS); } finally { Application.UseWaitCursor = false; dlgStatus.Close(); } FPetraUtilsObject.SetChangedFlag(); } else { dlgStatus.Close(); } } }
/// <summary> /// this supports the batch export files from Petra 2.x. /// Each line starts with a type specifier, B for batch, J for journal, T for transaction /// </summary> public void ImportBatches(TGiftImportDataSourceEnum AImportSource, GiftBatchTDS AMainDS) { bool ImportOK = false; bool RefreshGUIAfterImport = false; OpenFileDialog OFileDialog = null; if (FPetraUtilsObject.HasChanges) { // saving failed, therefore do not try to import MessageBox.Show(Catalog.GetString("Please save before calling this function!"), Catalog.GetString( "Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ALedgerRow LedgerRow = (ALedgerRow)AMainDS.ALedger.Rows[0]; int CurrentTopBatchNumber = LedgerRow.LastGiftBatchNumber; try { FMyForm.FCurrentGiftBatchAction = Logic.TExtraGiftBatchChecks.GiftBatchAction.IMPORTING; bool datesMayBeIntegers = TUserDefaults.GetBooleanDefault(MCommonConstants.USERDEFAULT_IMPORTEDDATESMAYBEINTEGERS, false); FdlgSeparator = new TDlgSelectCSVSeparator(false); FdlgSeparator.DateMayBeInteger = datesMayBeIntegers; if (AImportSource == TGiftImportDataSourceEnum.FromClipboard) { string ImportString = Clipboard.GetText(TextDataFormat.UnicodeText); if ((ImportString == null) || (ImportString.Length == 0)) { MessageBox.Show(Catalog.GetString("Please first copy data from your spreadsheet application!"), Catalog.GetString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FdlgSeparator.CSVData = ImportString; } else if (AImportSource == TGiftImportDataSourceEnum.FromFile) { OFileDialog = new OpenFileDialog(); string exportPath = TClientSettings.GetExportPath(); string fullPath = TUserDefaults.GetStringDefault("Imp Filename", exportPath + Path.DirectorySeparatorChar + "import.csv"); TImportExportDialogs.SetOpenFileDialogFilePathAndName(OFileDialog, fullPath, exportPath); OFileDialog.Title = Catalog.GetString("Import Batches from CSV File"); OFileDialog.Filter = Catalog.GetString("Gift Batch Files(*.csv)|*.csv|Text Files(*.txt)|*.txt"); // This call fixes Windows7 Open File Dialogs. It must be the line before ShowDialog() TWin7FileOpenSaveDialog.PrepareDialog(Path.GetFileName(fullPath)); if (OFileDialog.ShowDialog() == DialogResult.OK) { Boolean fileCanOpen = FdlgSeparator.OpenCsvFile(OFileDialog.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } else { return; } } else { // unknown source!! return; } String impOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); FdlgSeparator.DateFormat = dateFormatString; FdlgSeparator.NumberFormat = (impOptions.Length > 1) ? impOptions.Substring(1) : TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN; FdlgSeparator.SelectedSeparator = StringHelper.GetCSVSeparator(FdlgSeparator.FileContent) ?? ((impOptions.Length > 0) ? impOptions.Substring(0, 1) : ";"); if (FdlgSeparator.ShowDialog() == DialogResult.OK) { Hashtable requestParams = new Hashtable(); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("Delimiter", FdlgSeparator.SelectedSeparator); requestParams.Add("DateFormatString", FdlgSeparator.DateFormat); requestParams.Add("DatesMayBeIntegers", datesMayBeIntegers); requestParams.Add("NumberFormat", FdlgSeparator.NumberFormat); requestParams.Add("NewLine", Environment.NewLine); bool Repeat = true; while (Repeat) { Repeat = false; TVerificationResultCollection AMessages = new TVerificationResultCollection(); GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber = new GiftBatchTDSAGiftDetailTable(); Thread ImportThread = new Thread(() => ImportGiftBatches( requestParams, FdlgSeparator.FileContent, out AMessages, out ImportOK, out RefreshGUIAfterImport, out NeedRecipientLedgerNumber)); using (TProgressDialog ImportDialog = new TProgressDialog(ImportThread)) { ImportDialog.ShowDialog(); } // If NeedRecipientLedgerNumber contains data then AMessages will only ever contain // one message alerting the user that no data has been imported. // We do not want to show this as we will be displaying another more detailed message. if (NeedRecipientLedgerNumber.Rows.Count == 0) { if (TVerificationHelper.ResultsContainErrorCode(AMessages, PetraErrorCodes.ERR_DB_SERIALIZATION_EXCEPTION)) { TConcurrentServerTransactions.ShowTransactionSerializationExceptionDialog(); } else { ShowMessages(AMessages); } } // if the import contains gifts with Motivation Group 'GIFT' and that have a Family recipient with no Gift Destination // then the import will have failed and we need to alert the user if (NeedRecipientLedgerNumber.Rows.Count > 0) { bool OfferToRunImportAgain = true; bool DoNotShowMessageBoxEverytime = false; TFrmExtendedMessageBox.TResult Result = TFrmExtendedMessageBox.TResult.embrUndefined; int count = 1; // for each gift in which the recipient needs a Git Destination foreach (GiftBatchTDSAGiftDetailRow Row in NeedRecipientLedgerNumber.Rows) { if (!DoNotShowMessageBoxEverytime) { string CheckboxText = string.Empty; // only show checkbox if there is at least one more occurrence of this error if (NeedRecipientLedgerNumber.Rows.Count - count > 0) { CheckboxText = string.Format( Catalog.GetString( "Do this for all further occurrences ({0})?"), NeedRecipientLedgerNumber.Rows.Count - count); } TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(FPetraUtilsObject.GetForm()); extendedMessageBox.ShowDialog(string.Format( Catalog.GetString( "Gift Import has been cancelled as the recipient '{0}' ({1}) has no Gift Destination assigned."), Row.RecipientDescription, Row.RecipientKey) + "\n\r\n\r\n\r" + Catalog.GetString("Do you want to assign a Gift Destination to this partner now?"), Catalog.GetString("Import Errors"), CheckboxText, TFrmExtendedMessageBox.TButtons.embbYesNo, TFrmExtendedMessageBox.TIcon.embiWarning); Result = extendedMessageBox.GetResult(out DoNotShowMessageBoxEverytime); } if (Result == TFrmExtendedMessageBox.TResult.embrYes) { // allow the user to assign a Gift Destingation TFrmGiftDestination GiftDestinationForm = new TFrmGiftDestination(FPetraUtilsObject.GetForm(), Row.RecipientKey); GiftDestinationForm.ShowDialog(); } else { OfferToRunImportAgain = false; if (DoNotShowMessageBoxEverytime) { break; } } count++; } // if the user has clicked yes to assigning Gift Destinations then offer to restart the import if (OfferToRunImportAgain && (MessageBox.Show(Catalog.GetString("Would you like to import this Gift Batch again?"), Catalog.GetString("Gift Import"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)) { Repeat = true; } } } } // We save the defaults even if ok is false - because the client will probably want to try and import // the same file again after correcting any errors SaveUserDefaults(OFileDialog); if (ImportOK) { MessageBox.Show(Catalog.GetString("Your data was imported successfully!"), Catalog.GetString("Gift Import"), MessageBoxButtons.OK, MessageBoxIcon.Information); } if (ImportOK) { FMyUserControl.LoadBatchesForCurrentYear(); FMyForm.GetBatchControl().SelectRowInBatchGrid(1); DataView allNewBatches = new DataView(AMainDS.AGiftBatch); allNewBatches.RowFilter = String.Format("{0} > {1}", AGiftBatchTable.GetBatchNumberDBName(), CurrentTopBatchNumber); foreach (DataRowView drv in allNewBatches) { drv.Row.SetModified(); } FPetraUtilsObject.SetChangedFlag(); //Force initial inactive values check FMyForm.SaveChangesManual(FMyForm.FCurrentGiftBatchAction); } else if (RefreshGUIAfterImport) { FMyUserControl.LoadBatchesForCurrentYear(); FMyForm.GetBatchControl().SelectRowInBatchGrid(1); } } finally { FMyForm.FCurrentGiftBatchAction = Logic.TExtraGiftBatchChecks.GiftBatchAction.NONE; } }
/// <summary> /// Export Partners from an Extract. /// </summary> /// <param name="AExtractId">Extract Identifier.</param> /// <param name="AOldPetraFormat">Set to true if old format should be used.</param> public static Boolean ExportPartnersInExtract(int AExtractId, Boolean AOldPetraFormat) { String SuggestedFileName = ""; Boolean Result = false; // prepare suggestion for file name: Extract name SuggestedFileName = "p_" + TRemote.MPartner.Partner.WebConnectors.GetExtractName(AExtractId); String FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File"), SuggestedFileName); if (AExtractId < 0) { return(false); } if (FileName.Length > 0) { bool ExportFamiliesPersons = false; bool ContainsFamily = TRemote.MPartner.ImportExport.WebConnectors.CheckExtractContainsFamily(AExtractId); if (ContainsFamily) { if (MessageBox.Show( Catalog.GetString("When exporting a FAMILY record do you want to also export all associated PERSON records?"), Catalog.GetString("Export Partners"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ExportFamiliesPersons = true; } } if (FileName.EndsWith("ext")) { string Doc = string.Empty; // run in thread so we can have Progress Dialog Thread t = new Thread(() => ExportExtractToString(AExtractId, ExportFamiliesPersons, ref Doc, AOldPetraFormat)); using (TProgressDialog dialog = new TProgressDialog(t)) { dialog.ShowDialog(); } // null if the user cancelled the operation if (Doc == null) { MessageBox.Show(Catalog.GetString("Export cancelled."), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } Result = TImportExportDialogs.ExportTofile(Doc, FileName, AOldPetraFormat); if (!Result) { MessageBox.Show(Catalog.GetString("Export of Partners in Extract failed!"), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(Catalog.GetString("Export of Partners in Extract finished."), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { // XmlDocument doc = new XmlDocument(); MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString( "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error); // doc.LoadXml(TRemote.MPartner.ImportExport.WebConnectors.ExportExtractPartners(GetSelectedDetailRow().ExtractId, false)); // Result = TImportExportDialogs.ExportTofile(doc, FileName); } return(Result); } return(false); }