--V1.7.6所作升级
if exists( Select OptValue from tSysOpt where OptName='DBEdition')
begin
  Declare @DBVer varchar(10)
  Select @DBVer=OptValue from tSysOpt where OptName='DBEdition'
  Set @DBVer=Substring(@DBVer,1,4)+'-'+Substring(@DBVer,6,2)+'-'+Substring(@DBVer,9,2)
  if @DBVer>='2007-08-28'
    Return
end
 

update tSysFunc Set HelpFile='供应商结算/K0507' where FuncCode='K0507'

update tSysFunc Set HelpFile='供应商结算/K0508' where FuncCode='K0508'

update tSysFunc Set HelpFile='供应商结算/K0509' where FuncCode='K0509'

update tSysFunc Set HelpFile='采购管理/K0415' where FuncCode='K0415'


--tColumnSet
update tColumnSet Set
Caption=Case when CharIndex('批发',Caption)>0 then
SubString(Caption,1,CharIndex('批发',Caption)-1)+SubString(Caption,CharIndex('批发',Caption)+len('批发')
,Len(Caption)-CharIndex('批发',Caption)-len('批发')+1)
else Caption end
,CName=Case when CharIndex('批发',CName)>0 then
SubString(CName,1,CharIndex('批发',CName)-1)+SubString(CName,CharIndex('批发',CName)+len('批发')
,Len(CName)-CharIndex('批发',CName)-len('批发')+1)
else CName end
where cName like '%批发%' or Caption like '%批发%'


update tColumnSet Set
Caption=Case when SubString(Caption,1,1) = '价' then '售'+Caption 
when SubString(Caption,1,1) = '|' then '销售'+Caption
else Caption end
,CName=Case when SubString(CName,1,1) = '价' then '售'+CName 
when SubString(CName,1,1) = '|' then '销售'+CName
else CName end
where SubString(Cname,1,1) in ('价' ,'|') or SubString(Caption,1,1) in ('价' ,'|')

--UserRptParam
update UserRptParam Set
Caption=Case when CharIndex('批发',Caption)>0 then
SubString(Caption,1,CharIndex('批发',Caption)-1)+SubString(Caption,CharIndex('批发',Caption)+len('批发')
,Len(Caption)-CharIndex('批发',Caption)-len('批发')+1)
else Caption end
where Caption like '%批发%'

--RepItemSet

update repItemSet Set
CFieldName=Case when CharIndex('批发',CFieldName)>0 then
SubString(CFieldName,1,CharIndex('批发',CFieldName)-1)+SubString(CFieldName,CharIndex('批发',CFieldName)+len('批发')
,Len(CFieldName)-CharIndex('批发',CFieldName)-len('批发')+1)
else CFieldName end
,FieldCaption=Case when CharIndex('批发',FieldCaption)>0 then
SubString(FieldCaption,1,CharIndex('批发',FieldCaption)-1)+SubString(FieldCaption,CharIndex('批发',FieldCaption)+len('批发')
,Len(FieldCaption)-CharIndex('批发',FieldCaption)-len('批发')+1)
else FieldCaption end
where CFieldName like '%批发%' or FieldCaption like '%批发%'

update repItemSet Set
CFieldName=Case when SubString(CFieldName,1,1) = '价' then '售'+CFieldName 
when SubString(CFieldName,1,1) = '|' then '销售'+CFieldName
else CFieldName end
,FieldCaption=Case when SubString(FieldCaption,1,1) = '价' then '售'+FieldCaption 
when SubString(FieldCaption,1,1) = '|' then '销售'+FieldCaption
else FieldCaption end
where SubString(CFieldName,1,1) in ('价' ,'|') or SubString(FieldCaption,1,1) in ('价' ,'|')

--RepOtherSet

update repOtherSet Set
ItemData=Case when CharIndex('批发',ItemData)>0 then
SubString(ItemData,1,CharIndex('批发',ItemData)-1)+SubString(ItemData,CharIndex('批发',ItemData)+len('批发')
,Len(ItemData)-CharIndex('批发',ItemData)-len('批发')+1)
else ItemData end
where ItemData like '%批发%'  

--tNodeTree

update tNodeTree Set
tNodeName=Case when CharIndex('批发',tNodeName)>0 then
SubString(tNodeName,1,CharIndex('批发',tNodeName)-1)+'销售'+SubString(tNodeName,CharIndex('批发',tNodeName)+len('批发')
,Len(tNodeName)-CharIndex('批发',tNodeName)-len('批发')+1)
else tNodeName end
where tNodeName like '%批发%'  

