/// <summary> /// Performs checks to determine whether a deletion of the current /// row is permissable /// </summary> /// <param name="ARowToDelete">the currently selected row to be deleted</param> /// <param name="ADeletionQuestion">can be changed to a context-sensitive deletion confirmation question</param> /// <returns>true if user is permitted and able to delete the current row</returns> private bool PreDeleteManual(PartnerEditTDSPPartnerLocationRow ARowToDelete, ref string ADeletionQuestion) { Boolean DeleteSecurityOK; /* * Check security */ DeleteSecurityOK = CheckDeleteSecurityGeneral(true); if (!DeleteSecurityOK) { return false; } // Determine the Text of the question that is shown to the user FSharedLocationPartnerLocation = FPartnerEditUIConnector.HasPartnerLocationOtherPartnerReferences(ARowToDelete.SiteKey, ARowToDelete.LocationKey); DeletedRowSiteKey = ARowToDelete.SiteKey; DeletedRowLocationKey = ARowToDelete.LocationKey; if (FSharedLocationPartnerLocation) { ADeletionQuestion = Catalog.GetString("Are you sure you want to remove this address from this partner?"); } else { // Check security if Location is not shared (needs to be deletable then) if (!CheckDeleteSecurityNonSharedLocation(true)) { return false; } ADeletionQuestion = Catalog.GetString("Are you sure you want to remove this address from the database (it is not used elsewhere)?"); } ADeletionQuestion += String.Format("{0}{0}({1} {2},{0}{3} {4},{0}{5} {6})", Environment.NewLine, lblLocationStreetName.Text, txtLocationStreetName.Text, lblLocationCity.Text, txtLocationCity.Text, lblLocationCountryCode.Text, cmbLocationCountryCode.GetSelectedString()); // Keep a copy of the current PartnerLocation record in case the // deleted record was the last one and a new default record needs to be // created afterwards FJustDeletedPartnerLocationsRow = FMainDS.PPartnerLocation.NewRow(); FJustDeletedPartnerLocationsRow.ItemArray = ARowToDelete.ItemArray; return true; }
/// <summary> /// manual code when adding new row /// </summary> /// <param name="ARow"></param> private void NewRowManual(ref PartnerEditTDSPPartnerLocationRow ARow) { PLocationRow NewLocationRow = FMainDS.PLocation.NewRowTyped(true); Int32 LocationKey = -1; while (FMainDS.PLocation.Rows.Find(new object[] { ARow.SiteKey, LocationKey }) != null) { LocationKey = LocationKey - 1; } NewLocationRow.LocationKey = LocationKey; FMainDS.PLocation.Rows.Add(NewLocationRow); ARow.PartnerKey = ((PPartnerRow)FMainDS.PPartner.Rows[0]).PartnerKey; // LocationKey has to be set properly later on server side ARow.LocationKey = LocationKey; // initialize "valid from" date with today's date ARow.DateEffective = DateTime.Today; // initialize country code, email address, URL and mobile number from last (currently) selected address if ((FPreviouslySelectedDetailRow != null) && (FPreviouslySelectedDetailRow.RowState != DataRowState.Detached)) { ARow.LocationCountryCode = FPreviouslySelectedDetailRow.LocationCountryCode; ARow.EmailAddress = FPreviouslySelectedDetailRow.EmailAddress; ARow.Url = FPreviouslySelectedDetailRow.Url; ARow.MobileNumber = FPreviouslySelectedDetailRow.MobileNumber; } // initialize location type with default value depending on partner class ARow.LocationType = TSharedAddressHandling.GetDefaultLocationType(SharedTypes.PartnerClassStringToEnum(FMainDS.PPartner[0].PartnerClass)); // make sure this is initialized as otherwise initial drawing of cell gives problems ARow.BestAddress = false; ARow.Icon = 1; RemoveDefaultRecord(); }
private void ValidateDataDetailsManual(PartnerEditTDSPPartnerLocationRow ARow) { TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; TSharedPartnerValidation_Partner.ValidatePartnerAddressManual(this, ARow, ref VerificationResultCollection, FValidationControlsDict); }
/// <summary> /// Code to be run after the deletion process /// </summary> /// <param name="ARowToDelete">the row that was/was to be deleted</param> /// <param name="AAllowDeletion">whether or not the user was permitted to delete</param> /// <param name="ADeletionPerformed">whether or not the deletion was performed successfully</param> /// <param name="ACompletionMessage">if specified, is the deletion completion message</param> private void PostDeleteManual(PartnerEditTDSPPartnerLocationRow ARowToDelete, bool AAllowDeletion, bool ADeletionPerformed, string ACompletionMessage) { DataRow LocationRow; if (ADeletionPerformed) { if (!FSharedLocationPartnerLocation) { // delete location row if it was the last one LocationRow = FMainDS.PLocation.Rows.Find(new object[] { DeletedRowSiteKey, DeletedRowLocationKey }); if (LocationRow != null) { LocationRow.Delete(); } } // reset temporary variables DeletedRowSiteKey = -1; DeletedRowLocationKey = -1; // Determination of the Grid icons and the 'Best Address' (these calls change certain columns in some rows!) Calculations.DeterminePartnerLocationsDateStatus((DataSet)FMainDS); Calculations.DetermineBestAddress((DataSet)FMainDS); if (grdDetails.Rows.Count <= 1) { AddDefaultRecord(); grdDetails.SelectRowInGrid(1); } ApplySecurity(); DoRecalculateScreenParts(); } else { FJustDeletedPartnerLocationsRow = null; } }
/// <summary> /// Update extra location specific fields in DataRow APartnerLocationDR /// </summary> /// <param name="ALocationDT">Table containing location records to be used to update APartnerLocation records.</param> /// <param name="APartnerLocationDR">Single DataRow to be updated with Location specific information.</param> /// <param name="AMakePLocationRecordUnchanged">Set to true to make the PLocation Record unchanged /// (by calling .AcceptChanges() on it).</param> public static void SyncPartnerEditTDSPartnerLocation(PLocationTable ALocationDT, PartnerEditTDSPPartnerLocationRow APartnerLocationDR, bool AMakePLocationRecordUnchanged = false) { DataRow Row; PLocationRow LocationRow; if (APartnerLocationDR.RowState != DataRowState.Deleted) { Row = ALocationDT.Rows.Find(new Object[] { APartnerLocationDR.SiteKey, APartnerLocationDR.LocationKey }); if (Row != null) { LocationRow = (PLocationRow)Row; APartnerLocationDR.LocationLocality = LocationRow.Locality; APartnerLocationDR.LocationStreetName = LocationRow.StreetName; APartnerLocationDR.LocationAddress3 = LocationRow.Address3; APartnerLocationDR.LocationCity = LocationRow.City; APartnerLocationDR.LocationCounty = LocationRow.County; APartnerLocationDR.LocationPostalCode = LocationRow.PostalCode; APartnerLocationDR.LocationCountryCode = LocationRow.CountryCode; APartnerLocationDR.LocationCreatedBy = LocationRow.CreatedBy; if (!LocationRow.IsDateCreatedNull()) { APartnerLocationDR.LocationDateCreated = (DateTime)LocationRow.DateCreated; } APartnerLocationDR.LocationModifiedBy = LocationRow.ModifiedBy; if (!LocationRow.IsDateModifiedNull()) { APartnerLocationDR.LocationDateModified = (DateTime)LocationRow.DateModified; } if (AMakePLocationRecordUnchanged) { Row.AcceptChanges(); } } } }
/// <summary> /// Validates the Partner Edit screens' Address Tab data. /// </summary> /// <param name="AContext">Context that describes where the data validation failed.</param> /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param> /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if /// data validation errors occur.</param> /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that /// display data that is about to be validated.</param> public static void ValidatePartnerAddressManual(object AContext, PartnerEditTDSPPartnerLocationRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'Email' must be in correct format ValidationColumn = ARow.Table.Columns[PartnerEditTDSPPartnerLocationTable.ColumnEmailAddressId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TStringChecks.ValidateEmail(ARow.EmailAddress, true, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }