USE [Vertragsverwaltung]
GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_Insert]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_MADetails_Insert]
GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_Update]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_MADetails_Update]
GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_Delete]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_MADetails_Delete]
GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_SelectOne]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_MADetails_SelectOne]
GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_SelectAll]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_MADetails_SelectAll]
GO

/****** Object:  StoredProcedure [dbo].[pr_OE_Insert]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_OE_Insert]
GO

/****** Object:  StoredProcedure [dbo].[pr_OE_Update]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_OE_Update]
GO

/****** Object:  StoredProcedure [dbo].[pr_OE_Delete]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_OE_Delete]
GO

/****** Object:  StoredProcedure [dbo].[pr_OE_SelectOne]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_OE_SelectOne]
GO

/****** Object:  StoredProcedure [dbo].[pr_OE_SelectAll]    Script Date: 01.03.2014 11:47:44 ******/
DROP PROCEDURE [dbo].[pr_OE_SelectAll]
GO

/****** Object:  StoredProcedure [dbo].[pr_OE_SelectAll]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will select all rows from the table 'OE'
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_OE_SelectAll]
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- SELECT all rows from the table.
SELECT
	[OeNr],
	[ParentId],
	[Bezeichnung],
	[Kuerzel],
	[Beschreibung],
	[Aktiv],
	[Erstellt_am],
	[Mutiert_am],
	[Mutierer],
	[Sortierung],
	[Planwert_RTB_Team],
	[Reduktion_Nicht_Verrechenbar]
FROM [dbo].[OE]
ORDER BY 
	[OeNr] ASC
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

/****** Object:  StoredProcedure [dbo].[pr_OE_SelectOne]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will select an existing row from the table 'OE'
-- based on the Primary Key.
-- Gets: @iOeNr int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_OE_SelectOne]
	@iOeNr int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- SELECT an existing row from the table.
SELECT
	[OeNr],
	[ParentId],
	[Bezeichnung],
	[Kuerzel],
	[Beschreibung],
	[Aktiv],
	[Erstellt_am],
	[Mutiert_am],
	[Mutierer],
	[Sortierung],
	[Planwert_RTB_Team],
	[Reduktion_Nicht_Verrechenbar]
FROM [dbo].[OE]
WHERE
	[OeNr] = @iOeNr
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

/****** Object:  StoredProcedure [dbo].[pr_OE_Delete]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will delete an existing row from the table 'OE'
-- using the Primary Key. 
-- Gets: @iOeNr int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_OE_Delete]
	@iOeNr int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- DELETE an existing row from the table.
DELETE FROM [dbo].[OE]
WHERE
	[OeNr] = @iOeNr
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

/****** Object:  StoredProcedure [dbo].[pr_OE_Update]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will update an existing row in the table 'OE'
-- Gets: @iOeNr int
-- Gets: @iParentId int
-- Gets: @sBezeichnung varchar(50)
-- Gets: @sKuerzel varchar(50)
-- Gets: @sBeschreibung varchar(1024)
-- Gets: @bAktiv bit
-- Gets: @daErstellt_am datetime
-- Gets: @daMutiert_am datetime
-- Gets: @iMutierer int
-- Gets: @iSortierung int
-- Gets: @iPlanwert_RTB_Team int
-- Gets: @iReduktion_Nicht_Verrechenbar int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_OE_Update]
	@iOeNr int,
	@iParentId int,
	@sBezeichnung varchar(50),
	@sKuerzel varchar(50),
	@sBeschreibung varchar(1024),
	@bAktiv bit,
	@daErstellt_am datetime,
	@daMutiert_am datetime,
	@iMutierer int,
	@iSortierung int,
	@iPlanwert_RTB_Team int,
	@iReduktion_Nicht_Verrechenbar int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- UPDATE an existing row in the table.
UPDATE [dbo].[OE]
SET 
	[ParentId] = @iParentId,
	[Bezeichnung] = @sBezeichnung,
	[Kuerzel] = @sKuerzel,
	[Beschreibung] = @sBeschreibung,
	[Aktiv] = @bAktiv,
	[Erstellt_am] = @daErstellt_am,
	[Mutiert_am] = @daMutiert_am,
	[Mutierer] = @iMutierer,
	[Sortierung] = @iSortierung,
	[Planwert_RTB_Team] = @iPlanwert_RTB_Team,
	[Reduktion_Nicht_Verrechenbar] = @iReduktion_Nicht_Verrechenbar
WHERE
	[OeNr] = @iOeNr
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

/****** Object:  StoredProcedure [dbo].[pr_OE_Insert]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will insert 1 row in the table 'OE'
-- Gets: @iOeNr int
-- Gets: @iParentId int
-- Gets: @sBezeichnung varchar(50)
-- Gets: @sKuerzel varchar(50)
-- Gets: @sBeschreibung varchar(1024)
-- Gets: @bAktiv bit
-- Gets: @daErstellt_am datetime
-- Gets: @daMutiert_am datetime
-- Gets: @iMutierer int
-- Gets: @iSortierung int
-- Gets: @iPlanwert_RTB_Team int
-- Gets: @iReduktion_Nicht_Verrechenbar int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_OE_Insert]
	@iOeNr int,
	@iParentId int,
	@sBezeichnung varchar(50),
	@sKuerzel varchar(50),
	@sBeschreibung varchar(1024),
	@bAktiv bit,
	@daErstellt_am datetime,
	@daMutiert_am datetime,
	@iMutierer int,
	@iSortierung int,
	@iPlanwert_RTB_Team int,
	@iReduktion_Nicht_Verrechenbar int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- INSERT a new row in the table.
INSERT [dbo].[OE]
(
	[OeNr],
	[ParentId],
	[Bezeichnung],
	[Kuerzel],
	[Beschreibung],
	[Aktiv],
	[Erstellt_am],
	[Mutiert_am],
	[Mutierer],
	[Sortierung],
	[Planwert_RTB_Team],
	[Reduktion_Nicht_Verrechenbar]
)
VALUES
(
	@iOeNr,
	@iParentId,
	@sBezeichnung,
	@sKuerzel,
	@sBeschreibung,
	@bAktiv,
	@daErstellt_am,
	@daMutiert_am,
	@iMutierer,
	@iSortierung,
	@iPlanwert_RTB_Team,
	@iReduktion_Nicht_Verrechenbar
)
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_SelectAll]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will select all rows from the table 'MADetails'
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_MADetails_SelectAll]
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- SELECT all rows from the table.
SELECT
	[MADetailNr],
	[MANr],
	[MitarbeiterTypNr],
	[OENr],
	[Engagement],
	[Gueltig_ab],
	[Bemerkung],
	[Aktiv],
	[Erstellt_am],
	[Mutiert_am],
	[Mutierer],
	[Individuelle_Reduktion],
	[Individuelle_Reduktion_Bemerkung],
	[Planwert_Anteil_RTB_Person]
FROM [dbo].[MADetails]
ORDER BY 
	[MADetailNr] ASC
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_SelectOne]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will select an existing row from the table 'MADetails'
-- based on the Primary Key.
-- Gets: @iMADetailNr int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_MADetails_SelectOne]
	@iMADetailNr int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- SELECT an existing row from the table.
SELECT
	[MADetailNr],
	[MANr],
	[MitarbeiterTypNr],
	[OENr],
	[Engagement],
	[Gueltig_ab],
	[Bemerkung],
	[Aktiv],
	[Erstellt_am],
	[Mutiert_am],
	[Mutierer],
	[Individuelle_Reduktion],
	[Individuelle_Reduktion_Bemerkung],
	[Planwert_Anteil_RTB_Person]
FROM [dbo].[MADetails]
WHERE
	[MADetailNr] = @iMADetailNr
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_Delete]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will delete an existing row from the table 'MADetails'
-- using the Primary Key. 
-- Gets: @iMADetailNr int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_MADetails_Delete]
	@iMADetailNr int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- DELETE an existing row from the table.
DELETE FROM [dbo].[MADetails]
WHERE
	[MADetailNr] = @iMADetailNr
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_Update]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will update an existing row in the table 'MADetails'
-- Gets: @iMADetailNr int
-- Gets: @iMANr int
-- Gets: @iMitarbeiterTypNr int
-- Gets: @iOENr int
-- Gets: @iEngagement int
-- Gets: @daGueltig_ab datetime
-- Gets: @sBemerkung varchar(1024)
-- Gets: @bAktiv bit
-- Gets: @daErstellt_am datetime
-- Gets: @daMutiert_am datetime
-- Gets: @iMutierer int
-- Gets: @iIndividuelle_Reduktion int
-- Gets: @sIndividuelle_Reduktion_Bemerkung varchar(1024)
-- Gets: @iPlanwert_Anteil_RTB_Person int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_MADetails_Update]
	@iMADetailNr int,
	@iMANr int,
	@iMitarbeiterTypNr int,
	@iOENr int,
	@iEngagement int,
	@daGueltig_ab datetime,
	@sBemerkung varchar(1024),
	@bAktiv bit,
	@daErstellt_am datetime,
	@daMutiert_am datetime,
	@iMutierer int,
	@iIndividuelle_Reduktion int,
	@sIndividuelle_Reduktion_Bemerkung varchar(1024),
	@iPlanwert_Anteil_RTB_Person int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- UPDATE an existing row in the table.
UPDATE [dbo].[MADetails]
SET 
	[MANr] = @iMANr,
	[MitarbeiterTypNr] = @iMitarbeiterTypNr,
	[OENr] = @iOENr,
	[Engagement] = @iEngagement,
	[Gueltig_ab] = @daGueltig_ab,
	[Bemerkung] = @sBemerkung,
	[Aktiv] = @bAktiv,
	[Erstellt_am] = @daErstellt_am,
	[Mutiert_am] = @daMutiert_am,
	[Mutierer] = @iMutierer,
	[Individuelle_Reduktion] = @iIndividuelle_Reduktion,
	[Individuelle_Reduktion_Bemerkung] = @sIndividuelle_Reduktion_Bemerkung,
	[Planwert_Anteil_RTB_Person] = @iPlanwert_Anteil_RTB_Person
WHERE
	[MADetailNr] = @iMADetailNr
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

/****** Object:  StoredProcedure [dbo].[pr_MADetails_Insert]    Script Date: 01.03.2014 11:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


---------------------------------------------------------------------------------
-- Stored procedure that will insert 1 row in the table 'MADetails'
-- Gets: @iMADetailNr int
-- Gets: @iMANr int
-- Gets: @iMitarbeiterTypNr int
-- Gets: @iOENr int
-- Gets: @iEngagement int
-- Gets: @daGueltig_ab datetime
-- Gets: @sBemerkung varchar(1024)
-- Gets: @bAktiv bit
-- Gets: @daErstellt_am datetime
-- Gets: @daMutiert_am datetime
-- Gets: @iMutierer int
-- Gets: @iIndividuelle_Reduktion int
-- Gets: @sIndividuelle_Reduktion_Bemerkung varchar(1024)
-- Gets: @iPlanwert_Anteil_RTB_Person int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_MADetails_Insert]
	@iMADetailNr int,
	@iMANr int,
	@iMitarbeiterTypNr int,
	@iOENr int,
	@iEngagement int,
	@daGueltig_ab datetime,
	@sBemerkung varchar(1024),
	@bAktiv bit,
	@daErstellt_am datetime,
	@daMutiert_am datetime,
	@iMutierer int,
	@iIndividuelle_Reduktion int,
	@sIndividuelle_Reduktion_Bemerkung varchar(1024),
	@iPlanwert_Anteil_RTB_Person int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- INSERT a new row in the table.
INSERT [dbo].[MADetails]
(
	[MADetailNr],
	[MANr],
	[MitarbeiterTypNr],
	[OENr],
	[Engagement],
	[Gueltig_ab],
	[Bemerkung],
	[Aktiv],
	[Erstellt_am],
	[Mutiert_am],
	[Mutierer],
	[Individuelle_Reduktion],
	[Individuelle_Reduktion_Bemerkung],
	[Planwert_Anteil_RTB_Person]
)
VALUES
(
	@iMADetailNr,
	@iMANr,
	@iMitarbeiterTypNr,
	@iOENr,
	@iEngagement,
	@daGueltig_ab,
	@sBemerkung,
	@bAktiv,
	@daErstellt_am,
	@daMutiert_am,
	@iMutierer,
	@iIndividuelle_Reduktion,
	@sIndividuelle_Reduktion_Bemerkung,
	@iPlanwert_Anteil_RTB_Person
)
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR

GO

