if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Products_Categories]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[Products] DROP CONSTRAINT FK_Products_Categories
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Orders_Customers]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[Orders] DROP CONSTRAINT FK_Orders_Customers
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Employees_Employees]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[Employees] DROP CONSTRAINT FK_Employees_Employees
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Orders_Employees]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[Orders] DROP CONSTRAINT FK_Orders_Employees
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Order_Details_Orders]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[OrderDetails] DROP CONSTRAINT FK_Order_Details_Orders
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Order_Details_Products]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[OrderDetails] DROP CONSTRAINT FK_Order_Details_Products
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_ShoppingCart_Products]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[ShoppingCart] DROP CONSTRAINT FK_ShoppingCart_Products
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Orders_Shippers]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[Orders] DROP CONSTRAINT FK_Orders_Shippers
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Products_Suppliers]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[Products] DROP CONSTRAINT FK_Products_Suppliers
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Add_To_Cart]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Add_To_Cart]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Authenticate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Authenticate]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Delete_Cart_Item]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Delete_Cart_Item]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Get_Cart]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Get_Cart]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Get_Cart_Item_Count]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Get_Cart_Item_Count]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Get_Cart_Total]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Get_Cart_Total]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Get_Categories]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Get_Categories]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Get_Customer]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Get_Customer]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Get_Product_Details]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Get_Product_Details]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Get_Products_By_Category]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Get_Products_By_Category]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Insert_Customer]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Insert_Customer]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Insert_Order]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Insert_Order]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Insert_Order_Details]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Insert_Order_Details]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Update_Cart_Item]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Update_Cart_Item]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Update_Customer]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_Update_Customer]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[vw_Cart_Products]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[vw_Cart_Products]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[vw_Categories_Products]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[vw_Categories_Products]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Categories]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Categories]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Customers]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Customers]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Employees]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Employees]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[OrderDetails]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[OrderDetails]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Orders]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Orders]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Products]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Products]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Region]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Region]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Shippers]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Shippers]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ShoppingCart]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ShoppingCart]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Suppliers]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Suppliers]
GO

CREATE TABLE [dbo].[Categories] (
	[CategoryID] [int] NOT NULL ,
	[CategoryName] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[Description] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Picture] [image] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


