CREATE PROCEDURE AjouterArticle
 @ID int OUTPUT,
 @Designation varchar(50),
 @Stock int,
 @Visible bit,
 @Actif bit,
 @PrixHTVA money
AS
 INSERT INTO Article(Designation,Stock,Visible,Actif,PrixHTVA)
  VALUES(@Designation,@Stock,@Visible,@Actif,@PrixHTVA)
 SET @ID=@@IDENTITY
RETURN
GO
CREATE PROCEDURE ModifierArticle
 @ID int,
 @Designation varchar(50),
 @Stock int,
 @Visible bit,
 @Actif bit,
 @PrixHTVA money
AS
 IF(@ID IS NULL OR @ID=0)
  RAISERROR('Identifiant requis !',16,1)
 ELSE  UPDATE Article
        SET Designation=@Designation,Stock=@Stock,Visible=@Visible,Actif=@Actif,PrixHTVA=@PrixHTVA
        WHERE ID=@ID
RETURN
GO
CREATE PROCEDURE SelectionnerArticle
 @Index VARCHAR(10)
AS
 IF(@Index='Designation') SELECT * FROM Article ORDER BY Designation
 ELSE IF(@Index='Stock') SELECT * FROM Article ORDER BY Stock
 ELSE IF(@Index='Visible') SELECT * FROM Article ORDER BY Visible
 ELSE IF(@Index='Actif') SELECT * FROM Article ORDER BY Actif
 ELSE IF(@Index='PrixHTVA') SELECT * FROM Article ORDER BY PrixHTVA
 ELSE SELECT * FROM Article ORDER BY ID
RETURN
GO
CREATE PROCEDURE SelectionnerArticle_ID
 @ID int
AS
 IF(@ID IS NULL)
  RAISERROR('Identifiant requis !',16,1)
 ELSE
  SELECT ID,Designation,Stock,Visible,Actif,PrixHTVA
  FROM Article
  WHERE @ID=ID
RETURN
GO
CREATE PROCEDURE SupprimerArticle
 @ID int
AS
 IF(@ID IS NULL)
  RAISERROR('Identifiant requis !',16,1)
 ELSE
  DELETE FROM Article WHERE @ID=ID
RETURN
GO
