Beispiel #1
0
        public PaymentModeActionStatus CreateUpdateDeletePaymentMode(PaymentModeInfo paymentMode, DataProviderAction action)
        {
            if (paymentMode == null)
            {
                return(PaymentModeActionStatus.UnknowError);
            }

            PaymentModeActionStatus status = PaymentModeActionStatus.UnknowError;

            switch (action)
            {
            case DataProviderAction.Create:
                status = CreatePaymentMode(paymentMode);
                break;

            case DataProviderAction.Update:
                status = UpdatePaymentMode(paymentMode);
                break;

            case DataProviderAction.Delete:
                status = DeletePaymentMode(paymentMode);
                break;

            default:
                break;
            }
            return(status);
        }
Beispiel #2
0
        public static bool DeletePaymentMode(int modeId)
        {
            PaymentModeActionStatus unknowError = PaymentModeActionStatus.UnknowError;
            PaymentModeInfo         paymentMode = new PaymentModeInfo
            {
                ModeId = modeId
            };

            unknowError = service.CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Delete);
            return(unknowError == PaymentModeActionStatus.Success);
        }
Beispiel #3
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            string     gateway;
            ConfigData configData;
            decimal    charge;

            if (!this.ValidateValues(out gateway, out configData, out charge))
            {
                return;
            }
            PaymentModeInfo paymentMode = new PaymentModeInfo
            {
                Name            = this.txtName.Text,
                Description     = this.fcContent.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", ""),
                Gateway         = gateway,
                IsUseInpour     = this.radiIsUseInpour.SelectedValue,
                Charge          = charge,
                IsPercent       = this.chkIsPercent.Checked,
                ApplicationType = PayApplicationType.payOnPC,
                Settings        = this.txtName.Text == "微信扫码支付" ? "1hSUSkKQ/ENo0JDZah8KKQweixin" : HiCryptographer.Encrypt(configData.SettingsXml)
            };
            PaymentModeActionStatus paymentModeActionStatus = SalesHelper.CreatePaymentMode(paymentMode);

            if (paymentModeActionStatus == PaymentModeActionStatus.Success)
            {
                base.Response.Redirect(Globals.GetAdminAbsolutePath("sales/PaymentTypes.aspx"));
                return;
            }
            if (paymentModeActionStatus == PaymentModeActionStatus.DuplicateGateway)
            {
                this.ShowMsg("已经添加了一个相同类型的支付接口", false);
                return;
            }
            if (paymentModeActionStatus == PaymentModeActionStatus.DuplicateName)
            {
                this.ShowMsg("已经存在一个相同的支付方式名称", false);
                return;
            }
            if (paymentModeActionStatus == PaymentModeActionStatus.OutofNumber)
            {
                this.ShowMsg("支付方式的数目已经超出系统设置的数目", false);
                return;
            }
            this.ShowMsg("未知错误", false);
        }
Beispiel #4
0
        private void btnUpdate_Click(object sender, System.EventArgs e)
        {
            string     gateway;
            ConfigData configData;
            decimal    charge;

            if (!this.ValidateValues(out gateway, out configData, out charge))
            {
                return;
            }
            PaymentModeInfo paymentMode = new PaymentModeInfo
            {
                ModeId             = this.modeId,
                Name               = this.txtName.Text.Trim(),
                Description        = this.fcContent.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", ""),
                Gateway            = gateway,
                IsUseInpour        = this.radiIsUseInpour.SelectedValue,
                IsUseInDistributor = this.radiIsUseInDistributor.SelectedValue,
                Charge             = charge,
                IsPercent          = this.chkIsPercent.Checked,
                Settings           = HiCryptographer.Encrypt(configData.SettingsXml)
            };
            PaymentModeActionStatus paymentModeActionStatus = SalesHelper.UpdatePaymentMode(paymentMode);

            if (paymentModeActionStatus == PaymentModeActionStatus.Success)
            {
                base.Response.Redirect(Globals.GetAdminAbsolutePath("sales/PaymentTypes.aspx"));
                return;
            }
            if (paymentModeActionStatus == PaymentModeActionStatus.DuplicateName)
            {
                this.ShowMsg("已经存在一个相同的支付方式名称", false);
                return;
            }
            if (paymentModeActionStatus == PaymentModeActionStatus.OutofNumber)
            {
                this.ShowMsg("支付方式的数目已经超出系统设置的数目", false);
                return;
            }
            if (paymentModeActionStatus == PaymentModeActionStatus.UnknowError)
            {
                this.ShowMsg("未知错误", false);
            }
        }
