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

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

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

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[NSBook]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[NSBook]
GO
--51aspx.com
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[NSDep]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[NSDep]
GO

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

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

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

CREATE TABLE [dbo].[NSBook] (
	[NSBookID] [int] IDENTITY (1, 1) NOT NULL ,
	[NSBookName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[NSBookImage] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NSDep] (
	[NSDepID] [int] IDENTITY (1, 1) NOT NULL ,
	[NSDepName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[NSDepMaster] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[NSDepAdd] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NSUser] (
	[NSUserID] [int] IDENTITY (1, 1) NOT NULL ,
	[NSDepID] [int] NOT NULL ,
	[NSNickName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[NSUserName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[NSUserPwd] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[NSNoAdmin] [varchar] (4) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NSBookDe] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[NSBookID] [int] NOT NULL ,
	[NSDepID] [int] NOT NULL ,
	[NSBookName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[NSBookInfo] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[NSBookPrice] [decimal](18, 0) NULL ,
	[NSBookNum] [decimal](18, 0) NOT NULL ,
	[NSBookDate] [datetime] NOT NULL ,
	[NSBookSH] [datetime] NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[NSSale] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[NSBookID] [int] NOT NULL ,
	[NSDepID] [int] NOT NULL ,
	[NSSaleNum] [decimal](18, 0) NOT NULL ,
	[NSStartTime] [datetime] NOT NULL ,
	[NSEndTime] [datetime] NOT NULL 
) ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


CREATE PROCEDURE [insert_NSBookDe_1]

	(@NSBookID	[int],
	 @NSDepID       [int],
	 
	 @NSBookName 	[varchar](50),
 
	 @NSBookInfo    [varchar](200),
	 @NSBookPrice   [decimal](9),
 	 @NSBookNum     [decimal](9),
	 @NSBookDate 	[DateTime],
	 @NSBookSH 	[DateTime])

AS INSERT INTO [NScontract].[dbo].[NSBookDe] 
	 ([NSBookID],
	 [NSDepID],
	 [NSBookName],
	  [NSBookInfo],
	 [NSBookPrice],
	
	 [NSBookNum],
	 [NSBookDate],
	 [NSBookSH]) 
 
VALUES 
	(@NSBookID,
	 @NSDepID,
	 @NSBookName,
	
	 @NSBookInfo,
	 @NSBookPrice,
	 @NSBookNum,
	 @NSBookDate,
	 @NSBookSH)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO


CREATE PROCEDURE [insert_NSSale_1]

	(@NSDepID       [int],
	 @NSBookID	[int],
	 @NSSaleNum 	[Decimal](9),
	 @NSStartTime 	[DateTime],
	 @NSEndTime 	[DateTime])

AS INSERT INTO [NScontract].[dbo].[NSSale] 
	 ([NSDepID],
	[NSBookID],
	 [NSSaleNum],
	 [NSStartTime],
	 [NSEndTime]) 
 
VALUES 
	(@NSDepID,
	@NSBookID,
	 @NSSaleNum,
	 @NSStartTime,
	 @NSEndTime)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO


CREATE PROCEDURE [insert_NSUser_1]

	(@NSDepID       [int],
	@NSNickName	[varchar](50),
	 @NSUserName 	[varchar](50),
	 @NSUserPwd 	[varchar](50),
	 @NSNoAdmin 	[int])

AS INSERT INTO [NScontract].[dbo].[NSUser] 
	 ([NSDepID],
	[NSNickName],
	 [NSUserName],
	 [NSUserPwd],
	 [NSNoAdmin]) 
 
VALUES 
	(@NSDepID,
	@NSNickName,
	 @NSUserName,
	 @NSUserPwd,
	 @NSNoAdmin)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

-- 51aspx
CREATE PROCEDURE [update_NSBookDe_1]
	(@ID           int, 
	 @NSBookID     int,
	 @NSDepID      int,
	 @NSBookName   [varchar](50),	
	 @NSBookInfo   [varchar](200),
	 @NSBookPrice  [decimal](9),
	 @NSBookNum    [decimal](9),
	 @NSBookDate     [decimal](9),
	 @NSBookSH     [datetime])

AS UPDATE [STcontract].[dbo].[NSBookDe] 

SET 	 
	 [NSBookID]   = @NSBookID, 
	 [NSDepID]   = @NSDepID,
	 [NSBookName]	 = @NSBookName,	
	 [NSBookInfo]	 = @NSBookInfo,
	 [NSBookPrice]	 = @NSBookPrice, 
	 [NSBookNum]	 = @NSBookNum,
	 [NSBookDate]	 = @NSBookDate,
	 [NSBookSH]      = @NSBookSH
WHERE

         ([ID] = @ID)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

