-- 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.
--

--------------------------------------------------------------------------------------------------------
-- Mandantendaten abrufen (auf dem Proxy)
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P' and [name] = 'itcproc_WebMandant_get')
  DROP PROCEDURE [dbo].[itcproc_WebMandant_get]
GO
CREATE PROCEDURE [dbo].[itcproc_WebMandant_get]
  @Parm_Knr varchar(20)
 ,@Parm_Uid varchar(30)
 ,@Parm_KnrFilter varchar(20)
AS
  select m.Knr, m.Descr, m.Uri, m.SubUri, a.Name1, a.Name2, a.Strasse, a.Ort, a.EMail from dbo.ut_WebMandant m 
    left join dbo.ut_Adressen a on a.DESTDEBNR = m.Knr
  where m.Knr = @Parm_Knr and m.Locked = 0 and @Parm_KnrFilter = @Parm_Knr
GO

-------------------------------------------------------------------------------------------------------
-- Mandanten updaten (auf dem Proxy)
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'itcproc_WebMandant_update')
  DROP PROCEDURE [dbo].[itcproc_WebMandant_update]
GO
CREATE PROCEDURE [dbo].[itcproc_WebMandant_update]
  @Parm_Knr varchar(20)
 ,@Parm_Uid varchar(30)  -- Nutzer, der den Aufruf gestarted hat
 ,@Parm_KnrFilter varchar(30) -- Kunde, um den es geht
 ,@Parm_Descr varchar(50)
 ,@Parm_Uri varchar(200)  -- wird aktualisiert
 ,@Parm_SubUri varchar(200)  -- wird aktualisiert
 ,@Parm_Name1 varchar(40)
 ,@Parm_Name2 varchar(40)
 ,@Parm_Strasse varchar(40)
 ,@Parm_Ort varchar(40)
 ,@Parm_Email varchar(80)
AS
  UPDATE [dbo].[ut_WebMandant] SET 
    [Uri] = @Parm_Uri, [SubUri] = @Parm_SubUri  
  where Knr = @Parm_Knr and Locked = 0 and @Parm_KnrFilter = @Parm_Knr
GO

-------------------------------------------------------------------------------------------------------