Beispiel #5
0
        public PaymentModeActionStatus CreateUpdateDeletePaymentMode(PaymentModeInfo paymentMode, DataProviderAction action)
        {
            PaymentModeActionStatus result;

            if (null == paymentMode)
            {
                result = PaymentModeActionStatus.UnknowError;
            }
            else
            {
                System.Data.Common.DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_PaymentType_CreateUpdateDelete");
                this.database.AddInParameter(storedProcCommand, "Action", System.Data.DbType.Int32, (int)action);
                this.database.AddOutParameter(storedProcCommand, "Status", System.Data.DbType.Int32, 4);
                if (action == DataProviderAction.Create)
                {
                    this.database.AddOutParameter(storedProcCommand, "ModeId", System.Data.DbType.Int32, 4);
                }
                else
                {
                    this.database.AddInParameter(storedProcCommand, "ModeId", System.Data.DbType.Int32, paymentMode.ModeId);
                }
                if (action != DataProviderAction.Delete)
                {
                    this.database.AddInParameter(storedProcCommand, "Name", System.Data.DbType.String, paymentMode.Name);
                    this.database.AddInParameter(storedProcCommand, "Description", System.Data.DbType.String, paymentMode.Description);
                    this.database.AddInParameter(storedProcCommand, "Gateway", System.Data.DbType.String, paymentMode.Gateway);
                    this.database.AddInParameter(storedProcCommand, "IsUseInpour", System.Data.DbType.Boolean, paymentMode.IsUseInpour);
                    this.database.AddInParameter(storedProcCommand, "IsUseInDistributor", System.Data.DbType.Boolean, paymentMode.IsUseInDistributor);
                    this.database.AddInParameter(storedProcCommand, "Charge", System.Data.DbType.Currency, paymentMode.Charge);
                    this.database.AddInParameter(storedProcCommand, "IsPercent", System.Data.DbType.Boolean, paymentMode.IsPercent);
                    this.database.AddInParameter(storedProcCommand, "Settings", System.Data.DbType.String, paymentMode.Settings);
                }
                this.database.ExecuteNonQuery(storedProcCommand);
                PaymentModeActionStatus paymentModeActionStatus = (PaymentModeActionStatus)((int)this.database.GetParameterValue(storedProcCommand, "Status"));
                result = paymentModeActionStatus;
            }
            return(result);
        }
Beispiel #6
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);
                this.database.AddInParameter(storedProcCommand, "DrivePath", DbType.String, paymentMode.DrivePath);
                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")));
        }
