예제 #1
0
        /// <summary>
        /// Main Method for updating the data that is displayed in the UserControl.
        /// </summary>
        /// <param name="APartnerKey">Partner Key of Partner for which Partner Info data should be retrieved.</param>
        /// <param name="APartnerDR">DataRow containing Partner data, Location Data, Partner Location Data and 'Rest' data.</param>
        /// <param name="ALocationPK">Location PrimaryKey of the Location for which Address data should be retrieved.
        /// If it is null, it is constructed from data in APartnerDR!</param>
        /// <param name="AScope">Scope of data that is already available client-side.</param>
        private void UpdateControls(Int64 APartnerKey, DataRow APartnerDR, TLocationPK ALocationPK, TPartnerInfoAvailDataEnum AScope)
        {
            TLocationPK LocationPK;
            bool LoadRestOfData;

//            TLogging.Log("Received UpdateControls request for Partner " + APartnerKey.ToString() + ".");

            FPartnerKey = APartnerKey;
            FPartnerDR = APartnerDR;

            if (ALocationPK != null)
            {
                LocationPK = ALocationPK;
            }
            else
            {
                LocationPK = new TLocationPK(-1, -1);
            }

            if (FPartnerDR != null)
            {
                FPartnerClass = SharedTypes.PartnerClassStringToEnum(
                    FPartnerDR[PPartnerTable.GetPartnerClassDBName()].ToString());
                FPartnerShortName = APartnerDR[PPartnerTable.GetPartnerShortNameDBName()].ToString();

                if (LocationPK.LocationKey == -1)
                {
                    LocationPK = new TLocationPK(
                        Convert.ToInt64(APartnerDR[PLocationTable.GetSiteKeyDBName()]),
                        Convert.ToInt32(APartnerDR[PLocationTable.GetLocationKeyDBName()]));
                }
            }

            LoadRestOfData = FPartnerKey != FLastPartnerKey;

            ClearControls(!LoadRestOfData);

            lblNoPartner.Visible = false;
            pnlKeyInfo.Visible = true;

            /*
             * Update Controls with the Data from the passed in DataRow APartnerDR
             * and with data from the DB, if necessary.
             */
            switch (AScope)
            {
                case TPartnerInfoAvailDataEnum.piadHeadOnly:
                {
                    ShowHideLoadingInfo(true, true, LoadRestOfData);

                    FHeadDataServerRetrieved = false;
                    UpdateControlsHeadData();

                    if (LoadRestOfData)
                    {
                        lock (FServerCallParamsLock)
                        {
                            FServerCallParams = new TServerCallParams(APartnerKey,
                                LocationPK,
                                AScope,
                                LoadRestOfData,
                                TPartnerInfoScopeEnum.pisLocationPartnerLocationAndRestOnly);
                        }

                        if (!FFetchingData)
                        {
                            // Request Partner Info data from the PetraServer
                            FTimer.Change(0, System.Threading.Timeout.Infinite);
                        }
                    }
                    else
                    {
                        lock (FServerCallParamsLock)
                        {
                            FServerCallParams = new TServerCallParams(APartnerKey,
                                LocationPK,
                                AScope,
                                LoadRestOfData,
                                TPartnerInfoScopeEnum.pisLocationPartnerLocationOnly);
                        }

                        if (!FFetchingData)
                        {
                            // Request Partner Info data from the PetraServer
                            FTimer.Change(0, System.Threading.Timeout.Infinite);
                        }
                    }

                    break;
                }

                case TPartnerInfoAvailDataEnum.piadHeadAndLocationOnly:
                {
                    ShowHideLoadingInfo(true, false, LoadRestOfData);

                    FHeadDataServerRetrieved = false;
                    UpdateControlsHeadData();

                    FLocationDataServerRetrieved = false;
                    UpdateControlsLocationData();

                    if (LoadRestOfData)
                    {
                        lock (FServerCallParamsLock)
                        {
                            FServerCallParams = new TServerCallParams(APartnerKey,
                                LocationPK,
                                AScope,
                                LoadRestOfData,
                                TPartnerInfoScopeEnum.pisPartnerLocationAndRestOnly);
                        }

                        if (!FFetchingData)
                        {
                            // Request Partner Info data from the PetraServer
                            FTimer.Change(0, System.Threading.Timeout.Infinite);
                        }
                    }
                    else
                    {
                        lock (FServerCallParamsLock)
                        {
                            FServerCallParams = new TServerCallParams(APartnerKey,
                                LocationPK,
                                AScope,
                                LoadRestOfData,
                                TPartnerInfoScopeEnum.pisPartnerLocationOnly);
                        }

                        if (!FFetchingData)
                        {
                            // Request Partner Info data from the PetraServer
                            FTimer.Change(0, System.Threading.Timeout.Infinite);
                        }
                    }

                    break;
                }

                case TPartnerInfoAvailDataEnum.piadNone:
                {
                    ShowHideLoadingInfoFullSize(true);

                    lock (FServerCallParamsLock)
                    {
                        FServerCallParams = new TServerCallParams(APartnerKey,
                            LocationPK,
                            AScope,
                            LoadRestOfData,
                            TPartnerInfoScopeEnum.pisFull);
                    }

                    if (!FFetchingData)
                    {
                        // Request Partner Info data from the PetraServer
                        FTimer.Change(0, System.Threading.Timeout.Infinite);
                    }

                    break;
                }

                case TPartnerInfoAvailDataEnum.piadFull:
                {
                    ShowHideLoadingInfo(true, true, LoadRestOfData);

                    FHeadDataServerRetrieved = false;
                    UpdateControlsHeadData();

                    FLocationDataServerRetrieved = false;
                    UpdateControlsLocationData();

                    UpdateControlsRestData();

                    ShowHideLoadingInfo(false, true, LoadRestOfData);

                    break;
                }
            }

            FLastPartnerKey = FPartnerKey;
        }
예제 #2
0
            /// <summary>
            /// Construcor.
            /// </summary>
            /// <param name="APartnerKey">PartnerKey of Partner that should be retrieved.</param>
            /// <param name="ALocationKey">Location Primary Key of Partner that should be retrieved.</param>
            /// <param name="AScope">Scope of data that is already available client-side.</param>
            /// <param name="ALoadRestOfData">Determines whether the 'rest' of the data needs to be retrieved as well.</param>
            /// <param name="APartnerInfoScope">Scope of data that should be retrieved.</param>
            public TServerCallParams(Int64 APartnerKey, TLocationPK ALocationKey,
                TPartnerInfoAvailDataEnum AScope,
                bool ALoadRestOfData,
                TPartnerInfoScopeEnum APartnerInfoScope)
            {
                FPartnerKey = APartnerKey;
                FLocationKey = ALocationKey;
                FLoadRestOfData = ALoadRestOfData;
                FScope = AScope;
                FPartnerInfoScope = APartnerInfoScope;

//                TLogging.Log("Created new TServerCallParams. PartnerKey: " + FPartnerKey.ToString() +
//                             "; LocationKey: " + FLocationKey.LocationKey.ToString() +
//                             "; PartnerInfoScope: " + FPartnerInfoScope.ToString("G"));
            }