带输出参数的存储过程的定义,以及在aso.net中调用

ALTER proc [dbo].[mp_w_RechargePortalPayPal_All]

(

@PayPalOrderNo nvarchar(50), --订单号

@nAccountIDFrom int, --充值帐号

@nAccountIDTo int, --充入帐号

@cTotalMoney numeric(18,2), --总价        用户所在货币总价

@nMoneyType int, --货币类型    用户所在货币类型    -- 非system货币

@nToGameID int, --充入游戏

@nToGameAreaID int, --充入游戏区域

@nToGameServerID int, --冲入游戏服务器

@GameRoleName nvarchar(50) ,
--冲入游戏角色名

@nVMoney int, --平台币(总)

@nGamePoint int, --游戏币(总)

@AccountIP nvarchar(50), --充值IP

@AccountName nvarchar(150), --姓名

@AccountEmail nvarchar(150), --邮件

@AccountTel nvarchar(50), --电话

@PayType int, --支付方式

@BuyType int, --购买方式

@rv int out, -- >0成功 -1帐号不存在 -2帐号被封或冻结

@rOrderNo nvarchar(50) out,

@rBalanceMoney numeric(18,2) out

)

as

declare @rate decimal(18,6) --汇率

declare @LocalMoneyType int --系统的当地货币类型

declare @orderID int --订单ID

declare @LocalMoneyPrice numeric(18,2) --系统的当地货币

declare @sAccountFrom nvarchar(150) --充值帐户

declare @sAccountTo nvarchar(150) --充入帐户

declare @orderNO nvarchar(50) --订单号

declare @SKUID nvarchar(58) --SKUID

set @rOrderNo=‘‘;

set @rBalanceMoney=0;

--判断帐号是否存在

if not exists (select 1 from w_MainAccountInfo where [email protected])

begin

set @rv=-1

return

end

--判断账号的状态是否正常

if not exists(select 1 from w_MainAccountInfo ma left join w_MainAccountDetailInfo da on ma.NAccountID=da.NAccountID where ma.naccountID [email protected] and da.coldtime<getdate() and ma.status=1)

begin

set @rv=-2

end

--判断订单号是否存在,存在则重新生成

if exists (select 1 from w_OnlinePayOrderInfo where [email protected])

begin

set @PayPalOrderNo=dbo.f_generateOrderNO(@BuyType,@nToGameID,newid())

end

--查询账户信息

select @sAccountFrom=sAccount from w_MainAccountInfo where [email protected]

select @sAccountTo=sAccount from w_MainAccountInfo where [email protected]

--写入订单表

set @orderNO = @PayPalOrderNo -- 订单号为卡号  -- dbo.f_generateOrderNO(1,@cardCountry,newid())

--查询汇率,将金额兑换为美元

if @nMoneyType <> 99

begin

select top 1 @rate = moneyprice/balanceMoneyPrice,@LocalMoneyType=balanceMoneyType from w_OnlinePayExchangeRate where moneyType = @nMoneyType order by AddDate desc

set @LocalMoneyPrice = @cTotalMoney / @rate

end

else

begin

set @rate=1

set @LocalMoneyPrice =
@cTotalMoney

set @LocalMoneyType=
@nMoneyType

end

--查询赠送点数

declare @GiftPoints int

declare @RealnGamePoint int

if(@nToGameID>0)

begin

--exec mp_w_RechargeGiftPoints @orderNO,@nToGameID,@PayType,@nGamePoint,@NaccountIDTo,@GiftPoints output

--declare @INGameServerName nvarchar(10)

--if(@nToGameID=3 or @nToGameID=12 or @nToGameID=18 or @nToGameID=19)

--begin

-- set @INGameServerName = ‘S‘+CONVERT(nvarchar(10),@GiftServerID)

--end

--exec mp_w_RechargeServerGiftPoints @orderNO,@nToGameID,@PayType,@nGamePoint,@nAccountIDTo,@INGameServerName,@GiftPoints output

exec mp_w_RechargeServerGiftPoints @orderNO,@nToGameID,@PayType,@nGamePoint,@nAccountIDTo,@nToGameServerID,@GiftPoints output

end

else if(@nToGameID=0)

begin

set @GiftPoints=0

end

--手工兑换上线后,调用存储过程需删除

--exec mp_w_RechargeGiftPoints @orderNO,@nToGameID,@PayType,@nGamePoint,@NaccountIDTo,@GiftPoints output

set @[email protected]+@GiftPoints

--插入订单表 OrderState为0

insert into w_OnlinePayOrderInfo(NaccountID,sAccount,OrderNo,MoneyPrice,MoneyType,OrderState

,BuyVMoneyNum,BuyGamePointNum,balanceMoneyPrice,balanceMoneyType,balanceRate,balancePoundage

,AddDate,PayDate,PayType,nAccountID_To,sAccount_To,UserHostIP

,SendVMoneyDate,GameID,MoneyOldPrice,RechargeArea,UserName,UserEmail

,UserTel,RechargeServerID)