--DelHistory

update DelHistory Set
DelName=Case 
 when  (CharIndex('批发',DelName)=CharIndex('结算',DelName)-2) then
SubString(DelName,1,CharIndex('批发',DelName)-1)+'客户'+SubString(DelName,CharIndex('批发',DelName)+len('批发')
,Len(DelName)-CharIndex('批发',DelName)-len('批发')+1)
else
SubString(DelName,1,CharIndex('批发',DelName)-1)+'销售'+SubString(DelName,CharIndex('批发',DelName)+len('批发')
,Len(DelName)-CharIndex('批发',DelName)-len('批发')+1)
 end
from DelHistory
where DelName like '%批发%'  

--InitData

update InitData Set
InitName=Case when CharIndex('批发',InitName)>0 then
SubString(InitName,1,CharIndex('批发',InitName)-1)+'售'+SubString(InitName,CharIndex('批发',InitName)+len('批发')
,Len(InitName)-CharIndex('批发',InitName)-len('批发')+1)
else InitName end
where InitName like '%批发%'  

--tProdSet
 
update tProdSet Set
CName=Case when CharIndex('批发',CName)>0 then
SubString(CName,1,CharIndex('批发',CName)-1)+''+SubString(CName,CharIndex('批发',CName)+len('批发')
,Len(CName)-CharIndex('批发',CName)-len('批发')+1)
else CName end
where CName like '%批发%'  

update tProdSet Set
CName=Case when SubString(CName,1,1) = '价' then '售'+CName 
else CName end
where SubString(CName,1,1) in ('价' ,'|')  

--UserReport
   
update UserReport Set
QryName=
Case when CharIndex('批发',QryName)>0 and (CharIndex('批发',QryName)>CharIndex('客户',QryName)) then
SubString(QryName,1,CharIndex('批发',QryName)-1)+'销售'+SubString(QryName,CharIndex('批发',QryName)+len('批发')
,Len(QryName)-CharIndex('批发',QryName)-len('批发')+1)
 when CharIndex('批发',QryName)>0  then
SubString(QryName,1,CharIndex('批发',QryName)-1)+''+SubString(QryName,CharIndex('批发',QryName)+len('批发')
,Len(QryName)-CharIndex('批发',QryName)-len('批发')+1)  
else QryName end
where QryName like '%批发%'  

--tSysFunc

update tSysFunc Set
FuncName=
Case 
--批发价 
when  (CharIndex('批发',FuncName)=CharIndex('价',FuncName)-2) then
SubString(FuncName,1,CharIndex('批发',FuncName)-1)+'售'+SubString(FuncName,CharIndex('批发',FuncName)+len('批发')
,Len(FuncName)-CharIndex('批发',FuncName)-len('批发')+1)
--批发销货
 when  (CharIndex('批发',FuncName)=CharIndex('销货',FuncName)-2) then
SubString(FuncName,1,CharIndex('批发',FuncName)-1)+''+SubString(FuncName,CharIndex('批发',FuncName)+len('批发')
,Len(FuncName)-CharIndex('批发',FuncName)-len('批发')+1)
--批发结算
 when  (CharIndex('批发',FuncName)=CharIndex('结算',FuncName)-2) then
SubString(FuncName,1,CharIndex('批发',FuncName)-1)+'客户'+SubString(FuncName,CharIndex('批发',FuncName)+len('批发')
,Len(FuncName)-CharIndex('批发',FuncName)-len('批发')+1)
--批发预收款
 when  (CharIndex('批发',FuncName)=CharIndex('预',FuncName)-2) then
SubString(FuncName,1,CharIndex('批发',FuncName)-1)+'客户'+SubString(FuncName,CharIndex('批发',FuncName)+len('批发')
,Len(FuncName)-CharIndex('批发',FuncName)-len('批发')+1)

 when CharIndex('批发',FuncName)=1  then
SubString(FuncName,1,CharIndex('批发',FuncName)-1)+''+SubString(FuncName,CharIndex('批发',FuncName)+len('批发')
,Len(FuncName)-CharIndex('批发',FuncName)-len('批发')+1)  
else 
SubString(FuncName,1,CharIndex('批发',FuncName)-1)+'销售'+SubString(FuncName,CharIndex('批发',FuncName)+len('批发')
,Len(FuncName)-CharIndex('批发',FuncName)-len('批发')+1)
end
where FuncName like '%批发%' 

Update tGridSet Set iDetail=210 where iDetail=0 and FuncCode like 'U%'

 
