CREATE PROCEDURE AjouterPanier
 @ID int OUTPUT,
 @UserId int,
 @Nom varchar(50),
 @Status int,
 @DateAchat datetime,
 @Type int
AS
 INSERT INTO Panier(UserId,Nom,Status,DateAchat,Type)
  VALUES(@UserId,@Nom,@Status,@DateAchat,@Type)
 SET @ID=@@IDENTITY
RETURN
GO
CREATE PROCEDURE ModifierPanier
 @ID int,
 @UserId int,
 @Nom varchar(50),
 @Status int,
 @DateAchat datetime,
 @Type int
AS
 IF(@ID IS NULL OR @ID=0)
  RAISERROR('Identifiant requis !',16,1)
 ELSE  UPDATE Panier
        SET UserId=@UserId,Nom=@Nom,Status=@Status,DateAchat=@DateAchat,Type=@Type
        WHERE ID=@ID
RETURN
GO
CREATE PROCEDURE SelectionnerPanier
 @Index VARCHAR(10)
AS
 IF(@Index='UserId') SELECT * FROM Panier ORDER BY UserId
 ELSE IF(@Index='Nom') SELECT * FROM Panier ORDER BY Nom
 ELSE IF(@Index='Status') SELECT * FROM Panier ORDER BY Status
 ELSE IF(@Index='DateAchat') SELECT * FROM Panier ORDER BY DateAchat
 ELSE IF(@Index='Type') SELECT * FROM Panier ORDER BY Type
 ELSE SELECT * FROM Panier ORDER BY ID
RETURN
GO
CREATE PROCEDURE SelectionnerPanier_ID
 @ID int
AS
 IF(@ID IS NULL)
  RAISERROR('Identifiant requis !',16,1)
 ELSE
  SELECT ID,UserId,Nom,Status,DateAchat,Type
  FROM Panier
  WHERE @ID=ID
RETURN
GO
CREATE PROCEDURE SupprimerPanier
 @ID int
AS
 IF(@ID IS NULL)
  RAISERROR('Identifiant requis !',16,1)
 ELSE
  DELETE FROM Panier WHERE @ID=ID
RETURN
GO
