IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_customer1_modify_11]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_customer1_modify_11]
GO

-- 生成时间:2018-10-15 17:18:43 by ebs-core  
CREATE  procedure mps_customer1_modify_11(
@cmpid int,
@branchid int,
@userdpid int,
@useruid int,
@userotid int,
@ccid bigint,@sourcefield varchar(50)=default, 
@cc_accountperiod int=default,
@cc_addr nvarchar(100)=default,
@cc_birth datetime=default,
@cc_branch nvarchar(50)=default,
@cc_caption nvarchar(50)=default,
@cc_code varchar(50)=default,
@cc_company nvarchar(50)=default,
@cc_contact varchar(50)=default,
@cc_createcuid int=default,
@cc_createdepart nvarchar(50)=default,
@cc_createdpid int=default,
@cc_creator nvarchar(50)=default,
@cc_creditquantum int=default,
@cc_cuid int=default,
@cc_cuname nvarchar(50)=default,
@cc_depart nvarchar(50)=default,
@cc_dj nvarchar(100)=default,
@cc_dpid int=default,
@cc_email varchar(100)=default,
@cc_fccid int=default,
@cc_gender int=default,
@cc_gn nvarchar(100)=default,
@cc_icon varchar(50)=default,
@cc_identno varchar(20)=default,
@cc_identtype nvarchar(20)=default,
@cc_mobile varchar(18)=default,
@cc_monthday varchar(4)=default,
@cc_msnqq varchar(50)=default,
@cc_name nvarchar(50)=default,
@cc_pp nvarchar(100)=default,
@cc_rjph nvarchar(100)=default,
@cc_score decimal(18,4)=default,
@cc_security int=default,
@cc_sjch nvarchar(100)=default,
@cc_source nvarchar(50)=default,
@cc_status nvarchar(50)=default,
@cc_total decimal(18,4)=default,
@cc_type nvarchar(50)=default,
@cc_use int=default,
@cc_useruid bigint=default,
@cc_value decimal(18,4)=default,
@cc_wxqq nvarchar(100)=default,
@cc_xg nvarchar(100)=default,
@cc_xh nvarchar(100)=default,
@cc_xq nvarchar(100)=default,
@cc_zy nvarchar(100)=default,
@cc_yqid int=default ) 
as  
begin  
set nocount on  
declare @nonedate datetime 
set @nonedate = CONVERT(datetime,'1910-1-1')
 declare @operation varchar(50)
declare @errorinfo nvarchar(4000) 
 set @operation = 'continue' 
set @errorinfo = '' 

-- 处理编码
 declare @bmcode varchar(200) 
 declare @newno nvarchar(50) 
 declare @ctid int 
 select top 1 @ctid=cc_ctid,@bmcode = ct_bmcode from mps_customer1,mps_csttype where cc_id=@ccid and cc_ctid=ct_id and (cc_code='' or cc_code like '%临%')
 set @ctid = isnull(@ctid,0) 
 if (@ctid>0) 
 begin
exec mps_bm_getorset @cmpid,'cst',@ctid,@ccid,@useruid,@bmcode,0,@newno output,1
set @cc_code = @newno 
end 


if (dbo.checkprocedure('mps_customer1_check_11')=0) 
begin
declare @sql1 nvarchar(max) 
exec drop_temp_table '#old'
select * into #old from mps_customer1 where cc_id=@ccid 

