예제 #1
0
        //
        // Put Methods for the validation of Cacheable DataTables in this code file.
        //

        partial void ValidateCountryListManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable)
        {
            TValidationControlsDict ValidationControlsDict = new TValidationControlsDict();

            ValidationControlsDict.Add(ASubmitTable.Columns[PCountryTable.ColumnInternatTelephoneCodeId],
                                       new TValidationControlsData(null, PCountryTable.GetInternatTelephoneCodeDBName()));
            ValidationControlsDict.Add(ASubmitTable.Columns[PCountryTable.ColumnInternatPostalTypeCodeId],
                                       new TValidationControlsData(null, PCountryTable.GetInternatAccessCodeDBName()));
            ValidationControlsDict.Add(ASubmitTable.Columns[PCountryTable.ColumnTimeZoneMinimumId],
                                       new TValidationControlsData(null, PCountryTable.GetTimeZoneMinimumDBName(),
                                                                   null, PCountryTable.GetTimeZoneMaximumDBName()));

            for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++)
            {
                TSharedValidation_CacheableDataTables.ValidateCountrySetupManual(this.GetType().Name +
                                                                                 " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English
                                                                                 (PCountryRow)ASubmitTable.Rows[Counter], ref AVerificationResult,
                                                                                 ValidationControlsDict);
            }
        }
