private void HandleBaseResult(UPCRMResult result)
        {
            int count = result.RowCount;

            if (count > 0)
            {
                this.conditionDictionary = new Dictionary <string, UPSEPricingCondition>(count);
                int bundleKeyIndex = 0;
                if (this.BundleConfigFieldControl != null)
                {
                    int infoAreaIndex = this.currentQuery.IndexOfResultInfoAreaIdLinkId(this.BundleConfigFieldControl.InfoAreaId, -1);
                    if (infoAreaIndex > 0)
                    {
                        bundleKeyIndex = infoAreaIndex;
                    }
                }

                for (int i = 0; i < count; i++)
                {
                    UPSEPricingCondition condition = new UPSEPricingCondition(
                        (UPCRMResultRow)result.ResultRowAtIndex(i), this.ConfigFieldControl, bundleKeyIndex, this);

                    this.conditionDictionary[condition.RecordIdentification] = condition;
                }

                this.StartBaseScaleQuery();
            }
            else
            {
#if  PRICINGDEMO
                this.conditionDictionary = NSMutableDictionary.TheNew();
                this.bundleDictionary    = NSMutableDictionary.TheNew();
                UPSEPricingCondition condition     = UPSEPricingCondition.DemoBase();
                UPSEBundlePricing    bundlePricing = UPSEPricingCondition.DemoBundle();
                this.conditionDictionary.SetObjectForKey(condition, condition.RecordIdentification);
                this.bundleDictionary.SetObjectForKey(bundlePricing, bundlePricing.RecordIdentification);
#endif

                this.FinishedLoadingSuccessfully();
            }
        }
        private void HandleBaseScaleResult(UPCRMResult result)
        {
            int count = result.RowCount;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i);
                    string         conditionRecordIdentification = row.RecordIdentificationAtIndex(1);
                    if (!string.IsNullOrEmpty(conditionRecordIdentification))
                    {
                        UPSEPricingCondition root = this.conditionDictionary.ValueOrDefault(row.RecordIdentificationAtIndex(1));
                        if (root != null)
                        {
                            UPSEPricingScale pricingScale = new UPSEPricingScale(row, this.ScaleConfigFieldControl, this.Pricing);
                            root.AddScale(pricingScale);
                        }
                    }
                }
            }

            this.StartBundleQuery();
        }
        /// <summary>
        /// Conditionses for data key order row record identifier.
        /// </summary>
        /// <param name="matchDictionary">The match dictionary.</param>
        /// <param name="keyOrder">The key order.</param>
        /// <param name="rowRecordId">The row record identifier.</param>
        /// <returns></returns>
        public UPSEPricingCondition ConditionsForDataKeyOrderRowRecordId(Dictionary <string, object> matchDictionary, List <string> keyOrder, string rowRecordId)
        {
            int matchIndex = keyOrder.Count + 1;
            UPSEPricingCondition matchingCondition = null;

            foreach (UPSEPricingCondition condition in this.conditionDictionary.Values)
            {
                int currentMatchIndex = condition.MatchingIndexKeyOrderMaxMatchIndex(matchDictionary, keyOrder, matchIndex - 1);
                if (currentMatchIndex >= 0)
                {
                    if (currentMatchIndex < matchIndex)
                    {
                        matchingCondition = condition;
                        matchIndex        = currentMatchIndex;
                        if (matchIndex == 0)
                        {
                            break;
                        }
                    }
                }
            }

            return(matchingCondition);
        }