USE [Vertragsverwaltung_20160404] GO /****** Object: StoredProcedure [dbo].[sp_update_CheckedListBoxData] Script Date: 02.12.2016 09:08:53 ******/ DROP PROCEDURE [dbo].[sp_update_CheckedListBoxData] GO /****** Object: StoredProcedure [dbo].[sp_update_CheckedListBoxData] Script Date: 02.12.2016 09:08:55 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE PROCEDURE [dbo].[sp_update_CheckedListBoxData] @mitarbeiternr int, @key int, @applikationsnr int, @typ int, @Checked int as SET NOCOUNT ON; -- Installationstyp/Installationauf if @typ=1 begin if @checked=0 begin delete from applikationinstallationtyp where applikationnr=@applikationsnr and installationtypnr=@key end if @checked=1 begin select ApplikationInstallationNr from applikationinstallationtyp where applikationnr=@applikationsnr and installationtypnr=@key if @@rowcount = 0 begin insert applikationinstallationtyp(applikationnr, installationtypnr, aktiv, erstellt_am, mutiert_am, mutierer) values (@applikationsnr, @key, 1,getdate(), getdate(),@mitarbeiternr) end end end -- Installationals if @typ=2 begin if @checked=0 begin delete from applikationinstallationals where applikationnr=@applikationsnr and installationalstypnr=@key end if @checked=1 begin select ApplikationInstallationAlsTypNr from applikationinstallationals where applikationnr=@applikationsnr and installationalstypnr=@key if @@rowcount = 0 begin insert applikationinstallationals(applikationnr, installationalstypnr, aktiv, erstellt_am, mutiert_am, mutierer) values (@applikationsnr, @key, 1,getdate(), getdate(),@mitarbeiternr) end end end -- StandardFuer if @typ=3 begin if @checked=0 begin delete from applikationinstallationfuer where applikationnr=@applikationsnr and ApplikationStandardTypNr=@key end if @checked=1 begin select ApplikationInstallationfuerNr from applikationinstallationfuer where applikationnr=@applikationsnr and ApplikationStandardTypNr=@key if @@rowcount = 0 begin insert applikationinstallationfuer(applikationnr, ApplikationStandardTypNr, aktiv, erstellt_am, mutiert_am, mutierer) values (@applikationsnr, @key, 1,getdate(), getdate(),@mitarbeiternr) end end end -- Applikation_ApplikationAbhaengigkeit if @typ=4 begin if @checked=0 begin delete from applikationapplikationabhaengigkeit where applikationnr=@applikationsnr and ApplikationAbhaengigkeitTyp=@key end if @checked=1 begin select ApplikationApplikationAbhaengigkeit from ApplikationApplikationAbhaengigkeit where applikationnr=@applikationsnr and ApplikationAbhaengigkeitTyp=@key if @@rowcount = 0 begin insert applikationapplikationabhaengigkeit(applikationnr, ApplikationAbhaengigkeitTyp, aktiv, erstellt_am, mutiert_am, mutierer) values (@applikationsnr, @key, 1,getdate(), getdate(),@mitarbeiternr) end end end GO