The definition of a stored procedure with output parameters, and the call in Aso.net

Source: Internet
Author: User

ALTER proc [dbo]. [Mp_w_rechargeportalpaypal_all]
(
@PayPalOrderNo nvarchar (50), --Order Number
@nAccountIDFrom int, --Recharge Account
@nAccountIDTo int, --fill in the account number
@cTotalMoney Numeric (18,2), --Total price of the user's currency
@nMoneyType int, --Currency type user's currency type--Non-system currency
@nToGameID int, --filling in the game
@nToGameAreaID int, --fill in the game area
@nToGameServerID int, --rushed into the game server
@GameRoleName nvarchar (50) ,--punch into the game role name


@nVMoney int, --Platform currency (total)
@nGamePoint int, --Game currency (total)
@AccountIP nvarchar (50), --Recharge IP
@AccountName nvarchar (150), --Name
@AccountEmail nvarchar (150), --Mail
@AccountTel nvarchar (50), --Telephone
@PayType int, --Payment method
@BuyType int, --How to buy


@rv int out, -->0 Success-1 account does not exist-2 account is blocked or blocked
@rOrderNo nvarchar () out,
@rBalanceMoney Numeric (18,2) out
)
As


DECLARE @rate decimal (18,6) --exchange rate
DECLARE @LocalMoneyType int --The local currency type of the system
DECLARE @orderID int --Order ID
Declare @LocalMoneyPrice numeric (18,2) --local currency of the system
declare @sAccountFrom nvarchar (150) --Recharge Account
declare @sAccountTo nvarchar (150) --Fill in account
declare @orderNO nvarchar (50) --Order Number
declare @SKUID nvarchar (58) --skuid
Set @rOrderNo = ';
Set @rBalanceMoney = 0;




--Infer if the account exists
If not exists (select 1 from w_mainaccountinfo where [email protected])
Begin
Set @rv =-1
Return
End
--Infer if the status of the account is normal
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
--Infer if the order number exists and is generated again
if exists (select 1 from w_onlinepayorderinfo where [email protected])
Begin
Set @PayPalOrderNo =dbo.f_generateorderno (@BuyType, @nToGameID, newid ())
End


--Query account information
Select @sAccountFrom =saccount from w_mainaccountinfo where [email protected]
Select @sAccountTo =saccount from w_mainaccountinfo where [email protected]




--Write order Form
Set @orderNO = @PayPalOrderNo--order number is card number--Dbo.f_generateorderno (1, @cardCountry, newid ())


--Query the exchange rate. Convert the amount to USD
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


--Query Gift points
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 (ten), @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


--After the manual exchange on the line. Calling a stored procedure needs to be deleted
--exec mp_w_rechargegiftpoints @orderNO, @nToGameID, @PayType, @nGamePoint, @NaccountIDTo, @GiftPoints output


Set @[email Protected][email protected]


--Insert order form Orderstate to 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]


--Record Gift log
if (@GiftPoints > 0)
Begin


Update w_onlinepaygiftpointshistory Set [email protected],[email protected],
[Email Protected],rechargedate=getdate () where [email protected]


End


----Order Journal

--insert into W_onlinepayorderlog (info) VALUES (' Paypal_all order: ' + @orderNO + ' build succeeded ')



<param name= "storedprocname" > Stored procedure name </param>
<param name= "Parameters" > Stored procedure parameters </param>
<param name= "rowsaffected" > Number of rows affected </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 pric EType, 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);
}

















The definition of a stored procedure with output parameters, and the call in Aso.net

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.