update #old set  cc_accountperiod=case when @cc_accountperiod is null or @cc_accountperiod = -999999999  then cc_accountperiod else @cc_accountperiod end,cc_addr=case when @cc_addr is null or @cc_addr = '_none_'  then cc_addr else @cc_addr end,cc_birth=case when @cc_birth is null or @cc_birth = @nonedate then cc_birth else @cc_birth end,cc_branch=case when @cc_branch is null or @cc_branch = '_none_'  then cc_branch else @cc_branch end,cc_caption=case when @cc_caption is null or @cc_caption = '_none_'  then cc_caption else @cc_caption end,cc_code=case when @cc_code is null or @cc_code = '_none_'  then cc_code else @cc_code end,cc_company=case when @cc_company is null or @cc_company = '_none_'  then cc_company else @cc_company end,cc_contact=case when @cc_contact is null or @cc_contact = '_none_'  then cc_contact else @cc_contact end,cc_createcuid=case when @cc_createcuid is null or @cc_createcuid = -999999999  then cc_createcuid else @cc_createcuid end,cc_createdepart=case when @cc_createdepart is null or @cc_createdepart = '_none_'  then cc_createdepart else @cc_createdepart end,cc_createdpid=case when @cc_createdpid is null or @cc_createdpid = -999999999  then cc_createdpid else @cc_createdpid end,cc_creator=case when @cc_creator is null or @cc_creator = '_none_'  then cc_creator else @cc_creator end,cc_creditquantum=case when @cc_creditquantum is null or @cc_creditquantum = -999999999  then cc_creditquantum else @cc_creditquantum end,cc_cuid=case when @cc_cuid is null or @cc_cuid = -999999999  then cc_cuid else @cc_cuid end,cc_cuname=case when @cc_cuname is null or @cc_cuname = '_none_'  then cc_cuname else @cc_cuname end,cc_depart=case when @cc_depart is null or @cc_depart = '_none_'  then cc_depart else @cc_depart end,cc_dj=case when @cc_dj is null or @cc_dj = '_none_'  then cc_dj else @cc_dj end,cc_dpid=case when @cc_dpid is null or @cc_dpid = -999999999  then cc_dpid else @cc_dpid end,cc_email=case when @cc_email is null or @cc_email = '_none_'  then cc_email else @cc_email end,cc_fccid=case when @cc_fccid is null or @cc_fccid = -999999999  then cc_fccid else @cc_fccid end,cc_gender=case when @cc_gender is null or @cc_gender = -999999999  then cc_gender else @cc_gender end,cc_gn=case when @cc_gn is null or @cc_gn = '_none_'  then cc_gn else @cc_gn end,cc_icon=case when @cc_icon is null or @cc_icon = '_none_'  then cc_icon else @cc_icon end,cc_identno=case when @cc_identno is null or @cc_identno = '_none_'  then cc_identno else @cc_identno end,cc_identtype=case when @cc_identtype is null or @cc_identtype = '_none_'  then cc_identtype else @cc_identtype end,cc_mobile=case when @cc_mobile is null or @cc_mobile = '_none_'  then cc_mobile else @cc_mobile end,cc_monthday=case when @cc_monthday is null or @cc_monthday = '_none_'  then cc_monthday else @cc_monthday end,cc_msnqq=case when @cc_msnqq is null or @cc_msnqq = '_none_'  then cc_msnqq else @cc_msnqq end,cc_name=case when @cc_name is null or @cc_name = '_none_'  then cc_name else @cc_name end,cc_pp=case when @cc_pp is null or @cc_pp = '_none_'  then cc_pp else @cc_pp end,cc_rjph=case when @cc_rjph is null or @cc_rjph = '_none_'  then cc_rjph else @cc_rjph end,cc_score=case when @cc_score is null or @cc_score = -999999999  then cc_score else @cc_score end,cc_security=case when @cc_security is null or @cc_security = -999999999  then cc_security else @cc_security end,cc_sjch=case when @cc_sjch is null or @cc_sjch = '_none_'  then cc_sjch else @cc_sjch end,cc_source=case when @cc_source is null or @cc_source = '_none_'  then cc_source else @cc_source end,cc_status=case when @cc_status is null or @cc_status = '_none_'  then cc_status else @cc_status end,cc_total=case when @cc_total is null or @cc_total = -999999999  then cc_total else @cc_total end,cc_type=case when @cc_type is null or @cc_type = '_none_'  then cc_type else @cc_type end,cc_use=case when @cc_use is null or @cc_use = -999999999  then cc_use else @cc_use end,cc_useruid=case when @cc_useruid is null or @cc_useruid = -999999999  then cc_useruid else @cc_useruid end,cc_value=case when @cc_value is null or @cc_value = -999999999  then cc_value else @cc_value end,cc_wxqq=case when @cc_wxqq is null or @cc_wxqq = '_none_'  then cc_wxqq else @cc_wxqq end,cc_xg=case when @cc_xg is null or @cc_xg = '_none_'  then cc_xg else @cc_xg end,cc_xh=case when @cc_xh is null or @cc_xh = '_none_'  then cc_xh else @cc_xh end,cc_xq=case when @cc_xq is null or @cc_xq = '_none_'  then cc_xq else @cc_xq end,cc_zy=case when @cc_zy is null or @cc_zy = '_none_'  then cc_zy else @cc_zy end,cc_yqid=case when @cc_yqid is null or @cc_yqid = -999999999  then cc_yqid else @cc_yqid end  where cc_id=@ccid  

set @operation='continue'
set @errorinfo = '' 
set @sql1 =  N' exec mps_customer1_check_11 @cmpid,@branchid,@userdpid,@useruid,@userotid,@ccid,@operation output , @errorinfo output ' 
exec sp_executesql @sql1, N'@cmpid int, @branchid int,@userdpid int,@useruid int,@userotid int,@ccid bigint,@operation varchar(50) output , @errorinfo nvarchar(4000) output', 
@cmpid,@branchid,@userdpid,@useruid,@userotid,@ccid,@operation output , @errorinfo output  
if (@operation='abort') 
begin
if (@errorinfo='') set @errorinfo='数据验证失败'
select 'abort' operation , @errorinfo errorinfo 
return 
end 

end 

 --- 以下是预处理事件中的临时表
 update mps_customer1 set 
