Пример #1
0
 internal static void EncryptPaymentMode(PaymentModeInfo paymentMode)
 {
     if (paymentMode != null)
     {
         using (MsCryptographer cryptographer = new MsCryptographer(false, true))
         {
             if (!string.IsNullOrEmpty(paymentMode.SecretKey))
             {
                 paymentMode.SecretKey = cryptographer.Encrypt(paymentMode.SecretKey);
             }
             if (!string.IsNullOrEmpty(paymentMode.SecondKey))
             {
                 paymentMode.SecondKey = cryptographer.Encrypt(paymentMode.SecondKey);
             }
             if (!string.IsNullOrEmpty(paymentMode.Password))
             {
                 paymentMode.Password = cryptographer.Encrypt(paymentMode.Password);
             }
             if (!string.IsNullOrEmpty(paymentMode.Partner))
             {
                 paymentMode.Partner = cryptographer.Encrypt(paymentMode.Partner);
             }
         }
     }
 }
Пример #2
0
 public static bool DeletePaymentMode(int modeId)
 {
     PaymentModeInfo info2 = new PaymentModeInfo {
         ModeId = modeId
     };
     PaymentModeInfo paymentMode = info2;
     return (service.CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Delete) == PaymentModeActionStatus.Success);
 }
Пример #3
0
 public static PaymentModeActionStatus CreatePaymentMode(PaymentModeInfo paymentMode)
 {
     if (paymentMode == null)
     {
         return PaymentModeActionStatus.UnknowError;
     }
     EncryptPaymentMode(paymentMode);
     return service.CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Create);
 }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.btnUpdate.Click += new EventHandler(this.btnUpdate_Click);
     this.dropPayInterface.SelectedIndexChanged += new EventHandler(this.dropPayInterface_SelectedIndexChanged);
     if (!this.Page.IsPostBack)
     {
         string tmpModeId = this.Page.Request.QueryString["modeId"];
         if (!string.IsNullOrEmpty(tmpModeId))
         {
             PaymentModeInfo paymentMode = PaymentModeManage.GetPaymentMode(Globals.SafeInt(this.Page.Request.QueryString["modeId"], 0));
             if (paymentMode == null)
             {
                 throw new NullReferenceException();
             }
             this.Item = paymentMode;
         }
         this.dropPayInterface.DataBind();
         this.DisplayControls();
         if (this.item != null)
         {
             this.dropPayInterface.SelectedValue = this.item.Gateway;
             this.DisplayControls();
             this.txtName.Text = Globals.HtmlDecode(this.item.Name);
             this.txtMerchantCode.Text = this.item.MerchantCode;
             this.radAllowRecharge.SelectedValue = this.item.AllowRecharge;
             this.fcContent.Value = this.item.Description;
             if (!string.IsNullOrEmpty(this.item.EmailAddress))
             {
                 this.txtEmailAddress.Text = Globals.HtmlDecode(this.item.EmailAddress);
             }
             this.txtDisplaySequence.Text = this.item.DisplaySequence.ToString(CultureInfo.InvariantCulture);
             this.txtSecretKey.Text = this.item.SecretKey;
             this.txtSecondKey.Text = this.item.SecondKey;
             this.txtCharge.Text = this.item.Charge.ToString("F", CultureInfo.InvariantCulture);
             this.chkIsPercent.Checked = this.item.IsPercent;
             if (!string.IsNullOrEmpty(this.item.Password))
             {
                 this.txtPassword.Text = this.item.Password;
             }
             if (!string.IsNullOrEmpty(this.item.Partner))
             {
                 this.txtPartner.Text = Globals.HtmlDecode(this.item.Partner);
             }
             foreach (string str in this.item.SupportedCurrencys)
             {
                 if (str == "")
                 {
                     this.chkCurrencysList.Items[0].Selected = true;
                 }
                 else
                 {
                     this.chkCurrencysList.Items.FindByValue(str).Selected = true;
                 }
             }
         }
     }
     this.txtName.Focus();
 }
