context: //
  // DO NOT REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  //
  // @Authors:
  //       christiank
  //
  // Copyright 2004-2010 by OM International
  //
  // This file is part of OpenPetra.org.
  //
  // OpenPetra.org is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // OpenPetra.org is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with OpenPetra.org.  If not, see <http://www.gnu.org/licenses/>.
  //
  using System;
  using System.Data;
  using System.Windows.Forms;
  using Ict.Common;
  using Ict.Common.Verification;
  using Ict.Petra.Shared;
  using Ict.Petra.Shared.MPartner.Partner.Data;
  using Ict.Petra.Shared.MPartner.Mailroom.Data;
  using Ict.Petra.Shared.MPartner;
  using Ict.Petra.Client.App.Core;
  
  namespace Ict.Petra.Client.MPartner.Verification
  {
      /// <summary>
      /// Contains verification logic for the UC_PartnerSubscription UserControl.
      /// </summary>
      public class TPartnerSubscriptionVerification
      {
          #region Resourcestrings
  
          private static readonly string StrGiftGivenByMandatory = Catalog.GetString(
              "You need to specify the Partner who has made the gift for this Subscription!" + "\r\n" +
              "Either choose the 'Gift Given By' button to select the Partner or enter\r\n" +
              "the Partners' Partner Key in the Field next to it.\r\n\r\n" +
              "Note: If the price for the Subscription is no longer paid by another Partner, you need to select\r\n" +
              "a different Subscription Status than 'GIFT'.");
  
          private static readonly string StrGiftGivenByMandatoryTitle = Catalog.GetString("Gift Given By Mandatory");
  
          #endregion
  
          #region TPartnerSubscriptionVerification
  
          /// <summary>
          /// todoComment
          /// </summary>
          /// <param name="e"></param>
          /// <param name="AVerificationResultCollection"></param>
          /// <param name="AVerificationResult"></param>
          /// <param name="FDataColumnComparedTo"></param>
          /// <returns></returns>
          public static Boolean VerifySubscriptionData(DataColumnChangeEventArgs e,
              TVerificationResultCollection AVerificationResultCollection,
              out TVerificationResult AVerificationResult,
              out DataColumn FDataColumnComparedTo)
          {
              Boolean ReturnValue;
  
              AVerificationResult = null;
              DataColumn FDataColumnComparedTo2 = null;
  
              if ((e.Column.ColumnName == PSubscriptionTable.GetDateCancelledDBName())
                  || (e.Column.ColumnName == PSubscriptionTable.GetExpiryDateDBName())
                  || (e.Column.ColumnName == PSubscriptionTable.GetDateNoticeSentDBName())
                  || (e.Column.ColumnName == PSubscriptionTable.GetStartDateDBName())
                  || (e.Column.ColumnName == PSubscriptionTable.GetSubscriptionRenewalDateDBName())
                  || (e.Column.ColumnName == PSubscriptionTable.GetFirstIssueDBName()) || (e.Column.ColumnName == PSubscriptionTable.GetLastIssueDBName()))
              {
                  VerifySubscriptionDates(e, AVerificationResultCollection, out AVerificationResult, out FDataColumnComparedTo2);
              }
  
              FDataColumnComparedTo = FDataColumnComparedTo2;
  
              // if (e.Column.Ordinal = (e.Column.Table as PPartnerLocationTable).ColumnEmailAddress.Ordinal) then
              // begin
              // VerifyEMailAddress(e, AVerificationResult);
              // end;
              if ((e.Column.ColumnName == PSubscriptionTable.GetPublicationCopiesDBName())
                  || (e.Column.ColumnName == PSubscriptionTable.GetNumberIssuesReceivedDBName())
                  || (e.Column.ColumnName == PSubscriptionTable.GetNumberComplimentaryDBName()))
              {
                  VerifyInteger(e, out AVerificationResult);
              }
  
              // any verification errors?
              if (AVerificationResult == null)
              {
                  ReturnValue = true;
              }
              else
              {
                  ReturnValue = false;
              }
  
              return ReturnValue;
          }
  
          /// <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);
  
  
gt:                 if (VerificationResult != null)