Skip to content

Commit

Permalink
Merge pull request #5 from amrkh97/Feature-Positions
Browse files Browse the repository at this point in the history
Feature positions
  • Loading branch information
amrkh97 committed Sep 11, 2019
2 parents 2e7a84c + 6bad246 commit 560496a
Show file tree
Hide file tree
Showing 4 changed files with 696 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

*.json

.vscode/settings.json
82 changes: 82 additions & 0 deletions CombinedSP.sql
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,85 @@ AND PaymentYear = @Year
END
GO
--------------------------------------------------------------------------------------------------


CREATE OR ALTER PROC usp_Positions_Add
@PositionName NVARCHAR(100),
@PositionDescription NVARCHAR(500),
@HexCode NVARCHAR(2) OUTPUT,
@HexMsg NVARCHAR(100) OUTPUT
AS
BEGIN

IF EXISTS(SELECT * FROM Positions WHERE PositionName = @PositionName)
BEGIN
SET @HexCode ='01'
SET @HexMsg = 'Position Already Exists'
RETURN -1
END

INSERT INTO Positions
(
PositionName,
PositionDescription
)
VALUES
(
@PositionName,
@PositionDescription
)


IF NOT EXISTS(SELECT * FROM Positions WHERE PositionName = @PositionName)
BEGIN
SET @HexCode ='01'
SET @HexMsg = 'Failed To Add Position'
RETURN -1
END


SET @HexCode = '00'
SET @HexMsg = 'Position Added Successfully!'
END
GO


CREATE OR ALTER PROC usp_Positions_GetAll
AS
BEGIN

SELECT * FROM Positions

END
GO

CREATE OR ALTER PROC usp_Positions_EditDescription
@PositionID INT,
@PositionDescription NVARCHAR(500),
@HexCode NVARCHAR(2) OUTPUT,
@HexMsg NVARCHAR(100) OUTPUT
AS
BEGIN

IF NOT EXISTS(SELECT * FROM Positions WHERE ID = @PositionID)
BEGIN
SET @HexCode = '01'
SET @HexMsg = 'Position Does Not Exist, Check Position ID'
RETURN -1
END

UPDATE Positions
SET PositionDescription = @PositionDescription
WHERE ID = @PositionID

IF NOT EXISTS(SELECT * FROM Positions WHERE ID = @PositionID AND PositionDescription = @PositionDescription)
BEGIN
SET @HexCode = '01'
SET @HexMsg = 'Position Update Failed!'
RETURN -1
END

SET @HexCode = '00'
SET @HexMsg = 'Description Updated Successfully!'
END
GO
83 changes: 83 additions & 0 deletions Positions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
USE RAC_SARAYAT
GO

CREATE OR ALTER PROC usp_Positions_Add
@PositionName NVARCHAR(100),
@PositionDescription NVARCHAR(500),
@HexCode NVARCHAR(2) OUTPUT,
@HexMsg NVARCHAR(100) OUTPUT
AS
BEGIN

IF EXISTS(SELECT * FROM Positions WHERE PositionName = @PositionName)
BEGIN
SET @HexCode ='01'
SET @HexMsg = 'Position Already Exists'
RETURN -1
END

INSERT INTO Positions
(
PositionName,
PositionDescription
)
VALUES
(
@PositionName,
@PositionDescription
)


IF NOT EXISTS(SELECT * FROM Positions WHERE PositionName = @PositionName)
BEGIN
SET @HexCode ='01'
SET @HexMsg = 'Failed To Add Position'
RETURN -1
END


SET @HexCode = '00'
SET @HexMsg = 'Position Added Successfully!'
END
GO


CREATE OR ALTER PROC usp_Positions_GetAll
AS
BEGIN

SELECT * FROM Positions

END
GO

CREATE OR ALTER PROC usp_Positions_EditDescription
@PositionID INT,
@PositionDescription NVARCHAR(500),
@HexCode NVARCHAR(2) OUTPUT,
@HexMsg NVARCHAR(100) OUTPUT
AS
BEGIN

IF NOT EXISTS(SELECT * FROM Positions WHERE ID = @PositionID)
BEGIN
SET @HexCode = '01'
SET @HexMsg = 'Position Does Not Exist, Check Position ID'
RETURN -1
END

UPDATE Positions
SET PositionDescription = @PositionDescription
WHERE ID = @PositionID

IF NOT EXISTS(SELECT * FROM Positions WHERE ID = @PositionID AND PositionDescription = @PositionDescription)
BEGIN
SET @HexCode = '01'
SET @HexMsg = 'Position Update Failed!'
RETURN -1
END

SET @HexCode = '00'
SET @HexMsg = 'Description Updated Successfully!'
END
GO
Loading

0 comments on commit 560496a

Please sign in to comment.