Пример #5
0
 public PaymentModeActionStatus CreateUpdateDeletePaymentMode(PaymentModeInfo paymentMode, DataProviderAction action)
 {
     if (paymentMode == null)
     {
         return PaymentModeActionStatus.UnknowError;
     }
     DbCommand storedProcCommand = this.database.GetStoredProcCommand("sp_Pay_PaymentMode_CreateUpdateDelete");
     this.database.AddInParameter(storedProcCommand, "Action", DbType.Int32, (int) action);
     this.database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4);
     if (action == DataProviderAction.Create)
     {
         this.database.AddOutParameter(storedProcCommand, "ModeId", DbType.Int32, 4);
     }
     else
     {
         this.database.AddInParameter(storedProcCommand, "ModeId", DbType.Int32, paymentMode.ModeId);
     }
     if (action != DataProviderAction.Delete)
     {
         this.database.AddInParameter(storedProcCommand, "MerchantCode", DbType.String, paymentMode.MerchantCode);
         this.database.AddInParameter(storedProcCommand, "EmailAddress", DbType.String, paymentMode.EmailAddress);
         this.database.AddInParameter(storedProcCommand, "SecretKey", DbType.String, paymentMode.SecretKey);
         this.database.AddInParameter(storedProcCommand, "SecondKey", DbType.String, paymentMode.SecondKey);
         this.database.AddInParameter(storedProcCommand, "Password", DbType.String, paymentMode.Password);
         this.database.AddInParameter(storedProcCommand, "Partner", DbType.String, paymentMode.Partner);
         this.database.AddInParameter(storedProcCommand, "Name", DbType.String, paymentMode.Name);
         this.database.AddInParameter(storedProcCommand, "Description", DbType.String, paymentMode.Description);
         this.database.AddInParameter(storedProcCommand, "AllowRecharge", DbType.Boolean, paymentMode.AllowRecharge);
         this.database.AddInParameter(storedProcCommand, "Gateway", DbType.String, paymentMode.Gateway);
         if (paymentMode.DisplaySequence > 0)
         {
             this.database.AddInParameter(storedProcCommand, "DisplaySequence", DbType.Int32, paymentMode.DisplaySequence);
         }
         this.database.AddInParameter(storedProcCommand, "Charge", DbType.Currency, paymentMode.Charge);
         this.database.AddInParameter(storedProcCommand, "IsPercent", DbType.Boolean, paymentMode.IsPercent);
     }
     PaymentModeActionStatus unknowError = PaymentModeActionStatus.UnknowError;
     if ((action != DataProviderAction.Delete) && (paymentMode.SupportedCurrencys.Count > 0))
     {
         using (DbConnection connection = this.database.CreateConnection())
         {
             connection.Open();
             DbTransaction transaction = connection.BeginTransaction();
             try
             {
                 this.database.ExecuteNonQuery(storedProcCommand, transaction);
                 unknowError = (PaymentModeActionStatus) ((int) this.database.GetParameterValue(storedProcCommand, "Status"));
                 int num = (action == DataProviderAction.Create) ? ((int) this.database.GetParameterValue(storedProcCommand, "ModeId")) : paymentMode.ModeId;
                 if (unknowError == PaymentModeActionStatus.Success)
                 {
                     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("  ");
                     this.database.AddInParameter(sqlStringCommand, "ModeId", DbType.Int32, num);
                     StringBuilder builder = new StringBuilder();
                     if (action == DataProviderAction.Update)
                     {
                         builder.Append("DELETE  From  Pay_PaymentCurrencys Where ModeId=@ModeId");
                     }
                     builder.Append(" DECLARE @intErrorCode INT;SET @intErrorCode = 0;");
                     int num2 = 0;
                     foreach (string str in paymentMode.SupportedCurrencys)
                     {
                         builder.Append("INSERT INTO Pay_PaymentCurrencys(ModeId,Code) Values(").Append("@ModeId").Append(",@Code").Append(num2).Append(");SET @intErrorCode = @intErrorCode + @@ERROR;");
                         this.database.AddInParameter(sqlStringCommand, "Code" + num2, DbType.String, str);
                         num2++;
                     }
                     sqlStringCommand.CommandText = builder.Append("SELECT @intErrorCode;").ToString();
                     if (((int) this.database.ExecuteScalar(sqlStringCommand, transaction)) == 0)
                     {
                         transaction.Commit();
                     }
                     else
                     {
                         transaction.Rollback();
                         unknowError = PaymentModeActionStatus.UnknowError;
                     }
                 }
                 else
                 {
                     transaction.Rollback();
                 }
             }
             catch
             {
                 transaction.Rollback();
                 unknowError = PaymentModeActionStatus.UnknowError;
             }
             connection.Close();
             return unknowError;
         }
     }
     this.database.ExecuteNonQuery(storedProcCommand);
     return (PaymentModeActionStatus) ((int) this.database.GetParameterValue(storedProcCommand, "Status"));
 }
