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

-- 生成时间:2018-06-25 14:16:47 by ebs-core  
CREATE  procedure order_40_modify(
@cmpid int,
@branchid int,
@userdpid int,
@useruid int,
@userotid int,
@jbid bigint,
@ordid bigint,@sourcefield varchar(50)=default, 
@ord_branch nvarchar(50)=default,
@ord_cbid bigint=default,
@ord_cjzd nvarchar(100)=default,
@ord_createcuid int=default,
@ord_createdepart nvarchar(50)=default,
@ord_createdpid int=default,
@ord_creator nvarchar(50)=default,
@ord_enddate datetime=default,
@ord_fbizid int=default,
@ord_ford2id bigint=default,
@ord_ford2tag int=default,
@ord_fordid bigint=default,
@ord_ftype varchar(10)=default,
@ord_gdjbf decimal(18,2)=default,
@ord_gh nvarchar(100)=default,
@ord_gl nvarchar(100)=default,
@ord_gwgz decimal(18,2)=default,
@ord_hj decimal(18,2)=default,
@ord_htjzrq datetime=default,
@ord_htsxrq datetime=default,
@ord_hyzk nvarchar(100)=default,
@ord_jg nvarchar(100)=default,
@ord_jtbt decimal(18,2)=default,
@ord_jxgz decimal(18,2)=default,
@ord_key varchar(30)=default,
@ord_lxdh nvarchar(100)=default,
@ord_mz nvarchar(100)=default,
@ord_nl int=default,
@ord_no varchar(50)=default,
@ord_noi int=default,
@ord_qt decimal(18,2)=default,
@ord_qt1 decimal(18,2)=default,
@ord_rbizid int=default,
@ord_rord2id bigint=default,
@ord_rord2tag int=default,
@ord_rordid bigint=default,
@ord_rtype varchar(10)=default,
@ord_rzbm nvarchar(100)=default,
@ord_rzfs nvarchar(100)=default,
@ord_rzsj datetime=default,
@ord_rztx nvarchar(100)=default,
@ord_rzzx nvarchar(100)=default,
@ord_security int=default,
@ord_sfzhm nvarchar(100)=default,
@ord_sfzszd nvarchar(100)=default,
@ord_skbx decimal(18,2)=default,
@ord_spwpry nvarchar(100)=default,
@ord_sr datetime=default,
@ord_status nvarchar(30)=default,
@ord_style int=default,
@ord_template nvarchar(50)=default,
@ord_templateid int=default,
@ord_title nvarchar(100)=default,
@ord_txbt decimal(18,2)=default,
@ord_type nvarchar(50)=default,
@ord_wpdp nvarchar(100)=default,
@ord_wzrgz decimal(18,2)=default,
@ord_xb nvarchar(100)=default,
@ord_xm nvarchar(100)=default,
@ord_xzdj nvarchar(100)=default,
@ord_ygzt nvarchar(100)=default,
@ord_yx nvarchar(100)=default,
@ord_yxhm nvarchar(100)=default,
@ord_yxkhsf nvarchar(100)=default,
@ord_yxkhx nvarchar(100)=default,
@ord_yxqh nvarchar(100)=default,
@ord_zj nvarchar(100)=default,
@ord_zw nvarchar(100)=default,
@ord_zzmm nvarchar(100)=default,
@ord_zzzk nvarchar(100)=default,
@ord_fjbid bigint=default,
@ord_createbizids varchar(200)=default,
@ord_xcdj nvarchar(100)=default,
@ord_jlordid bigint=default,
@ord_htlb nvarchar(100)=default,
@ord_htnx nvarchar(100)=default,
@ord_qdcs nvarchar(100)=default,
@ord_zhij nvarchar(100)=default,
@ord_zzzb nvarchar(100)=default,
@ord_dqts nvarchar(100)=default,
@ord_ruzbm nvarchar(100)=default,
@ord_ruzzm nvarchar(100)=default,
@ord_ruzzx nvarchar(100)=default,
@ord_jsrq datetime=default,
@ord_ksrq datetime=default,
@ord_sylx nvarchar(100)=default,
@ord_syqx nvarchar(100)=default,
@ord_ycqx nvarchar(100)=default,
@ord_ycrq datetime=default,
@ord_zzrq datetime=default,
@ord_sydqts nvarchar(100)=default,
@ord_jy nvarchar(100)=default,
@ord_jylx nvarchar(100)=default,
@ord_lzfs nvarchar(100)=default,
@ord_lzlx nvarchar(100)=default,
@ord_lzsqrq datetime=default,
@ord_lzyy nvarchar(1000)=default,
@ord_lzyylx nvarchar(100)=default,
@ord_sjlzsj datetime=default,
@ord_yjlzsj datetime=default,
@ord_bysj datetime=default,
@ord_byyx nvarchar(100)=default,
@ord_csrq datetime=default,
@ord_jjlxr nvarchar(100)=default,
@ord_lxrdh nvarchar(100)=default,
@ord_lxrdz nvarchar(100)=default,
@ord_srlx nvarchar(100)=default,
@ord_xl nvarchar(100)=default,
@ord_yjby nvarchar(100)=default,
@ord_zhhsr datetime=default,
@ord_zy nvarchar(100)=default,
@ord_posid bigint=default,
@ord_rzzw nvarchar(100)=default,
@ord_rzw nvarchar(100)=default,
@ord_rutx nvarchar(100)=default,
@ord_xcdj1 nvarchar(100)=default,
@ord_xzdj1 nvarchar(100)=default,
@ord_cuid int=default,
@ord_depart nvarchar(50)=default,
@ord_dpid int=default,
@ord_empname nvarchar(50)=default,
@ord_bzxz decimal(18,2)=default,
@ord_qdlb nvarchar(100)=default,
@ord_gs nvarchar(100)=default,
@ord_rugs nvarchar(100)=default,
@ord_bmfzryj nvarchar(100)=default,
@ord_bz1 nvarchar(100)=default,
@ord_gzfs nvarchar(100)=default,
@ord_gzjl nvarchar(100)=default,
@ord_gzr nvarchar(100)=default,
@ord_gzrgh nvarchar(100)=default,
@ord_gzsj datetime=default,
@ord_lzgzlx nvarchar(100)=default,
@ord_sptz nvarchar(100)=default,
@ord_byzs int=default,
@ord_jl int=default,
@ord_ldgxjcs int=default,
@ord_qtzl nvarchar(100)=default,
@ord_sfzfyj int=default,
@ord_yxqfyj int=default,
@ord_zp int=default,
@ord_lzsj datetime=default,
@ord_splygrz nvarchar(100)=default,
@ord_spss nvarchar(100)=default,
@ord_htqdcs int=default,
@ord_htqdrq nvarchar(100)=default,
@ord_spqdht nvarchar(100)=default,
@ord_wqdly nvarchar(100)=default,
@ord_bmdpid bigint=default,
@ord_zbdpid bigint=default,
@ord_dpotid bigint=default,
@ord_bcidnow int=default,
@ord_dpidnow int=default,
@ord_ktebszh nvarchar(100)=default,
@ord_ktposzh nvarchar(100)=default,
@ord_qdrq datetime=default,
@ord_changebcid bigint=default,
@ord_changedpid bigint=default,
@ord_changezbdpid bigint=default,
@ord_dabh nvarchar(100)=default,
@ord_dpbh nvarchar(100)=default,
@ord_sjczlx nvarchar(100)=default,
@ord_gldj nvarchar(100)=default,
@ord_spsjms nvarchar(100)=default,
@ord_jhddpid bigint=default,
@ord_jhdotid bigint=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 = '' 
 --- 以下是预处理事件中的临时表
 update order_40 set 
ord_branch=case when @ord_branch is null or @ord_branch = '_none_'  then ord_branch else @ord_branch end,ord_cbid=case when @ord_cbid is null or @ord_cbid = -999999999  then ord_cbid else @ord_cbid end,ord_cjzd=case when @ord_cjzd is null or @ord_cjzd = '_none_'  then ord_cjzd else @ord_cjzd end,ord_createcuid=case when @ord_createcuid is null or @ord_createcuid = -999999999  then ord_createcuid else @ord_createcuid end,ord_createdepart=case when @ord_createdepart is null or @ord_createdepart = '_none_'  then ord_createdepart else @ord_createdepart end,ord_createdpid=case when @ord_createdpid is null or @ord_createdpid = -999999999  then ord_createdpid else @ord_createdpid end,ord_creator=case when @ord_creator is null or @ord_creator = '_none_'  then ord_creator else @ord_creator end,ord_enddate=case when @ord_enddate is null or @ord_enddate = @nonedate then ord_enddate else @ord_enddate end,ord_fbizid=case when @ord_fbizid is null or @ord_fbizid = -999999999  then ord_fbizid else @ord_fbizid end,ord_ford2id=case when @ord_ford2id is null or @ord_ford2id = -999999999  then ord_ford2id else @ord_ford2id end,ord_ford2tag=case when @ord_ford2tag is null or @ord_ford2tag = -999999999  then ord_ford2tag else @ord_ford2tag end,ord_fordid=case when @ord_fordid is null or @ord_fordid = -999999999  then ord_fordid else @ord_fordid end,ord_ftype=case when @ord_ftype is null or @ord_ftype = '_none_'  then ord_ftype else @ord_ftype end,ord_gdjbf=case when @ord_gdjbf is null or @ord_gdjbf = -999999999  then ord_gdjbf else @ord_gdjbf end,ord_gh=case when @ord_gh is null or @ord_gh = '_none_'  then ord_gh else @ord_gh end,ord_gl=case when @ord_gl is null or @ord_gl = '_none_'  then ord_gl else @ord_gl end,ord_gwgz=case when @ord_gwgz is null or @ord_gwgz = -999999999  then ord_gwgz else @ord_gwgz end,ord_hj=case when @ord_hj is null or @ord_hj = -999999999  then ord_hj else @ord_hj end,ord_htjzrq=case when @ord_htjzrq is null or @ord_htjzrq = @nonedate then ord_htjzrq else @ord_htjzrq end,ord_htsxrq=case when @ord_htsxrq is null or @ord_htsxrq = @nonedate then ord_htsxrq else @ord_htsxrq end,ord_hyzk=case when @ord_hyzk is null or @ord_hyzk = '_none_'  then ord_hyzk else @ord_hyzk end,ord_jg=case when @ord_jg is null or @ord_jg = '_none_'  then ord_jg else @ord_jg end,ord_jtbt=case when @ord_jtbt is null or @ord_jtbt = -999999999  then ord_jtbt else @ord_jtbt end,ord_jxgz=case when @ord_jxgz is null or @ord_jxgz = -999999999  then ord_jxgz else @ord_jxgz end,ord_key=case when @ord_key is null or @ord_key = '_none_'  then ord_key else @ord_key end,ord_lxdh=case when @ord_lxdh is null or @ord_lxdh = '_none_'  then ord_lxdh else @ord_lxdh end,ord_mz=case when @ord_mz is null or @ord_mz = '_none_'  then ord_mz else @ord_mz end,ord_nl=case when @ord_nl is null or @ord_nl = -999999999  then ord_nl else @ord_nl end,ord_no=case when @ord_no is null or @ord_no = '_none_'  then ord_no else @ord_no end,ord_noi=case when @ord_noi is null or @ord_noi = -999999999  then ord_noi else @ord_noi end,ord_qt=case when @ord_qt is null or @ord_qt = -999999999  then ord_qt else @ord_qt end,ord_qt1=case when @ord_qt1 is null or @ord_qt1 = -999999999  then ord_qt1 else @ord_qt1 end,ord_rbizid=case when @ord_rbizid is null or @ord_rbizid = -999999999  then ord_rbizid else @ord_rbizid end,ord_rord2id=case when @ord_rord2id is null or @ord_rord2id = -999999999  then ord_rord2id else @ord_rord2id end,ord_rord2tag=case when @ord_rord2tag is null or @ord_rord2tag = -999999999  then ord_rord2tag else @ord_rord2tag end,ord_rordid=case when @ord_rordid is null or @ord_rordid = -999999999  then ord_rordid else @ord_rordid end,ord_rtype=case when @ord_rtype is null or @ord_rtype = '_none_'  then ord_rtype else @ord_rtype end,ord_rzbm=case when @ord_rzbm is null or @ord_rzbm = '_none_'  then ord_rzbm else @ord_rzbm end,ord_rzfs=case when @ord_rzfs is null or @ord_rzfs = '_none_'  then ord_rzfs else @ord_rzfs end,ord_rzsj=case when @ord_rzsj is null or @ord_rzsj = @nonedate then ord_rzsj else @ord_rzsj end,ord_rztx=case when @ord_rztx is null or @ord_rztx = '_none_'  then ord_rztx else @ord_rztx end,ord_rzzx=case when @ord_rzzx is null or @ord_rzzx = '_none_'  then ord_rzzx else @ord_rzzx end,ord_security=case when @ord_security is null or @ord_security = -999999999  then ord_security else @ord_security end,ord_sfzhm=case when @ord_sfzhm is null or @ord_sfzhm = '_none_'  then ord_sfzhm else @ord_sfzhm end,ord_sfzszd=case when @ord_sfzszd is null or @ord_sfzszd = '_none_'  then ord_sfzszd else @ord_sfzszd end,ord_skbx=case when @ord_skbx is null or @ord_skbx = -999999999  then ord_skbx else @ord_skbx end,ord_spwpry=case when @ord_spwpry is null or @ord_spwpry = '_none_'  then ord_spwpry else @ord_spwpry end,ord_sr=case when @ord_sr is null or @ord_sr = @nonedate then ord_sr else @ord_sr end,ord_status=case when @ord_status is null or @ord_status = '_none_'  then ord_status else @ord_status end,ord_style=case when @ord_style is null or @ord_style = -999999999  then ord_style else @ord_style end,ord_template=case when @ord_template is null or @ord_template = '_none_'  then ord_template else @ord_template end,ord_templateid=case when @ord_templateid is null or @ord_templateid = -999999999  then ord_templateid else @ord_templateid end,ord_title=case when @ord_title is null or @ord_title = '_none_'  then ord_title else @ord_title end,ord_txbt=case when @ord_txbt is null or @ord_txbt = -999999999  then ord_txbt else @ord_txbt end,ord_type=case when @ord_type is null or @ord_type = '_none_'  then ord_type else @ord_type end,ord_wpdp=case when @ord_wpdp is null or @ord_wpdp = '_none_'  then ord_wpdp else @ord_wpdp end,ord_wzrgz=case when @ord_wzrgz is null or @ord_wzrgz = -999999999  then ord_wzrgz else @ord_wzrgz end,ord_xb=case when @ord_xb is null or @ord_xb = '_none_'  then ord_xb else @ord_xb end,ord_xm=case when @ord_xm is null or @ord_xm = '_none_'  then ord_xm else @ord_xm end,ord_xzdj=case when @ord_xzdj is null or @ord_xzdj = '_none_'  then ord_xzdj else @ord_xzdj end,ord_ygzt=case when @ord_ygzt is null or @ord_ygzt = '_none_'  then ord_ygzt else @ord_ygzt end,ord_yx=case when @ord_yx is null or @ord_yx = '_none_'  then ord_yx else @ord_yx end,ord_yxhm=case when @ord_yxhm is null or @ord_yxhm = '_none_'  then ord_yxhm else @ord_yxhm end,ord_yxkhsf=case when @ord_yxkhsf is null or @ord_yxkhsf = '_none_'  then ord_yxkhsf else @ord_yxkhsf end,ord_yxkhx=case when @ord_yxkhx is null or @ord_yxkhx = '_none_'  then ord_yxkhx else @ord_yxkhx end,ord_yxqh=case when @ord_yxqh is null or @ord_yxqh = '_none_'  then ord_yxqh else @ord_yxqh end,ord_zj=case when @ord_zj is null or @ord_zj = '_none_'  then ord_zj else @ord_zj end,ord_zw=case when @ord_zw is null or @ord_zw = '_none_'  then ord_zw else @ord_zw end,ord_zzmm=case when @ord_zzmm is null or @ord_zzmm = '_none_'  then ord_zzmm else @ord_zzmm end,ord_zzzk=case when @ord_zzzk is null or @ord_zzzk = '_none_'  then ord_zzzk else @ord_zzzk end,ord_fjbid=case when @ord_fjbid is null or @ord_fjbid = -999999999  then ord_fjbid else @ord_fjbid end,ord_createbizids=case when @ord_createbizids is null or @ord_createbizids = '_none_'  then ord_createbizids else @ord_createbizids end,ord_xcdj=case when @ord_xcdj is null or @ord_xcdj = '_none_'  then ord_xcdj else @ord_xcdj end,ord_jlordid=case when @ord_jlordid is null or @ord_jlordid = -999999999  then ord_jlordid else @ord_jlordid end,ord_htlb=case when @ord_htlb is null or @ord_htlb = '_none_'  then ord_htlb else @ord_htlb end,ord_htnx=case when @ord_htnx is null or @ord_htnx = '_none_'  then ord_htnx else @ord_htnx end,ord_qdcs=case when @ord_qdcs is null or @ord_qdcs = '_none_'  then ord_qdcs else @ord_qdcs end,ord_zhij=case when @ord_zhij is null or @ord_zhij = '_none_'  then ord_zhij else @ord_zhij end,ord_zzzb=case when @ord_zzzb is null or @ord_zzzb = '_none_'  then ord_zzzb else @ord_zzzb end,ord_dqts=case when @ord_dqts is null or @ord_dqts = '_none_'  then ord_dqts else @ord_dqts end,ord_ruzbm=case when @ord_ruzbm is null or @ord_ruzbm = '_none_'  then ord_ruzbm else @ord_ruzbm end,ord_ruzzm=case when @ord_ruzzm is null or @ord_ruzzm = '_none_'  then ord_ruzzm else @ord_ruzzm end,ord_ruzzx=case when @ord_ruzzx is null or @ord_ruzzx = '_none_'  then ord_ruzzx else @ord_ruzzx end,ord_jsrq=case when @ord_jsrq is null or @ord_jsrq = @nonedate then ord_jsrq else @ord_jsrq end,ord_ksrq=case when @ord_ksrq is null or @ord_ksrq = @nonedate then ord_ksrq else @ord_ksrq end,ord_sylx=case when @ord_sylx is null or @ord_sylx = '_none_'  then ord_sylx else @ord_sylx end,ord_syqx=case when @ord_syqx is null or @ord_syqx = '_none_'  then ord_syqx else @ord_syqx end,ord_ycqx=case when @ord_ycqx is null or @ord_ycqx = '_none_'  then ord_ycqx else @ord_ycqx end,ord_ycrq=case when @ord_ycrq is null or @ord_ycrq = @nonedate then ord_ycrq else @ord_ycrq end,ord_zzrq=case when @ord_zzrq is null or @ord_zzrq = @nonedate then ord_zzrq else @ord_zzrq end,ord_sydqts=case when @ord_sydqts is null or @ord_sydqts = '_none_'  then ord_sydqts else @ord_sydqts end,ord_jy=case when @ord_jy is null or @ord_jy = '_none_'  then ord_jy else @ord_jy end,ord_jylx=case when @ord_jylx is null or @ord_jylx = '_none_'  then ord_jylx else @ord_jylx end,ord_lzfs=case when @ord_lzfs is null or @ord_lzfs = '_none_'  then ord_lzfs else @ord_lzfs end,ord_lzlx=case when @ord_lzlx is null or @ord_lzlx = '_none_'  then ord_lzlx else @ord_lzlx end,ord_lzsqrq=case when @ord_lzsqrq is null or @ord_lzsqrq = @nonedate then ord_lzsqrq else @ord_lzsqrq end,ord_lzyy=case when @ord_lzyy is null or @ord_lzyy = '_none_'  then ord_lzyy else @ord_lzyy end,ord_lzyylx=case when @ord_lzyylx is null or @ord_lzyylx = '_none_'  then ord_lzyylx else @ord_lzyylx end,ord_sjlzsj=case when @ord_sjlzsj is null or @ord_sjlzsj = @nonedate then ord_sjlzsj else @ord_sjlzsj end,ord_yjlzsj=case when @ord_yjlzsj is null or @ord_yjlzsj = @nonedate then ord_yjlzsj else @ord_yjlzsj end,ord_bysj=case when @ord_bysj is null or @ord_bysj = @nonedate then ord_bysj else @ord_bysj end,ord_byyx=case when @ord_byyx is null or @ord_byyx = '_none_'  then ord_byyx else @ord_byyx end,ord_csrq=case when @ord_csrq is null or @ord_csrq = @nonedate then ord_csrq else @ord_csrq end,ord_jjlxr=case when @ord_jjlxr is null or @ord_jjlxr = '_none_'  then ord_jjlxr else @ord_jjlxr end,ord_lxrdh=case when @ord_lxrdh is null or @ord_lxrdh = '_none_'  then ord_lxrdh else @ord_lxrdh end,ord_lxrdz=case when @ord_lxrdz is null or @ord_lxrdz = '_none_'  then ord_lxrdz else @ord_lxrdz end,ord_srlx=case when @ord_srlx is null or @ord_srlx = '_none_'  then ord_srlx else @ord_srlx end,ord_xl=case when @ord_xl is null or @ord_xl = '_none_'  then ord_xl else @ord_xl end,ord_yjby=case when @ord_yjby is null or @ord_yjby = '_none_'  then ord_yjby else @ord_yjby end,ord_zhhsr=case when @ord_zhhsr is null or @ord_zhhsr = @nonedate then ord_zhhsr else @ord_zhhsr end,ord_zy=case when @ord_zy is null or @ord_zy = '_none_'  then ord_zy else @ord_zy end,ord_posid=case when @ord_posid is null or @ord_posid = -999999999  then ord_posid else @ord_posid end,ord_rzzw=case when @ord_rzzw is null or @ord_rzzw = '_none_'  then ord_rzzw else @ord_rzzw end,ord_rzw=case when @ord_rzw is null or @ord_rzw = '_none_'  then ord_rzw else @ord_rzw end,ord_rutx=case when @ord_rutx is null or @ord_rutx = '_none_'  then ord_rutx else @ord_rutx end,ord_xcdj1=case when @ord_xcdj1 is null or @ord_xcdj1 = '_none_'  then ord_xcdj1 else @ord_xcdj1 end,ord_xzdj1=case when @ord_xzdj1 is null or @ord_xzdj1 = '_none_'  then ord_xzdj1 else @ord_xzdj1 end,ord_cuid=case when @ord_cuid is null or @ord_cuid = -999999999  then ord_cuid else @ord_cuid end,ord_depart=case when @ord_depart is null or @ord_depart = '_none_'  then ord_depart else @ord_depart end,ord_dpid=case when @ord_dpid is null or @ord_dpid = -999999999  then ord_dpid else @ord_dpid end,ord_empname=case when @ord_empname is null or @ord_empname = '_none_'  then ord_empname else @ord_empname end,ord_bzxz=case when @ord_bzxz is null or @ord_bzxz = -999999999  then ord_bzxz else @ord_bzxz end,ord_qdlb=case when @ord_qdlb is null or @ord_qdlb = '_none_'  then ord_qdlb else @ord_qdlb end,ord_gs=case when @ord_gs is null or @ord_gs = '_none_'  then ord_gs else @ord_gs end,ord_rugs=case when @ord_rugs is null or @ord_rugs = '_none_'  then ord_rugs else @ord_rugs end,ord_bmfzryj=case when @ord_bmfzryj is null or @ord_bmfzryj = '_none_'  then ord_bmfzryj else @ord_bmfzryj end,ord_bz1=case when @ord_bz1 is null or @ord_bz1 = '_none_'  then ord_bz1 else @ord_bz1 end,ord_gzfs=case when @ord_gzfs is null or @ord_gzfs = '_none_'  then ord_gzfs else @ord_gzfs end,ord_gzjl=case when @ord_gzjl is null or @ord_gzjl = '_none_'  then ord_gzjl else @ord_gzjl end,ord_gzr=case when @ord_gzr is null or @ord_gzr = '_none_'  then ord_gzr else @ord_gzr end,ord_gzrgh=case when @ord_gzrgh is null or @ord_gzrgh = '_none_'  then ord_gzrgh else @ord_gzrgh end,ord_gzsj=case when @ord_gzsj is null or @ord_gzsj = @nonedate then ord_gzsj else @ord_gzsj end,ord_lzgzlx=case when @ord_lzgzlx is null or @ord_lzgzlx = '_none_'  then ord_lzgzlx else @ord_lzgzlx end,ord_sptz=case when @ord_sptz is null or @ord_sptz = '_none_'  then ord_sptz else @ord_sptz end,ord_byzs=case when @ord_byzs is null or @ord_byzs = -999999999  then ord_byzs else @ord_byzs end,ord_jl=case when @ord_jl is null or @ord_jl = -999999999  then ord_jl else @ord_jl end,ord_ldgxjcs=case when @ord_ldgxjcs is null or @ord_ldgxjcs = -999999999  then ord_ldgxjcs else @ord_ldgxjcs end,ord_qtzl=case when @ord_qtzl is null or @ord_qtzl = '_none_'  then ord_qtzl else @ord_qtzl end,ord_sfzfyj=case when @ord_sfzfyj is null or @ord_sfzfyj = -999999999  then ord_sfzfyj else @ord_sfzfyj end,ord_yxqfyj=case when @ord_yxqfyj is null or @ord_yxqfyj = -999999999  then ord_yxqfyj else @ord_yxqfyj end,ord_zp=case when @ord_zp is null or @ord_zp = -999999999  then ord_zp else @ord_zp end,ord_lzsj=case when @ord_lzsj is null or @ord_lzsj = @nonedate then ord_lzsj else @ord_lzsj end,ord_splygrz=case when @ord_splygrz is null or @ord_splygrz = '_none_'  then ord_splygrz else @ord_splygrz end,ord_spss=case when @ord_spss is null or @ord_spss = '_none_'  then ord_spss else @ord_spss end,ord_htqdcs=case when @ord_htqdcs is null or @ord_htqdcs = -999999999  then ord_htqdcs else @ord_htqdcs end,ord_htqdrq=case when @ord_htqdrq is null or @ord_htqdrq = '_none_'  then ord_htqdrq else @ord_htqdrq end,ord_spqdht=case when @ord_spqdht is null or @ord_spqdht = '_none_'  then ord_spqdht else @ord_spqdht end,ord_wqdly=case when @ord_wqdly is null or @ord_wqdly = '_none_'  then ord_wqdly else @ord_wqdly end,ord_bmdpid=case when @ord_bmdpid is null or @ord_bmdpid = -999999999  then ord_bmdpid else @ord_bmdpid end,ord_zbdpid=case when @ord_zbdpid is null or @ord_zbdpid = -999999999  then ord_zbdpid else @ord_zbdpid end,ord_dpotid=case when @ord_dpotid is null or @ord_dpotid = -999999999  then ord_dpotid else @ord_dpotid end,ord_bcidnow=case when @ord_bcidnow is null or @ord_bcidnow = -999999999  then ord_bcidnow else @ord_bcidnow end,ord_dpidnow=case when @ord_dpidnow is null or @ord_dpidnow = -999999999  then ord_dpidnow else @ord_dpidnow end,ord_ktebszh=case when @ord_ktebszh is null or @ord_ktebszh = '_none_'  then ord_ktebszh else @ord_ktebszh end,ord_ktposzh=case when @ord_ktposzh is null or @ord_ktposzh = '_none_'  then ord_ktposzh else @ord_ktposzh end,ord_qdrq=case when @ord_qdrq is null or @ord_qdrq = @nonedate then ord_qdrq else @ord_qdrq end,ord_changebcid=case when @ord_changebcid is null or @ord_changebcid = -999999999  then ord_changebcid else @ord_changebcid end,ord_changedpid=case when @ord_changedpid is null or @ord_changedpid = -999999999  then ord_changedpid else @ord_changedpid end,ord_changezbdpid=case when @ord_changezbdpid is null or @ord_changezbdpid = -999999999  then ord_changezbdpid else @ord_changezbdpid end,ord_dabh=case when @ord_dabh is null or @ord_dabh = '_none_'  then ord_dabh else @ord_dabh end,ord_dpbh=case when @ord_dpbh is null or @ord_dpbh = '_none_'  then ord_dpbh else @ord_dpbh end,ord_sjczlx=case when @ord_sjczlx is null or @ord_sjczlx = '_none_'  then ord_sjczlx else @ord_sjczlx end,ord_gldj=case when @ord_gldj is null or @ord_gldj = '_none_'  then ord_gldj else @ord_gldj end,ord_spsjms=case when @ord_spsjms is null or @ord_spsjms = '_none_'  then ord_spsjms else @ord_spsjms end,ord_jhddpid=case when @ord_jhddpid is null or @ord_jhddpid = -999999999  then ord_jhddpid else @ord_jhddpid end,ord_jhdotid=case when @ord_jhdotid is null or @ord_jhdotid = -999999999  then ord_jhdotid else @ord_jhdotid end,
ord_finished=case when ord_finished=0 then 1 else ord_finished end ,
ord_updated=getdate() 
where ord_id=@ordid 
 if (@operation='continue') 
 begin
 set @nonedate = @nonedate 
 
 if (@ord_fordid>0) -- 说明有可能在修改上级关系
begin
if (dbo.checkprocedure('order_40_calc_relation')=0)
begin
exec order_40_calc_relation @cmpid , @ordid 
end
end 
 select 'ok' operation, '' errorinfo 
end  else 
begin
select @operation operation, @errorinfo errorinfo  
end


-- 对项目进行处理
declare @style int 
declare @finished int 
select @style=ord_style , @finished=ord_finished from order_40 where ord_id=@ordid 
if (@style=0)
begin
if (@finished>=10 or @finished<=0) 
begin
delete mps_order where ord_bizid=40 and ord_id=@ordid 
end  else 
begin
if (exists (select 1 from mps_order where ord_bizid=40 and ord_id=@ordid)) 
begin
update a set 
a.ord_bcid=b.ord_bcid ,
a.ord_branch=b.ord_branch,
a.ord_createdpid=b.ord_createdpid,
a.ord_createdepart=b.ord_createdepart,
a.ord_dpid=b.ord_dpid,
a.ord_depart=b.ord_depart,
a.ord_createcuid=b.ord_createcuid,
a.ord_creator=b.ord_creator,
a.ord_cuid=b.ord_cuid,
a.ord_empname=b.ord_empname,
a.ord_date=b.ord_date,
a.ord_enddate=b.ord_enddate,
a.ord_finished=b.ord_finished,
a.ord_no=b.ord_no,
a.ord_title=b.ord_title,
a.ord_status=b.ord_status,
a.ord_type =b.ord_type
from mps_order a , order_40 b
where a.ord_bizid=40 and a.ord_id=b.ord_id and b.ord_id=@ordid 
end else
begin
insert into mps_order(
ord_bizid,
ord_id,
ord_cmpid,
ord_bcid,
ord_branch,
ord_createdpid,
ord_createdepart,
ord_dpid,
ord_depart,
ord_createcuid,
ord_creator,
ord_cuid,
ord_empname,
ord_date,
ord_enddate,
ord_finished,
ord_no,
ord_title,
ord_status,
ord_type )
select 
ord_bizid,
ord_id,
ord_cmpid,
ord_bcid,
ord_branch,
ord_createdpid,
ord_createdepart,
ord_dpid,
ord_depart,
ord_createcuid,
ord_creator,
ord_cuid,
ord_empname,
ord_date,
ord_enddate,
ord_finished,
ord_no,
ord_title,
ord_status,
ord_type
from order_40 where ord_id=@ordid 
end 
end 
end 
set nocount off 
end