IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_up_employee_cucuse]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_up_employee_cucuse]
GO
create proc [dbo].[mps_up_employee_cucuse]
@cuuse int,
@cuid int
as
begin
set nocount on
update mps_employee set cu_use = @cuuse where cu_id = @cuid
if(@cuuse=1)
begin
delete from mps_login where cu_id = @cuid and cu_objid = @cuid
end else
if (@cuuse = 0)
begin
insert into mps_login(cu_id,cu_objid,cu_account, cu_callname, cu_gender,cu_bcid,cu_branch,cu_dpid,  
cu_depart,  
cu_otid,  
cu_title,  
cu_function,  
cu_mobile,  
cu_otlevel,  
cu_managelevel,  
cu_professionlevel,
cu_pass,
cu_cmpid)
select cu_id,cu_id,
cu_account,  
cu_name,  
cu_gender,  
cu_bcid,  
cu_branch,  
cu_dpid,  
cu_depart,  
cu_otid,  
cu_title,  
cu_function,  
cu_mobile,  
cu_otlevel,  
cu_managelevel,  
cu_professionlevel,
'd41d8cd98f00b204e9800998ecf8427e',
cu_cmpid
from mps_employee  
    where cu_id=@cuid 
end
 
set nocount off
end