Beispiel #7
0
        private PaymentModeActionStatus UpdatePaymentMode(PaymentModeInfo paymentMode)
        {
            PaymentModeActionStatus status = PaymentModeActionStatus.UnknowError;

            //连接MySql数据库
            using (MySqlConnection connection = DbHelperMySQL.GetConnection)
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }
                using (MySqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        string           strSql = string.Format("Select DisplaySequence  From Pay_PaymentTypes where ModeId={0}", paymentMode.ModeId);
                        MySqlParameter[] pars   = { };
                        object           objSeq = DbHelperMySQL.GetSingle4Trans(new CommandInfo(strSql, pars), transaction);
                        int displaySequence     = Common.Globals.SafeInt(objSeq, -1);
                        if (displaySequence != paymentMode.DisplaySequence)
                        {
                            List <CommandInfo> sqllist = new List <CommandInfo>();
                            StringBuilder      strSql1 = new StringBuilder();
                            strSql1.AppendFormat("UPDATE Pay_PaymentTypes set DisplaySequence = DisplaySequence + 1 where DisplaySequence >= {0} ;", paymentMode.DisplaySequence);
                            MySqlParameter[] parameters1 = { };
                            sqllist.Add(new CommandInfo(strSql1.ToString(), parameters1, EffentNextType.ExcuteEffectRows));
                            DbHelperMySQL.ExecuteSqlTran4Indentity(sqllist, transaction);
                        }

                        List <CommandInfo> sqllist2 = new List <CommandInfo>();
                        string             str2     = @"UPDATE Pay_PaymentTypes SET MerchantCode=?MerchantCode, EmailAddress=?EmailAddress, SecretKey=?SecretKey, SecondKey=?SecondKey, Password=?Password,Partner=?Partner, Name=?Name, Description=?Description, Gateway=?Gateway, DisplaySequence=?DisplaySequence, Charge=?Charge, IsPercent=?IsPercent, AllowRecharge=?AllowRecharge,Logo=?Logo,DrivePath=?DrivePath WHERE ModeId = ?ModeId;";
                        MySqlParameter[]   pars2    =
                        {
                            new MySqlParameter("?MerchantCode",    MySqlDbType.VarChar,  300),
                            new MySqlParameter("?EmailAddress",    MySqlDbType.VarChar,  255),
                            new MySqlParameter("?SecretKey",       MySqlDbType.VarChar, 4000),
                            new MySqlParameter("?SecondKey",       MySqlDbType.VarChar, 4000),
                            new MySqlParameter("?Password",        MySqlDbType.VarChar, 4000),
                            new MySqlParameter("?Partner",         MySqlDbType.VarChar,  300),
                            new MySqlParameter("?Name",            MySqlDbType.VarChar,  100),
                            new MySqlParameter("?Description",     MySqlDbType.Text),
                            new MySqlParameter("?Gateway",         MySqlDbType.VarChar,  200),
                            new MySqlParameter("?DisplaySequence", MySqlDbType.Int32,      4),
                            new MySqlParameter("?Charge",          MySqlDbType.Decimal,    8),
                            new MySqlParameter("?IsPercent",       MySqlDbType.Int16,      2),
                            new MySqlParameter("?AllowRecharge",   MySqlDbType.Int16,      2),
                            new MySqlParameter("?Logo",            MySqlDbType.VarChar,  255),
                            new MySqlParameter("?DrivePath",       MySqlDbType.VarChar,  255),
                            new MySqlParameter("?ModeId",          MySqlDbType.Int32, 4)
                        };
                        pars2[0].Value  = paymentMode.MerchantCode;
                        pars2[1].Value  = paymentMode.EmailAddress;
                        pars2[2].Value  = paymentMode.SecretKey;
                        pars2[3].Value  = paymentMode.SecondKey;
                        pars2[4].Value  = paymentMode.Password;
                        pars2[5].Value  = paymentMode.Partner;
                        pars2[6].Value  = paymentMode.Name;
                        pars2[7].Value  = paymentMode.Description;
                        pars2[8].Value  = paymentMode.Gateway;
                        pars2[9].Value  = paymentMode.DisplaySequence;
                        pars2[10].Value = paymentMode.Charge;
                        pars2[11].Value = paymentMode.IsPercent;
                        pars2[12].Value = paymentMode.AllowRecharge;
                        pars2[13].Value = paymentMode.Logo;
                        pars2[14].Value = paymentMode.DrivePath;
                        pars2[15].Value = paymentMode.ModeId;
                        sqllist2.Add(new CommandInfo(str2, pars2, EffentNextType.ExcuteEffectRows));

                        string strDel = string.Format("DELETE  From  Pay_PaymentCurrencys Where ModeId={0}", paymentMode.ModeId);
                        sqllist2.Add(new CommandInfo(strDel, pars2, EffentNextType.None));

                        DbHelperMySQL.ExecuteSqlTran4Indentity(sqllist2, transaction);

                        List <CommandInfo> sqllist3 = new List <CommandInfo>();
                        StringBuilder      strSql3  = new StringBuilder();
                        int num = 0;
                        foreach (string str in paymentMode.SupportedCurrencys)
                        {
                            strSql3.AppendFormat("INSERT INTO Pay_PaymentCurrencys(ModeId,Code) Values({0},'{1}');", paymentMode.ModeId, str);
                            num++;
                        }
                        if (strSql3.Length > 0)
                        {
                            MySqlParameter[] parameters3 = { };
                            sqllist3.Add(new CommandInfo(strSql3.ToString(), parameters3, EffentNextType.ExcuteEffectRows));
                            DbHelperMySQL.ExecuteSqlTran4Indentity(sqllist3, transaction);
                        }

                        transaction.Commit();
                        status = PaymentModeActionStatus.Success;
                    }
                    catch (MySqlException)
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }
            return(status);
        }
