public static TSubmitChangesResult SaveData(string ATablename, ref TTypedDataTable ASubmitTable, out TVerificationResultCollection AVerificationResult) { // check access permissions for the current user TModuleAccessManager.CheckUserPermissionsForTable(ATablename, TTablePermissionEnum.eCanModify | TTablePermissionEnum.eCanModify | TTablePermissionEnum.eCanDelete); TSubmitChangesResult ReturnValue = TSubmitChangesResult.scrError; TTypedDataTable SubmitTable = null; TVerificationResultCollection VerificationResult = null; TDBTransaction WriteTransaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("SaveData"); SubmitTable = ASubmitTable; bool submitOK = true; // Automatic handling of a DB Transaction - and also the automatic establishment and closing of a DB // Connection where a DB Transaction can be exectued (only if that should be needed). db.WriteTransaction( ref WriteTransaction, ref submitOK, delegate { ReturnValue = SaveData(ATablename, ref SubmitTable, out VerificationResult, WriteTransaction); submitOK = ReturnValue == TSubmitChangesResult.scrOK; }); AVerificationResult = VerificationResult; if ((ATablename == SSystemDefaultsTable.GetTableDBName()) && (ReturnValue == TSubmitChangesResult.scrOK)) { // TODO Reload the site key into the session, in case that was changed } return(ReturnValue); }
/// <summary> /// constructor /// </summary> /// <param name="ATableId"></param> /// <param name="AColumnNr"></param> /// <param name="ACriteriaDataRow"></param> /// <param name="ACriteriaField"></param> /// <param name="ACriteriaMatchField"></param> /// <param name="AWhereClause"></param> /// <param name="AIntParamArray"></param> public TDynamicSearchHelper( short ATableId, short AColumnNr, DataRow ACriteriaDataRow, String ACriteriaField, String ACriteriaMatchField, ref String AWhereClause, ref ArrayList AIntParamArray) { FDataRow = ACriteriaDataRow; FCriteriaField = ACriteriaField; FMatchField = ACriteriaMatchField; FDBFieldName = "PUB_" + TTypedDataTable.GetTableNameSQL(ATableId) + "." + TTypedDataTable.GetColumnNameSQL(ATableId, AColumnNr); object ParameterValue = GetParameterValue(); if (ParameterValue.ToString() != String.Empty) { OdbcParameter miParam = TTypedDataTable.CreateOdbcParameter(ATableId, AColumnNr); miParam.Value = ParameterValue; AIntParamArray.Add(miParam); AWhereClause = AWhereClause + GetWhereString(); } }
public static TSubmitChangesResult SaveData(string ATablename, ref TTypedDataTable ASubmitTable, out TVerificationResultCollection AVerificationResult) { TSubmitChangesResult ReturnValue = TSubmitChangesResult.scrError; TDBTransaction WriteTransaction = null; TTypedDataTable SubmitTable = null; TVerificationResultCollection VerificationResult = null; SubmitTable = ASubmitTable; // Automatic handling of a DB Transaction - and also the automatic establishment and closing of a DB // Connection where a DB Transaction can be exectued (only if that should be needed). DBAccess.SimpleAutoTransactionWrapper("TCommonDataReader.SaveData", out WriteTransaction, ref ReturnValue, delegate { ReturnValue = SaveData(ATablename, ref SubmitTable, out VerificationResult, WriteTransaction); }); if ((ATablename == SSystemDefaultsTable.GetTableDBName()) && (ReturnValue == TSubmitChangesResult.scrOK)) { // Refresh the cache immediately so clients will get the changes TSystemDefaultsCache.GSystemDefaultsCache.ReloadSystemDefaultsTable(); } AVerificationResult = VerificationResult; return(ReturnValue); }
// // Put Methods for the validation of Personnel Module WebConnectors in this code file. // static partial void ValidatePersonnelStaffManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { TValidationControlsDict ValidationControlsDict = new TValidationControlsDict(); ValidationControlsDict.Add(ASubmitTable.Columns[PmStaffDataTable.ColumnReceivingFieldId], new TValidationControlsData(null, PmStaffDataTable.GetReceivingFieldDBName())); ValidationControlsDict.Add(ASubmitTable.Columns[PmStaffDataTable.ColumnStartOfCommitmentId], new TValidationControlsData(null, PmStaffDataTable.GetStartOfCommitmentDBName())); ValidationControlsDict.Add(ASubmitTable.Columns[PmStaffDataTable.ColumnEndOfCommitmentId], new TValidationControlsData(null, PmStaffDataTable.GetEndOfCommitmentDBName(), null, PmStaffDataTable.GetStartOfCommitmentDBName())); ValidationControlsDict.Add(ASubmitTable.Columns[PmStaffDataTable.ColumnStatusCodeId], new TValidationControlsData(null, PmStaffDataTable.GetStatusCodeDBName())); ValidationControlsDict.Add(ASubmitTable.Columns[PmStaffDataTable.ColumnHomeOfficeId], new TValidationControlsData(null, PmStaffDataTable.GetHomeOfficeDBName())); ValidationControlsDict.Add(ASubmitTable.Columns[PmStaffDataTable.ColumnOfficeRecruitedById], new TValidationControlsData(null, PmStaffDataTable.GetOfficeRecruitedByDBName())); for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { TSharedPersonnelValidation_Personnel.ValidateCommitmentManual("TPersonnelWebConnector" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (PmStaffDataRow)ASubmitTable.Rows[Counter], ref AVerificationResult, ValidationControlsDict); } }
/// <summary> /// Saves the data to the server /// </summary> /// <param name="ATable">The typed table from the data set</param> /// <param name="ATableChanges">The changes table</param> /// <param name="ATableDbName">The server table name to write to</param> /// <returns></returns> public static bool SaveChanges(TTypedDataTable ATable, TTypedDataTable ATableChanges, string ATableDbName) { TSubmitChangesResult SubmissionResult; TVerificationResultCollection VerificationResult; if (ATableChanges == null) { // There is nothing to be saved. return(true); } // Submit changes to the PETRAServer try { SubmissionResult = TRemote.MCommon.DataReader.WebConnectors.SaveData(ATableDbName, ref ATableChanges, out VerificationResult); } catch (ESecurityDBTableAccessDeniedException) { Console.WriteLine("Error saving data prior to test: Access denied"); return(false); } catch (EDBConcurrencyException) { Console.WriteLine("Error saving data prior to test: Concurrency exception"); return(false); } catch (Exception Exp) { Console.WriteLine("Error saving data prior to test: General exception: {0}", Exp.Message); return(false); } switch (SubmissionResult) { case TSubmitChangesResult.scrOK: // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server ATable.AcceptChanges(); // Merge back with data from the Server (eg. for getting Sequence values) ATableChanges.AcceptChanges(); ATable.Merge(ATableChanges, false); // need to accept the new modification ID ATable.AcceptChanges(); return(true); case TSubmitChangesResult.scrNothingToBeSaved: return(true); case TSubmitChangesResult.scrError: Console.WriteLine("Error saving data prior to test: Submission of data failed"); break; case TSubmitChangesResult.scrInfoNeeded: Console.WriteLine("Error saving data prior to test: Info Needed"); break; } return(false); }
public static int GetNonCacheableRecordReferenceCountManual(TTypedDataTable ADataTable, object[] APrimaryKeyValues, out TVerificationResultCollection AVerificationResult) { int ReturnValue = 0; Boolean NewTransaction; TDBTransaction ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction( IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { if (ADataTable is PcConferenceTable) { ReturnValue = CountByPrimaryKey(APrimaryKeyValues, ReadTransaction, true, out AVerificationResult); } else { AVerificationResult = new TVerificationResultCollection(); } } finally { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(9, ADataTable.TableName + ": GetNonCacheableRecordReferenceCount: committed own transaction."); } } return(ReturnValue); }
static partial void ValidateGiftDetailManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { TValidationControlsDict ValidationControlsDict = new TValidationControlsDict(); ValidationControlsDict.Add(ASubmitTable.Columns[AGiftDetailTable.ColumnGiftCommentOneId], new TValidationControlsData(null, AGiftDetailTable.GetGiftCommentOneDBName())); TPartnerClass RecipientPartnerClass; string RecipientDescription; for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { if (ASubmitTable.Rows[Counter].RowState != DataRowState.Deleted) { TPartnerServerLookups.GetPartnerShortName(((GiftBatchTDSAGiftDetailRow)ASubmitTable.Rows[Counter]).RecipientKey, out RecipientDescription, out RecipientPartnerClass); GiftBatchTDSAGiftDetailRow Row = (GiftBatchTDSAGiftDetailRow)ASubmitTable.Rows[Counter]; Row.RecipientClass = RecipientPartnerClass.ToString(); TSharedFinanceValidation_Gift.ValidateGiftDetailManual("TTransactionWebConnector" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English Row, ref AVerificationResult, ValidationControlsDict); } } }
/// <summary> /// /// </summary> /// <param name="AExchangeRateDT">The corporate or daily exchange rate table</param> /// <param name="AImportMode">Determines whether corporate or daily exchange rates specified - either 'Daily' or 'Corporate'</param> /// <param name="AResultCollection">A validation collection to which errors will be added</param> /// <returns>The number of rows that were actually imported. Rows that duplicate existing rows do not count. /// This is usually because this is an attempt to import again after a failed previous attempt.</returns> public static int ImportCurrencyExRates(TTypedDataTable AExchangeRateDT, string AImportMode, TVerificationResultCollection AResultCollection) { OpenFileDialog DialogBox = new OpenFileDialog(); DialogBox.Title = Catalog.GetString("Import exchange rates from spreadsheet file"); DialogBox.Filter = Catalog.GetString("Spreadsheet files (*.csv)|*.csv"); if (DialogBox.ShowDialog() == DialogResult.OK) { String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); String impOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); bool dateMayBeAnInteger = TUserDefaults.GetBooleanDefault(MCommonConstants.USERDEFAULT_IMPORTEDDATESMAYBEINTEGERS, false); TDlgSelectCSVSeparator DlgSeparator = new TDlgSelectCSVSeparator(false); DlgSeparator.DateMayBeInteger = dateMayBeAnInteger; Boolean fileCanOpen = DlgSeparator.OpenCsvFile(DialogBox.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Import Exchange Rates"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return 0; } DlgSeparator.DateFormat = dateFormatString; DlgSeparator.NumberFormat = (impOptions.Length > 1) ? impOptions.Substring(1) : TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN; DlgSeparator.SelectedSeparator = StringHelper.GetCSVSeparator(DlgSeparator.FileContent) ?? ((impOptions.Length > 0) ? impOptions.Substring(0, 1) : ";"); if (DlgSeparator.ShowDialog() == DialogResult.OK) { // Save the settings that we specified SaveOptions(DlgSeparator); // Do the import and return the number of rows imported and any messages return ImportCurrencyExRatesFromCSV(AExchangeRateDT, DlgSeparator.FileContent, DlgSeparator.SelectedSeparator, DlgSeparator.NumberFormat, DlgSeparator.DateFormat, dateMayBeAnInteger, AImportMode, AResultCollection, Path.GetFileNameWithoutExtension(DialogBox.FileName)); } else { // Save the options anyway SaveOptions(DlgSeparator); } } return 0; }
static partial void ValidatePBankManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { TPartnerValidation_Partner.ValidatePartnerBankManual("TPartnerEditUIConnector" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (PBankRow)ASubmitTable.Rows[Counter], ref AVerificationResult); } }
// // Put Methods for the validation of AP EditTransaction in this code file. // static partial void ValidateApDocumentDetailManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { TSharedFinanceValidation_AP.ValidateApDocumentDetailManual("TTransactionWebConnector" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (AApDocumentDetailRow)ASubmitTable.Rows[Counter], ref AVerificationResult); } }
// // Put Methods for the validation of Personnel Module WebConnectors in this code file. // static partial void ValidatePersonnelStaffManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { TPersonnelValidation_Personnel.ValidateCommitmentManual("TPersonnelWebConnector" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (PmStaffDataRow)ASubmitTable.Rows[Counter], ref AVerificationResult); } }
// // Put Methods for the validation of Common Module WebConnectors and DataReaders in this code file. // static partial void ValidateInternationalPostalTypeManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { PInternationalPostalTypeValidation.Validate("TCommonDataReader.ValidateInternationalPostalTypeManual" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (PInternationalPostalTypeRow)ASubmitTable.Rows[Counter], ref AVerificationResult); } }
/// <summary> /// /// </summary> /// <param name="AExchangeRateDT">The corporate or daily exchange rate table</param> /// <param name="AImportMode">Determines whether corporate or daily exchange rates specified - either 'Daily' or 'Corporate'</param> /// <param name="AResultCollection">A validation collection to which errors will be added</param> /// <returns>The number of rows that were actually imported. Rows that duplicate existing rows do not count. /// This is usually because this is an attempt to import again after a failed previous attempt.</returns> public static int ImportCurrencyExRates(TTypedDataTable AExchangeRateDT, string AImportMode, TVerificationResultCollection AResultCollection) { OpenFileDialog DialogBox = new OpenFileDialog(); DialogBox.Title = Catalog.GetString("Import exchange rates from spreadsheet file"); DialogBox.Filter = Catalog.GetString("Spreadsheet files (*.csv)|*.csv"); if (DialogBox.ShowDialog() == DialogResult.OK) { String dateFormatString = TUserDefaults.GetStringDefault("Imp Date", "MDY"); String impOptions = TUserDefaults.GetStringDefault("Imp Options", ";" + TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN); TDlgSelectCSVSeparator DlgSeparator = new TDlgSelectCSVSeparator(false); Boolean fileCanOpen = DlgSeparator.OpenCsvFile(DialogBox.FileName); if (!fileCanOpen) { MessageBox.Show(Catalog.GetString("Unable to open file."), Catalog.GetString("Import Exchange Rates"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return(0); } DlgSeparator.DateFormat = dateFormatString; if (impOptions.Length > 1) { DlgSeparator.NumberFormat = impOptions.Substring(1); } DlgSeparator.SelectedSeparator = impOptions.Substring(0, 1); if (DlgSeparator.ShowDialog() == DialogResult.OK) { // Save the settings that we specified impOptions = DlgSeparator.SelectedSeparator; impOptions += DlgSeparator.NumberFormat; TUserDefaults.SetDefault("Imp Options", impOptions); TUserDefaults.SetDefault("Imp Date", DlgSeparator.DateFormat); TUserDefaults.SaveChangedUserDefaults(); // Do the import and retuen the number of rows imported and any messages return(ImportCurrencyExRatesFromCSV(AExchangeRateDT, DialogBox.FileName, DlgSeparator.SelectedSeparator, DlgSeparator.NumberFormat, DlgSeparator.DateFormat, AImportMode, AResultCollection)); } } return(0); }
/// create a dictionary that contains all columns static public TValidationControlsDict PopulateDictionaryWithAllColumns(TTypedDataTable ATable) { TValidationControlsDict ValidationControlsDict = new TValidationControlsDict(); foreach (DataColumn col in ATable.Columns) { ValidationControlsDict.Add(col, new TValidationControlsData(null, col.ColumnName)); } return(ValidationControlsDict); }
public static bool SaveChanges() { TTypedDataTable TableChanges = ADailyExchangeRate.GetChangesTyped(); if (!SerialisableDS.SaveChanges(ADailyExchangeRate, TableChanges, ADailyExchangeRateTable.GetTableDBName())) { // throwing an exception because the return value is not verified in many places throw new Exception("TDailyExchangeRateTest:FMainDS:SaveChanges: Could not save the changes. see log for details"); } return(true); }
/// <summary> /// This over-ride should be used for testing purposes. It reads from the specified test file and always uses US numbers and date/time. /// You supply the separator character as a single character string /// </summary> /// <param name="AExchangeRateDT">The corporate or daily exchange rate table</param> /// <param name="AImportFileName">The test file to import</param> /// <param name="ACSVSeparator">The separator that the file uses</param> /// <param name="AImportMode">Determines whether corporate or daily exchange rates specified - either 'Daily' or 'Corporate'</param> /// <param name="AResultCollection">A validation collection to which errors will be added</param> /// <returns>The number of rows that were actually imported. Rows that duplicate existing rows do not count. /// This is usually because this is an attempt to import again after a failed previous attempt.</returns> public static int ImportCurrencyExRates(TTypedDataTable AExchangeRateDT, string AImportFileName, string ACSVSeparator, string AImportMode, TVerificationResultCollection AResultCollection) { // Test import always uses standard file with US formats return(ImportCurrencyExRatesFromCSV(AExchangeRateDT, AImportFileName, ACSVSeparator, TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN, "MM/dd/yyyy", AImportMode, AResultCollection)); }
/// <summary> /// check the validity of each location and update the icon for each location (current address, old address, future address) /// for the current date /// </summary> /// <param name="APartnerLocationsDS">the dataset with the locations</param> public static void DeterminePartnerLocationsDateStatus(DataSet APartnerLocationsDS) { DataTable ProcessDT; if ((APartnerLocationsDS is PartnerEditTDS) || (APartnerLocationsDS.Tables.Contains(TTypedDataTable.GetTableName(PPartnerLocationTable.TableId)) == true)) { ProcessDT = APartnerLocationsDS.Tables[TTypedDataTable.GetTableName(PPartnerLocationTable.TableId)]; } else { ProcessDT = APartnerLocationsDS.Tables["PartnerLocation"]; } DeterminePartnerLocationsDateStatus(ProcessDT, DateTime.Today); }
// // Put Methods for the validation of AP EditTransaction in this code file. // static partial void ValidateApDocumentDetailManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { TValidationControlsDict ValidationControlsDict = new TValidationControlsDict(); ValidationControlsDict.Add(ASubmitTable.Columns[AApDocumentDetailTable.ColumnAmountId], new TValidationControlsData(null, AApDocumentDetailTable.GetAmountDBName())); for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { TSharedFinanceValidation_AP.ValidateApDocumentDetailManual("TTransactionWebConnector" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (AApDocumentDetailRow)ASubmitTable.Rows[Counter], ref AVerificationResult, ValidationControlsDict); } }
// // Put Methods for the validation of Partner Edit screen data in this code file. // static partial void ValidatePPartnerManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { TValidationControlsDict ValidationControlsDict = new TValidationControlsDict(); ValidationControlsDict.Add(ASubmitTable.Columns[PPartnerTable.ColumnStatusCodeId], new TValidationControlsData(null, Catalog.GetString("Partner &Status"))); for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { TSharedPartnerValidation_Partner.ValidatePartnerManual("TPartnerEditUIConnector" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (PPartnerRow)ASubmitTable.Rows[Counter], ref AVerificationResult, ValidationControlsDict); } }
/// <summary> /// Determines which address is the 'Best Address' of a Partner, and marks it in the DataColumn 'BestAddress'. /// </summary> /// <remarks>There are convenient overloaded server-side Methods, Ict.Petra.Server.MPartner.ServerCalculations.DetermineBestAddress, /// which work by specifying the PartnerKey of a Partner in an Argument.</remarks> /// <param name="APartnerLocationsDS">Dataset containing the addresses of a Partner.</param> /// <returns>A <see cref="TLocationPK" /> which points to the 'Best Address'. If no 'Best Address' was found, /// SiteKey and LocationKey of this instance will be both -1.</returns> public static TLocationPK DetermineBestAddress(DataSet APartnerLocationsDS) { DataTable ProcessDT; if ((APartnerLocationsDS is PartnerEditTDS) || (APartnerLocationsDS.Tables.Contains(TTypedDataTable.GetTableName(PPartnerLocationTable.TableId)) == true)) { ProcessDT = APartnerLocationsDS.Tables[TTypedDataTable.GetTableName(PPartnerLocationTable.TableId)]; } else { ProcessDT = APartnerLocationsDS.Tables["PartnerLocation"]; } return(DetermineBestAddress(ProcessDT)); }
void FPetraUtilsObject_DataSavingStarted(object Sender, EventArgs e) { // We need to delete the rows in the extra data set first so that we will be able to save the deleted rows in the main data set DataTable DeletedDT = FExtraDS.PDataLabelUse.GetChanges(DataRowState.Deleted); if (DeletedDT == null) { return; } TTypedDataTable SubmitDT = (TTypedDataTable)DeletedDT; SubmitDT.InitVars(); SaveDataLabelUseChanges(SubmitDT); }
static partial void ValidateRecurringGiftBatchManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { TValidationControlsDict ValidationControlsDict = new TValidationControlsDict(); ValidationControlsDict.Add(ASubmitTable.Columns[ARecurringGiftBatchTable.ColumnBatchDescriptionId], new TValidationControlsData(null, ARecurringGiftBatchTable.GetBatchDescriptionDBName())); for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { TSharedFinanceValidation_Gift.ValidateRecurringGiftBatchManual("TTransactionWebConnector" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (ARecurringGiftBatchRow)ASubmitTable.Rows[Counter], ref AVerificationResult, ValidationControlsDict); } }
public static bool GetData(string ATablename, TSearchCriteria[] ASearchCriteria, out TTypedDataTable AResultTable) { TDBTransaction ReadTransaction = null; TTypedDataTable ResultTable = null; // Automatic handling of a Read-only DB Transaction - and also the automatic establishment and closing of a DB // Connection where a DB Transaction can be exectued (only if that should be needed). DBAccess.SimpleAutoReadTransactionWrapper("TCommonDataReader.GetData", out ReadTransaction, delegate { GetData(ATablename, ASearchCriteria, out ResultTable, ReadTransaction); }); AResultTable = ResultTable; return(true); }
public static bool GetData(string ATablename, TSearchCriteria[] ASearchCriteria, out TTypedDataTable AResultTable) { TTypedDataTable ResultTable = null; TDBTransaction ReadTransaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("GetData"); // Automatic handling of a Read-only DB Transaction - and also the automatic establishment and closing of a DB // Connection where a DB Transaction can be exectued (only if that should be needed). db.ReadTransaction(ref ReadTransaction, delegate { GetData(ATablename, ASearchCriteria, out ResultTable, ReadTransaction); }); AResultTable = ResultTable; return(true); }
/// <summary> /// This procedure retrieves the length of the textbox specified in the datarow /// of the UFoundControlTable table. /// /// </summary> /// <returns>void</returns> private void RetrieveTextBoxMaxLength(System.Data.DataRow ADataRow) { String mTableName; String mColumnName; System.Int32 mMaxLength; String mKey; String mControlName; String mMessageStr; System.Windows.Forms.Control mControl; // Initialization mTableName = ADataRow[strFoundControlTableName].ToString(); mColumnName = ADataRow[strFoundControlColumnName].ToString(); try { mMaxLength = TTypedDataTable.GetLength(mTableName, mColumnName); } catch (Exception e) { mMaxLength = 32767; MessageBox.Show("TableName: " + mTableName + "ColumnName: " + mColumnName + "\n" + "\n" + e.ToString()); } mControl = (System.Windows.Forms.Control)ADataRow[strFoundControlTextBox]; // Compile some information to check the results mKey = ADataRow[strFoundControlKey].ToString(); mControlName = mControl.Name; mMessageStr = "Got the information for the following TextBox: " + "\n" + " TableName: " + mTableName + "\n" + " ColumnName: " + mColumnName + "\n" + " ControlName: " + mControlName + "\n" + " MaxLength: " + mMaxLength.ToString() + "\n" + " Key internal info: " + mKey + "\n"; // Check whether the result is still invalid and if possible provide reasons if (mMaxLength < 0) { // TLogging.Log(mMessageStr, [TLoggingType.ToLogfile]); throw new System.Exception(mMessageStr); } // Messagebox.Show(mMessageStr); SetMaxLength(mControl, mMaxLength); }
// // Put Methods for the validation of Common Module WebConnectors and DataReaders in this code file. // static partial void ValidateInternationalPostalTypeManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { TValidationControlsDict ValidationControlsDict = new TValidationControlsDict(); ValidationControlsDict.Add(ASubmitTable.Columns[(short)PInternationalPostalTypeTable.ColumnInternatPostalTypeCodeId], new TValidationControlsData(null, PInternationalPostalTypeTable.GetInternatPostalTypeCodeDBName())); ValidationControlsDict.Add(ASubmitTable.Columns[(short)PInternationalPostalTypeTable.ColumnDescriptionId], new TValidationControlsData(null, PInternationalPostalTypeTable.GetDescriptionDBName())); ValidationControlsDict.Add(ASubmitTable.Columns[(short)PInternationalPostalTypeTable.ColumnDeletableId], new TValidationControlsData(null, PInternationalPostalTypeTable.GetDeletableDBName())); for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { PInternationalPostalTypeValidation.Validate("TCommonDataReader.ValidateInternationalPostalTypeManual" + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (PInternationalPostalTypeRow)ASubmitTable.Rows[Counter], ref AVerificationResult, ValidationControlsDict); } }
/// <summary> /// This over-ride should be used for testing purposes. It reads from the specified test file and always uses US numbers and date/time. /// You supply the separator character as a single character string /// </summary> /// <param name="AExchangeRateDT">The corporate or daily exchange rate table</param> /// <param name="AImportFileName">The test file to import</param> /// <param name="ACSVSeparator">The separator that the file uses</param> /// <param name="AImportMode">Determines whether corporate or daily exchange rates specified - either 'Daily' or 'Corporate'</param> /// <param name="AResultCollection">A validation collection to which errors will be added</param> /// <returns>The number of rows that were actually imported. Rows that duplicate existing rows do not count. /// This is usually because this is an attempt to import again after a failed previous attempt.</returns> public static int ImportCurrencyExRates(TTypedDataTable AExchangeRateDT, string AImportFileName, string ACSVSeparator, string AImportMode, TVerificationResultCollection AResultCollection) { // Test import always uses standard file with US formats TDlgSelectCSVSeparator separatorDialog = new TDlgSelectCSVSeparator(false); separatorDialog.OpenCsvFile(AImportFileName); return ImportCurrencyExRatesFromCSV(AExchangeRateDT, separatorDialog.FileContent, ACSVSeparator, TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN, "MM/dd/yyyy", false, AImportMode, AResultCollection, Path.GetFileNameWithoutExtension(AImportFileName)); }
public static TSubmitChangesResult SaveData(string ATablename, ref TTypedDataTable ASubmitTable, out TVerificationResultCollection AVerificationResult) { TSubmitChangesResult ReturnValue = TSubmitChangesResult.scrError; TDBTransaction WriteTransaction = null; TTypedDataTable SubmitTable = null; TVerificationResultCollection VerificationResult = null; SubmitTable = ASubmitTable; // Automatic handling of a DB Transaction - and also the automatic establishment and closing of a DB // Connection where a DB Transaction can be exectued (only if that should be needed). DBAccess.SimpleAutoTransactionWrapper("TCommonDataReader.SaveData", out WriteTransaction, ref ReturnValue, delegate { ReturnValue = SaveData(ATablename, ref SubmitTable, out VerificationResult, WriteTransaction); }); AVerificationResult = VerificationResult; return(ReturnValue); }
public static int GetNonCacheableRecordReferenceCountManual(TTypedDataTable ADataTable, object[] APrimaryKeyValues, out TVerificationResultCollection AVerificationResult) { int ReturnValue = 0; TVerificationResultCollection VerificationResult = new TVerificationResultCollection(); TDBTransaction Transaction = new TDBTransaction(); DBAccess.ReadTransaction( ref Transaction, delegate { if (ADataTable is PcConferenceTable) { ReturnValue = CountByPrimaryKey(APrimaryKeyValues, Transaction, true, out VerificationResult); } }); AVerificationResult = VerificationResult; return(ReturnValue); }
private void SaveDataLabelUseChanges(TTypedDataTable ASubmitChanges) { // Submit changes to the PETRAServer for the DataLabelUse table // This code is basically lifted from a typical auto-generated equivalent // TODO: If the standard code changes because TODO's get done, we will need to change this manual code TSubmitChangesResult SubmissionResult; TVerificationResultCollection VerificationResult; try { SubmissionResult = TDataCache.SaveChangedCacheableDataTableToPetraServer("DataLabelUseList", ref ASubmitChanges, out VerificationResult); } catch (ESecurityDBTableAccessDeniedException Exp) { FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException); this.Cursor = Cursors.Default; TMessages.MsgSecurityException(Exp, this.GetType()); return; } catch (EDBConcurrencyException Exp) { FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException); this.Cursor = Cursors.Default; TMessages.MsgDBConcurrencyException(Exp, this.GetType()); return; } catch (Exception exp) { TLogging.Log( "An error occured while saving the 'used by' data" + Environment.NewLine + exp.ToString(), TLoggingType.ToLogfile); MessageBox.Show( Catalog.GetString("An error occured while saving the 'used by' data") + Environment.NewLine + Catalog.GetString("For details see the log file: ") + TLogging.GetLogFileName(), Catalog.GetString("Failed to Save 'Used By' Data"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } switch (SubmissionResult) { case TSubmitChangesResult.scrOK: // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server FExtraDS.PDataLabelUse.AcceptChanges(); // Merge back with data from the Server (eg. for getting Sequence values) ASubmitChanges.AcceptChanges(); FExtraDS.PDataLabelUse.Merge(ASubmitChanges, false); // need to accept the new modification ID FExtraDS.PDataLabelUse.AcceptChanges(); // need to refresh the cacheable DataTable 'DataLabelsForPartnerClassesList' (used by Partner Find's Maintain Menu) TDataCache.TMPartner.RefreshCacheablePartnerTable(TCacheablePartnerTablesEnum.DataLabelsForPartnerClassesList); return; case TSubmitChangesResult.scrNothingToBeSaved: return; case TSubmitChangesResult.scrError: MessageBox.Show(Catalog.GetString( "The 'UsedBy' part of the data could not be saved! There has been an error while making changes to the table."), Catalog.GetString("Submit Changes to Table Error"), MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case TSubmitChangesResult.scrInfoNeeded: MessageBox.Show(Catalog.GetString( "The 'UsedBy' part of the data could not be saved! Insufficient information was provided when making changes to the table."), Catalog.GetString("Submit Changes to Table Error"), MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } }