private void Save() { MessageDisplay msgDisplay = CreateMessageDisplay("money", "point", "minvalue"); PointRechargeRuleCollection rules = new PointRechargeRuleCollection(); int i = 0; foreach (UserPoint point in AllSettings.Current.PointSettings.EnabledUserPoints) { int pointID = (int)point.Type; PointRechargeRule rule = new PointRechargeRule(); rule.UserPointType = point.Type; rule.Enable = _Request.IsChecked("canRecharge." + pointID, Method.Post, false); rule.Money = _Request.Get<int>("money." + pointID, Method.Post, 0); rule.Point = _Request.Get<int>("point." + pointID, Method.Post, 0); rule.MinValue = _Request.Get<int>("minvalue." + pointID, Method.Post, 0); if (rule.Enable) { if (rule.Money < 1) { msgDisplay.AddError("money", i, "人民币必须为大于0的整数"); } if (rule.Point < 1) { msgDisplay.AddError("point", i, "积分数量必须为大于0的整数"); } if (rule.Point < 1) { msgDisplay.AddError("minvalue", i, "一次至少需要充值的积分数量必须大于0"); } } rules.Add(rule); i++; } if (msgDisplay.HasAnyError()) return; PointSettings pointSetting = SettingManager.CloneSetttings<PointSettings>(PointSettings); PaySettings paySettings = SettingManager.CloneSetttings<PaySettings>(PaySettings); pointSetting.PointRechargeRules = rules; paySettings.EnablePointRecharge = _Request.Get<bool>("enable", Method.Post, false); if (paySettings.EnablePointRecharge) { paySettings.ProductName = _Request.Get("ProductName", Method.Post, string.Empty); paySettings.EnableAlipay = _Request.Get<bool>("enableAlipay", Method.Post, false); paySettings.EnableTenpay = _Request.Get<bool>("EnableTenpay", Method.Post, false); paySettings.Enable99Bill = _Request.Get<bool>("Enable99Bill", Method.Post, false); if (paySettings.EnableAlipay) { paySettings.Alipay_SellerEmail = _Request.Get("Alipay_SellerEmail", Method.Post, string.Empty); paySettings.Alipay_PartnerID = _Request.Get("Alipay_PartnerID", Method.Post, string.Empty); paySettings.Alipay_Key = _Request.Get("Alipay_Key", Method.Post, string.Empty); } if (paySettings.EnableTenpay) { paySettings.Tenpay_BargainorID = _Request.Get("Tenpay_BargainorID", Method.Post, string.Empty); paySettings.Tenpay_Key = _Request.Get("Tenpay_Key", Method.Post, string.Empty); } if (paySettings.Enable99Bill) { paySettings._99Bill_MerchantAcctID = _Request.Get("_99Bill_MerchantAcctID", Method.Post, string.Empty); paySettings._99Bill_Key = _Request.Get("_99Bill_Key", Method.Post, string.Empty); } } else { paySettings.EnableAlipay = false; paySettings.EnableTenpay = false; paySettings.Enable99Bill = false; } if (paySettings.EnablePointRecharge) { foreach (PointRechargeRule rule in rules) { if (rule.Enable) { pointSetting.UserPoints.GetUserPoint(rule.UserPointType).MaxValue = int.MaxValue; } } } try { SettingManager.SaveSettings(pointSetting); SettingManager.SaveSettings(paySettings); PostBOV5.Instance.ClearShowChargePointLinks(); } catch (Exception ex) { msgDisplay.AddError(ex.Message); } }
private void Save() { MessageDisplay msgDisplay = CreateMessageDisplay("money", "point", "minvalue"); PointRechargeRuleCollection rules = new PointRechargeRuleCollection(); int i = 0; foreach (UserPoint point in AllSettings.Current.PointSettings.EnabledUserPoints) { int pointID = (int)point.Type; PointRechargeRule rule = new PointRechargeRule(); rule.UserPointType = point.Type; rule.Enable = _Request.IsChecked("canRecharge." + pointID, Method.Post, false); rule.Money = _Request.Get <int>("money." + pointID, Method.Post, 0); rule.Point = _Request.Get <int>("point." + pointID, Method.Post, 0); rule.MinValue = _Request.Get <int>("minvalue." + pointID, Method.Post, 0); if (rule.Enable) { if (rule.Money < 1) { msgDisplay.AddError("money", i, "人民币必须为大于0的整数"); } if (rule.Point < 1) { msgDisplay.AddError("point", i, "积分数量必须为大于0的整数"); } if (rule.Point < 1) { msgDisplay.AddError("minvalue", i, "一次至少需要充值的积分数量必须大于0"); } } rules.Add(rule); i++; } if (msgDisplay.HasAnyError()) { return; } PointSettings pointSetting = SettingManager.CloneSetttings <PointSettings>(PointSettings); PaySettings paySettings = SettingManager.CloneSetttings <PaySettings>(PaySettings); pointSetting.PointRechargeRules = rules; paySettings.EnablePointRecharge = _Request.Get <bool>("enable", Method.Post, false); if (paySettings.EnablePointRecharge) { paySettings.ProductName = _Request.Get("ProductName", Method.Post, string.Empty); paySettings.EnableAlipay = _Request.Get <bool>("enableAlipay", Method.Post, false); paySettings.EnableTenpay = _Request.Get <bool>("EnableTenpay", Method.Post, false); paySettings.Enable99Bill = _Request.Get <bool>("Enable99Bill", Method.Post, false); if (paySettings.EnableAlipay) { paySettings.Alipay_SellerEmail = _Request.Get("Alipay_SellerEmail", Method.Post, string.Empty); paySettings.Alipay_PartnerID = _Request.Get("Alipay_PartnerID", Method.Post, string.Empty); paySettings.Alipay_Key = _Request.Get("Alipay_Key", Method.Post, string.Empty); } if (paySettings.EnableTenpay) { paySettings.Tenpay_BargainorID = _Request.Get("Tenpay_BargainorID", Method.Post, string.Empty); paySettings.Tenpay_Key = _Request.Get("Tenpay_Key", Method.Post, string.Empty); } if (paySettings.Enable99Bill) { paySettings._99Bill_MerchantAcctID = _Request.Get("_99Bill_MerchantAcctID", Method.Post, string.Empty); paySettings._99Bill_Key = _Request.Get("_99Bill_Key", Method.Post, string.Empty); } } else { paySettings.EnableAlipay = false; paySettings.EnableTenpay = false; paySettings.Enable99Bill = false; } if (paySettings.EnablePointRecharge) { foreach (PointRechargeRule rule in rules) { if (rule.Enable) { pointSetting.UserPoints.GetUserPoint(rule.UserPointType).MaxValue = int.MaxValue; } } } try { SettingManager.SaveSettings(pointSetting); SettingManager.SaveSettings(paySettings); PostBOV5.Instance.ClearShowChargePointLinks(); } catch (Exception ex) { msgDisplay.AddError(ex.Message); } }