예제 #1
0
            /// <summary>
            /// Given all relevant transaction/line info, this method builds a charge configuration header
            /// containing the appropriate relations to be consumed by the ChargeDataManager to find
            /// charge configurations in the database.
            /// </summary>
            /// <param name="accountType">The customer relation type on the header.</param>
            /// <param name="itemType">The item relation type on the header.</param>
            /// <param name="deliveryType">The delivery relation type on the header.</param>
            /// <param name="customerId">The account number of the customer on the header.</param>
            /// <param name="customerGroup">The customer charge account group on the header.</param>
            /// <param name="itemId">The item id.</param>
            /// <param name="itemGroup">The item charge group id.</param>
            /// <param name="deliveryMode">The delivery mode code.</param>
            /// <param name="deliveryModeGroup">The delivery mode charge group id.</param>
            /// <returns>
            /// Charge configuration header built from the parameters to use to query for configurations.
            /// </returns>
            private static ChargeConfigurationHeader BuildConfigurationHeader(
                ChargeAccountType accountType,
                ChargeItemType itemType,
                ChargeDeliveryType deliveryType,
                string customerId,
                string customerGroup,
                string itemId,
                string itemGroup,
                string deliveryMode,
                string deliveryModeGroup)
            {
                // extract appropriate account relation string
                string accountRelation = string.Empty;

                if (accountType == ChargeAccountType.Customer)
                {
                    accountRelation = customerId;
                }
                else if (accountType == ChargeAccountType.CustomerGroup)
                {
                    accountRelation = customerGroup;
                }

                // extract appropriate item relation string
                string itemRelation = string.Empty;

                if (itemType == ChargeItemType.Item)
                {
                    itemRelation = itemId;
                }
                else if (itemType == ChargeItemType.ItemGroup)
                {
                    itemRelation = itemGroup;
                }

                // extract appropriate delivery mode relation string
                string deliveryRelation = string.Empty;

                if (deliveryType == ChargeDeliveryType.DeliveryMode)
                {
                    deliveryRelation = deliveryMode;
                }
                else if (deliveryType == ChargeDeliveryType.DeliveryModeGroup)
                {
                    deliveryRelation = deliveryModeGroup;
                }

                var header = new ChargeConfigurationHeader
                {
                    AccountType      = accountType,
                    AccountRelation  = accountRelation ?? string.Empty,
                    ItemType         = itemType,
                    ItemRelation     = itemRelation ?? string.Empty,
                    DeliveryType     = deliveryType,
                    DeliveryRelation = deliveryRelation ?? string.Empty,
                };

                return(header);
            }
예제 #2
0
            private void FilterChargeConfigurations(SqlPagedQuery query, ChargeLevel chargeType, ChargeConfigurationHeader header)
            {
                StringBuilder whereClause = new StringBuilder("(");

                whereClause.Append("(MODULECATEGORY = @ChargeType)");

                if (header.AccountType != ChargeAccountType.None)
                {
                    whereClause.Append(" AND (ACCOUNTCODE = @AccountType AND ACCOUNTRELATION = @AccountRelation) ");
                }

                if (header.ItemType != ChargeItemType.None)
                {
                    whereClause.Append(" AND (ITEMCODE = @ItemType AND ITEMRELATION = @ItemRelation AND MODULETYPE = 1) ");
                }

                if (header.DeliveryType != ChargeDeliveryType.None)
                {
                    whereClause.Append(" AND (DLVMODECODE = @DeliveryType AND DLVMODERELATION = @DeliveryRelation AND MODULETYPE = 3) ");
                }

                whereClause.Append(")");
                query.Where = whereClause.ToString();

                query.Parameters["@ChargeType"]       = chargeType;
                query.Parameters["@AccountType"]      = header.AccountType;
                query.Parameters["@AccountRelation"]  = header.AccountRelation;
                query.Parameters["@ItemType"]         = header.ItemType;
                query.Parameters["@ItemRelation"]     = header.ItemRelation;
                query.Parameters["@DeliveryType"]     = header.DeliveryType;
                query.Parameters["@DeliveryRelation"] = header.DeliveryRelation;
            }