/// <summary> /// Display data in control based on data from ARow /// </summary> /// <param name="ARow"></param> public void ShowDetails(PSubscriptionRow ARow) { FInitializationRunning = true; // show controls if not visible yet MakeScreenInvisible(false); // set member FSubscriptionDR = ARow; ShowData(ARow); // for every record initially disable issue group box, but enable button in the same group box if (FAllowEditIssues) { this.btnEditIssues.Visible = true; this.btnEditIssues.Enabled = true; } EnableDisableIssuesGroupBox(false); txtPublicationCost.ReadOnly = true; // make sure initialization happens PublicationStatusChanged(null, null); FInitializationRunning = false; }
private void ValidateDataManual(PSubscriptionRow ARow) { TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; TSharedPartnerValidation_Partner.ValidateSubscriptionManual(this, ARow, ref VerificationResultCollection, FValidationControlsDict); }
/// <summary> /// /// </summary> /// <param name="ARow"></param> private void GetDetailDataFromControlsManual(PSubscriptionRow ARow) { ucoDetails.GetDetails(ARow); // Clear validation messages as the exact same validation is carried out here as well as ucoDetails. // If we do not clear we get duplicate validation messages. FPetraUtilsObject.VerificationResultCollection.Clear(); }
/// <summary> /// Called by the instantiator of this Dialog to retrieve the values of Fields /// on the screen. /// </summary> /// <param name="ARow"></param> /// <returns>Boolean</returns> public Boolean GetReturnedParameters(ref PSubscriptionRow ARow) { Boolean ReturnValue = true; DataUtilities.CopyAllColumnValues(FMainDS.PSubscription.Rows[0], ARow); return(ReturnValue); }
/// <summary> /// Change subscription for Partners in selected Extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChangeSubscription(System.Object sender, EventArgs e) { PSubscriptionTable SubscriptionTable = new PSubscriptionTable(); PSubscriptionRow SubscriptionRow = SubscriptionTable.NewRowTyped(); PPartnerTable PartnersWithoutSubs = new PPartnerTable(); int SubscriptionsChanged; String MessageText; List <String> FieldsToChange = new List <string>(); if (!WarnIfNotSingleSelection(Catalog.GetString("Add Subscription")) && (GetSelectedDetailRow() != null)) { TFrmUpdateExtractChangeSubscriptionDialog dialog = new TFrmUpdateExtractChangeSubscriptionDialog(this.FindForm()); dialog.SetExtractName(GetSelectedDetailRow().ExtractName); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (dialog.GetReturnedParameters(ref SubscriptionRow, ref FieldsToChange)) { SubscriptionTable.Rows.Add(SubscriptionRow); // perform update of extract data on server side TRemote.MPartner.Partner.WebConnectors.ChangeSubscription (GetSelectedDetailRow().ExtractId, ref SubscriptionTable, FieldsToChange, out PartnersWithoutSubs, out SubscriptionsChanged); MessageText = String.Format(Catalog.GetString( "Subscription {0} successfully changed for {1} out of {2} Partner(s) in Extract {3}."), SubscriptionRow.PublicationCode, SubscriptionsChanged, GetSelectedDetailRow().KeyCount, GetSelectedDetailRow().ExtractName); if (PartnersWithoutSubs.Rows.Count > 0) { MessageText += "\r\n\r\n" + String.Format(Catalog.GetString( "See the following Dialog for the {0} Partner(s) that are not subscribed for this Publication and therefore no change was made for them."), PartnersWithoutSubs.Rows.Count); } MessageBox.Show(MessageText, Catalog.GetString("Change Subscription"), MessageBoxButtons.OK, MessageBoxIcon.Information); if (PartnersWithoutSubs.Rows.Count > 0) { TFrmSimplePartnerListDialog partnerDialog = new TFrmSimplePartnerListDialog(this.FindForm()); partnerDialog.SetExplanation("These partners do not have a Subscription for " + SubscriptionRow.PublicationCode, "The Subscription was therefore not changed for the following Partners:"); partnerDialog.SetPartnerList(PartnersWithoutSubs); partnerDialog.ShowDialog(); } } } } }
/// <summary> /// /// </summary> /// <param name="ARow"></param> private void NewRowManual(ref PSubscriptionRow ARow) { // apply changes from previous record //GetDetailsFromControls(GetSelectedDetailRow()); // Initialize subscription ARow.PartnerKey = ((PPartnerRow)FMainDS.PPartner.Rows[0]).PartnerKey; ARow.PublicationCode = ""; }
/// <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(PSubscriptionRow ARowToDelete, bool AAllowDeletion, bool ADeletionPerformed, string ACompletionMessage) { if (ADeletionPerformed) { DoRecalculateScreenParts(); } }
/// <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(PSubscriptionRow ARowToDelete, ref string ADeletionQuestion) { /*Code to execute before the delete can take place*/ ADeletionQuestion = Catalog.GetString("Are you sure you want to delete the current row?"); ADeletionQuestion += String.Format("{0}{0}({1} {2})", Environment.NewLine, ucoDetails.PublicationCodeLabel, ucoDetails.PublicationCodeValue); return(true); }
/// <summary> /// /// </summary> /// <param name="ARow"></param> private void ShowDetailsManual(PSubscriptionRow ARow) { if (ARow != null) { ucoDetails.AllowEditIssues = true; ucoDetails.ShowDetails(ARow); } if (ARow != null) { btnCancelAllSubscriptions.Enabled = true; } }
private void InitializeManualCode() { // show this dialog in center of screen this.StartPosition = FormStartPosition.CenterScreen; FMainDS = new PartnerEditTDS(); // now add the one subscription row to the DS that we are working with PSubscriptionTable SubscriptionTable = new PSubscriptionTable(); FMainDS.Merge(SubscriptionTable); PSubscriptionRow SubscriptionRow = FMainDS.PSubscription.NewRowTyped(true); SubscriptionRow.PublicationCode = ""; // avoid NOT NULL error message FMainDS.PSubscription.Rows.Add(SubscriptionRow); ucoSubscription.MainDS = FMainDS; ucoSubscription.SpecialInitUserControl(); FPetraUtilsObject.HasChanges = false; }
private static void CreateSubscriptions(XmlNode ANode, Int64 APartnerKey, ref PartnerImportExportTDS AMainDS) { int SubsCount = 0; foreach (XmlAttribute Attr in ANode.Attributes) { if ((Attr.Name.ToLower().IndexOf("subscribe_") == 0) && (Attr.Value.ToLower() == "yes")) { PSubscriptionRow NewRow = AMainDS.PSubscription.NewRowTyped(); NewRow.PartnerKey = APartnerKey; NewRow.PublicationCode = Attr.Name.Substring(10).ToUpper(); AMainDS.PSubscription.Rows.Add(NewRow); SubsCount++; } } if (SubsCount > 0) { AddVerificationResult("Subscriptions Created.", TResultSeverity.Resv_Status); } }
/// <summary> /// Called by the instantiator of this Dialog to retrieve the values of Fields /// on the screen. /// </summary> /// <param name="ARow"></param> /// <returns>Boolean</returns> public Boolean GetReturnedParameters(ref PSubscriptionRow ARow) { Boolean ReturnValue = true; DataUtilities.CopyAllColumnValues(FMainDS.PSubscription.Rows[0], ARow); return ReturnValue; }
/// <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(PSubscriptionRow ARowToDelete, ref string ADeletionQuestion) { /*Code to execute before the delete can take place*/ ADeletionQuestion = Catalog.GetString("Are you sure you want to delete the current row?"); ADeletionQuestion += String.Format("{0}{0}({1} {2})", Environment.NewLine, ucoDetails.PublicationCodeLabel, ucoDetails.PublicationCodeValue); return true; }
public void TestDeleteFamily() { DataSet ResponseDS = new PartnerEditTDS(); TVerificationResultCollection VerificationResult; String TextMessage; Boolean CanDeletePartner; PPartnerRow FamilyPartnerRow; PFamilyRow FamilyRow; PPersonRow PersonRow; TSubmitChangesResult result; Int64 PartnerKey; TPartnerEditUIConnector connector = new TPartnerEditUIConnector(); PartnerEditTDS MainDS = new PartnerEditTDS(); FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS); result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "Create family record"); // check if Family partner can be deleted (still needs to be possible at this point) CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage); if (TextMessage.Length > 0) { TLogging.Log(TextMessage); } Assert.IsTrue(CanDeletePartner); // add a person to the family which means the family is not allowed to be deleted any longer FamilyRow = (PFamilyRow)MainDS.PFamily.Rows[0]; FamilyRow.FamilyMembers = true; TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS); result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create new location"); PartnerEditTDS PersonDS = new PartnerEditTDS(); PersonRow = TCreateTestPartnerData.CreateNewPerson(PersonDS, FamilyPartnerRow.PartnerKey, MainDS.PLocation[0].LocationKey, "Adam", "Mr", 0); PersonRow.FamilyKey = FamilyPartnerRow.PartnerKey; result = connector.SubmitChanges(ref PersonDS, ref ResponseDS, out VerificationResult); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create person record"); CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage); if (TextMessage.Length > 0) { TLogging.Log(TextMessage); } Assert.IsTrue(!CanDeletePartner); // create new family and create subscription given as gift from this family: not allowed to be deleted FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS); PPublicationTable PublicationTable = PPublicationAccess.LoadByPrimaryKey("TESTPUBLICATION", DBAccess.GDBAccessObj.Transaction); if (PublicationTable.Count == 0) { // first check if frequency "Annual" exists and if not then create it if (!AFrequencyAccess.Exists("Annual", DBAccess.GDBAccessObj.Transaction)) { // set up details (e.g. bank account) for this Bank so deletion is not allowed AFrequencyTable FrequencyTable = new AFrequencyTable(); AFrequencyRow FrequencyRow = FrequencyTable.NewRowTyped(); FrequencyRow.FrequencyCode = "Annual"; FrequencyRow.FrequencyDescription = "Annual Frequency"; FrequencyTable.Rows.Add(FrequencyRow); AFrequencyAccess.SubmitChanges(FrequencyTable, DBAccess.GDBAccessObj.Transaction); } // now add the publication "TESTPUBLICATION" PPublicationRow PublicationRow = PublicationTable.NewRowTyped(); PublicationRow.PublicationCode = "TESTPUBLICATION"; PublicationRow.FrequencyCode = "Annual"; PublicationTable.Rows.Add(PublicationRow); PPublicationAccess.SubmitChanges(PublicationTable, DBAccess.GDBAccessObj.Transaction); } // make sure that "reason subscription given" exists if (!PReasonSubscriptionGivenAccess.Exists("FREE", DBAccess.GDBAccessObj.Transaction)) { // set up details (e.g. bank account) for this Bank so deletion is not allowed PReasonSubscriptionGivenTable ReasonTable = new PReasonSubscriptionGivenTable(); PReasonSubscriptionGivenRow ReasonRow = ReasonTable.NewRowTyped(); ReasonRow.Code = "FREE"; ReasonRow.Description = "Free Subscription"; ReasonTable.Rows.Add(ReasonRow); PReasonSubscriptionGivenAccess.SubmitChanges(ReasonTable, DBAccess.GDBAccessObj.Transaction); } // now add the publication "TESTPUBLICATION" to the first family record and indicate it was a gift from newly created family record PSubscriptionRow SubscriptionRow = MainDS.PSubscription.NewRowTyped(); SubscriptionRow.PublicationCode = "TESTPUBLICATION"; SubscriptionRow.PartnerKey = FamilyRow.PartnerKey; // link subscription with original family SubscriptionRow.GiftFromKey = FamilyPartnerRow.PartnerKey; // indicate that subscription is a gift from newly created family SubscriptionRow.ReasonSubsGivenCode = "FREE"; MainDS.PSubscription.Rows.Add(SubscriptionRow); result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "add publication to family record"); // this should now not be allowed since partner record has a subscription linked to it CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage); if (TextMessage.Length > 0) { TLogging.Log(TextMessage); } Assert.IsTrue(!CanDeletePartner); // now test actual deletion of Family partner FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS); PartnerKey = FamilyPartnerRow.PartnerKey; result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family record"); // check if Family record is being deleted Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult)); // check that Family record is really deleted Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey)); }
private void ValidateDataManual(PSubscriptionRow ARow) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; bool NoClearingOfVerificationResult = false; TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; if (!chkChangeReasonSubsGivenCode.Checked) { if (VerificationResultCollection.Contains(ARow.Table.Columns[PSubscriptionTable.ColumnReasonSubsGivenCodeId])) { VerificationResultCollection.Remove(ARow.Table.Columns[PSubscriptionTable.ColumnReasonSubsGivenCodeId]); } } if (!chkChangeStartDate.Checked) { if (VerificationResultCollection.Contains(ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId])) { VerificationResultCollection.Remove(ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId]); } } // if 'SubscriptionStatus' is CANCELLED or EXPIRED then 'Reason Ended' and 'End Date' must be set ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnSubscriptionStatusId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if ((!ARow.IsSubscriptionStatusNull()) && ((ARow.SubscriptionStatus == "CANCELLED") || (ARow.SubscriptionStatus == "EXPIRED"))) { if (ARow.IsReasonSubsCancelledCodeNull() || (ARow.ReasonSubsCancelledCode == String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDMANDATORY_WHEN_EXPIRED)), ValidationColumn, ValidationControlsData.ValidationControl); } else if (ARow.IsDateCancelledNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDMANDATORY_WHEN_EXPIRED)), ValidationColumn, ValidationControlsData.ValidationControl); } } else { // if 'SubscriptionStatus' is not CANCELLED or EXPIRED then 'Reason Ended' and 'End Date' must NOT be set if (chkChangeReasonSubsCancelledCode.Checked) { if ((ARow.IsReasonSubsCancelledCodeNull()) || (ARow.ReasonSubsCancelledCode == String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); } } else if (!chkChangeReasonSubsCancelledCode.Checked) { if (ARow.SubscriptionStatus != String.Empty) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); VerificationResult.OverrideResultText(Catalog.GetString( "Reason Ended must be cleared when a Subscription is made active.")); NoClearingOfVerificationResult = true; } } if ((!ARow.IsReasonSubsCancelledCodeNull()) && (ARow.ReasonSubsCancelledCode != String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); } else if (!ARow.IsDateCancelledNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); } else if (!chkChangeDateCancelled.Checked) { if (ARow.SubscriptionStatus != String.Empty) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); VerificationResult.OverrideResultText(Catalog.GetString("Date Ended must be cleared when a Subscription is made active.")); } } else { if (!NoClearingOfVerificationResult) { VerificationResult = null; } } } // Handle addition/removal to/from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } }
/// <summary> /// /// </summary> /// <param name="ARow"></param> private void GetDetailDataFromControlsManual(PSubscriptionRow ARow) { ucoDetails.GetDetails(ARow); }
public static bool SavePartner(PartnerEditTDS AMainDS, List <string> ASubscriptions, List <string> APartnerTypes) { List <string> Dummy1, Dummy2; string Dummy3, Dummy4, Dummy5; PartnerEditTDS SaveDS; if (AMainDS.PPartner[0].ModificationId == DateTime.MinValue) { // this is a new partner SaveDS = AMainDS; if (SaveDS.PPartner[0].PartnerKey == -1) { SaveDS.PPartner[0].PartnerKey = NewPartnerKey(); } if (SaveDS.PFamily.Count > 0) { SaveDS.PFamily[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } else if (SaveDS.PPerson.Count > 0) { SaveDS.PPerson[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } else if (SaveDS.PChurch.Count > 0) { SaveDS.PChurch[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } else if (SaveDS.POrganisation.Count > 0) { SaveDS.POrganisation[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } PPartnerLocationRow partnerlocation = SaveDS.PPartnerLocation.NewRowTyped(); partnerlocation.PartnerKey = SaveDS.PPartner[0].PartnerKey; partnerlocation.LocationKey = SaveDS.PLocation[0].LocationKey; partnerlocation.SiteKey = SaveDS.PLocation[0].SiteKey; SaveDS.PPartnerLocation.Rows.Add(partnerlocation); } else { SaveDS = GetPartnerDetails(AMainDS.PPartner[0].PartnerKey, out Dummy1, out Dummy2, out Dummy3, out Dummy4, out Dummy5); DataUtilities.CopyDataSet(AMainDS, SaveDS); } List <string> ExistingPartnerTypes = new List <string>(); foreach (PPartnerTypeRow partnertype in SaveDS.PPartnerType.Rows) { if (!APartnerTypes.Contains(partnertype.TypeCode)) { partnertype.Delete(); } else { ExistingPartnerTypes.Add(partnertype.TypeCode); } } // add new partner types foreach (string partnertype in APartnerTypes) { if (!ExistingPartnerTypes.Contains(partnertype)) { PPartnerTypeRow partnertypeRow = SaveDS.PPartnerType.NewRowTyped(); partnertypeRow.PartnerKey = AMainDS.PPartner[0].PartnerKey; partnertypeRow.TypeCode = partnertype; SaveDS.PPartnerType.Rows.Add(partnertypeRow); } } List <string> ExistingSubscriptions = new List <string>(); foreach (PSubscriptionRow subscription in SaveDS.PSubscription.Rows) { if (!ASubscriptions.Contains(subscription.PublicationCode)) { subscription.Delete(); } else { ExistingSubscriptions.Add(subscription.PublicationCode); } } // add new subscriptions foreach (string subscription in ASubscriptions) { if (!ExistingSubscriptions.Contains(subscription)) { PSubscriptionRow subscriptionRow = SaveDS.PSubscription.NewRowTyped(); subscriptionRow.PartnerKey = AMainDS.PPartner[0].PartnerKey; subscriptionRow.PublicationCode = subscription; subscriptionRow.ReasonSubsGivenCode = "FREE"; SaveDS.PSubscription.Rows.Add(subscriptionRow); } } // TODO: either reuse Partner Edit UIConnector // or check for changed partner key, or changed Partner Class, etc. // set Partner Short Name if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_PERSON) { SaveDS.PPartner[0].PartnerShortName = Calculations.DeterminePartnerShortName( SaveDS.PPerson[0].FamilyName, SaveDS.PPerson[0].Title, SaveDS.PPerson[0].FirstName, SaveDS.PPerson[0].MiddleName1); } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_FAMILY) { SaveDS.PPartner[0].PartnerShortName = Calculations.DeterminePartnerShortName( SaveDS.PFamily[0].FamilyName, SaveDS.PFamily[0].Title, SaveDS.PFamily[0].FirstName); } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_UNIT) { SaveDS.PPartner[0].PartnerShortName = SaveDS.PUnit[0].UnitName; } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_ORGANISATION) { SaveDS.PPartner[0].PartnerShortName = SaveDS.POrganisation[0].OrganisationName; } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_BANK) { SaveDS.PPartner[0].PartnerShortName = SaveDS.PBank[0].BranchName; } // TODO: check if location 0 (no address) was changed. we don't want to overwrite that // alternative: check if somebody else uses that location, and split the locations. or ask if others should be updated??? if (SaveDS.PLocation[0].RowState == DataRowState.Modified && SaveDS.PLocation[0].LocationKey == 0) { TLogging.Log("we cannot update addresses of people with location 0"); return(false); } PartnerEditTDSAccess.SubmitChanges(SaveDS); return(true); }
/// <summary> /// Validates the Subscription data of a Partner. /// </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> /// <returns>void</returns> public static void ValidateSubscriptionManual(object AContext, PSubscriptionRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; DataColumn ValidationColumn2; TValidationControlsData ValidationControlsData; TValidationControlsData ValidationControlsData2; TScreenVerificationResult ScreenVerificationResult; TVerificationResult VerificationResult = null; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'SubscriptionStatus' must not be null or empty ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnSubscriptionStatusId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (((!ARow.IsSubscriptionStatusNull()) && (ARow.SubscriptionStatus == String.Empty)) || (ARow.IsSubscriptionStatusNull())) { ScreenVerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_STATUSMANDATORY)), ValidationColumn, ValidationControlsData.ValidationControl); } else { ScreenVerificationResult = null; } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, ScreenVerificationResult, ValidationColumn); } // perform checks that include 'Start Date' ---------------------------------------------------------------- ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { // 'Start Date' must not be later than 'Expiry Date' ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnExpiryDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.ExpiryDate, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Start Date' must not be later than 'Renewal Date' ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnSubscriptionRenewalDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.SubscriptionRenewalDate, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Start Date' must not be later than 'End Date' ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnDateCancelledId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.DateCancelled, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Start Date' must not be later than 'Notice Sent' ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnDateNoticeSentId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.DateNoticeSent, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Start Date' must not be later than 'First Sent' ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnFirstIssueId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.FirstIssue, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Start Date' must not be later than 'Last Date' ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnLastIssueId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.LastIssue, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } // perform checks that include 'Date Renewed' ---------------------------------------------------------------- ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnSubscriptionRenewalDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { // 'Date Renewed' must not be later than today VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.SubscriptionRenewalDate, DateTime.Today, ValidationControlsData.ValidationControlLabel, Catalog.GetString("Today's Date"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); // 'Date Renewed' must not be later than 'Date Expired' ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnExpiryDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.SubscriptionRenewalDate, ARow.ExpiryDate, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Date Renewed' must not be later than 'Date Notice Sent' ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnDateNoticeSentId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.SubscriptionRenewalDate, ARow.DateNoticeSent, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } // 'Date Cancelled' must not be before today ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnDateCancelledId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.DateCancelled, DateTime.Today, ValidationControlsData.ValidationControlLabel, Catalog.GetString("Today's Date"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'First Sent' must not be later than 'Last Sent' ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnFirstIssueId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnLastIssueId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.FirstIssue, ARow.LastIssue, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } // 'First Sent' must not be later than today ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnFirstIssueId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.FirstIssue, DateTime.Today, ValidationControlsData.ValidationControlLabel, Catalog.GetString("Today's Date"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Date Started' must not be later than 'First Sent' ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnFirstIssueId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.FirstIssue, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } // 'Last Sent' must not be later than today ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnLastIssueId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.LastIssue, DateTime.Today, ValidationControlsData.ValidationControlLabel, Catalog.GetString("Today's Date"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnSubscriptionStatusId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if ((!ARow.IsSubscriptionStatusNull()) && ((ARow.SubscriptionStatus == "CANCELLED") || (ARow.SubscriptionStatus == "EXPIRED"))) { // When status is CANCELLED or EXPIRED then make sure that Reason ended and End date are set if (ARow.IsReasonSubsCancelledCodeNull() || (ARow.ReasonSubsCancelledCode == String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDMANDATORY_WHEN_EXPIRED)), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } if (ARow.IsDateCancelledNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDMANDATORY_WHEN_EXPIRED)), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } else { // When Reason ended or End date are set then status must be CANCELLED or EXPIRED if ((!ARow.IsReasonSubsCancelledCodeNull()) && (ARow.ReasonSubsCancelledCode != String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } if (!ARow.IsDateCancelledNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } } }
/// <summary> /// todoComment /// </summary> /// <param name="Row"></param> /// <param name="AVerificationResultCollection"></param> /// <param name="VerificationResult"></param> /// <param name="AErroneousDC"></param> /// <param name="FtmpPartnerKeyValid"></param> /// <returns></returns> public static Boolean VerifySubscriptionDataFinal(PSubscriptionRow Row, out TVerificationResultCollection AVerificationResultCollection, out TVerificationResult VerificationResult, out DataColumn AErroneousDC, Boolean FtmpPartnerKeyValid) { Boolean ReturnValue; Boolean Completed; //Boolean NoErrors; TVerificationResultCollection TmpCollection = null; //TVerificationResult TmpError; DataColumn TmpDC; DataColumn NilDataColumn; String mVerifiedString; bool mPartnerExists; bool mPartnerIsMerged; TPartnerClass mPartnerClass; TPartnerClass[] mPartnerClassSet; Completed = false; ReturnValue = false; VerificationResult = null; AVerificationResultCollection = null; AErroneousDC = null; while (!Completed) { TmpDC = Row.Table.Columns[PSubscriptionTable.GetStartDateDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetStartDateDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetExpiryDateDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetExpiryDateDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetSubscriptionRenewalDateDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetSubscriptionRenewalDateDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetDateNoticeSentDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetDateNoticeSentDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetDateCancelledDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetDateCancelledDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetFirstIssueDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetFirstIssueDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetLastIssueDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetLastIssueDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } // if subscription status is cancelled, is there a partner that gives the gift. TmpDC = Row.Table.Columns[PSubscriptionTable.GetGiftFromKeyDBName()]; if (Row.IsSubscriptionStatusNull()) { // we go no further: VerificationResult = new TVerificationResult("", "Please select a valid subscription status", "Subscription Status Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; // escape before we crash return false; } if (Row.SubscriptionStatus == "GIFT") { // validate partner key again, to be sure! mPartnerClassSet = new TPartnerClass[0]; FtmpPartnerKeyValid = TServerLookup.TMPartner.VerifyPartner(Row.GiftFromKey, mPartnerClassSet, out mPartnerExists, out mVerifiedString, out mPartnerClass, out mPartnerIsMerged); } if ((Row.SubscriptionStatus == "GIFT") && ((!FtmpPartnerKeyValid) || (Row.GiftFromKey == 00000000))) { // MessageBox.Show('FtmpPartnerKeyValid: ' + FtmpPartnerKeyValid.toString); VerificationResult = new TVerificationResult("", StrGiftGivenByMandatory, StrGiftGivenByMandatoryTitle, "", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetReasonSubsCancelledCodeDBName()]; if ((Row.SubscriptionStatus == "CANCELLED") && (Row.IsReasonSubsCancelledCodeNull())) { VerificationResult = new TVerificationResult("", "Please select reason for the cancellation", "Reason for Cancellation Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } else { if ((Row.SubscriptionStatus == "CANCELLED") && (Row.ReasonSubsCancelledCode.Length < 2)) { VerificationResult = new TVerificationResult("", "Please select reason for the cancellation", "Reason for Cancellation Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } } TmpDC = Row.Table.Columns[PSubscriptionTable.GetReasonSubsCancelledCodeDBName()]; if ((Row.SubscriptionStatus == "EXPIRED") && (Row.IsReasonSubsCancelledCodeNull())) { VerificationResult = new TVerificationResult("", "Please select reason for the cancellation", "Reason for Cancellation Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } else { if ((Row.SubscriptionStatus == "EXPIRED") && (Row.ReasonSubsCancelledCode.Length < 2)) { VerificationResult = new TVerificationResult("", "Please select reason for the cancellation", "Reason for Cancellation Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } } TmpDC = Row.Table.Columns[PSubscriptionTable.GetReasonSubsGivenCodeDBName()]; try { if (Row.ReasonSubsGivenCode.Length < 2) { VerificationResult = new TVerificationResult("", "Please select reason for the Gift", "Reason for Gift Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } } catch (Exception) { VerificationResult = new TVerificationResult("", "Please select reason why the publication is given", "Reason for Gift Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } Completed = true; ReturnValue = true; } return ReturnValue; }
public static bool SavePartner(PartnerEditTDS AMainDS, List <string> ASubscriptions, List <string> APartnerTypes, bool ASendMail, string ADefaultEmailAddress, string ADefaultPhoneMobile, string ADefaultPhoneLandline, out TVerificationResultCollection AVerificationResult) { List <string> Dummy1, Dummy2; string Dummy3, Dummy4, Dummy5; PartnerEditTDS SaveDS; AVerificationResult = new TVerificationResultCollection(); if (AMainDS.PPartner[0].ModificationId == DateTime.MinValue) { // this is a new partner SaveDS = AMainDS; if (SaveDS.PPartner[0].PartnerKey == -1) { SaveDS.PPartner[0].PartnerKey = NewPartnerKey(); } if (SaveDS.PFamily.Count > 0) { SaveDS.PFamily[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } else if (SaveDS.PPerson.Count > 0) { SaveDS.PPerson[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } else if (SaveDS.PChurch.Count > 0) { SaveDS.PChurch[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } else if (SaveDS.POrganisation.Count > 0) { SaveDS.POrganisation[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } PPartnerLocationRow partnerlocation = SaveDS.PPartnerLocation.NewRowTyped(); partnerlocation.PartnerKey = SaveDS.PPartner[0].PartnerKey; partnerlocation.LocationKey = SaveDS.PLocation[0].LocationKey; partnerlocation.SiteKey = SaveDS.PLocation[0].SiteKey; partnerlocation.SendMail = ASendMail; SaveDS.PPartnerLocation.Rows.Add(partnerlocation); } else { SaveDS = GetPartnerDetails(AMainDS.PPartner[0].PartnerKey, out Dummy1, out Dummy2, out Dummy3, out Dummy4, out Dummy5); DataUtilities.CopyDataSet(AMainDS, SaveDS); } List <string> ExistingPartnerTypes = new List <string>(); foreach (PPartnerTypeRow partnertype in SaveDS.PPartnerType.Rows) { if (!APartnerTypes.Contains(partnertype.TypeCode)) { partnertype.Delete(); } else { ExistingPartnerTypes.Add(partnertype.TypeCode); } } // add new partner types foreach (string partnertype in APartnerTypes) { if (!ExistingPartnerTypes.Contains(partnertype)) { PPartnerTypeRow partnertypeRow = SaveDS.PPartnerType.NewRowTyped(); partnertypeRow.PartnerKey = AMainDS.PPartner[0].PartnerKey; partnertypeRow.TypeCode = partnertype; SaveDS.PPartnerType.Rows.Add(partnertypeRow); } } List <string> ExistingSubscriptions = new List <string>(); foreach (PSubscriptionRow subscription in SaveDS.PSubscription.Rows) { if (!ASubscriptions.Contains(subscription.PublicationCode)) { subscription.Delete(); } else { ExistingSubscriptions.Add(subscription.PublicationCode); } } // add new subscriptions foreach (string subscription in ASubscriptions) { if (!ExistingSubscriptions.Contains(subscription)) { PSubscriptionRow subscriptionRow = SaveDS.PSubscription.NewRowTyped(); subscriptionRow.PartnerKey = AMainDS.PPartner[0].PartnerKey; subscriptionRow.PublicationCode = subscription; subscriptionRow.ReasonSubsGivenCode = "FREE"; SaveDS.PSubscription.Rows.Add(subscriptionRow); } } bool foundDefaultEmailAddress = false; bool foundDefaultPhoneLandLine = false; bool foundDefaultMobileLandLine = false; foreach (PPartnerAttributeRow partnerattr in SaveDS.PPartnerAttribute.Rows) { if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_EMAIL) { partnerattr.Value = ADefaultEmailAddress; foundDefaultEmailAddress = true; } else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_PHONE) { partnerattr.Value = ADefaultPhoneLandline; foundDefaultPhoneLandLine = true; } else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_MOBILE_PHONE) { partnerattr.Value = ADefaultPhoneMobile; foundDefaultMobileLandLine = true; } } if (!foundDefaultEmailAddress) { PPartnerAttributeRow partnerattr = SaveDS.PPartnerAttribute.NewRowTyped(); partnerattr.PartnerKey = SaveDS.PPartner[0].PartnerKey; partnerattr.AttributeType = MPartnerConstants.ATTR_TYPE_EMAIL; partnerattr.Value = ADefaultEmailAddress; partnerattr.Index = 0; SaveDS.PPartnerAttribute.Rows.Add(partnerattr); } if (!foundDefaultPhoneLandLine) { PPartnerAttributeRow partnerattr = SaveDS.PPartnerAttribute.NewRowTyped(); partnerattr.PartnerKey = SaveDS.PPartner[0].PartnerKey; partnerattr.AttributeType = MPartnerConstants.ATTR_TYPE_PHONE; partnerattr.Value = ADefaultPhoneLandline; partnerattr.Index = 0; SaveDS.PPartnerAttribute.Rows.Add(partnerattr); } if (!foundDefaultMobileLandLine) { PPartnerAttributeRow partnerattr = SaveDS.PPartnerAttribute.NewRowTyped(); partnerattr.PartnerKey = SaveDS.PPartner[0].PartnerKey; partnerattr.AttributeType = MPartnerConstants.ATTR_TYPE_MOBILE_PHONE; partnerattr.Value = ADefaultPhoneMobile; partnerattr.Index = 0; SaveDS.PPartnerAttribute.Rows.Add(partnerattr); } // TODO: either reuse Partner Edit UIConnector // or check for changed partner key, or changed Partner Class, etc. // set Partner Short Name if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_PERSON) { SaveDS.PPartner[0].PartnerShortName = Calculations.DeterminePartnerShortName( SaveDS.PPerson[0].FamilyName, SaveDS.PPerson[0].Title, SaveDS.PPerson[0].FirstName, SaveDS.PPerson[0].MiddleName1); } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_FAMILY) { // check if we have a valid family name if (SaveDS.PFamily[0].FamilyName.Trim().Length == 0) { AVerificationResult.Add(new TVerificationResult("error", "Please specify the family name", "", "MaintainPartners.ErrMissingFamilyName", TResultSeverity.Resv_Critical)); return(false); } // check if we have a valid title if (SaveDS.PFamily[0].Title.Trim().Length == 0) { AVerificationResult.Add(new TVerificationResult("error", "Please specify the title", "", "MaintainPartners.ErrMissingTitle", TResultSeverity.Resv_Critical)); return(false); } SaveDS.PPartner[0].PartnerShortName = Calculations.DeterminePartnerShortName( SaveDS.PFamily[0].FamilyName, SaveDS.PFamily[0].Title, SaveDS.PFamily[0].FirstName); } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_UNIT) { SaveDS.PPartner[0].PartnerShortName = SaveDS.PUnit[0].UnitName; } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_ORGANISATION) { // check if we have a valid organisation name if (SaveDS.POrganisation[0].OrganisationName.Trim().Length == 0) { AVerificationResult.Add(new TVerificationResult("error", "Please specify the organisation name", "", "MaintainPartners.ErrMissingOrganisationName", TResultSeverity.Resv_Critical)); return(false); } SaveDS.PPartner[0].PartnerShortName = SaveDS.POrganisation[0].OrganisationName; } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_BANK) { SaveDS.PPartner[0].PartnerShortName = SaveDS.PBank[0].BranchName; } // change legacy addresses. create a new separate location for each partner if (SaveDS.PLocation[0].LocationKey == 0) { PLocationRow location = SaveDS.PLocation.NewRowTyped(); DataUtilities.CopyAllColumnValues(SaveDS.PLocation[0], location); location.SiteKey = DomainManager.GSiteKey; location.LocationKey = -1; SaveDS.PLocation.Rows.Clear(); SaveDS.PLocation.Rows.Add(location); PPartnerLocationRow plocation = SaveDS.PPartnerLocation.NewRowTyped(); DataUtilities.CopyAllColumnValues(SaveDS.PPartnerLocation[0], plocation); plocation.LocationKey = -1; plocation.SiteKey = DomainManager.GSiteKey; SaveDS.PPartnerLocation[0].Delete(); SaveDS.PPartnerLocation.Rows.Add(plocation); } // check if we have a valid country code if (SaveDS.PLocation[0].CountryCode.Trim().Length == 0) { AVerificationResult.Add(new TVerificationResult("error", "The country code is missing", TResultSeverity.Resv_Critical)); return(false); } TDBTransaction Transaction = new TDBTransaction(); bool WrongCountryCode = false; DBAccess.ReadTransaction(ref Transaction, delegate { WrongCountryCode = !PCountryAccess.Exists(SaveDS.PLocation[0].CountryCode, Transaction); }); if (WrongCountryCode) { AVerificationResult.Add(new TVerificationResult("error", "The country code does not match a country", TResultSeverity.Resv_Critical)); return(false); } DataSet ResponseDS = new PartnerEditTDS(); TPartnerEditUIConnector uiconnector = new TPartnerEditUIConnector(SaveDS.PPartner[0].PartnerKey); try { TSubmitChangesResult result = uiconnector.SubmitChanges( ref SaveDS, ref ResponseDS, out AVerificationResult); return(result == TSubmitChangesResult.scrOK); } catch (Exception e) { TLogging.Log(e.ToString()); AVerificationResult.Add(new TVerificationResult("error", e.Message, TResultSeverity.Resv_Critical)); return(false); } }
/// <summary> /// Called by the instantiator of this Dialog to retrieve the values of Fields /// on the screen. /// </summary> /// <param name="ARow"></param> /// <param name="AFieldsToChange"></param> /// <returns>Boolean</returns> public Boolean GetReturnedParameters(ref PSubscriptionRow ARow, ref List <String>AFieldsToChange) { Boolean ReturnValue = true; ARow.InitValues(); AFieldsToChange.Clear(); // publication code needs to be set, otherwise change can not be performed if (cmbPSubscriptionPublicationCode.GetSelectedString() == "") { return false; } ARow.PublicationCode = cmbPSubscriptionPublicationCode.GetSelectedString(); if (chkChangeSubscriptionStatus.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetSubscriptionStatusDBName()); ARow.SubscriptionStatus = cmbPSubscriptionSubscriptionStatus.Text; } if (chkChangeGratisSubscription.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetGratisSubscriptionDBName()); ARow.GratisSubscription = chkPSubscriptionGratisSubscription.Checked; } if (chkChangeNumberComplimentary.Checked && txtPSubscriptionNumberComplimentary.NumberValueInt.HasValue) { AFieldsToChange.Add(PSubscriptionTable.GetNumberComplimentaryDBName()); ARow.NumberComplimentary = txtPSubscriptionNumberComplimentary.NumberValueInt.Value; } if (chkChangePublicationCopies.Checked && txtPSubscriptionPublicationCopies.NumberValueInt.HasValue) { AFieldsToChange.Add(PSubscriptionTable.GetPublicationCopiesDBName()); ARow.PublicationCopies = txtPSubscriptionPublicationCopies.NumberValueInt.Value; } if (chkChangeReasonSubsGivenCode.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetReasonSubsGivenCodeDBName()); ARow.ReasonSubsGivenCode = cmbPSubscriptionReasonSubsGivenCode.GetSelectedString(); } if (chkChangeReasonSubsCancelledCode.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetReasonSubsCancelledCodeDBName()); ARow.ReasonSubsCancelledCode = cmbPSubscriptionReasonSubsCancelledCode.GetSelectedString(); } if (chkChangeGiftFromKey.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetGiftFromKeyDBName()); ARow.GiftFromKey = Convert.ToInt64(txtPSubscriptionGiftFromKey.Text); } if (chkChangeStartDate.Checked && dtpPSubscriptionStartDate.Date.HasValue) { AFieldsToChange.Add(PSubscriptionTable.GetStartDateDBName()); ARow.StartDate = dtpPSubscriptionStartDate.Date.Value; } if (chkChangeExpiryDate.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetExpiryDateDBName()); ARow.ExpiryDate = dtpPSubscriptionExpiryDate.Date; } if (chkChangeRenewalDate.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetSubscriptionRenewalDateDBName()); ARow.SubscriptionRenewalDate = dtpPSubscriptionSubscriptionRenewalDate.Date; } if (chkChangeDateNoticeSent.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetDateNoticeSentDBName()); ARow.DateNoticeSent = dtpPSubscriptionDateNoticeSent.Date; } if (chkChangeDateCancelled.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetDateCancelledDBName()); ARow.DateCancelled = dtpPSubscriptionDateCancelled.Date; } if (chkChangeNumberIssuesReceived.Checked && txtPSubscriptionNumberIssuesReceived.NumberValueInt.HasValue) { AFieldsToChange.Add(PSubscriptionTable.GetNumberIssuesReceivedDBName()); ARow.NumberIssuesReceived = txtPSubscriptionNumberIssuesReceived.NumberValueInt.Value; } if (chkChangeFirstIssue.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetFirstIssueDBName()); ARow.FirstIssue = dtpPSubscriptionFirstIssue.Date; } if (chkChangeLastIssue.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetLastIssueDBName()); ARow.LastIssue = dtpPSubscriptionLastIssue.Date; } return ReturnValue; }
public static bool SavePartner(PartnerEditTDS AMainDS, List <string> ASubscriptions, List <string> APartnerTypes, bool ASendMail, string ADefaultEmailAddress, string ADefaultPhoneMobile, string ADefaultPhoneLandline, out TVerificationResultCollection AVerificationResult) { List <string> Dummy1, Dummy2; string Dummy3, Dummy4, Dummy5; PartnerEditTDS SaveDS; AVerificationResult = new TVerificationResultCollection(); if (AMainDS.PPartner[0].ModificationId == DateTime.MinValue) { // this is a new partner SaveDS = AMainDS; if (SaveDS.PPartner[0].PartnerKey == -1) { SaveDS.PPartner[0].PartnerKey = NewPartnerKey(); } if (SaveDS.PFamily.Count > 0) { SaveDS.PFamily[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } else if (SaveDS.PPerson.Count > 0) { SaveDS.PPerson[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } else if (SaveDS.PChurch.Count > 0) { SaveDS.PChurch[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } else if (SaveDS.POrganisation.Count > 0) { SaveDS.POrganisation[0].PartnerKey = SaveDS.PPartner[0].PartnerKey; } PPartnerLocationRow partnerlocation = SaveDS.PPartnerLocation.NewRowTyped(); partnerlocation.PartnerKey = SaveDS.PPartner[0].PartnerKey; partnerlocation.LocationKey = SaveDS.PLocation[0].LocationKey; partnerlocation.SiteKey = SaveDS.PLocation[0].SiteKey; partnerlocation.SendMail = ASendMail; SaveDS.PPartnerLocation.Rows.Add(partnerlocation); } else { SaveDS = GetPartnerDetails(AMainDS.PPartner[0].PartnerKey, out Dummy1, out Dummy2, out Dummy3, out Dummy4, out Dummy5); DataUtilities.CopyDataSet(AMainDS, SaveDS); } List <string> ExistingPartnerTypes = new List <string>(); foreach (PPartnerTypeRow partnertype in SaveDS.PPartnerType.Rows) { if (!APartnerTypes.Contains(partnertype.TypeCode)) { partnertype.Delete(); } else { ExistingPartnerTypes.Add(partnertype.TypeCode); } } // add new partner types foreach (string partnertype in APartnerTypes) { if (!ExistingPartnerTypes.Contains(partnertype)) { PPartnerTypeRow partnertypeRow = SaveDS.PPartnerType.NewRowTyped(); partnertypeRow.PartnerKey = AMainDS.PPartner[0].PartnerKey; partnertypeRow.TypeCode = partnertype; SaveDS.PPartnerType.Rows.Add(partnertypeRow); } } List <string> ExistingSubscriptions = new List <string>(); foreach (PSubscriptionRow subscription in SaveDS.PSubscription.Rows) { if (!ASubscriptions.Contains(subscription.PublicationCode)) { subscription.Delete(); } else { ExistingSubscriptions.Add(subscription.PublicationCode); } } // add new subscriptions foreach (string subscription in ASubscriptions) { if (!ExistingSubscriptions.Contains(subscription)) { PSubscriptionRow subscriptionRow = SaveDS.PSubscription.NewRowTyped(); subscriptionRow.PartnerKey = AMainDS.PPartner[0].PartnerKey; subscriptionRow.PublicationCode = subscription; subscriptionRow.ReasonSubsGivenCode = "FREE"; SaveDS.PSubscription.Rows.Add(subscriptionRow); } } bool foundDefaultEmailAddress = false; bool foundDefaultPhoneLandLine = false; bool foundDefaultMobileLandLine = false; foreach (PPartnerAttributeRow partnerattr in SaveDS.PPartnerAttribute.Rows) { if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_EMAIL) { partnerattr.Value = ADefaultEmailAddress; foundDefaultEmailAddress = true; } else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_PHONE) { partnerattr.Value = ADefaultPhoneLandline; foundDefaultPhoneLandLine = true; } else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_MOBILE_PHONE) { partnerattr.Value = ADefaultPhoneMobile; foundDefaultMobileLandLine = true; } } if (!foundDefaultEmailAddress) { PPartnerAttributeRow partnerattr = SaveDS.PPartnerAttribute.NewRowTyped(); partnerattr.PartnerKey = SaveDS.PPartner[0].PartnerKey; partnerattr.AttributeType = MPartnerConstants.ATTR_TYPE_EMAIL; partnerattr.Value = ADefaultEmailAddress; SaveDS.PPartnerAttribute.Rows.Add(partnerattr); } if (!foundDefaultPhoneLandLine) { PPartnerAttributeRow partnerattr = SaveDS.PPartnerAttribute.NewRowTyped(); partnerattr.PartnerKey = SaveDS.PPartner[0].PartnerKey; partnerattr.AttributeType = MPartnerConstants.ATTR_TYPE_PHONE; partnerattr.Value = ADefaultPhoneLandline; SaveDS.PPartnerAttribute.Rows.Add(partnerattr); } if (!foundDefaultMobileLandLine) { PPartnerAttributeRow partnerattr = SaveDS.PPartnerAttribute.NewRowTyped(); partnerattr.PartnerKey = SaveDS.PPartner[0].PartnerKey; partnerattr.AttributeType = MPartnerConstants.ATTR_TYPE_MOBILE_PHONE; partnerattr.Value = ADefaultPhoneMobile; SaveDS.PPartnerAttribute.Rows.Add(partnerattr); } // TODO: either reuse Partner Edit UIConnector // or check for changed partner key, or changed Partner Class, etc. // set Partner Short Name if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_PERSON) { SaveDS.PPartner[0].PartnerShortName = Calculations.DeterminePartnerShortName( SaveDS.PPerson[0].FamilyName, SaveDS.PPerson[0].Title, SaveDS.PPerson[0].FirstName, SaveDS.PPerson[0].MiddleName1); } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_FAMILY) { SaveDS.PPartner[0].PartnerShortName = Calculations.DeterminePartnerShortName( SaveDS.PFamily[0].FamilyName, SaveDS.PFamily[0].Title, SaveDS.PFamily[0].FirstName); } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_UNIT) { SaveDS.PPartner[0].PartnerShortName = SaveDS.PUnit[0].UnitName; } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_ORGANISATION) { SaveDS.PPartner[0].PartnerShortName = SaveDS.POrganisation[0].OrganisationName; } else if (SaveDS.PPartner[0].PartnerClass == MPartnerConstants.PARTNERCLASS_BANK) { SaveDS.PPartner[0].PartnerShortName = SaveDS.PBank[0].BranchName; } // TODO: check if location 0 (no address) was changed. we don't want to overwrite that // alternative: check if somebody else uses that location, and split the locations. or ask if others should be updated??? if (SaveDS.PLocation[0].RowState == DataRowState.Modified && SaveDS.PLocation[0].LocationKey == 0) { TLogging.Log("we cannot update addresses of people with location 0"); AVerificationResult.Add(new TVerificationResult("error", "we cannot update addresses of people with location 0", TResultSeverity.Resv_Critical)); return(false); } DataSet ResponseDS = new PartnerEditTDS(); TPartnerEditUIConnector uiconnector = new TPartnerEditUIConnector(SaveDS.PPartner[0].PartnerKey); try { TSubmitChangesResult result = uiconnector.SubmitChanges( ref SaveDS, ref ResponseDS, out AVerificationResult); return(result == TSubmitChangesResult.scrOK); } catch (Exception e) { TLogging.Log(e.ToString()); AVerificationResult.Add(new TVerificationResult("error", e.Message, TResultSeverity.Resv_Critical)); return(false); } }
private void ValidateDataManual(PSubscriptionRow ARow) { DataColumn ValidationColumn; DataColumn ValidationColumn2; TValidationControlsData ValidationControlsData; TValidationControlsData ValidationControlsData2; TVerificationResult VerificationResult = null; bool NoClearingOfVerificationResult = false; TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; if (!chkChangeReasonSubsGivenCode.Checked) { if (VerificationResultCollection.Contains(ARow.Table.Columns[PSubscriptionTable.ColumnReasonSubsGivenCodeId])) { VerificationResultCollection.Remove(ARow.Table.Columns[PSubscriptionTable.ColumnReasonSubsGivenCodeId]); } } if (!chkChangeStartDate.Checked) { if (VerificationResultCollection.Contains(ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId])) { VerificationResultCollection.Remove(ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId]); } } // if 'SubscriptionStatus' is CANCELLED or EXPIRED then 'Reason Ended' and 'End Date' must be set ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnSubscriptionStatusId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if ((!ARow.IsSubscriptionStatusNull()) && ((ARow.SubscriptionStatus == "CANCELLED") || (ARow.SubscriptionStatus == "EXPIRED"))) { if (ARow.IsReasonSubsCancelledCodeNull() || (ARow.ReasonSubsCancelledCode == String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDMANDATORY_WHEN_EXPIRED)), ValidationColumn, ValidationControlsData.ValidationControl); } else if (ARow.IsDateCancelledNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDMANDATORY_WHEN_EXPIRED)), ValidationColumn, ValidationControlsData.ValidationControl); } } else { // if 'SubscriptionStatus' is not CANCELLED or EXPIRED then 'Reason Ended' and 'End Date' must NOT be set if (chkChangeReasonSubsCancelledCode.Checked) { if ((ARow.IsReasonSubsCancelledCodeNull()) || (ARow.ReasonSubsCancelledCode == String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); } } else if (!chkChangeReasonSubsCancelledCode.Checked) { if (ARow.SubscriptionStatus != String.Empty) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); VerificationResult.OverrideResultText(Catalog.GetString( "Reason Ended must be cleared when a Subscription is made active.")); NoClearingOfVerificationResult = true; } } if ((!ARow.IsReasonSubsCancelledCodeNull()) && (ARow.ReasonSubsCancelledCode != String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); } else if (!ARow.IsDateCancelledNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); } else if (!chkChangeDateCancelled.Checked) { if (ARow.SubscriptionStatus != String.Empty) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); VerificationResult.OverrideResultText(Catalog.GetString("Date Ended must be cleared when a Subscription is made active.")); } } else { if (!NoClearingOfVerificationResult) { VerificationResult = null; } } } // Handle addition/removal to/from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); // perform checks that include 'Start Date' ---------------------------------------------------------------- if (chkChangeStartDate.Checked) { ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { // 'Start Date' must not be later than 'Expiry Date' if (chkChangeExpiryDate.Checked) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnExpiryDateId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.ExpiryDate, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } // 'Start Date' must not be later than 'Renewal Date' if (chkChangeRenewalDate.Checked) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnSubscriptionRenewalDateId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.SubscriptionRenewalDate, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } // 'Start Date' must not be later than 'End Date' if (chkChangeDateCancelled.Checked) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnDateCancelledId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.DateCancelled, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } // 'Start Date' must not be later than 'Notice Sent' if (chkChangeDateNoticeSent.Checked) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnDateNoticeSentId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.DateNoticeSent, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } // 'Start Date' must not be later than 'First Sent' if (chkChangeFirstIssue.Checked) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnFirstIssueId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.FirstIssue, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } // 'Start Date' must not be later than 'Last Date' if (chkChangeLastIssue.Checked) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnLastIssueId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.LastIssue, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } } } // perform checks that include 'Date Renewed' ---------------------------------------------------------------- if (chkChangeRenewalDate.Checked) { ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnSubscriptionRenewalDateId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { // 'Date Renewed' must not be later than today VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.SubscriptionRenewalDate, DateTime.Today, ValidationControlsData.ValidationControlLabel, Catalog.GetString("Today's Date"), this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); // 'Date Renewed' must not be later than 'Date Expired' if (chkChangeExpiryDate.Checked) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnExpiryDateId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.SubscriptionRenewalDate, ARow.ExpiryDate, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } // 'Date Renewed' must not be later than 'Date Notice Sent' if (chkChangeDateNoticeSent.Checked) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnDateNoticeSentId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.SubscriptionRenewalDate, ARow.DateNoticeSent, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } } } // 'Date Cancelled' must not be before today if (chkChangeDateCancelled.Checked) { ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnDateCancelledId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.DateCancelled, DateTime.Today, ValidationControlsData.ValidationControlLabel, Catalog.GetString("Today's Date"), this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } // 'First Sent' must not be later than 'Last Sent' if (chkChangeFirstIssue.Checked && chkChangeLastIssue.Checked) { ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnFirstIssueId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnLastIssueId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.FirstIssue, ARow.LastIssue, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } } // 'First Sent' must not be later than today if (chkChangeFirstIssue.Checked) { ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnFirstIssueId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.FirstIssue, DateTime.Today, ValidationControlsData.ValidationControlLabel, Catalog.GetString("Today's Date"), this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } // 'Date Started' must not be later than 'First Sent' if (chkChangeFirstIssue.Checked && chkChangeStartDate.Checked) { ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { ValidationColumn2 = ARow.Table.Columns[PSubscriptionTable.ColumnFirstIssueId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.StartDate, ARow.FirstIssue, ValidationControlsData.ValidationControlLabel, ValidationControlsData2.ValidationControlLabel, this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } } // 'Last Sent' must not be later than today if (chkChangeLastIssue.Checked) { ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnLastIssueId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate (ARow.LastIssue, DateTime.Today, ValidationControlsData.ValidationControlLabel, Catalog.GetString("Today's Date"), this, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } } }
/// <summary> /// todoComment /// </summary> /// <param name="Row"></param> /// <param name="AVerificationResultCollection"></param> /// <param name="VerificationResult"></param> /// <param name="AErroneousDC"></param> /// <param name="FtmpPartnerKeyValid"></param> /// <returns></returns> public static Boolean VerifySubscriptionDataFinal(PSubscriptionRow Row, out TVerificationResultCollection AVerificationResultCollection, out TVerificationResult VerificationResult, out DataColumn AErroneousDC, Boolean FtmpPartnerKeyValid) { Boolean ReturnValue; Boolean Completed; //Boolean NoErrors; TVerificationResultCollection TmpCollection = null; //TVerificationResult TmpError; DataColumn TmpDC; DataColumn NilDataColumn; String mVerifiedString; bool mPartnerExists; TPartnerClass mPartnerClass; TStdPartnerStatusCode partnerStatus; TPartnerClass[] mPartnerClassSet; Completed = false; ReturnValue = false; VerificationResult = null; AVerificationResultCollection = null; AErroneousDC = null; while (!Completed) { TmpDC = Row.Table.Columns[PSubscriptionTable.GetStartDateDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetStartDateDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetExpiryDateDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetExpiryDateDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetSubscriptionRenewalDateDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetSubscriptionRenewalDateDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetDateNoticeSentDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetDateNoticeSentDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetDateCancelledDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetDateCancelledDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetFirstIssueDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetFirstIssueDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetLastIssueDBName()]; VerifySubscriptionDates(new DataColumnChangeEventArgs(Row, TmpDC, Row[PSubscriptionTable.GetLastIssueDBName()]), TmpCollection, out VerificationResult, out NilDataColumn); if (VerificationResult != null) { Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } // if subscription status is cancelled, is there a partner that gives the gift. TmpDC = Row.Table.Columns[PSubscriptionTable.GetGiftFromKeyDBName()]; if (Row.IsSubscriptionStatusNull()) { // we go no further: VerificationResult = new TVerificationResult("", "Please select a valid subscription status", "Subscription Status Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; // escape before we crash return(false); } if (Row.SubscriptionStatus == "GIFT") { // validate partner key again, to be sure! mPartnerClassSet = new TPartnerClass[0]; FtmpPartnerKeyValid = TServerLookup.TMPartner.VerifyPartner(Row.GiftFromKey, mPartnerClassSet, out mPartnerExists, out mVerifiedString, out mPartnerClass, out partnerStatus); } if ((Row.SubscriptionStatus == "GIFT") && ((!FtmpPartnerKeyValid) || (Row.GiftFromKey == 00000000))) { // MessageBox.Show('FtmpPartnerKeyValid: ' + FtmpPartnerKeyValid.toString); VerificationResult = new TVerificationResult("", StrGiftGivenByMandatory, StrGiftGivenByMandatoryTitle, "", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } TmpDC = Row.Table.Columns[PSubscriptionTable.GetReasonSubsCancelledCodeDBName()]; if ((Row.SubscriptionStatus == "CANCELLED") && (Row.IsReasonSubsCancelledCodeNull())) { VerificationResult = new TVerificationResult("", "Please select reason for the cancellation", "Reason for Cancellation Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } else { if ((Row.SubscriptionStatus == "CANCELLED") && (Row.ReasonSubsCancelledCode.Length < 2)) { VerificationResult = new TVerificationResult("", "Please select reason for the cancellation", "Reason for Cancellation Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } } TmpDC = Row.Table.Columns[PSubscriptionTable.GetReasonSubsCancelledCodeDBName()]; if ((Row.SubscriptionStatus == "EXPIRED") && (Row.IsReasonSubsCancelledCodeNull())) { VerificationResult = new TVerificationResult("", "Please select reason for the cancellation", "Reason for Cancellation Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } else { if ((Row.SubscriptionStatus == "EXPIRED") && (Row.ReasonSubsCancelledCode.Length < 2)) { VerificationResult = new TVerificationResult("", "Please select reason for the cancellation", "Reason for Cancellation Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } } TmpDC = Row.Table.Columns[PSubscriptionTable.GetReasonSubsGivenCodeDBName()]; try { if (Row.ReasonSubsGivenCode.Length < 2) { VerificationResult = new TVerificationResult("", "Please select reason for the Gift", "Reason for Gift Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } } catch (Exception) { VerificationResult = new TVerificationResult("", "Please select reason why the publication is given", "Reason for Gift Mandatory", "X_0041", TResultSeverity.Resv_Critical); Completed = true; ReturnValue = false; AErroneousDC = TmpDC; break; } Completed = true; ReturnValue = true; } return(ReturnValue); }
private void ValidateDataDetailsManual(PSubscriptionRow ARow) { TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; TSharedPartnerValidation_Partner.ValidateSubscriptionManual(this, ARow, ref VerificationResultCollection, FValidationControlsDict); }
/// <summary> /// Called by the instantiator of this Dialog to retrieve the values of Fields /// on the screen. /// </summary> /// <param name="ARow"></param> /// <param name="AFieldsToChange"></param> /// <returns>Boolean</returns> public Boolean GetReturnedParameters(ref PSubscriptionRow ARow, ref List <String> AFieldsToChange) { Boolean ReturnValue = true; ARow.InitValues(); AFieldsToChange.Clear(); // publication code needs to be set, otherwise change can not be performed if (cmbPSubscriptionPublicationCode.GetSelectedString() == "") { return(false); } ARow.PublicationCode = cmbPSubscriptionPublicationCode.GetSelectedString(); if (chkChangeSubscriptionStatus.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetSubscriptionStatusDBName()); ARow.SubscriptionStatus = cmbPSubscriptionSubscriptionStatus.Text; } if (chkChangeGratisSubscription.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetGratisSubscriptionDBName()); ARow.GratisSubscription = chkPSubscriptionGratisSubscription.Checked; } if (chkChangeNumberComplimentary.Checked && txtPSubscriptionNumberComplimentary.NumberValueInt.HasValue) { AFieldsToChange.Add(PSubscriptionTable.GetNumberComplimentaryDBName()); ARow.NumberComplimentary = txtPSubscriptionNumberComplimentary.NumberValueInt.Value; } if (chkChangePublicationCopies.Checked && txtPSubscriptionPublicationCopies.NumberValueInt.HasValue) { AFieldsToChange.Add(PSubscriptionTable.GetPublicationCopiesDBName()); ARow.PublicationCopies = txtPSubscriptionPublicationCopies.NumberValueInt.Value; } if (chkChangeReasonSubsGivenCode.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetReasonSubsGivenCodeDBName()); ARow.ReasonSubsGivenCode = cmbPSubscriptionReasonSubsGivenCode.GetSelectedString(); } if (chkChangeReasonSubsCancelledCode.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetReasonSubsCancelledCodeDBName()); ARow.ReasonSubsCancelledCode = cmbPSubscriptionReasonSubsCancelledCode.GetSelectedString(); } if (chkChangeGiftFromKey.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetGiftFromKeyDBName()); ARow.GiftFromKey = Convert.ToInt64(txtPSubscriptionGiftFromKey.Text); } if (chkChangeStartDate.Checked && dtpPSubscriptionStartDate.Date.HasValue) { AFieldsToChange.Add(PSubscriptionTable.GetStartDateDBName()); ARow.StartDate = dtpPSubscriptionStartDate.Date.Value; } if (chkChangeExpiryDate.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetExpiryDateDBName()); ARow.ExpiryDate = dtpPSubscriptionExpiryDate.Date; } if (chkChangeRenewalDate.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetSubscriptionRenewalDateDBName()); ARow.SubscriptionRenewalDate = dtpPSubscriptionSubscriptionRenewalDate.Date; } if (chkChangeDateNoticeSent.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetDateNoticeSentDBName()); ARow.DateNoticeSent = dtpPSubscriptionDateNoticeSent.Date; } if (chkChangeDateCancelled.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetDateCancelledDBName()); ARow.DateCancelled = dtpPSubscriptionDateCancelled.Date; } if (chkChangeNumberIssuesReceived.Checked && txtPSubscriptionNumberIssuesReceived.NumberValueInt.HasValue) { AFieldsToChange.Add(PSubscriptionTable.GetNumberIssuesReceivedDBName()); ARow.NumberIssuesReceived = txtPSubscriptionNumberIssuesReceived.NumberValueInt.Value; } if (chkChangeFirstIssue.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetFirstIssueDBName()); ARow.FirstIssue = dtpPSubscriptionFirstIssue.Date; } if (chkChangeLastIssue.Checked) { AFieldsToChange.Add(PSubscriptionTable.GetLastIssueDBName()); ARow.LastIssue = dtpPSubscriptionLastIssue.Date; } return(ReturnValue); }
private void GetDataFromControlsManual(PSubscriptionRow ARow) { }
/// <summary> /// Read data from controls into ARow parameter /// </summary> /// <param name="ARow"></param> public void GetDetails(PSubscriptionRow ARow) { ValidateAllData(TErrorProcessingMode.Epm_None); //GetDataFromControls(ARow); }
private void InitializeManualCode() { // show this dialog in center of screen this.StartPosition = FormStartPosition.CenterScreen; // remove validation handler for controls as we only want validation when clicking the ok button cmbPSubscriptionPublicationCode.Validated -= new System.EventHandler(this.ControlValidatedHandler); cmbPSubscriptionSubscriptionStatus.Validated -= new System.EventHandler(this.ControlValidatedHandler); chkPSubscriptionGratisSubscription.Validated -= new System.EventHandler(this.ControlValidatedHandler); txtPSubscriptionNumberComplimentary.Validated -= new System.EventHandler(this.ControlValidatedHandler); txtPSubscriptionPublicationCopies.Validated -= new System.EventHandler(this.ControlValidatedHandler); cmbPSubscriptionReasonSubsGivenCode.Validated -= new System.EventHandler(this.ControlValidatedHandler); cmbPSubscriptionReasonSubsCancelledCode.Validated -= new System.EventHandler(this.ControlValidatedHandler); txtPSubscriptionGiftFromKey.Validated -= new System.EventHandler(this.ControlValidatedHandler); dtpPSubscriptionStartDate.Validated -= new System.EventHandler(this.ControlValidatedHandler); dtpPSubscriptionExpiryDate.Validated -= new System.EventHandler(this.ControlValidatedHandler); dtpPSubscriptionDateCancelled.Validated -= new System.EventHandler(this.ControlValidatedHandler); dtpPSubscriptionDateNoticeSent.Validated -= new System.EventHandler(this.ControlValidatedHandler); dtpPSubscriptionSubscriptionRenewalDate.Validated -= new System.EventHandler(this.ControlValidatedHandler); dtpPSubscriptionFirstIssue.Validated -= new System.EventHandler(this.ControlValidatedHandler); dtpPSubscriptionLastIssue.Validated -= new System.EventHandler(this.ControlValidatedHandler); txtPSubscriptionNumberIssuesReceived.Validated -= new System.EventHandler(this.ControlValidatedHandler); FMainDS = new PartnerEditTDS(); // now add the one subscription row to the DS that we are working with PSubscriptionTable SubscriptionTable = new PSubscriptionTable(); FMainDS.Merge(SubscriptionTable); PSubscriptionRow SubscriptionRow = FMainDS.PSubscription.NewRowTyped(true); SubscriptionRow.PublicationCode = ""; // avoid NOT NULL error message FMainDS.PSubscription.Rows.Add(SubscriptionRow); FPetraUtilsObject.HasChanges = false; // initialize all check box sections so fields are disabled OnTickChangeItem(chkChangeSubscriptionStatus, null); OnTickChangeItem(chkChangeGratisSubscription, null); OnTickChangeItem(chkChangeNumberComplimentary, null); OnTickChangeItem(chkChangePublicationCopies, null); OnTickChangeItem(chkChangeReasonSubsGivenCode, null); OnTickChangeItem(chkChangeReasonSubsCancelledCode, null); OnTickChangeItem(chkChangeGiftFromKey, null); OnTickChangeItem(chkChangeStartDate, null); OnTickChangeItem(chkChangeExpiryDate, null); OnTickChangeItem(chkChangeRenewalDate, null); OnTickChangeItem(chkChangeDateNoticeSent, null); OnTickChangeItem(chkChangeDateCancelled, null); OnTickChangeItem(chkChangeNumberIssuesReceived, null); OnTickChangeItem(chkChangeFirstIssue, null); OnTickChangeItem(chkChangeLastIssue, null); // Hook up this event manually here after all initalisation has happened as otherwise // Bug #2481 would occur if the first Publication in the 'Publication Code' ComboBox is not Valid cmbPSubscriptionPublicationCode.SelectedValueChanged += new System.EventHandler(this.PublicationCodeChanged); }
/// <summary> /// Read data from controls into ARow parameter /// </summary> /// <param name="ARow"></param> public void GetDetails(PSubscriptionRow ARow) { ValidateAllData(false); //GetDataFromControls(ARow); }
private static void ParsePartners(ref PartnerImportExportTDS AMainDS, XmlNode ACurNode, TDBTransaction ATransaction, ref TVerificationResultCollection AVerificationResult) { XmlNode LocalNode = ACurNode; while (LocalNode != null) { if (LocalNode.Name.StartsWith("PartnerGroup")) { ParsePartners(ref AMainDS, LocalNode.FirstChild, ATransaction, ref AVerificationResult); } else if (LocalNode.Name.StartsWith("Partner")) { PPartnerRow PartnerRow = AMainDS.PPartner.NewRowTyped(); Boolean IsExistingPartner = false; if (!TYml2Xml.HasAttributeRecursive(LocalNode, "SiteKey")) { throw new Exception(Catalog.GetString("Missing SiteKey Attribute")); } if (!TYml2Xml.HasAttributeRecursive(LocalNode, "status")) { throw new Exception(Catalog.GetString("Missing status Attribute")); } // get a new partner key if (TYml2Xml.HasAttribute(LocalNode, "PartnerKey")) { PartnerRow.PartnerKey = Convert.ToInt64(TYml2Xml.GetAttribute(LocalNode, "PartnerKey")); if (PPartnerAccess.Exists(PartnerRow.PartnerKey, ATransaction)) { AMainDS.Merge(PPartnerAccess.LoadByPrimaryKey(PartnerRow.PartnerKey, ATransaction)); AMainDS.PPartner.DefaultView.RowFilter = String.Format("{0} = '{1}'", PPartnerTable.GetPartnerKeyDBName(), PartnerRow.PartnerKey); PartnerRow = (PPartnerRow)AMainDS.PPartner.DefaultView[0].Row; IsExistingPartner = true; } else { AMainDS.PPartner.Rows.Add(PartnerRow); } } else { PartnerRow.PartnerKey = TImportExportYml.NewPartnerKey; TImportExportYml.NewPartnerKey--; } String PartnerClass = TYml2Xml.GetAttributeRecursive(LocalNode, "class"); TLogging.LogAtLevel(TLogging.DEBUGLEVEL_TRACE, PartnerClass + " " + LocalNode.Name + " " + "PartnerKey=" + PartnerRow.PartnerKey ); if (IsExistingPartner && (PartnerClass != PartnerRow.PartnerClass)) { throw new Exception(String.Format("Error: Yml contains Existing Partner {0} with a different partner class {1}!", PartnerRow.PartnerKey, PartnerClass)); } PartnerRow.PartnerClass = PartnerClass; if (PartnerClass == MPartnerConstants.PARTNERCLASS_FAMILY) { PFamilyRow FamilyRow; if (IsExistingPartner) { AMainDS.Merge(PFamilyAccess.LoadByPrimaryKey(PartnerRow.PartnerKey, ATransaction)); AMainDS.PFamily.DefaultView.RowFilter = String.Format("{0} = '{1}'", PFamilyTable.GetPartnerKeyDBName(), PartnerRow.PartnerKey); FamilyRow = (PFamilyRow)AMainDS.PFamily.DefaultView[0].Row; } else { FamilyRow = AMainDS.PFamily.NewRowTyped(); FamilyRow.PartnerKey = PartnerRow.PartnerKey; PartnerRow.PartnerClass = MPartnerConstants.PARTNERCLASS_FAMILY; AMainDS.PFamily.Rows.Add(FamilyRow); } FamilyRow.FamilyName = TYml2Xml.GetAttributeRecursive(LocalNode, "LastName"); FamilyRow.FirstName = TYml2Xml.GetAttribute(LocalNode, "FirstName"); FamilyRow.Title = TYml2Xml.GetAttribute(LocalNode, "Title"); if (TYml2Xml.HasAttribute(LocalNode, "CreatedAt")) { FamilyRow.DateCreated = Convert.ToDateTime(TYml2Xml.GetAttribute(LocalNode, "CreatedAt")); } PartnerRow.AddresseeTypeCode = MPartnerConstants.PARTNERCLASS_FAMILY; PartnerRow.PartnerShortName = Calculations.DeterminePartnerShortName(FamilyRow.FamilyName, FamilyRow.Title, FamilyRow.FirstName); } if (PartnerClass == MPartnerConstants.PARTNERCLASS_PERSON) { PPersonRow PersonRow; if (IsExistingPartner) { AMainDS.Merge(PPersonAccess.LoadByPrimaryKey(PartnerRow.PartnerKey, ATransaction)); AMainDS.PPerson.DefaultView.RowFilter = String.Format("{0} = '{1}'", PPersonTable.GetPartnerKeyDBName(), PartnerRow.PartnerKey); PersonRow = (PPersonRow)AMainDS.PPerson.DefaultView[0].Row; } else { PersonRow = AMainDS.PPerson.NewRowTyped(); PersonRow.PartnerKey = PartnerRow.PartnerKey; AMainDS.PPerson.Rows.Add(PersonRow); } PersonRow.FamilyName = TYml2Xml.GetAttributeRecursive(LocalNode, "LastName"); PersonRow.FirstName = TYml2Xml.GetAttribute(LocalNode, "FirstName"); PersonRow.Title = TYml2Xml.GetAttribute(LocalNode, "Title"); if (TYml2Xml.HasAttribute(LocalNode, "CreatedAt")) { PersonRow.DateCreated = Convert.ToDateTime(TYml2Xml.GetAttribute(LocalNode, "CreatedAt")); } // PersonRow.Sp PartnerRow.PartnerShortName = Calculations.DeterminePartnerShortName(PersonRow.FamilyName, PersonRow.Title, PersonRow.FirstName); } else if (PartnerClass == MPartnerConstants.PARTNERCLASS_ORGANISATION) { POrganisationRow OrganisationRow; if (IsExistingPartner) { AMainDS.Merge(POrganisationAccess.LoadByPrimaryKey(PartnerRow.PartnerKey, ATransaction)); AMainDS.POrganisation.DefaultView.RowFilter = String.Format("{0} = '{1}'", POrganisationTable.GetPartnerKeyDBName(), PartnerRow.PartnerKey); OrganisationRow = (POrganisationRow)AMainDS.POrganisation.DefaultView[0].Row; } else { OrganisationRow = AMainDS.POrganisation.NewRowTyped(); OrganisationRow.PartnerKey = PartnerRow.PartnerKey; AMainDS.POrganisation.Rows.Add(OrganisationRow); } OrganisationRow.OrganisationName = TYml2Xml.GetAttributeRecursive(LocalNode, "Name"); PartnerRow.PartnerShortName = OrganisationRow.OrganisationName; } else if (PartnerClass == MPartnerConstants.PARTNERCLASS_UNIT) { PUnitRow UnitRow; if (IsExistingPartner) { AMainDS.Merge(PUnitAccess.LoadByPrimaryKey(PartnerRow.PartnerKey, ATransaction)); AMainDS.PUnit.DefaultView.RowFilter = String.Format("{0} = '{1}'", PUnitTable.GetPartnerKeyDBName(), PartnerRow.PartnerKey); UnitRow = (PUnitRow)AMainDS.PUnit.DefaultView[0].Row; } else { UnitRow = AMainDS.PUnit.NewRowTyped(); UnitRow.PartnerKey = PartnerRow.PartnerKey; AMainDS.PUnit.Rows.Add(UnitRow); } UnitRow.UnitTypeCode = TYml2Xml.GetAttributeRecursive(LocalNode, "UnitTypeCode"); UnitRow.UnitName = TYml2Xml.GetAttributeRecursive(LocalNode, "Name"); if (PartnerRow.PartnerKey < -1) { throw new Exception("Invalid Partner Key or No Partner Key - and no proper handling implemented"); // from here... /* * AVerificationResult.Add(new TVerificationResult( * String.Format(Catalog.GetString("Importing Unit {0}"), UnitRow.UnitName), * Catalog.GetString("You need to provide a partner key for the unit"), * TResultSeverity.Resv_Critical)); */ // ...to here: throws Exception in case of a illegal import file? // The above code must have a glitch } if (!TYml2Xml.HasAttribute(LocalNode, "ParentUnitKey")) { throw new Exception( "The currently being processed unit (PartnerKey " + PartnerRow.PartnerKey + ") requires a ParentUnitKey."); } Int64 ParentKey = Convert.ToInt64(TYml2Xml.GetAttributeRecursive(LocalNode, "ParentUnitKey")); UmUnitStructureRow UnitStructureRow = null; if (IsExistingPartner) { AMainDS.Merge(UmUnitStructureAccess.LoadViaPUnitChildUnitKey(PartnerRow.PartnerKey, ATransaction)); AMainDS.UmUnitStructure.DefaultView.RowFilter = String.Format("{0} = '{1}'", UmUnitStructureTable.GetChildUnitKeyDBName(), PartnerRow.PartnerKey); if (AMainDS.UmUnitStructure.DefaultView.Count > 0) { UnitStructureRow = (UmUnitStructureRow)AMainDS.UmUnitStructure.DefaultView[0].Row; } } if (UnitStructureRow == null) { UnitStructureRow = AMainDS.UmUnitStructure.NewRowTyped(); UnitStructureRow.ParentUnitKey = ParentKey; UnitStructureRow.ChildUnitKey = PartnerRow.PartnerKey; AMainDS.UmUnitStructure.Rows.Add(UnitStructureRow); } else { UnitStructureRow.ParentUnitKey = ParentKey; UnitStructureRow.ChildUnitKey = PartnerRow.PartnerKey; } PartnerRow.PartnerShortName = UnitRow.UnitName; } else if (PartnerClass == MPartnerConstants.PARTNERCLASS_BANK) { PBankRow BankRow; if (IsExistingPartner) { AMainDS.Merge(PBankAccess.LoadByPrimaryKey(PartnerRow.PartnerKey, ATransaction)); AMainDS.PBank.DefaultView.RowFilter = String.Format("{0} = '{1}'", PBankTable.GetPartnerKeyDBName(), PartnerRow.PartnerKey); BankRow = (PBankRow)AMainDS.PBank.DefaultView[0].Row; } else { BankRow = AMainDS.PBank.NewRowTyped(); BankRow.PartnerKey = PartnerRow.PartnerKey; AMainDS.PBank.Rows.Add(BankRow); } BankRow.BranchName = TYml2Xml.GetAttribute(LocalNode, "BranchName"); BankRow.BranchCode = TYml2Xml.GetAttribute(LocalNode, "BranchCode"); BankRow.Bic = TYml2Xml.GetAttribute(LocalNode, "BranchBic"); BankRow.EpFormatFile = TYml2Xml.GetAttribute(LocalNode, "EpFormatFile"); if (TYml2Xml.HasAttribute(LocalNode, "CreatedAt")) { BankRow.DateCreated = Convert.ToDateTime(TYml2Xml.GetAttribute(LocalNode, "CreatedAt")); } } else { /* * throw new Exception( * "Unknown Partner Class" + * TYml2Xml.GetAttributeRecursive(LocalNode, "class")); */ // TODO AVerificationResult add failing problem: unknown partner class } PartnerRow.StatusCode = TYml2Xml.GetAttributeRecursive(LocalNode, "status"); // import special types StringCollection SpecialTypes = StringHelper.StrSplit(TYml2Xml.GetAttributeRecursive(LocalNode, "SpecialTypes"), ","); if (IsExistingPartner) { PPartnerTypeAccess.LoadViaPPartner(AMainDS, PartnerRow.PartnerKey, ATransaction); } foreach (string SpecialType in SpecialTypes) { PPartnerTypeRow PartnerTypeRow = null; AMainDS.PPartnerType.DefaultView.RowFilter = String.Format("{0}={1} AND {2}='{3}'", PPartnerTypeTable.GetPartnerKeyDBName(), PartnerRow.PartnerKey, PPartnerTypeTable.GetTypeCodeDBName(), SpecialType ); if (AMainDS.PPartnerType.DefaultView.Count > 0) { PartnerTypeRow = (PPartnerTypeRow)AMainDS.PPartnerType.DefaultView[0].Row; } else { PartnerTypeRow = AMainDS.PPartnerType.NewRowTyped(); PartnerTypeRow.PartnerKey = PartnerRow.PartnerKey; PartnerTypeRow.TypeCode = SpecialType.Trim(); AMainDS.PPartnerType.Rows.Add(PartnerTypeRow); } // Check Partner type exists, or create it bool TypeIsKnown = PTypeAccess.Exists(PartnerTypeRow.TypeCode, ATransaction); if (!TypeIsKnown) { Int32 RowIdx = AMainDS.PType.DefaultView.Find(PartnerTypeRow.TypeCode); // I might have created it a second ago.. if (RowIdx < 0) { PTypeRow TypeRow = AMainDS.PType.NewRowTyped(); TypeRow.TypeCode = PartnerTypeRow.TypeCode; TypeRow.TypeDescription = "Created from YAML import"; AMainDS.PType.Rows.Add(TypeRow); } } } // import subscriptions StringCollection Subscriptions = StringHelper.StrSplit(TYml2Xml.GetAttributeRecursive(LocalNode, "Subscriptions"), ","); foreach (string publicationCode in Subscriptions) { PSubscriptionRow subscription = AMainDS.PSubscription.NewRowTyped(); subscription.PartnerKey = PartnerRow.PartnerKey; subscription.PublicationCode = publicationCode.Trim(); subscription.ReasonSubsGivenCode = "FREE"; AMainDS.PSubscription.Rows.Add(subscription); } // import address XmlNode addressNode = TYml2Xml.GetChild(LocalNode, "Address"); if ((addressNode == null) || (TYml2Xml.GetAttributeRecursive(addressNode, "Street").Length == 0)) { if (!IsExistingPartner) { // add the empty location PPartnerLocationRow partnerlocation = AMainDS.PPartnerLocation.NewRowTyped(true); partnerlocation.SiteKey = 0; partnerlocation.PartnerKey = PartnerRow.PartnerKey; partnerlocation.DateEffective = DateTime.Now; partnerlocation.LocationType = "HOME"; partnerlocation.SendMail = false; partnerlocation.EmailAddress = TYml2Xml.GetAttributeRecursive(addressNode, "Email"); partnerlocation.TelephoneNumber = TYml2Xml.GetAttributeRecursive(addressNode, "Phone"); partnerlocation.MobileNumber = TYml2Xml.GetAttributeRecursive(addressNode, "MobilePhone"); AMainDS.PPartnerLocation.Rows.Add(partnerlocation); } } else { PLocationRow location = AMainDS.PLocation.NewRowTyped(true); location.LocationKey = (AMainDS.PLocation.Rows.Count + 1) * -1; location.SiteKey = 0; if (!TYml2Xml.HasAttributeRecursive(LocalNode, "Country")) { throw new Exception(Catalog.GetString("Missing Country Attribute")); } location.CountryCode = TYml2Xml.GetAttributeRecursive(addressNode, "Country"); location.StreetName = TYml2Xml.GetAttributeRecursive(addressNode, "Street"); location.City = TYml2Xml.GetAttributeRecursive(addressNode, "City"); location.PostalCode = TYml2Xml.GetAttributeRecursive(addressNode, "PostCode"); AMainDS.PLocation.Rows.Add(location); PPartnerLocationRow partnerlocation = AMainDS.PPartnerLocation.NewRowTyped(true); partnerlocation.SiteKey = 0; partnerlocation.LocationKey = location.LocationKey; partnerlocation.PartnerKey = PartnerRow.PartnerKey; partnerlocation.SendMail = true; partnerlocation.DateEffective = DateTime.Now; partnerlocation.LocationType = "HOME"; partnerlocation.EmailAddress = TYml2Xml.GetAttributeRecursive(addressNode, "Email"); partnerlocation.TelephoneNumber = TYml2Xml.GetAttributeRecursive(addressNode, "Phone"); partnerlocation.MobileNumber = TYml2Xml.GetAttributeRecursive(addressNode, "MobilePhone"); AMainDS.PPartnerLocation.Rows.Add(partnerlocation); } // import finance details (bank account number) XmlNode financialDetailsNode = TYml2Xml.GetChild(LocalNode, "FinancialDetails"); ParseFinancialDetails(AMainDS, financialDetailsNode, PartnerRow.PartnerKey, ATransaction); } LocalNode = LocalNode.NextSibling; } }