values (@NaccountIDFrom,@sAccountFrom,@orderNO,@LocalMoneyPrice,@LocalMoneyType,0

,@nVMoney,@RealnGamePoint,@cTotalMoney,@nMoneyType,@rate,0

,getdate(),0,@PayType,@NaccountIDTo,@sAccountTo,@AccountIP

,0,@nToGameID,0,@nToGameAreaID,@AccountName,@AccountEmail

,@AccountTel,@nToGameServerID)

select @[email protected]@identity

if(LEN( @AccountName)>58)

SET @SKUID=substring( @AccountName,1,56)

else

SET @[email protected]

insert into w_OnlinePayOrderDetailInfo(OrderID,ItemNum,cVmoneyNum,cMoneyPrice,cMoneyType,cGamePointNum) values (@orderID,1,@nVMoney,@cTotalMoney,@nMoneyType,@nGamePoint)

insert into w_OnlinePayBuyerInfo(OrderID,INGameRoleName,INGameServerName,SKUID) values (@orderID,@GameRoleName,@nToGameServerID,@SKUID)

set @[email protected]

set @[email protected]

set @[email protected]

--记录赠送日志

if(@GiftPoints > 0)

begin

update w_OnlinepayGiftPointsHistory set [email protected],[email protected],

[email protected],rechargedate=getdate() where [email protected]

end

----订单日志

--insert into w_OnlinePayOrderLog(info) values (‘PayPal_All订单:‘ + @orderNO + ‘生成成功‘)

/// <param name="storedProcName">存储过程名</param>

/// <param name="parameters">存储过程参数</param>

/// <param name="rowsAffected">影响的行数</param>

/// <returns></returns>

public static int RunProcedure(string storedProcName, int DataBaseType, IDataParameter[] parameters, out int rowsAffected)

{

using (SqlConnection connection = new SqlConnection(GetDBGameConnstring(DataBaseType)))

{

int result;

connection.Open();

SqlCommand command = BuildIntCommand(connection, storedProcName, parameters);

command.CommandTimeout = 60;

rowsAffected = command.ExecuteNonQuery();

result = (int)command.Parameters["ReturnValue"].Value;

//Connection.Close();

return result;

}

}

public static void OnlineRechargePayPalAll(string OrderNo, int AccountIDFrom, int AccountIDTo, string TotalMoney, int PriceType, int GameID, int GameArea, int AreaServerID, string sGameRoleName, int vMoney, int GamePoint, string IP, string Name, string
Email, string Tel, int PayType, int BuyType, out int ErrorCode, out string ReturnOrderNo, out string BalanceMoney)

{

int iRows = 0;

SqlParameter[] parsRechargePayPal = {

new SqlParameter("@PayPalOrderNo", SqlDbType.NVarChar,50),

new SqlParameter("@nAccountIDFrom", SqlDbType.Int),

new SqlParameter("@nAccountIDTo", SqlDbType.Int),

new SqlParameter("@cTotalMoney", SqlDbType.Decimal),

new SqlParameter("@nMoneyType",SqlDbType.Int),

new SqlParameter("@nToGameID",SqlDbType.Int),

new SqlParameter("@nToGameAreaID",SqlDbType.Int),

new SqlParameter("@nToGameServerID",SqlDbType.Int),

new SqlParameter("@GameRoleName",SqlDbType.NVarChar,50),

new SqlParameter("@nVMoney",SqlDbType.Int),

new SqlParameter("@nGamePoint",SqlDbType.Int),

new SqlParameter("@AccountIP",SqlDbType.NVarChar,50),

new SqlParameter("@AccountName",SqlDbType.NVarChar,150),

new SqlParameter("@AccountEmail",SqlDbType.NVarChar,150),

new SqlParameter("@AccountTel",SqlDbType.NVarChar,50),

new SqlParameter("@PayType",SqlDbType.Int),

new SqlParameter("@BuyType",SqlDbType.Int),

new SqlParameter("@rv",SqlDbType.Int),

new SqlParameter("@rOrderNo",SqlDbType.NVarChar,50),

new SqlParameter("@rBalanceMoney",SqlDbType.Decimal)};

parsRechargePayPal[0].Value = OrderNo;

parsRechargePayPal[1].Value = AccountIDFrom;

parsRechargePayPal[2].Value = AccountIDTo;

parsRechargePayPal[3].Value = TotalMoney;

parsRechargePayPal[4].Value = PriceType;

parsRechargePayPal[5].Value = GameID;

parsRechargePayPal[6].Value = GameArea;

parsRechargePayPal[7].Value = AreaServerID;

parsRechargePayPal[8].Value = sGameRoleName;

parsRechargePayPal[9].Value = vMoney;

parsRechargePayPal[10].Value = GamePoint;

parsRechargePayPal[11].Value = IP;

parsRechargePayPal[12].Value = Name;

parsRechargePayPal[13].Value = Email;

parsRechargePayPal[14].Value = Tel;

parsRechargePayPal[15].Value = PayType;

parsRechargePayPal[16].Value = BuyType;

parsRechargePayPal[17].Direction = ParameterDirection.Output;

parsRechargePayPal[17].Value = 0;

parsRechargePayPal[18].Direction = ParameterDirection.Output;

parsRechargePayPal[18].Value = "";

parsRechargePayPal[19].Direction = ParameterDirection.Output;

parsRechargePayPal[19].Value = "0.0";

parsRechargePayPal[19].Precision = 10;

parsRechargePayPal[19].Scale = 2;

DbHelperSQL.RunProcedure("mp_w_RechargePortalPayPal_All", parsRechargePayPal, out iRows);

ErrorCode = CmnProc.getInt(parsRechargePayPal[17].Value);

ReturnOrderNo = CmnProc.getString(parsRechargePayPal[18].Value);

BalanceMoney = CmnProc.getString(parsRechargePayPal[19].Value);

}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-11 00:33:17