cc_accountperiod=case when @cc_accountperiod is null or @cc_accountperiod = -999999999  then cc_accountperiod else @cc_accountperiod end,cc_addr=case when @cc_addr is null or @cc_addr = '_none_'  then cc_addr else @cc_addr end,cc_birth=case when @cc_birth is null or @cc_birth = @nonedate then cc_birth else @cc_birth end,cc_branch=case when @cc_branch is null or @cc_branch = '_none_'  then cc_branch else @cc_branch end,cc_caption=case when @cc_caption is null or @cc_caption = '_none_'  then cc_caption else @cc_caption end,cc_code=case when @cc_code is null or @cc_code = '_none_'  then cc_code else @cc_code end,cc_company=case when @cc_company is null or @cc_company = '_none_'  then cc_company else @cc_company end,cc_contact=case when @cc_contact is null or @cc_contact = '_none_'  then cc_contact else @cc_contact end,cc_createcuid=case when @cc_createcuid is null or @cc_createcuid = -999999999  then cc_createcuid else @cc_createcuid end,cc_createdepart=case when @cc_createdepart is null or @cc_createdepart = '_none_'  then cc_createdepart else @cc_createdepart end,cc_createdpid=case when @cc_createdpid is null or @cc_createdpid = -999999999  then cc_createdpid else @cc_createdpid end,cc_creator=case when @cc_creator is null or @cc_creator = '_none_'  then cc_creator else @cc_creator end,cc_creditquantum=case when @cc_creditquantum is null or @cc_creditquantum = -999999999  then cc_creditquantum else @cc_creditquantum end,cc_cuid=case when @cc_cuid is null or @cc_cuid = -999999999  then cc_cuid else @cc_cuid end,cc_cuname=case when @cc_cuname is null or @cc_cuname = '_none_'  then cc_cuname else @cc_cuname end,cc_depart=case when @cc_depart is null or @cc_depart = '_none_'  then cc_depart else @cc_depart end,cc_dj=case when @cc_dj is null or @cc_dj = '_none_'  then cc_dj else @cc_dj end,cc_dpid=case when @cc_dpid is null or @cc_dpid = -999999999  then cc_dpid else @cc_dpid end,cc_email=case when @cc_email is null or @cc_email = '_none_'  then cc_email else @cc_email end,cc_fccid=case when @cc_fccid is null or @cc_fccid = -999999999  then cc_fccid else @cc_fccid end,cc_gender=case when @cc_gender is null or @cc_gender = -999999999  then cc_gender else @cc_gender end,cc_gn=case when @cc_gn is null or @cc_gn = '_none_'  then cc_gn else @cc_gn end,cc_icon=case when @cc_icon is null or @cc_icon = '_none_'  then cc_icon else @cc_icon end,cc_identno=case when @cc_identno is null or @cc_identno = '_none_'  then cc_identno else @cc_identno end,cc_identtype=case when @cc_identtype is null or @cc_identtype = '_none_'  then cc_identtype else @cc_identtype end,cc_mobile=case when @cc_mobile is null or @cc_mobile = '_none_'  then cc_mobile else @cc_mobile end,cc_monthday=case when @cc_monthday is null or @cc_monthday = '_none_'  then cc_monthday else @cc_monthday end,cc_msnqq=case when @cc_msnqq is null or @cc_msnqq = '_none_'  then cc_msnqq else @cc_msnqq end,cc_name=case when @cc_name is null or @cc_name = '_none_'  then cc_name else @cc_name end,cc_pp=case when @cc_pp is null or @cc_pp = '_none_'  then cc_pp else @cc_pp end,cc_rjph=case when @cc_rjph is null or @cc_rjph = '_none_'  then cc_rjph else @cc_rjph end,cc_score=case when @cc_score is null or @cc_score = -999999999  then cc_score else @cc_score end,cc_security=case when @cc_security is null or @cc_security = -999999999  then cc_security else @cc_security end,cc_sjch=case when @cc_sjch is null or @cc_sjch = '_none_'  then cc_sjch else @cc_sjch end,cc_source=case when @cc_source is null or @cc_source = '_none_'  then cc_source else @cc_source end,cc_status=case when @cc_status is null or @cc_status = '_none_'  then cc_status else @cc_status end,cc_total=case when @cc_total is null or @cc_total = -999999999  then cc_total else @cc_total end,cc_type=case when @cc_type is null or @cc_type = '_none_'  then cc_type else @cc_type end,cc_use=case when @cc_use is null or @cc_use = -999999999  then cc_use else @cc_use end,cc_useruid=case when @cc_useruid is null or @cc_useruid = -999999999  then cc_useruid else @cc_useruid end,cc_value=case when @cc_value is null or @cc_value = -999999999  then cc_value else @cc_value end,cc_wxqq=case when @cc_wxqq is null or @cc_wxqq = '_none_'  then cc_wxqq else @cc_wxqq end,cc_xg=case when @cc_xg is null or @cc_xg = '_none_'  then cc_xg else @cc_xg end,cc_xh=case when @cc_xh is null or @cc_xh = '_none_'  then cc_xh else @cc_xh end,cc_xq=case when @cc_xq is null or @cc_xq = '_none_'  then cc_xq else @cc_xq end,cc_zy=case when @cc_zy is null or @cc_zy = '_none_'  then cc_zy else @cc_zy end,cc_yqid=case when @cc_yqid is null or @cc_yqid = -999999999  then cc_yqid else @cc_yqid end,
cc_updated=getdate() 
where cc_id=@ccid 
 if (@operation='continue') 
 begin
 set @nonedate = @nonedate 
 
 select 'ok' operation, '' errorinfo 
end  else 
begin
select @operation operation, @errorinfo errorinfo  
end

 
set nocount off 
end