Beispiel #8
0
        private PaymentModeActionStatus CreatePaymentMode(PaymentModeInfo paymentMode)
        {
            PaymentModeActionStatus status = PaymentModeActionStatus.UnknowError;

            //连接MySql数据库
            using (SqlConnection connection = DBHelper.DefaultDBHelper.GetDBObject().GetConnection)
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }
                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        //List<CommandInfo> sqllist = new List<CommandInfo>();
                        //StringBuilder strSql1 = new StringBuilder();
                        //strSql1.AppendFormat("UPDATE Pay_PaymentTypes set DisplaySequence = DisplaySequence + 1 where DisplaySequence >= {0} ;", paymentMode.DisplaySequence);
                        //SqlParameter[] parameters1 = { };
                        //sqllist.Add(new CommandInfo(strSql1.ToString(), parameters1, EffentNextType.ExcuteEffectRows));
                        //DBHelper.DefaultDBHelper.ExecuteSqlTran4Indentity(sqllist, transaction);

                        string str2 = @"INSERT INTO 
			                            Pay_PaymentTypes(MerchantCode, EmailAddress, SecretKey, SecondKey, Password,Partner, Name, Description, Gateway, DisplaySequence, Charge, IsPercent, AllowRecharge,Logo,DrivePath) VALUES (@MerchantCode, @EmailAddress, @SecretKey, @SecondKey, @Password,@Partner, @Name, @Description, @Gateway, @DisplaySequence, @Charge, @IsPercent, @AllowRecharge,@Logo,@DrivePath);
		                             select @@IDENTITY;"        ;

                        SqlParameter[] pars2 =
                        {
                            new SqlParameter("@MerchantCode",    SqlDbType.NVarChar,  300),
                            new SqlParameter("@EmailAddress",    SqlDbType.NVarChar,  255),
                            new SqlParameter("@SecretKey",       SqlDbType.NVarChar, 4000),
                            new SqlParameter("@SecondKey",       SqlDbType.NVarChar, 4000),
                            new SqlParameter("@Password",        SqlDbType.NVarChar, 4000),
                            new SqlParameter("@Partner",         SqlDbType.NVarChar,  300),
                            new SqlParameter("@Name",            SqlDbType.NVarChar,  100),
                            new SqlParameter("@Description",     SqlDbType.Text),
                            new SqlParameter("@Gateway",         SqlDbType.NVarChar,  200),
                            new SqlParameter("@DisplaySequence", SqlDbType.Int,         4),
                            new SqlParameter("@Charge",          SqlDbType.Money,       8),
                            new SqlParameter("@IsPercent",       SqlDbType.BigInt,      8),
                            new SqlParameter("@AllowRecharge",   SqlDbType.BigInt,      8),
                            new SqlParameter("@Logo",            SqlDbType.NVarChar,  255),
                            new SqlParameter("@DrivePath",       SqlDbType.NVarChar, 255)
                        };
                        pars2[0].Value  = paymentMode.MerchantCode;
                        pars2[1].Value  = paymentMode.EmailAddress;
                        pars2[2].Value  = paymentMode.SecretKey;
                        pars2[3].Value  = paymentMode.SecondKey;
                        pars2[4].Value  = paymentMode.Password;
                        pars2[5].Value  = paymentMode.Partner;
                        pars2[6].Value  = paymentMode.Name;
                        pars2[7].Value  = paymentMode.Description;
                        pars2[8].Value  = paymentMode.Gateway;
                        pars2[9].Value  = paymentMode.DisplaySequence;
                        pars2[10].Value = paymentMode.Charge;
                        pars2[11].Value = paymentMode.IsPercent;
                        pars2[12].Value = paymentMode.AllowRecharge;
                        pars2[13].Value = paymentMode.Logo;
                        pars2[14].Value = paymentMode.DrivePath;
                        object objId = DBHelper.DefaultDBHelper.GetSingle4Trans(new CommandInfo(str2, pars2), transaction);

                        int modeId = Common.Globals.SafeInt(objId, 0);
                        List <CommandInfo> sqllist2 = new List <CommandInfo>();
                        StringBuilder      strSql2  = new StringBuilder();
                        int num = 0;
                        foreach (string str in paymentMode.SupportedCurrencys)
                        {
                            strSql2.AppendFormat("INSERT INTO Pay_PaymentCurrencys(ModeId,Code) Values({0},'{1}');", modeId, str);
                            num++;
                        }
                        if (strSql2.Length > 0)
                        {
                            SqlParameter[] parameters2 = { };
                            sqllist2.Add(new CommandInfo(strSql2.ToString(), parameters2, EffentNextType.ExcuteEffectRows));
                            DBHelper.DefaultDBHelper.ExecuteSqlTran4Indentity(sqllist2, transaction);
                        }

                        transaction.Commit();
                        if (modeId > 0)
                        {
                            status = PaymentModeActionStatus.Success;
                        }
                    }
                    catch (SqlException)
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }
            return(status);
        }