You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
161 lines
9.9 KiB
161 lines
9.9 KiB
USE [Vertragsverwaltung_20160404]
|
|
GO
|
|
/****** Object: UserDefinedFunction [dbo].[Get_Type] Script Date: 02.12.2016 09:08:53 ******/
|
|
DROP FUNCTION [dbo].[Get_Type]
|
|
GO
|
|
/****** Object: UserDefinedFunction [dbo].[Get_Type] Script Date: 02.12.2016 09:08:55 ******/
|
|
SET ANSI_NULLS ON
|
|
GO
|
|
SET QUOTED_IDENTIFIER ON
|
|
GO
|
|
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date, ,>
|
|
-- Description: <Description, ,>
|
|
-- =============================================
|
|
CREATE FUNCTION [dbo].[Get_Type]
|
|
|
|
(
|
|
|
|
@typ int,
|
|
|
|
@det varchar(25),
|
|
|
|
@applnr int
|
|
|
|
)
|
|
|
|
RETURNS varchar(50)
|
|
|
|
AS
|
|
|
|
BEGIN
|
|
|
|
declare @ret varchar(50)
|
|
|
|
declare @cnt int
|
|
|
|
declare @user varchar(50)
|
|
|
|
if @typ=1 begin
|
|
|
|
if @det='TS' select @cnt=count(*) from ApplikationInstallationTyp where applikationnr=@applnr and installationtypnr=1 and aktiv = 1
|
|
|
|
if @det='Filer' select @cnt=count(*) from ApplikationInstallationTyp where applikationnr=@applnr and installationtypnr=2 and aktiv = 1
|
|
|
|
if @det='FAT (paketiert)' select @cnt=count(*) from ApplikationInstallationTyp where applikationnr=@applnr and installationtypnr=3 and aktiv = 1
|
|
|
|
if @det='FAT Manuell' select @cnt=count(*) from ApplikationInstallationTyp where applikationnr=@applnr and installationtypnr=4 and aktiv = 1
|
|
|
|
if @det='Web-Server' select @cnt=count(*) from ApplikationInstallationTyp where applikationnr=@applnr and installationtypnr=5 and aktiv = 1
|
|
|
|
if @det='Standalone' select @cnt=count(*) from ApplikationInstallationTyp where applikationnr=@applnr and installationtypnr=6 and aktiv = 1
|
|
|
|
if @det='externe URL' select @cnt=count(*) from ApplikationInstallationTyp where applikationnr=@applnr and installationtypnr=7 and aktiv = 1
|
|
|
|
|
|
if @cnt>0 set @ret='X' else set @ret=''
|
|
|
|
|
|
return @ret
|
|
|
|
end
|
|
|
|
|
|
|
|
if @typ=2 begin
|
|
|
|
if @det='SPF' select @cnt=count(*) from ApplikationInstallationals where applikationnr=@applnr and installationalstypnr=1 and aktiv=1
|
|
|
|
if @det='IPF' select @cnt=count(*) from ApplikationInstallationals where applikationnr=@applnr and installationalstypnr=2 and aktiv=1
|
|
|
|
if @det='NL' select @cnt=count(*) from ApplikationInstallationals where applikationnr=@applnr and installationalstypnr=3 and aktiv=1
|
|
|
|
if @det='HS' select @cnt=count(*) from ApplikationInstallationals where applikationnr=@applnr and installationalstypnr=4 and aktiv=1
|
|
|
|
if @det='CC' select @cnt=count(*) from ApplikationInstallationals where applikationnr=@applnr and installationalstypnr=5 and aktiv=1
|
|
|
|
if @det='Handel' select @cnt=count(*) from ApplikationInstallationals where applikationnr=@applnr and installationalstypnr=6 and aktiv=1
|
|
|
|
if @cnt>0 set @ret='X' else set @ret=''
|
|
|
|
return @ret
|
|
|
|
end
|
|
|
|
|
|
|
|
if @typ=3 begin
|
|
|
|
if @det='PK' select @cnt=count(*) from ApplikationInstallationFuer where applikationnr=@applnr and ApplikationStandardTypNr=1 and aktiv=1
|
|
|
|
if @det='FK' select @cnt=count(*) from ApplikationInstallationFuer where applikationnr=@applnr and ApplikationStandardTypNr=2 and aktiv=1
|
|
|
|
if @det='PBI'select @cnt=count(*) from ApplikationInstallationFuer where applikationnr=@applnr and ApplikationStandardTypNr=3 and aktiv=1
|
|
|
|
if @det='Stab' select @cnt=count(*) from ApplikationInstallationFuer where applikationnr=@applnr and ApplikationStandardTypNr=4 and aktiv=1
|
|
|
|
if @cnt>0 set @ret='X' else set @ret=''
|
|
|
|
return @ret
|
|
|
|
end
|
|
|
|
|
|
|
|
if @typ=4 begin
|
|
|
|
if @det='Key_User' begin
|
|
|
|
SELECT @ret=dbo.Person.Name + ' ' + dbo.Person.Vorname
|
|
|
|
FROM dbo.ApplikationKontakt INNER JOIN
|
|
|
|
dbo.Person ON dbo.ApplikationKontakt.PersonNr = dbo.Person.PersonNr
|
|
|
|
WHERE (dbo.ApplikationKontakt.Aktiv = 1) AND (dbo.ApplikationKontakt.Applikationnr = @applnr) AND (dbo.ApplikationKontakt.KontakttypNr = 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
if @det='Key_User_Stv' begin
|
|
|
|
SELECT @ret=dbo.Person.Name + ' ' + dbo.Person.Vorname
|
|
|
|
FROM dbo.ApplikationKontakt INNER JOIN
|
|
|
|
dbo.Person ON dbo.ApplikationKontakt.PersonNr = dbo.Person.PersonNr
|
|
|
|
WHERE (dbo.ApplikationKontakt.Aktiv =1 ) AND (dbo.ApplikationKontakt.Applikationnr = @applnr) AND (dbo.ApplikationKontakt.KontakttypNr = 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
if @det='Fachvertreter' begin
|
|
|
|
SELECT @ret=dbo.Person.Name + ' ' + dbo.Person.Vorname
|
|
|
|
FROM dbo.ApplikationKontakt INNER JOIN
|
|
|
|
dbo.Person ON dbo.ApplikationKontakt.PersonNr = dbo.Person.PersonNr
|
|
|
|
WHERE (dbo.ApplikationKontakt.Aktiv = 1) AND (dbo.ApplikationKontakt.Applikationnr = @applnr) AND (dbo.ApplikationKontakt.KontakttypNr = 3)
|
|
|
|
end
|
|
|
|
return @ret
|
|
|
|
end
|
|
|
|
return @ret
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
|
GO
|