Пример #6
0
 public PaymentModeInfo PopupPayment(IDataRecord reader)
 {
     if (reader == null)
     {
         return null;
     }
     PaymentModeInfo info2 = new PaymentModeInfo {
         ModeId = (int) reader["ModeId"],
         Name = (string) reader["Name"],
         MerchantCode = (string) reader["MerchantCode"],
         DisplaySequence = (int) reader["DisplaySequence"],
         Charge = (decimal) reader["Charge"],
         IsPercent = (bool) reader["IsPercent"],
         AllowRecharge = (bool) reader["AllowRecharge"]
     };
     PaymentModeInfo info = info2;
     if (reader["EmailAddress"] != DBNull.Value)
     {
         info.EmailAddress = (string) reader["EmailAddress"];
     }
     if (reader["SecretKey"] != DBNull.Value)
     {
         info.SecretKey = (string) reader["SecretKey"];
     }
     if (reader["SecondKey"] != DBNull.Value)
     {
         info.SecondKey = (string) reader["SecondKey"];
     }
     if (reader["Password"] != DBNull.Value)
     {
         info.Password = (string) reader["Password"];
     }
     if (reader["Partner"] != DBNull.Value)
     {
         info.Partner = (string) reader["Partner"];
     }
     if (reader["Description"] != DBNull.Value)
     {
         info.Description = (string) reader["Description"];
     }
     if (reader["Gateway"] != DBNull.Value)
     {
         info.Gateway = (string) reader["Gateway"];
     }
     if (reader["Logo"] != DBNull.Value)
     {
         info.Logo = reader["Logo"].ToString();
     }
     return info;
 }
Пример #7
0
 public PaymentModeInfo GetPaymentMode(int modeId)
 {
     PaymentModeInfo info = new PaymentModeInfo();
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Pay_PaymentTypes WHERE ModeId = @ModeId;SELECT Code FROM Pay_PaymentCurrencys WHERE ModeId = @ModeId");
     this.database.AddInParameter(sqlStringCommand, "ModeId", DbType.Int32, modeId);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = this.PopupPayment(reader);
         }
         if (reader.NextResult())
         {
             goto Label_006B;
         }
         return info;
     Label_0059:
         info.SupportedCurrencys.Add(reader.GetString(0));
     Label_006B:
         if (reader.Read())
         {
             goto Label_0059;
         }
     }
     return info;
 }
