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

CREATE procedure [dbo].[mps_save_biztype] 
@cmpid int ,
@bizid int,
@biz_category nvarchar(100),
@biz_subcategory nvarchar(100),
@biz_title nvarchar(100),
@biz_order varchar(20),
@biz_code nvarchar(100),
@biz_icon varchar(200),
@biz_database varchar(50),
@biz_table int,
@biz_hidemenu int,
@biz_hidemenu_mobile int,
@biz_nomanualcreate int,
@biz_createinfather int,
@biz_onlysourcecreate int,
@biz_formstyle int,
@biz_funcs   varchar(200),
@biz_flows   nvarchar(1000) ,
@biz_params varchar(500),
@biz_sourcebizids varchar(500),
@biz_groupfields varchar(2000),
@biz_querytime int,
@biz_searchfields varchar(2000),
@biz_selectstyle int,
@biz_selectfuncs nvarchar(300),
@biz_viewscope int,
@biz_select nvarchar(4000),
@biz_from nvarchar(2000),
@biz_where nvarchar(4000),
@biz_orderby nvarchar(2000),
@biz_url nvarchar(200)=default 
 as
begin
declare @s1 varchar(200) 
declare @s0 varchar(200) 
set @s1 = @biz_icon 
declare @i int 
set @i = CHARINDEX('|',@s1) 
if (@i>0)
begin
set @s0 = substring(@s1,@i+1,200) 
set @s1 = SUBSTRING(@s1,1,@i-1) 
end else 
begin
set @s0 = '' 
end 
if (@s1='_none_')
begin
set @s1 = '_none_' 
set @s0 = '_none_' 
end 
if (@s1='') set  @s1 = '_none_' 
if (@s0='') set  @s0 = '_none_' 
  update mps_biztype set 
biz_url  = case when @biz_url='_none_' then biz_url else @biz_url end ,
    biz_category  = case when @biz_category='_none_' then biz_category else @biz_category end ,
    biz_subcategory   = case when  @biz_subcategory='_none_' then biz_subcategory else @biz_subcategory end ,
    biz_title   = case when  @biz_title='_none_' then biz_title else @biz_title end ,
    biz_order  = case when  @biz_order='_none_' then biz_order else @biz_order end ,
    biz_code  = case when  @biz_code='_none_' then biz_code else @biz_code end ,
    biz_icon    = case when  @s1='_none_' then biz_icon else @s1 end ,
    biz_icon0    = case when  @s0='_none_' then biz_icon0 else @s0 end ,
    biz_database   = case when @biz_database='_none_' then biz_database else @biz_database end ,
    biz_table   = case when  @biz_table=-999999999 then biz_table else @biz_table end ,
    biz_hidemenu   = case when  @biz_hidemenu=-999999999 then biz_hidemenu else @biz_hidemenu end ,
    biz_hidemenu_mobile   = case when  @biz_hidemenu_mobile=-999999999 then biz_hidemenu_mobile else @biz_hidemenu_mobile end ,
    biz_nomanualcreate  = case when  @biz_nomanualcreate=-999999999 then biz_nomanualcreate else @biz_nomanualcreate end ,
    biz_createinfather   = case when  @biz_createinfather=-999999999 then biz_createinfather else @biz_createinfather end ,
    biz_onlysourcecreate   = case when  @biz_onlysourcecreate=-999999999 then biz_onlysourcecreate else @biz_onlysourcecreate end ,
    biz_formstyle   = case when  @biz_formstyle=-999999999 then biz_formstyle else @biz_formstyle end ,
    biz_funcs    = case when  @biz_funcs='_none_' then biz_funcs else @biz_funcs end ,
    biz_flows    = case when  @biz_flows='_none_' then biz_flows else @biz_flows end ,
    biz_params   = case when  @biz_params='_none_' then biz_params else @biz_params end ,
    biz_select = case when  @biz_select='_none_' then biz_select else @biz_select end ,
    biz_from = case when  @biz_from='_none_' then biz_from else @biz_from end ,
    biz_where = case when  @biz_where='_none_' then biz_where else @biz_where end ,
    biz_orderby = case when  @biz_orderby='_none_' then biz_orderby else @biz_orderby end ,
    biz_sourcebizids   = case when  @biz_sourcebizids='_none_' then biz_sourcebizids else @biz_sourcebizids end ,
    biz_groupfields   = case when  @biz_groupfields='_none_' then biz_groupfields else @biz_groupfields end ,
    biz_searchfields   = case when  @biz_searchfields='_none_' then biz_searchfields else @biz_searchfields end ,
    biz_selectfuncs   = case when  @biz_selectfuncs='_none_' then biz_selectfuncs else @biz_selectfuncs end ,
    biz_querytime   = case when  @biz_querytime=-999999999 then biz_querytime else @biz_querytime end ,
    biz_selectstyle   = case when  @biz_selectstyle=-999999999 then biz_selectstyle else @biz_selectstyle end ,
    biz_viewscope    = case when  @biz_viewscope=-999999999 then biz_viewscope else @biz_viewscope end 
  where biz_id=@bizid   
  
  if (@s0<>'' and @s0<>'_none_')
  begin
  declare @cat nvarchar(200) 
  select top 1 @cat = biz_category from mps_biztype where biz_id=@bizid 
  update mps_biztype set biz_icon0=@s0 where biz_cmpid=@cmpid and biz_category=@cat 
  end 
end