| 复制代码/****** Object:  Stored Procedure dbo.KING_ELECTION_PROC    Script Date: 6/6/2006 6:03:33 PM ******/
CREATE PROCEDURE [dbo].[KING_ELECTION_PROC]
@strAccountID    char(21),        -- Voted man's account
@strCharID    char(21),        --     Nick's vote
@byNation    tinyint,
@strCandidacyID    char(21),        --     Nick chosen people
@nRet        smallint OUTPUT
AS
DECLARE @nRow smallint
SELECT @nRow = Count(strAccountID) FROM KING_BALLOT_BOX WHERE  strAccountID = @strAccountID
IF @nRow > 0        -- Vote for one person
BEGIN
    SET @nRet = -3
    RETURN
END
DECLARE @Loyalty int
SELECT @Loyalty = Loyalty FROM USERDATA WHERE strUserID = @strCharID
IF @Loyalty < 1000
BEGIN
    SET @nRet = -3
    RETURN
END
INSERT INTO KING_BALLOT_BOX (strAccountID, strCharID, byNation, strCandidacyID )
    VALUES ( @strAccountID, @strCharID, @byNation, @strCandidacyID )
UPDATE KING_ELECTION_LIST SET nMoney = nMoney + 1 
WHERE  byType = 4 and strName = @strCandidacyID
SET @nRet =  1
RETURN
GO
 |