IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_myinfo_alter]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_myinfo_alter]
GO
create procedure [dbo].[mps_myinfo_alter]
@cu_gender int,
@cu_birth varchar(255),
@cu_qq varchar(255),
@cu_email varchar(255),
@cu_mobile varchar(255),
@cu_pass varchar(255),
@cu_address varchar(255),
@cu_icon int,
@cu_sign int,
@cu_cmpid int,
@cu_id int,
@cu_bcid int
as 
declare @error nvarchar(100)
begin

 set nocount on
  update mps_employee set  
 cu_cmpid=case when @cu_cmpid is null or @cu_cmpid = -999999999  then cu_cmpid else @cu_cmpid end,  
 cu_bcid=case when @cu_bcid is null or @cu_bcid = -999999999  then cu_bcid else @cu_bcid end,  
 cu_gender=case when @cu_gender is null or @cu_gender = -999999999  then cu_gender else @cu_gender end,  
 cu_icon=case when @cu_icon is null or @cu_icon = -999999999  then cu_icon else @cu_icon end,  
 cu_sign=case when @cu_sign is null or @cu_sign = -999999999  then cu_sign else @cu_sign end,  
 cu_qq=case when @cu_qq is null or @cu_qq = '_none_'  then cu_qq else @cu_qq end,  
 cu_email=case when @cu_email is null or @cu_email = '_none_'  then cu_email else @cu_email end,  
 cu_birth=case when @cu_birth is null or @cu_birth = '_none_'  then cu_birth else @cu_birth end,  
 cu_address=case when @cu_address is null or @cu_address = '_none_'  then cu_address else @cu_address end
 where cu_id=@cu_id  and cu_cmpid=@cu_cmpid and cu_bcid=CASE WHEN @cu_bcid <> ''THEN @cu_bcid ELSE cu_bcid END
  
  update mps_login set  
 cu_pass=case when @cu_pass is null or @cu_pass = '_none_' then cu_pass else @cu_pass end
 where cu_id=@cu_id  and cu_cmpid=@cu_cmpid 

  set @error=0
  if not exists(select 1 from mps_employee where cu_mobile=@cu_mobile)
 begin
  update mps_employee set  
 cu_mobile=case when @cu_mobile is null or @cu_mobile = '_none_' then cu_mobile else @cu_mobile end
 where cu_id=@cu_id  and cu_cmpid=@cu_cmpid 
  set @error=1
     end
   select @error error,* from mps_employee,mps_login,mps_depart where mps_employee.cu_cmpid=@cu_cmpid and mps_employee.cu_id=@cu_id and mps_employee.cu_id=mps_login.cu_id 
and mps_depart.dp_id=mps_employee.cu_dpid 
set nocount off
end