-- This file is part of the it-crafts software and is subject to copyright protection.
-- (C) 2023, All rights reserved by Steffen Anders, Elsteraue - Germany
-- Visit also https://www.it-crafts.de.
--

----------------------------------------------------------------------------------------------
--
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'V' and [name] = 'itcview_MitarbeiterAuswahl')
  DROP VIEW [dbo].[itcview_MitarbeiterAuswahl]
GO
CREATE VIEW [dbo].[itcview_MitarbeiterAuswahl] AS
  SELECT a.RecId, a.DESTDEBNR, a.Annr, a.VorName, a.Name1, a.KostSt, a.Telefon1, a.Telefon2, a.EMail
  FROM ut_Adressen a WHERE DESTTYP = ' 4'
GO

--------------------------------------------------------------------------------------------------------
-- MitarbeiterAuswahl abrufen
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P' and [name] = 'itcproc_MitarbeiterAuswahl_get')
  DROP PROCEDURE [dbo].[itcproc_MitarbeiterAuswahl_get]
GO
CREATE PROCEDURE [dbo].[itcproc_MitarbeiterAuswahl_get]
  @Parm_Knr varchar(20)  
 ,@Parm_Uid varchar(30)  -- fuer spaetere Verwendung als Filter
 ,@Parm_Filter  varchar(40) = '%'
 ,@Parm_Sorting varchar(20) = 'Annr'
AS
  If @Parm_Sorting = 'Name1'
    SELECT * FROM [dbo].[itcview_MitarbeiterAuswahl] WHERE Name1 LIKE @Parm_Filter ORDER BY Name1
  ELSE
    SELECT * FROM [dbo].[itcview_MitarbeiterAuswahl] WHERE Annr LIKE @Parm_Filter ORDER BY Annr
GO