CREATE TABLE [dbo].[Employees] (
	[EmployeeID] [int] IDENTITY (1, 1) NOT NULL ,
	[LastName] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[FirstName] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[Title] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[TitleOfCourtesy] [nvarchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[BirthDate] [datetime] NULL ,
	[HireDate] [datetime] NULL ,
	[Address] [nvarchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[City] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Region] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[PostalCode] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Country] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[HomePhone] [nvarchar] (24) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Extension] [nvarchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Photo] [image] NULL ,
	[Notes] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[ReportsTo] [int] NULL ,
	[PhotoPath] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[OrderDetails] (
	[OrderID] [int] NOT NULL ,
	[ProductID] [int] NOT NULL ,
	[UnitPrice] [money] NOT NULL ,
	[Quantity] [smallint] NOT NULL ,
	[Discount] [real] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Orders] (
	[OrderID] [int] IDENTITY (1, 1) NOT NULL ,
	[CustomerID] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[EmployeeID] [int] NULL ,
	[OrderDate] [datetime] NULL ,
	[RequiredDate] [datetime] NULL ,
	[ShippedDate] [datetime] NULL ,
	[ShipVia] [int] NULL ,
	[Freight] [money] NULL ,
	[ShipName] [nvarchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[ShipAddress] [nvarchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[ShipCity] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[ShipRegion] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[ShipPostalCode] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[ShipCountry] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Products] (
	[ProductID] [int] IDENTITY (1, 1) NOT NULL ,
	[ProductName] [nvarchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[SupplierID] [int] NULL ,
	[CategoryID] [int] NULL ,
	[QuantityPerUnit] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[UnitPrice] [money] NULL ,
	[UnitsInStock] [smallint] NULL ,
	[UnitsOnOrder] [smallint] NULL ,
	[ReorderLevel] [smallint] NULL ,
	[Discontinued] [bit] NOT NULL ,
	[Description] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[ImageURL] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Region] (
	[RegionID] [int] NOT NULL ,
	[RegionDescription] [nchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Shippers] (
	[ShipperID] [int] IDENTITY (1, 1) NOT NULL ,
	[CompanyName] [nvarchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[Phone] [nvarchar] (24) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[ShoppingCart] (
	[PKID] [int] IDENTITY (1, 1) NOT NULL ,
	[CartID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[ProductID] [int] NOT NULL ,
	[Quantity] [int] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Suppliers] (
	[SupplierID] [int] IDENTITY (1, 1) NOT NULL ,
	[CompanyName] [nvarchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[ContactName] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[ContactTitle] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Address] [nvarchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[City] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Region] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[PostalCode] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Country] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Phone] [nvarchar] (24) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Fax] [nvarchar] (24) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[HomePage] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.vw_Categories_Products
AS
SELECT     TOP 100 PERCENT dbo.Categories.CategoryID, dbo.Categories.CategoryName, dbo.Products.ProductName, dbo.Products.UnitPrice, 
                      dbo.Products.QuantityPerUnit, dbo.Products.UnitsInStock, dbo.Products.ProductID, dbo.Products.Discontinued, dbo.Products.Description, 
                      dbo.Products.ImageURL, dbo.Products.UnitsOnOrder, dbo.Products.ReorderLevel
FROM         dbo.Categories INNER JOIN
                      dbo.Products ON dbo.Categories.CategoryID = dbo.Products.CategoryID
WHERE     (dbo.Products.Discontinued <> 1)
ORDER BY dbo.Categories.CategoryName, dbo.Products.ProductName

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.vw_Cart_Products
AS
SELECT     dbo.ShoppingCart.Quantity, dbo.ShoppingCart.CartID, dbo.ShoppingCart.ProductID, dbo.Products.ProductName, dbo.Products.UnitPrice, 
                      dbo.Products.Description, dbo.ShoppingCart.Quantity * dbo.Products.UnitPrice AS TotalDue, dbo.Products.QuantityPerUnit
FROM         dbo.ShoppingCart INNER JOIN
                      dbo.Products ON dbo.ShoppingCart.ProductID = dbo.Products.ProductID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE sp_Add_To_Cart
		@CartID varchar(50),
		@ProductID int,
		@Quantity int
	 AS

	Insert into ShoppingCart(CartID, ProductID, Quantity)
		Values(@CartID, @ProductID, @Quantity)

		return 1
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE sp_Delete_Cart_Item
		@CartID varchar(50),
		@ProductID int

	As
		Delete from ShoppingCart
		Where
			CartID = @CartID AND ProductID = @ProductID

		Return @@rowcount
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE sp_Get_Cart @cartID varchar(50) AS

	Select * from vw_Cart_Products Where CartID = @cartID

	return @@rowcount
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE sp_Get_Cart_Item_Count
		@CartID varchar(50),
		@ProductID int,
		@ItemCount int OUTPUT
 AS

	Select @ItemCount = Quantity
		From ShoppingCart 
		Where ProductID = @ProductID and CartID = @CartID
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

 CREATE Procedure sp_Get_Cart_Total @CartID varchar(50), 
					@CartSum money OUTPUT
	AS
           		SELECT @CartSum = SUM(UnitPrice * Quantity)
	FROM
               	vw_Cart_Products
           WHERE
                	CartID = @CartID
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE sp_Get_Categories AS

	Select CategoryID, CategoryName, Description
		From Categories
		Order By CategoryID DESC

		Return @@rowcount
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE sp_Get_Customer @CustomerID varchar(50) AS

	Select * from Customers 
		Where CustomerID = @CustomerID

		return @@rowcount
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE sp_Get_Product_Details @productID int AS

	Select * from vw_Categories_Products
		Where productID = @productID
		
		return @@rowcount
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE sp_Get_Products_By_Category @categoryID int AS

	Select * from vw_Categories_Products 
		Where CategoryID = @categoryID

	return @@rowcount
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE sp_Insert_Customer
	(@CustomerID 	nvarchar(50),
	 @CompanyName 	nvarchar(40),
	 @ContactName 	nvarchar(30),
	 @ContactTitle 	nvarchar(30),
	 @Address 	nvarchar(60),
	 @City 	nvarchar(15),
	 @Region 	nvarchar(15),
	 @PostalCode 	nvarchar(10),
	 @Country 	nvarchar(15),
	 @Phone 	nvarchar(24),
	 @Fax 	nvarchar(24),
	 @Email 	nvarchar(50),
	 @Password 	nvarchar(50))

AS INSERT INTO Customers 
	 ( CustomerID,
	 CompanyName,
	 ContactName,
	 ContactTitle,
	 Address,
	 City,
	 Region,
	 PostalCode,
	 Country,
	 Phone,
	 Fax,
	 Email,
	 Password) 
 
VALUES 
	( @CustomerID,
	 @CompanyName,
	 @ContactName,
	 @ContactTitle,
	 @Address,
	 @City,
	 @Region,
	 @PostalCode,
	 @Country,
	 @Phone,
	 @Fax,
	 @Email,
	 @Password)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE sp_Insert_Order
	(@CustomerID 	nvarchar(50),
	 @EmployeeID 	int,
	 @OrderDate 	datetime,
	 @RequiredDate 	datetime,
	 @ShippedDate 	datetime,
	 @ShipVia 	int,
	 @Freight 	money,
	 @ShipName 	nvarchar(40),
	 @ShipAddress 	nvarchar(60),
	 @ShipCity 	nvarchar(15),
	 @ShipRegion 	nvarchar(15),
	 @ShipPostalCode 	nvarchar(10),
	 @ShipCountry 	nvarchar(15))

AS INSERT INTO Orders 
	 ( CustomerID,
	 EmployeeID,
	 OrderDate,
	 RequiredDate,
	 ShippedDate,
	 ShipVia,
	 Freight,
	 ShipName,
	 ShipAddress,
	 ShipCity,
	 ShipRegion,
	 ShipPostalCode,
	 ShipCountry) 
 
VALUES 
	( @CustomerID,
	 @EmployeeID,
	 @OrderDate,
	 @RequiredDate,
	 @ShippedDate,
	 @ShipVia,
	 @Freight,
	 @ShipName,
	 @ShipAddress,
	 @ShipCity,
	 @ShipRegion,
	 @ShipPostalCode,
	 @ShipCountry)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE sp_Insert_Order_Details
	(@ProductID 	int,
	 @UnitPrice 	money,
	 @Quantity 	smallint,
	 @Discount 	real)

AS INSERT INTO OrderDetails
	 ( ProductID,
	 UnitPrice,
	 Quantity,
	 Discount) 
 
VALUES 
	( @ProductID,
	 @UnitPrice,
	 @Quantity,
	 0)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE sp_Update_Cart_Item
		@CartID varchar(50),
		@ProductID int,
		@Quantity int
 AS

	Update ShoppingCart set Quantity = @Quantity
		Where CartID = @CartID and ProductID = @ProductID
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

