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

-- 生成时间:2018-11-22 18:21:18 by ebs-core  
CREATE  procedure order_239_check(
     @cmpid int,
     @branchid int,
     @userdpid int,
     @useruid int,
     @userotid int,
     @jbid bigint,
     @ordid bigint,
     @operation varchar(50) output,
     @errorinfo nvarchar(4000) output
  ) 
as  
begin  
set nocount on  
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
declare @ord2group2 nvarchar(50) 
set @ord2group2 = '' 
declare @sys_recid bigint 
set @sys_recid = 0 
 declare @nonedate datetime 
set @nonedate = CONVERT(datetime,'1910-1-1')
 set @operation = 'continue'
 set @errorinfo = '' 
 --- 以下是预处理事件中的临时表
 
exec drop_temp_table '#master' 
select * into #master from order_239 with(nolock) where ord_id=@ordid  

 ---- 以下是开发人员写的 check order 事件 --------------
 declare @jbwkid int = 0
declare @whzt1 varchar(20)
declare @ddxm1 varchar(20)
select @jbwkid = jb_wrkid from mps_job where jb_id = @jbid

if(@jbwkid = 3056 or @jbwkid = 3058)
begin
   select @whzt1 = ord_whzt from #master
   if (@whzt1 = '')
   begin
      set @operation = 'abort'
      set @errorinfo = '外呼状态不能为空，请重新选择！'
   end
end
else if (@jbwkid = 3060)
begin
   select @ddxm1 = ord_ddxm from #master
   if (@ddxm1 = '')
   begin
      set @operation = 'abort'
      set @errorinfo = '到店项目不能为空，请重新选择！'
   end
end
 ---- 以上是开发人员写的 check order 事件 --------------
 
 if (@operation='continue') 
 begin
 set @sys_recid=@sys_recid  -- here useless 
 
end 
--- 清除临时表 

exec drop_temp_table '#master' 

set nocount off 
end