/// <summary>
        /// The screen has been shown
        /// </summary>
        private void RunOnceOnActivationManual()
        {
            // enable autofind in list for first character (so the user can press character to find list entry)
            this.clbAddress.AutoFindColumn = ((Int16)(1));
            this.clbAddress.AutoFindMode   = Ict.Common.Controls.TAutoFindModeEnum.FirstCharacter;

            clbAddress.SpecialKeys =
                ((SourceGrid.GridSpecialKeys)((((((SourceGrid.GridSpecialKeys.Arrows |
                                                   SourceGrid.GridSpecialKeys.PageDownUp) |
                                                  SourceGrid.GridSpecialKeys.Enter) |
                                                 SourceGrid.GridSpecialKeys.Escape) |
                                                SourceGrid.GridSpecialKeys.Control) | SourceGrid.GridSpecialKeys.Shift)));


            string CheckedColumn      = "CHECKED";
            string ShortNameColumn    = PPartnerTable.GetPartnerShortNameDBName();
            string PartnerKeyColumn   = PPartnerLocationTable.GetPartnerKeyDBName();
            string PartnerClassColumn = PPartnerTable.GetPartnerClassDBName();
            string TelephoneColumn    = PPartnerLocationTable.GetTelephoneNumberDBName();
            string LocationTypeColumn = PPartnerLocationTable.GetLocationTypeDBName();

            DataTable NewTable = FPartnerSharingLocationDV.ToTable(true,
                                                                   new string[] { ShortNameColumn, PartnerKeyColumn, PartnerClassColumn, TelephoneColumn, LocationTypeColumn });

            NewTable.Columns.Add(new DataColumn(CheckedColumn, typeof(bool)));

            clbAddress.Columns.Clear();
            clbAddress.AddCheckBoxColumn("", NewTable.Columns[CheckedColumn], 17, false);
            clbAddress.AddTextColumn(Catalog.GetString("Name"), NewTable.Columns[ShortNameColumn], 240);
            clbAddress.AddPartnerKeyColumn(Catalog.GetString("Partner Key"), NewTable.Columns[PartnerKeyColumn], 90);
            clbAddress.AddTextColumn(Catalog.GetString("Partner Class"), NewTable.Columns[PartnerClassColumn], 90);
            clbAddress.AddTextColumn(Catalog.GetString("Telephone"), NewTable.Columns[TelephoneColumn], 130);
            clbAddress.AddTextColumn(Catalog.GetString("Location Type"), NewTable.Columns[LocationTypeColumn], 90);

            clbAddress.DataBindGrid(NewTable, ShortNameColumn, CheckedColumn, PartnerKeyColumn, false, true, false);

            // initialize list of checked items
            clbAddress.SetCheckedStringList("");

            // this is just to avoid compiler warning from FMainDS being initialized but not used
            if (FMainDS.IsInitialized)
            {
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Determines the 'Best Address' of the PERSON and its Phone Number and Email Address.
        /// </summary>
        /// <param name="APhoneNumberOfPerson">Phone Number of the PERSON in international format.</param>
        /// <param name="AEmailAddressOfPerson">Email Address of the PERSON.</param>
        /// <returns><see cref="Ict.Petra.Shared.MPartner.TLocationPK" /> pointing to the 'Best Address' of the PERSON.</returns>
        private TLocationPK DetermineAddressComponents(out string APhoneNumberOfPerson, out string AEmailAddressOfPerson)
        {
            TLocationPK ReturnValue = Ict.Petra.Shared.MPartner.Calculations.DetermineBestAddress(
                FMainDS.Tables[PartnerEditTDSPPartnerLocationTable.GetTableName()]);
            DataRow BestPartnerLocationDR;
            DataRow BestLocationDR;
            string  TelephoneNumber;
            string  Extension;
            string  CountryCode;

            // Initialise out Arguments
            APhoneNumberOfPerson  = null;
            AEmailAddressOfPerson = null;

            BestPartnerLocationDR = FMainDS.Tables[PartnerEditTDSPPartnerLocationTable.GetTableName()].Rows.Find(new object[]
                                                                                                                 { FMainDS.PPerson[0].PartnerKey, ReturnValue.SiteKey, ReturnValue.LocationKey });

            if (BestPartnerLocationDR != null)
            {
                BestLocationDR = FMainDS.Tables[PLocationTable.GetTableName()].Rows.Find(new object[]
                                                                                         { ReturnValue.SiteKey, ReturnValue.LocationKey });

                if (!BestPartnerLocationDR.IsNull(PPartnerLocationTable.GetTelephoneNumberDBName()))
                {
                    TelephoneNumber = (string)BestPartnerLocationDR[PPartnerLocationTable.GetTelephoneNumberDBName()];
                }
                else
                {
                    TelephoneNumber = String.Empty;
                }

                if (!BestPartnerLocationDR.IsNull(PPartnerLocationTable.GetExtensionDBName()))
                {
                    Extension = ((int)BestPartnerLocationDR[PPartnerLocationTable.GetExtensionDBName()]).ToString();
                }
                else
                {
                    Extension = String.Empty;
                }

                if (!BestLocationDR.IsNull(PLocationTable.GetCountryCodeDBName()))
                {
                    CountryCode = (string)BestLocationDR[PLocationTable.GetCountryCodeDBName()];
                }
                else
                {
                    CountryCode = String.Empty;
                }

                APhoneNumberOfPerson = Ict.Petra.Shared.MPartner.Calculations.FormatIntlPhoneNumber(
                    TelephoneNumber,
                    Extension,
                    CountryCode,
                    @TDataCache.GetCacheableDataTableFromCache);

                if (!BestPartnerLocationDR.IsNull(PPartnerLocationTable.GetEmailAddressDBName()))
                {
                    AEmailAddressOfPerson = (string)BestPartnerLocationDR[PPartnerLocationTable.GetEmailAddressDBName()];
                }
                else
                {
                    AEmailAddressOfPerson = String.Empty;
                }
            }
            else
            {
                MessageBox.Show("Unexpected condition: 'Best Address of PERSON is null'", DEV_FIX);
            }

            return(ReturnValue);
        }