Пример #8
0
 public ActionResult ShowPayAndShip(int payId = -1, int shipId = -1, string sku = new string(), int count = 1, int c = -1, string viewName = "_ShowPayAndShip")
 {
     ShoppingCartInfo shoppingCart;
     PayAndShip model = new PayAndShip {
         ListPaymentMode = PaymentModeManage.GetPaymentModes()
     };
     if (payId > 0)
     {
         model.CurrentPaymentMode = PaymentModeManage.GetPaymentModeById(payId);
     }
     else if ((model.ListPaymentMode != null) && (model.ListPaymentMode.Count > 0))
     {
         model.CurrentPaymentMode = model.ListPaymentMode[0];
         model.ListShippingType = this._shippingTypeManage.GetListByPay(model.CurrentPaymentMode.ModeId);
     }
     else
     {
         PaymentModeInfo info = new PaymentModeInfo {
             ModeId = -1,
             Name = "未选择支付方式"
         };
         model.CurrentPaymentMode = info;
     }
     if (shipId > 0)
     {
         model.CurrentShippingType = this._shippingTypeManage.GetModelByCache(shipId);
     }
     else if ((model.ListShippingType != null) && (model.ListShippingType.Count > 0))
     {
         model.CurrentShippingType = model.ListShippingType[0];
     }
     else
     {
         Maticsoft.Model.Shop.Shipping.ShippingType type = new Maticsoft.Model.Shop.Shipping.ShippingType {
             ModeId = -1,
             Name = "未选择配送方式"
         };
         model.CurrentShippingType = type;
     }
     if (string.IsNullOrWhiteSpace(sku))
     {
         int userId = (base.currentUser == null) ? -1 : base.currentUser.UserID;
         shoppingCart = new ShoppingCartHelper(userId).GetShoppingCart();
     }
     else
     {
         Maticsoft.BLL.Shop.Products.SKUInfo info3 = new Maticsoft.BLL.Shop.Products.SKUInfo();
         Maticsoft.BLL.Shop.Products.ProductInfo info4 = new Maticsoft.BLL.Shop.Products.ProductInfo();
         Maticsoft.Model.Shop.Products.SKUInfo modelBySKU = info3.GetModelBySKU(sku);
         if (modelBySKU == null)
         {
             ((dynamic) base.ViewBag).Freight = 0;
             return base.View(viewName, model);
         }
         Maticsoft.Model.Shop.Products.ProductInfo productInfo = info4.GetModel(modelBySKU.ProductId);
         if (productInfo == null)
         {
             ((dynamic) base.ViewBag).Freight = 0;
             return base.View(viewName, model);
         }
         Maticsoft.Model.Shop.Products.ProductInfo proSaleInfo = null;
         if (c > 0)
         {
             proSaleInfo = info4.GetProSaleModel(c);
             if (proSaleInfo == null)
             {
                 ((dynamic) base.ViewBag).Freight = 0;
                 return base.View(viewName, model);
             }
         }
         shoppingCart = this.GetCartInfo4SKU(productInfo, modelBySKU, count, proSaleInfo);
     }
     ((dynamic) base.ViewBag).Freight = shoppingCart.CalcFreight(model.CurrentShippingType);
     return base.View(viewName, model);
 }
Пример #9
0
 public ActionResult PayAndShipInfo(int payId = -1, int shipId = -1, string viewName = "_PayAndShipInfo")
 {
     PayAndShip model = new PayAndShip {
         ListPaymentMode = PaymentModeManage.GetPaymentModes()
     };
     if (payId > 0)
     {
         model.CurrentPaymentMode = PaymentModeManage.GetPaymentModeById(payId);
         model.ListShippingType = this._shippingTypeManage.GetListByPay(payId);
     }
     else if ((model.ListPaymentMode != null) && (model.ListPaymentMode.Count > 0))
     {
         model.CurrentPaymentMode = model.ListPaymentMode[0];
         model.ListShippingType = this._shippingTypeManage.GetListByPay(model.CurrentPaymentMode.ModeId);
     }
     else
     {
         PaymentModeInfo info = new PaymentModeInfo {
             ModeId = -1,
             Name = "当前网站未设置任何支付方式"
         };
         model.CurrentPaymentMode = info;
         model.ListPaymentMode = new List<PaymentModeInfo> { model.CurrentPaymentMode };
     }
     if (shipId > 0)
     {
         model.CurrentShippingType = this._shippingTypeManage.GetModelByCache(shipId);
     }
     else if ((model.ListShippingType != null) && (model.ListShippingType.Count > 0))
     {
         model.CurrentShippingType = model.ListShippingType[0];
     }
     else
     {
         Maticsoft.Model.Shop.Shipping.ShippingType type = new Maticsoft.Model.Shop.Shipping.ShippingType {
             ModeId = -1,
             Name = "当前支付方式未设置任何配送",
             Description = "请选择其它支付方式"
         };
         model.CurrentShippingType = type;
         model.ListShippingType = new List<Maticsoft.Model.Shop.Shipping.ShippingType> { model.CurrentShippingType };
     }
     return base.View(viewName, model);
 }