带输出参数的存储过程的定义,以及在aso.net中调用的相关文章

sybase带输出参数的存储过程实例

使用return返回 --create pro USE yfb go create proc cwqi_test_pro(  @newName varchar(20) out,  @oldName varchar(20) in  ) as begin   set @[email protected]   return 1 end --run pro DECLARE @newName varchar(20) DECLARE @oldName varchar(20) DECLARE @result 

创建带输出参数的存储过程

语法: create proc 存储过程名 @参数1 数据类型=默认值 output, @参数2 数据类型=默认值 output as sql语句 go 例子: 1 --创建带输入输出参数的存储过程 2 /* 3 题目要求 4 向母婴用品这个类添加一种商品,要求成功后把商品的编号输出 5 */ 6 7 use E_Market 8 go 9 10 if exists(select * from sysobjects where name='usp_InsertCommodity') 11 dro

c#调用带输出参数的存储过程

sql server中编写一个存储过程: CREATE PROCEDURE ProGetPWD @username varchar(20), @password varchar(20) OUTPUT AS BEGIN SELECT @password = password FROM Users WHERE username = @username END -------------------------- 下面是.NET中调用存储过程的方法: string strConnection = "u

EF(ServerFirst)执行存储过程实例1(带输出参数)

1.不含动态sql.带输出参数存储过程调用实例 a.存储过程代码: b.EF自动生成代码(包括对应ObjectResult的实体模型): c.调用存储过程代码实例: 总结: ObjectParameter参数对应输出类型时,不必指定类似Output等 ObjectParameter的命名空间:using System.Data.Objects; ObjectParameter参数的Name是对应存储过程参数字符串去掉@符号,例如存储过程参数‘@Count int output‘,对应Name为”

创建有输出参数的存储过程并在c#中实现DataGridView分页功能

不足之处,欢迎指正! 创建有输出参数的存储过程 if exists(select * from sysobjects where name='usp_getPage1') drop procedure usp_getPage1 go create procedure usp_getPage1--存储过程名称 @count int output,--输出参数 @countIndex int=1,--参数带默认值 @countPage int=5--参数带默认值 as --一个sql语句.ROW_N

JdbcTemplate执行带输入参数和输出参数的存储过程

直接上代码: /** * 执行返回一个输出参数,若干输入参数的存储过程 * 方法第一个参数为存储过程名称,第二个参数为存放输入参数的数组(按顺序存放),方法返回值为存储过程输出参数 */ public String execProcedureWithOutParam(final String procName,final String[] inParams){ String returnVal=(String)getJdbcTemplate().execute(new CallableState

C#调用Oracle带输出数据集的存储过程

1.创建一个带输出数据集的Oracle存储过程 create or replace procedure PRO_test(in_top in number,cur_out out sys_refcursor) is --查询指定记录条数的数据,并返回总共记录数,返回多个数据集begin open cur_out for SELECT * FROM dept_dict where rownum < in_top;end PRO_test; 2.C#调用 Pu_Sys.GetConnObject c

带输出參数的存储过程的定义,以及在aso.net中调用

ALTER proc [dbo].[mp_w_RechargePortalPayPal_All] ( @PayPalOrderNo nvarchar(50), --订单号 @nAccountIDFrom int, --充值帐号 @nAccountIDTo int, --充入帐号 @cTotalMoney numeric(18,2), --总价        用户所在货币总价 @nMoneyType int, --货币类型    用户所在货币类型    -- 非system货币 @nToGameI

SQL SERVER 存储过程执行带输出参数的SQL语句拼接

注意:定义的要执行的SQL语句必须是nvarchar类型 CREATE PROC P_BranchOrderSalesStatistics @beginTime DateTime, --开始时间 @endTime DateTime, --结束时间 @branchCode varchar(20), --门店编码 @NewMemberCount int out, -- 新会员数量 @OrderCount int out, --订单数量 @SalesTotalPrice decimal(18,2) o