tarafından Admin C.tesi Tem. 17, 2010 1:48 am
- Kod:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[KING_ELECTION_PROC]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[KING_ELECTION_PROC]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[KING_ELECTION_PROC]
@strAccountID char(21),
@strCharID char(21),
@byNation tinyint,
@strCandidacyID char(21),
@nRet smallint OUTPUT
AS
DECLARE @VoteLevel tinyint
DECLARE @Level tinyint
SET @VoteLevel = 30
SELECT @Level = Level FROM USERDATA WHERE strUserID = @strCharID
IF @Level < @VoteLevel
BEGIN
SET @nRet = -4
RETURN
END
ELSE
BEGIN
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
ELSE
BEGIN
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
END
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
votelevel yerini istediginiz gibi ayarlayabilirsiniz.