Пример #10
0
 public ActionResult ShowPayAndShip(string viewName = "_ShowPayAndShip")
 {
     PayAndShip model = new PayAndShip();
     int modeId = Globals.SafeInt(base.Request.Params["payId"], 0);
     int num2 = Globals.SafeInt(base.Request.QueryString["shipId"], 0);
     model.ListPaymentMode = PaymentModeManage.GetPaymentModes();
     if (modeId > 0)
     {
         model.CurrentPaymentMode = PaymentModeManage.GetPaymentModeById(modeId);
     }
     else if ((model.ListPaymentMode != null) && (model.ListPaymentMode.Count > 0))
     {
         model.CurrentPaymentMode = model.ListPaymentMode[0];
         model.ListShippingType = this._shippingTypeManage.GetListByPay(model.CurrentPaymentMode.ModeId);
     }
     else
     {
         PaymentModeInfo info = new PaymentModeInfo {
             ModeId = -1,
             Name = "未选择支付方式"
         };
         model.CurrentPaymentMode = info;
     }
     if (num2 > 0)
     {
         model.CurrentShippingType = this._shippingTypeManage.GetModelByCache(num2);
     }
     else if ((model.ListShippingType != null) && (model.ListShippingType.Count > 0))
     {
         model.CurrentShippingType = model.ListShippingType[0];
     }
     else
     {
         Maticsoft.Model.Shop.Shipping.ShippingType type = new Maticsoft.Model.Shop.Shipping.ShippingType {
             ModeId = -1,
             Name = "未选择配送方式"
         };
         model.CurrentShippingType = type;
     }
     ShoppingCartInfo shoppingCart = new ShoppingCartInfo();
     int userId = (base.currentUser == null) ? -1 : base.currentUser.UserID;
     shoppingCart = new ShoppingCartHelper(userId).GetShoppingCart();
     ((dynamic) base.ViewBag).Freight = shoppingCart.CalcFreight(model.CurrentShippingType);
     return base.View(viewName, model);
 }
Пример #11
0
 public ActionResult PayAndShipInfo(string viewName = "PayAndShipInfo")
 {
     PayAndShip model = new PayAndShip {
         ListPaymentMode = PaymentModeManage.GetPaymentModes()
     };
     int modeId = Globals.SafeInt(base.Request.Params["payId"], 0);
     int num2 = Globals.SafeInt(base.Request.QueryString["shipId"], 0);
     if (modeId > 0)
     {
         model.CurrentPaymentMode = PaymentModeManage.GetPaymentModeById(modeId);
         model.ListShippingType = this._shippingTypeManage.GetListByPay(modeId);
     }
     else if ((model.ListPaymentMode != null) && (model.ListPaymentMode.Count > 0))
     {
         model.CurrentPaymentMode = model.ListPaymentMode[0];
         model.ListShippingType = this._shippingTypeManage.GetListByPay(model.CurrentPaymentMode.ModeId);
     }
     else
     {
         PaymentModeInfo info = new PaymentModeInfo {
             ModeId = -1,
             Name = "当前网站未设置任何支付方式"
         };
         model.CurrentPaymentMode = info;
         model.ListPaymentMode = new List<PaymentModeInfo> { model.CurrentPaymentMode };
     }
     if (num2 > 0)
     {
         model.CurrentShippingType = this._shippingTypeManage.GetModelByCache(num2);
     }
     else if ((model.ListShippingType != null) && (model.ListShippingType.Count > 0))
     {
         model.CurrentShippingType = model.ListShippingType[0];
     }
     else
     {
         Maticsoft.Model.Shop.Shipping.ShippingType type = new Maticsoft.Model.Shop.Shipping.ShippingType {
             ModeId = -1,
             Name = "当前支付方式未设置任何配送",
             Description = "请选择其它支付方式"
         };
         model.CurrentShippingType = type;
         model.ListShippingType = new List<Maticsoft.Model.Shop.Shipping.ShippingType> { model.CurrentShippingType };
     }
     ((dynamic) base.ViewBag).PayId = modeId;
     ((dynamic) base.ViewBag).ShipId = num2;
     return base.View(viewName, model);
 }