点击按钮触发事件调用存储过程5
USE [GSHRBasicDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[HR_CardID_GS_Mifare_Add]
@EmpID NVARCHAR(50),
@EmpCardID NVARCHAR(50),
@EmpSerialNo NVARCHAR(50),
@CUser NVARCHAR(50),
@ReturnStatus NVARCHAR(5) OUTPUT,
@ReturnID NVARCHAR(10) OUTPUT,
@ReturnMsg NVARCHAR(100) OUTPUT
AS
BEGIN
DECLARE @DayID NVARCHAR(10)
DECLARE @EmpName NVARCHAR(50)
-----------初始化-------------------------------------------
SET @ReturnStatus='0'
SET @ReturnID='E004000'
SET @ReturnMsg='新增Mifare卡号资料未执行!'
---------------------------------------------------------------
SET @DayID=convert(nvarchar(10),getdate(),111)
SET @EmpName=' '
IF(@EmpID is null or @EmpID=' ')
BEGIN
SET @ReturnStatus='0'
SET @RetunID='E004001'
SET @ReturnMsg='工号不可为空!'
RETURN
END
IF EXISTS(SELECT EmpSeriaNo From HR_Card_GS_Mifare WHERE EmpSerialNo=@EmpSerialNo)
BEGIN
SET @ReturnStatus='0'
SET @ReturnID='E004002'
SET @ReturnMsg='該卡片序列號已存在,不可製卡!'
RETURN
END
SELECT @EmpName=EmpName FROM HR_Emp_Now WHERE EmpID=@EmpID
BEGIN TRY
BEGIN TRAN
INSERT INTO HR_CardID_GS_Mifare(DayID,EmpCardID,EmpID,EmpName,EmpSerialNo,CUser)
VALUES(@DayID,@EmpCardID,@EmpID,@EmpName,@EmpSerialNo,@CUser)
NSERT INTO HR_CardID_GS_EmpCardID(EmpCardID,EmpID,EmpName,CUser)
SELECT EmpCardID,EmpID,EmpName,CUser FROM HR_CardID_GS_Mifare WHERE EmpID=@EmpID
INSERT INTO HR_CardID_GS_EmpCardID(EmpCardID,EmpID,EmpName,CUser)
SELECT EmpSerialNo,EmpID,EmpName,CUser FROM HR_CardID_GS_Mifare WHERE EmpID=@EmpID
COMMIT TRAN
END TRY
BEGIN CATCH
SET @ReturnStatus='0'
SET @ReturnID='E004004'
SET @ReturnMsg='Mifare卡號資料新增失敗!'
ROLLBACK TRAN
RETURN
END CATCH
SET @ReturnStatus='1'
SET @ReturnID='M004001'
SET @ReturnMsg='Mifare卡號資料新增成功!'
END