예제 #2
0
        /// <summary>
        /// Parses certain p_partner_location data columns' content into a data structure that is p_parnter_attribute
        /// representation.
        /// </summary>
        /// <remarks>Similar to code found in \csharp\ICT\BuildTools\DataDumpPetra2\FixData.cs, Method 'FixData',
        /// in the code section that starts with the comment 'Process p_partner_location records and migrate certain values
        /// of p_partner_location records to 'Contact Detail' records'.</remarks>
        /// <param name="AMainDS">Typed DataSet that holds the p_partner_location records that are to be parsed.</param>
        /// <param name="ATransaction">Instantiated DB Transaction.</param>
        public static void ParsePartnerLocationsForContactDetails(PartnerImportExportTDS AMainDS, TDBTransaction ATransaction)
        {
            DataTable PartnerLocationsDT;
            DataRow   NewPartnerLocationDR;
            string    TelephoneNumber = String.Empty;
            string    FaxNumber       = String.Empty;
            string    PhoneExtension;
            string    FaxExtension;

            // collect the partner classes
            foreach (PPartnerRow PartnerDR in AMainDS.PPartner.Rows)
            {
                TPartnerContactDetails.PartnerClassInformation[PartnerDR.PartnerKey] = PartnerDR.PartnerClass;
            }

            SortedList <long, DataTable> PartnerLocationsTables = new SortedList <long, DataTable>();

            for (int counter = 0; counter < TPartnerContactDetails.NumberOfTables; counter++)
            {
                PartnerLocationsTables[counter] = TPartnerContactDetails.BestAddressHelper.GetNewPPartnerLocationTableInstance();
            }

            TPartnerContactDetails.PartnerLocationRecords = PartnerLocationsTables;

            foreach (PPartnerLocationRow PartnerLocationDR in AMainDS.PPartnerLocation.Rows)
            {
                PartnerLocationsDT = PartnerLocationsTables[Math.Abs(PartnerLocationDR.PartnerKey) % TPartnerContactDetails.NumberOfTables];
                DataRow LocationDR = AMainDS.PLocation.Rows.Find(new object[] { PartnerLocationDR.SiteKey, PartnerLocationDR.LocationKey });

                // Phone Extension: Ignore if value in the dumped data is either null or 0
                if (PartnerLocationDR.IsExtensionNull())
                {
                    PhoneExtension = String.Empty;
                }

                PhoneExtension = PartnerLocationDR.Extension.ToString();

                if (PhoneExtension == "0")
                {
                    PhoneExtension = String.Empty;
                }

                // Fax Extension: Ignore if value in the dumped data is either null or 0
                if (PartnerLocationDR.IsFaxExtensionNull())
                {
                    FaxExtension = String.Empty;
                }

                FaxExtension = PartnerLocationDR.FaxExtension.ToString();

                if (FaxExtension == "0")
                {
                    FaxExtension = String.Empty;
                }

                if (!PartnerLocationDR.IsTelephoneNumberNull())
                {
                    // Concatenate Phone Number and Phone Extension ONLY if both of them aren't null and Phone Extension isn't 0 either.
                    TelephoneNumber = PartnerLocationDR.TelephoneNumber + PhoneExtension;
                }

                if (!PartnerLocationDR.IsFaxNumberNull())
                {
                    // Concatenate Fax Number and Fax Extension ONLY if both of them aren't null and Fax Extension isn't 0 either.
                    FaxNumber = PartnerLocationDR.FaxNumber + FaxExtension;
                }

                // Create representation of key data of the p_partner_location row and add it to the TPartnerContactDetails.PartnerLocationRecords Data Structure
                NewPartnerLocationDR = PartnerLocationsDT.NewRow();
                NewPartnerLocationDR["p_partner_key_n"]  = PartnerLocationDR.PartnerKey;
                NewPartnerLocationDR["p_site_key_n"]     = PartnerLocationDR.SiteKey;
                NewPartnerLocationDR["p_location_key_i"] = PartnerLocationDR.LocationKey;

                if (!PartnerLocationDR.IsDateEffectiveNull())
                {
                    NewPartnerLocationDR["p_date_effective_d"] = PartnerLocationDR.DateEffective;
                }
                else
                {
                    PartnerLocationDR.SetDateEffectiveNull();
                }

                if (!PartnerLocationDR.IsDateGoodUntilNull())
                {
                    NewPartnerLocationDR["p_date_good_until_d"] = PartnerLocationDR.DateGoodUntil;
                }
                else
                {
                    PartnerLocationDR.SetDateGoodUntilNull();
                }

                NewPartnerLocationDR["p_location_type_c"]       = PartnerLocationDR.LocationType;
                NewPartnerLocationDR["p_send_mail_l"]           = PartnerLocationDR.SendMail;
                NewPartnerLocationDR["p_telephone_number_c"]    = TelephoneNumber;
                NewPartnerLocationDR["p_fax_number_c"]          = FaxNumber;
                NewPartnerLocationDR["p_mobile_number_c"]       = PartnerLocationDR.MobileNumber;
                NewPartnerLocationDR["p_alternate_telephone_c"] = PartnerLocationDR.AlternateTelephone;
                NewPartnerLocationDR["p_email_address_c"]       = PartnerLocationDR.EmailAddress;
                NewPartnerLocationDR["p_url_c"]           = PartnerLocationDR.Url;
                NewPartnerLocationDR["p_value_country_c"] = LocationDR["p_country_code_c"];

                PartnerLocationsDT.Rows.Add(NewPartnerLocationDR);
            }

            // get data for entire country table
            PCountryTable CountryTable = PCountryAccess.LoadAll(ATransaction);

            string  InternatAccessCode = null;
            string  SiteCountryCode    = TAddressTools.GetCountryCodeFromSiteLedger(ATransaction);
            DataRow SiteCountryRow     = CountryTable.Rows.Find(SiteCountryCode);

            // get InternatAccessCode for site country
            if (SiteCountryRow != null)
            {
                InternatAccessCode = SiteCountryRow[PCountryTable.GetInternatAccessCodeDBName()].ToString();
            }

            TPartnerContactDetails.CreateContactDetailsRow        = CreatePartnerContactDetailRecord;
            TPartnerContactDetails.EmptyStringIndicator           = String.Empty;
            TPartnerContactDetails.PartnerAttributeHoldingDataSet = AMainDS;
            TPartnerContactDetails.CountryTable           = CountryTable;
            TPartnerContactDetails.SiteCountryCode        = SiteCountryCode;
            TPartnerContactDetails.SiteInternatAccessCode = InternatAccessCode;
            TPartnerContactDetails.PopulatePPartnerAttribute();

            Ict.Petra.Shared.MPartner.Calculations.DeterminePartnerContactDetailAttributes(AMainDS.PPartnerAttribute);
        }