Exemplo n.º 1
0
        public PointSettings()
        {
            UserPoints = new UserPointCollection();
            ExchangeProportions = new PointExchangeProportionCollection();

            ExchangeProportions.Add(UserPointType.Point1, 10);
            ExchangeProportions.Add(UserPointType.Point2, 1);
            ExchangeProportions.Add(UserPointType.Point3, 1);
            ExchangeProportions.Add(UserPointType.Point4, 1);
            ExchangeProportions.Add(UserPointType.Point5, 1);
            ExchangeProportions.Add(UserPointType.Point6, 1);
            ExchangeProportions.Add(UserPointType.Point7, 1);
            ExchangeProportions.Add(UserPointType.Point8, 1);

            EnablePointExchange = false;
            
            EnablePointTransfer = false;

            PointRechargeRules = new PointRechargeRuleCollection();

            PointExchangeRules = new PointExchangeRuleCollection();
            PointExchangeRule rule = new PointExchangeRule();
            rule.PointType = UserPointType.Point2;
            rule.TargetPointType = UserPointType.Point1;
            rule.TaxRate = 2;
            PointExchangeRules.Add(rule);

            GeneralPointName = "总积分";
            GeneralPointExpression = "p1+p2*10";
            DisplayGeneralPoint = true;
            TradeRate = 2;

            PointTransferRules = new PointTransferRuleCollection();
            PointTransferRule tRule = new PointTransferRule();
            tRule.CanTransfer = true;
            tRule.PointType = UserPointType.Point1;
            tRule.TaxRate = 2;
            PointTransferRules.Add(tRule);

            PointIcons = new PointIconCollection();
            PointIcon icon = new PointIcon();
            icon.IconCount = 4;
            icon.IconsString = "fortune_3.gif|fortune_2.gif|fortune_1.gif";
            icon.PointType = UserPointType.Point1;
            icon.PointValue = 1000;
            PointIcons.Add(icon);
        }
        private void SavepointTransferRules()
        {
            string[] names = new string[] { "taxRate", "minRemaining" };
            MessageDisplay msgDisplay = CreateMessageDisplay(names);

            PointTransferRuleCollection rules = new PointTransferRuleCollection();
            int i = 0;
            foreach (UserPoint userPoint in AllSettings.Current.PointSettings.EnabledUserPoints)
            {
                int pointID = (int)userPoint.Type;
                bool canTransfer = _Request.Get<bool>("canTransfer." + pointID, Method.Post, false);
                string valueString = _Request.Get("taxRate." + pointID, Method.Post, string.Empty);
                int taxRate = 0;
                if (!int.TryParse(valueString, out taxRate))
                {
                    msgDisplay.AddError("taxRate", i, Lang_Error.User_UserPointTransferTaxRateFormatError);
                }
                else if (taxRate < 0)
                {
                    msgDisplay.AddError("taxRate", i, Lang_Error.User_UserPointTransferTaxRateFormatError);
                }

                valueString = _Request.Get("minRemaining." + pointID, Method.Post, string.Empty);
                int minRemainingValue = 0;
                if (!int.TryParse(valueString, out minRemainingValue))
                {
                    msgDisplay.AddError("minRemaining", i, Lang_Error.User_UserPointTransferMinRemainingValueFormatError);
                }

                PointTransferRule rule = new PointTransferRule();
                rule.CanTransfer = canTransfer;
                rule.MinRemainingValue = minRemainingValue;
                rule.PointType = userPoint.Type;
                rule.TaxRate = taxRate;

                rules.Add(rule);
            }

            if (msgDisplay.HasAnyError())
                return;

            PointSettings setting = SettingManager.CloneSetttings<PointSettings>(AllSettings.Current.PointSettings);

            try
            {
                setting.PointTransferRules = rules;
                setting.EnablePointTransfer = _Request.IsChecked("enable", Method.Post, false);
                if (!SettingManager.SaveSettings(setting))
                {
                    CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error.TatgetName, error.TargetLine, error.Message);
                    });
                }
                else
                    AllSettings.Current.PointSettings = setting;
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void SavepointTransferRules()
        {
            string[]       names      = new string[] { "taxRate", "minRemaining" };
            MessageDisplay msgDisplay = CreateMessageDisplay(names);

            PointTransferRuleCollection rules = new PointTransferRuleCollection();
            int i = 0;

            foreach (UserPoint userPoint in AllSettings.Current.PointSettings.EnabledUserPoints)
            {
                int    pointID     = (int)userPoint.Type;
                bool   canTransfer = _Request.Get <bool>("canTransfer." + pointID, Method.Post, false);
                string valueString = _Request.Get("taxRate." + pointID, Method.Post, string.Empty);
                int    taxRate     = 0;
                if (!int.TryParse(valueString, out taxRate))
                {
                    msgDisplay.AddError("taxRate", i, Lang_Error.User_UserPointTransferTaxRateFormatError);
                }
                else if (taxRate < 0)
                {
                    msgDisplay.AddError("taxRate", i, Lang_Error.User_UserPointTransferTaxRateFormatError);
                }

                valueString = _Request.Get("minRemaining." + pointID, Method.Post, string.Empty);
                int minRemainingValue = 0;
                if (!int.TryParse(valueString, out minRemainingValue))
                {
                    msgDisplay.AddError("minRemaining", i, Lang_Error.User_UserPointTransferMinRemainingValueFormatError);
                }

                PointTransferRule rule = new PointTransferRule();
                rule.CanTransfer       = canTransfer;
                rule.MinRemainingValue = minRemainingValue;
                rule.PointType         = userPoint.Type;
                rule.TaxRate           = taxRate;

                rules.Add(rule);
            }

            if (msgDisplay.HasAnyError())
            {
                return;
            }

            PointSettings setting = SettingManager.CloneSetttings <PointSettings>(AllSettings.Current.PointSettings);

            try
            {
                setting.PointTransferRules  = rules;
                setting.EnablePointTransfer = _Request.IsChecked("enable", Method.Post, false);
                if (!SettingManager.SaveSettings(setting))
                {
                    CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error.TatgetName, error.TargetLine, error.Message);
                    });
                }
                else
                {
                    AllSettings.Current.PointSettings = setting;
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }