Professional Documents
Culture Documents
Procedure
Procedure
[PSP_User_Select]**/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[PSP_User_Select]
@UserID int = 0
AS
IF @UserID=0
BEGIN
SELECT
[UserID],[Username],[Userpass],[Fullname],[Status],[Systemright],[Address],[Phone]
FROM [dbo.tblUser]
ORDER BY [Status]
END
ELSE
BEGIN
SELECT
[UserID],[Username],[Userpass],[Fullname],[Status],[Systemright],[Address],[Phone]
FROM [dbo.tblUser] WHERE UserID=@UserID
ORDER BY [Status]
END
GO
/**StoreProcedure [dbo].[PSP_User_InsertUpdate]**/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[PSP_User_InsertUpdate]
@UserID INT,
@Username VARCHAR(50),
@Userpass NVARCHAR(50),
@Fullname NVARCHAR(50),
@Status INT,
@Systemright INT,
@Address NVARCHAR(100),
@Phone NVARCHAR(20)
AS
IF EXISTS (SELECT 1 FROM dbo.tblUser WHERE UserID=@UserID)
BEGIN
UPDATE dbo.tblUser
SET
[Username]=@Username,[Userpass]=pwdencrypt(@Userpass),[Fullname]=@Fullname,[Stat
us]=@Status,[Systemright]=@Systemright,[Address]=@Address,[Phone]=@Phone
WHERE [UserID]=@UserID
END
ELSE
BEGIN
INSERT INTO dbo.tblUser(UserID, Username, Userpass, Fullname, [Status],
Systemright, [Address], Phone)
VALUES (@UserID, @Username, pwdencrypt(@Userpass), @Fullname, @Status,
@Systemright, @Address, @Phone)
END
GO