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; } }
/// <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. " + VerificationResult.BuildVerificationResultString()); break; case TSubmitChangesResult.scrInfoNeeded: Console.WriteLine("Error saving data prior to test: Info Needed"); break; } return false; }