SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Product]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Product](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[SrcDetail] [nvarchar](150) NULL,
	[SrcList] [nvarchar](150) NULL,
	[AccPrice] [decimal](18, 2) NOT NULL CONSTRAINT [DF_Web_Product_Price]  DEFAULT ((0)),
	[SqlPrice] [decimal](18, 2) NOT NULL,
	[ShortContent] [nvarchar](500) NULL,
	[Content] [ntext] NULL,
	[Type] [nvarchar](50) NULL,
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Product_IsDel]  DEFAULT ((0)),
	[OrderID] [int] NOT NULL CONSTRAINT [DF_Web_Product_OrderID]  DEFAULT ((1000)),
	[Hits] [int] NOT NULL CONSTRAINT [DF_Web_Product_Hits]  DEFAULT ((0)),
	[ImgUrl] [nvarchar](150) NULL,
	[SrcIndex] [nvarchar](150) NULL,
	[SrcIndexShow] [nvarchar](150) NULL,
	[Content_1] [ntext] NULL,
	[Content_2] [ntext] NULL,
	[Content_3] [ntext] NULL,
	[Content_4] [ntext] NULL,
	[Content_5] [ntext] NULL,
	[Content_6] [ntext] NULL,
	[Content_7] [ntext] NULL,
	[Content_8] [ntext] NULL,
	[IsRec] [bit] NOT NULL CONSTRAINT [DF_Web_Product_IsRec]  DEFAULT ((0)),
	[SrcList_1] [nvarchar](150) NULL,
	[SrcList_2] [nvarchar](150) NULL,
	[ListContent] [nvarchar](500) NULL,
	[ImgUrl_1] [nvarchar](150) NULL,
	[TestUrl] [nvarchar](150) NULL,
	[AdminUrl] [nvarchar](150) NULL,
	[DataType] [nvarchar](50) NULL,
	[AdminText] [nvarchar](250) NULL,
	[ImgUrl_2] [nvarchar](150) NULL,
	[IsIndex] [bit] NOT NULL CONSTRAINT [DF_Web_Product_IsIndex]  DEFAULT ((0)),
	[Banner] [nvarchar](150) NULL,
 CONSTRAINT [PK_Web_Product] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Money]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Money](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Price] [decimal](18, 2) NOT NULL CONSTRAINT [DF_Web_Money_Price]  DEFAULT ((0)),
	[ActDate] [datetime] NOT NULL CONSTRAINT [DF_Web_Money_Date]  DEFAULT (getdate()),
	[AgentID] [int] NOT NULL CONSTRAINT [DF_Web_Money_AgentID]  DEFAULT ((0)),
	[Remark] [nvarchar](250) NULL,
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Money_IsDel]  DEFAULT ((0)),
	[UserID] [int] NOT NULL CONSTRAINT [DF_Web_Money_UserID]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_Money] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteProductByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteProductByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Product SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Link]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Link](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[AgentID] [int] NOT NULL CONSTRAINT [DF_Web_Link_AgentID]  DEFAULT ((0)),
	[Src] [nvarchar](150) NULL,
	[Href] [nvarchar](150) NULL,
	[Title] [nvarchar](150) NULL,
	[OrderID] [int] NOT NULL CONSTRAINT [DF_Web_Link_OrderID]  DEFAULT ((1000)),
	[IsPic] [bit] NOT NULL CONSTRAINT [DF_Web_Link_IsPic]  DEFAULT ((0)),
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Link_IsDel]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_Link] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteCustomerByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteCustomerByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Customer SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteDownloadByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteDownloadByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Download SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END


' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_BaseConfig]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_BaseConfig](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](100) NULL,
	[Url] [nvarchar](100) NULL,
	[Logo] [nvarchar](150) NULL,
	[Address] [nvarchar](150) NULL,
	[ICP] [nvarchar](50) NULL,
	[Zip] [nvarchar](50) NULL,
	[Connect_1] [nvarchar](250) NULL,
	[Connect_2] [nvarchar](250) NULL,
	[Connect_3] [nvarchar](250) NULL,
	[Connect_4] [nvarchar](250) NULL,
	[Connect_5] [nvarchar](250) NULL,
	[Connect_6] [nvarchar](250) NULL,
	[Connect_7] [nvarchar](250) NULL,
	[AgentID] [int] NOT NULL CONSTRAINT [DF_Web_BaseConfig_AgentID]  DEFAULT ((0)),
	[Remark] [nvarchar](250) NULL,
	[Banner] [nvarchar](150) NULL,
 CONSTRAINT [PK_Web_BaseConfig] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Customer]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Customer](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[Src] [nvarchar](150) NULL,
	[Href] [nvarchar](150) NULL,
	[Content] [nvarchar](500) NULL,
	[OrderID] [int] NOT NULL CONSTRAINT [DF_Web_Customer_OrderID]  DEFAULT ((1000)),
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Customer_IsDel]  DEFAULT ((0)),
	[IsAdmin] [bit] NOT NULL CONSTRAINT [DF_Web_Customer_IsAdmin]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_Customer] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Log]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Log](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Date] [datetime] NOT NULL CONSTRAINT [DF_Web_Log_Date]  DEFAULT (getdate()),
	[AgentID] [int] NOT NULL CONSTRAINT [DF_Web_Log_AgentID]  DEFAULT ((0)),
	[Remark] [nvarchar](100) NULL,
	[IP] [nvarchar](50) NULL,
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Log_IsDel]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_Log] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Order]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Order](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ProductID] [int] NOT NULL CONSTRAINT [DF_Web_Order_ProductID]  DEFAULT ((0)),
	[UserID] [int] NOT NULL CONSTRAINT [DF_Web_Order_UserID]  DEFAULT ((0)),
	[AgentID] [int] NOT NULL CONSTRAINT [DF_Web_Order_AgentID]  DEFAULT ((0)),
	[Date] [datetime] NOT NULL CONSTRAINT [DF_Web_Order_Date]  DEFAULT (getdate()),
	[Price] [decimal](18, 0) NOT NULL,
	[Remark] [nvarchar](250) NULL,
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Order_IsDel]  DEFAULT ((0)),
	[Number] [nvarchar](50) NULL,
	[IsAdmin] [bit] NOT NULL CONSTRAINT [DF_Web_Order_IsAdmin]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_Order] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteAgentByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteAgentByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Agent SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END

' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteUserByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteUserByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_User SET IsDel = 1 WHERE ID IN (''+@IDS+'') AND IsAdmin = 0'')
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_News]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_News](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](100) NULL,
	[Content] [ntext] NULL,
	[Date] [datetime] NOT NULL CONSTRAINT [DF_Web_News_Date]  DEFAULT (getdate()),
	[Hits] [int] NOT NULL CONSTRAINT [DF_Web_News_Hits]  DEFAULT ((0)),
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_News_IsDel]  DEFAULT ((0)),
	[Color] [nvarchar](50) NULL CONSTRAINT [DF_Web_News_Color]  DEFAULT (N'#000000'),
	[OrderID] [int] NOT NULL CONSTRAINT [DF_Web_News_OrderID]  DEFAULT ((1000)),
	[Bold] [nvarchar](50) NOT NULL CONSTRAINT [DF_Web_News_Bold]  DEFAULT (N'normal'),
	[Category] [int] NOT NULL CONSTRAINT [DF_Web_News_Category]  DEFAULT ((0)),
	[AgentID] [int] NOT NULL CONSTRAINT [DF_Web_News_AgentID]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_News] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Category]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Category](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[HeadID] [int] NOT NULL CONSTRAINT [DF_Web_Category_HeadID]  DEFAULT ((0)),
	[Level] [int] NOT NULL CONSTRAINT [DF_Web_Category_Level]  DEFAULT ((0)),
	[OrderID] [int] NOT NULL CONSTRAINT [DF_Web_Category_OrderID]  DEFAULT ((1000)),
	[Family] [nvarchar](255) NULL,
	[SpecialOrder] [nvarchar](50) NULL,
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Category_IsDel]  DEFAULT ((0)),
	[IsAgent] [bit] NOT NULL CONSTRAINT [DF_Web_Category_IsAgentMange]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_Category] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'类别等级' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Web_Category', @level2type=N'COLUMN', @level2name=N'Level'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'类别的排序号，用于排序' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Web_Category', @level2type=N'COLUMN', @level2name=N'OrderID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'家谱，用于子分类查询' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Web_Category', @level2type=N'COLUMN', @level2name=N'Family'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteCategoryByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteCategoryByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Category SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END


' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_User]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_User](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[Tel] [nvarchar](50) NULL,
	[Address] [nvarchar](150) NULL,
	[Url] [nvarchar](150) NULL,
	[Version] [nvarchar](50) NULL,
	[QQ] [nvarchar](100) NULL,
	[AgentID] [int] NOT NULL CONSTRAINT [DF_Web_User_AgentID]  DEFAULT ((0)),
	[GUID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Web_User_GUID]  DEFAULT (newid()),
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_User_IsDel]  DEFAULT ((0)),
	[Email] [nvarchar](50) NULL,
	[MSN] [nvarchar](100) NULL,
	[Sex] [int] NOT NULL CONSTRAINT [DF_Web_User_Sex]  DEFAULT ((0)),
	[Remark] [nvarchar](250) NULL,
	[Date] [datetime] NOT NULL CONSTRAINT [DF_Web_User_Date]  DEFAULT (getdate()),
	[IsAdmin] [bit] NOT NULL CONSTRAINT [DF_Web_User_IsAdmin]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_User] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteMoneyByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteMoneyByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Money SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END


' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteLinkByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteLinkByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Link SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END


' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetNoticeById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetNoticeById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Notice
	WHERE		ID = @ID
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteOrderByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteOrderByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Order SET IsDel = 1 WHERE ID IN (''+@IDS+'') AND IsAdmin = 0'')
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Notice]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Notice](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](100) NULL,
	[Content] [ntext] NULL,
	[Date] [datetime] NOT NULL CONSTRAINT [DF_Web_Notice_Date]  DEFAULT (getdate()),
	[Hits] [int] NOT NULL CONSTRAINT [DF_Web_Notice_Hits]  DEFAULT ((0)),
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Notice_IsDel]  DEFAULT ((0)),
	[Color] [nvarchar](50) NULL CONSTRAINT [DF_Web_Notice_Color]  DEFAULT (N'#000000'),
	[OrderID] [int] NOT NULL CONSTRAINT [DF_Web_Notice_OrderID]  DEFAULT ((1000)),
	[Bold] [nvarchar](50) NOT NULL CONSTRAINT [DF_Web_Notice_IsBold]  DEFAULT (N'normal'),
 CONSTRAINT [PK_Web_Notice] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteNewsByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteNewsByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_News SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteUserByIDSAdmin]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteUserByIDSAdmin] ''0,17''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteUserByIDSAdmin] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_User SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Gbook]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Gbook](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[AgentID] [int] NOT NULL CONSTRAINT [DF_Web_Gbook_AgentID]  DEFAULT ((0)),
	[AddDate] [datetime] NOT NULL CONSTRAINT [DF_Web_Gbook_AddDate]  DEFAULT (getdate()),
	[Title] [nvarchar](100) NULL,
	[Content] [nvarchar](500) NULL,
	[IsRead] [bit] NOT NULL CONSTRAINT [DF_Web_Gbook_IsRead]  DEFAULT ((0)),
	[Remark] [nvarchar](250) NULL CONSTRAINT [DF_Web_Gbook_Remark]  DEFAULT (N'未回复'),
	[IsRemark] [bit] NOT NULL CONSTRAINT [DF_Web_Gbook_IsRemark]  DEFAULT ((0)),
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Gbook_IsDel]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_Gbook] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Text]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Text](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) NULL,
	[Content] [ntext] NULL,
	[AgentID] [int] NOT NULL CONSTRAINT [DF_Web_Text_AgentID]  DEFAULT ((0)),
	[Mark] [nvarchar](50) NULL,
 CONSTRAINT [PK_Web_Text] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteFlashByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteFlashByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Flash SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Flash]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Flash](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Src] [nvarchar](250) NULL,
	[Href] [nvarchar](250) NULL,
	[OrderID] [int] NOT NULL CONSTRAINT [DF_Web_Flash_OrderID]  DEFAULT ((1000)),
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Flash_IsDel]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_Flash] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteNoticeByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteNoticeByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Notice SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Agent]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Agent](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[LoginID] [nvarchar](50) NULL,
	[Password] [nvarchar](50) NULL,
	[AddDate] [datetime] NOT NULL CONSTRAINT [DF_Web_Agent_AddDate]  DEFAULT (getdate()),
	[LoginDate] [datetime] NOT NULL CONSTRAINT [DF_Web_Agent_LoginDate]  DEFAULT (getdate()),
	[Email] [nvarchar](50) NULL,
	[Tel] [nvarchar](50) NULL,
	[Address] [nvarchar](150) NULL,
	[Sex] [int] NOT NULL CONSTRAINT [DF_Web_Agent_Sex]  DEFAULT ((0)),
	[LoginTimes] [int] NOT NULL CONSTRAINT [DF_Web_Agent_LoginTimes]  DEFAULT ((0)),
	[Url] [nvarchar](100) NULL,
	[IP] [nvarchar](20) NULL,
	[Remark] [nvarchar](250) NULL,
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Agent_IsDel]  DEFAULT ((0)),
 CONSTRAINT [PK_Web_Agent] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeleteGbookByIDS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[DeleteAgentByIDS] ''0,111,211,113''
-- =============================================
CREATE PROCEDURE [dbo].[DeleteGbookByIDS] 
	@IDS NVARCHAR(100)
AS
BEGIN
	Exec(''UPDATE Web_Gbook SET IsDel = 1 WHERE ID IN (''+@IDS+'')'')
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Web_Download]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Web_Download](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NULL,
	[IsDel] [bit] NOT NULL CONSTRAINT [DF_Web_Download_IsDel]  DEFAULT ((0)),
	[OrderID] [int] NOT NULL CONSTRAINT [DF_Web_Download_OrderID]  DEFAULT ((1000)),
	[Src] [nvarchar](250) NULL,
	[Hits] [int] NOT NULL CONSTRAINT [DF_Web_Download_Hits]  DEFAULT ((0)),
	[Content] [nvarchar](500) NULL,
 CONSTRAINT [PK_Web_Download] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewOrderCustomer]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewOrderCustomer] 
	@ProductID	INT,
	@AgentID	INT,
	@Number		NVARCHAR(50),
	@Version	NVARCHAR(50),
	@Name		NVARCHAR(50),
	@Email		NVARCHAR(50),
	@Tel		NVARCHAR(50),
	@Address	NVARCHAR(150),
	@Sex		INT,
	@Remark		NVARCHAR(250),
	@QQ			NVARCHAR(100)
AS
BEGIN
	DECLARE		@UserID			INT,
				@ProductPrice	DECIMAL(18,2)

	--获取产品信息
	SELECT	@ProductPrice = AccPrice
	FROM	Web_Product
	WHERE	ID = @ProductID
	--插入用户取用户ID
	INSERT INTO	Web_User
		(
			AgentID,
			Version,
			[Name],
			Email,
			Tel,
			Address,
			Sex,
			Remark,
			QQ
		)
	VALUES
		(
			@AgentID,
			@Version,
			@Name,
			@Email,
			@Tel,
			@Address,
			@Sex,
			@Remark,
			@QQ
		)
	--获取最新ID
	SELECT	TOP 1 @UserID = ID
	FROM	Web_User
	ORDER BY ID DESC
	--插入订单
	INSERT INTO Web_Order
		(
			ProductID,
			UserID,
			Price,
			Remark,
			AgentID,
			Number
		)
	VALUES
		(
			@ProductID,
			@UserID,
			@ProductPrice,
			@Remark,
			@AgentID,
			@Number
		)
END













' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetProductAllIndex]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetProductAllIndex] 
	
AS
BEGIN
	SELECT		* 
	FROM		Web_Product
	WHERE		IsIndex = 1
	ORDER BY	OrderID,
				ID DESC
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetOrderAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'







-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetOrderAll] 

AS
BEGIN
	SELECT		od.*,
				u.Name AS UserName,
				p.Name AS ProductName,
				ag.Name AS AgentName
	FROM		Web_Order od
	INNER JOIN	Web_User u
		ON		u.ID = od.UserID
	INNER JOIN  Web_Product p 
		ON		p.ID = od.ProductID 
	INNER JOIN  Web_Agent ag
		ON		ag.ID = od.AgentID
	WHERE		od.IsDel = 0
	ORDER BY	od.ID DESC
END








' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetOrderAllAgent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetOrderAllAgent] 
	@ID		INT
AS
BEGIN
	SELECT		od.*,
				u.Name AS UserName,
				p.Name AS ProductName
	FROM		Web_Order od
	INNER JOIN	Web_User u
	ON			u.ID = od.UserID
	INNER JOIN  Web_Product p 
	ON			p.ID = od.ProductID 
	WHERE		od.IsDel = 0
	AND			od.AgentID = @ID
	ORDER BY	od.ID DESC
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewProduct]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'






-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewProduct] 
	@Name			NVARCHAR(50),
	@Type			NVARCHAR(50),
	@Hits			INT,
	@OrderID		INT,
	@AccPrice		DECIMAL(18,2),
	@SqlPrice		DECIMAL(18,2),
	@ImgUrl			NVARCHAR(100),
	@ShortContent	NVARCHAR(500),
	@ListContent	NVARCHAR(500),
	@Content_1		NTEXT,
	@Content_2		NTEXT,
	@Content_3		NTEXT,
	@Content_4		NTEXT,
	@Content_5		NTEXT,
	@Content_6		NTEXT,
	@Content_7		NTEXT,
	@Content_8		NTEXT,
	@IsRec			INT,
	@ImgUrl_1		NVARCHAR(150),
	@SrcIndex		NVARCHAR(150),
	@SrcIndexShow	NVARCHAR(150),
	@ImgUrl_2		NVARCHAR(150),
	@DataType		NVARCHAR(150),
	@AdminText		NVARCHAR(500),
	@TestUrl		NVARCHAR(150),
	@AdminUrl		NVARCHAR(150),
	@IsIndex		INT,
	@SrcList_1		NVARCHAR(150),
	@SrcList_2		NVARCHAR(150),
	@Banner			NVARCHAR(150)
AS
BEGIN
	INSERT INTO Web_Product
		(
			[Name],
			[Type],
			Hits,
			OrderID,
			AccPrice,
			SqlPrice,
			ImgUrl,
			ShortContent,
			Content_1,
			Content_2,
			Content_3,
			Content_4,
			Content_5,
			Content_6,
			Content_7,
			Content_8,
			ImgUrl_1,
			SrcIndex,
			SrcIndexShow,
			ListContent,
			IsRec,
			DataType,
			AdminText,
			TestUrl,
			AdminUrl,
			IsIndex,
			SrcList_1,
			SrcList_2,
			Banner
		)
	VALUES
		(
			@Name,
			@Type,
			@Hits,
			@OrderID,
			@AccPrice,
			@SqlPrice,
			@ImgUrl,
			@ShortContent,
			@Content_1,
			@Content_2,
			@Content_3,
			@Content_4,
			@Content_5,
			@Content_6,
			@Content_7,
			@Content_8,
			@ImgUrl_1,
			@SrcIndex,
			@SrcIndexShow,
			@ListContent,
			@IsRec,
			@DataType,
			@AdminText,
			@TestUrl,
			@AdminUrl,
			@IsIndex,
			@SrcList_1,
			@SrcList_2,
			@Banner
		)
END







' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateProductByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'










-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateProductByID] 
	@ID				INT,
	@Name			NVARCHAR(50),
	@Type			NVARCHAR(50),
	@Hits			INT,
	@OrderID		INT,
	@AccPrice		DECIMAL(18,2),
	@SqlPrice		DECIMAL(18,2),
	@ImgUrl			NVARCHAR(100),
	@ShortContent	NVARCHAR(500),
	@Content_1		NTEXT,
	@Content_2		NTEXT,
	@Content_3		NTEXT,
	@Content_4		NTEXT,
	@Content_5		NTEXT,
	@Content_6		NTEXT,
	@Content_7		NTEXT,
	@Content_8		NTEXT,
	@IsRec			INT,
	@SrcList_1		NVARCHAR(150),
	@SrcList_2		NVARCHAR(150),
	@ListContent	NVARCHAR(500),
	@ImgUrl_1		NVARCHAR(150),
	@SrcIndex		NVARCHAR(150),
	@SrcIndexShow	NVARCHAR(150),
	@ImgUrl_2		NVARCHAR(150),
	@DataType		NVARCHAR(150),
	@AdminText		NVARCHAR(500),
	@TestUrl		NVARCHAR(150),
	@AdminUrl		NVARCHAR(150),
	@IsIndex		INT,
	@Banner			NVARCHAR(150),
	@IsDeletePic	NVARCHAR(10)
AS
BEGIN
	--修改资料
	UPDATE	Web_Product SET
			[Name]		= @Name,
			[Type]		= @Type,
			Hits		= @Hits,
			OrderID		= @OrderID,
			AccPrice	= @AccPrice,
			SqlPrice	= @SqlPrice,
			ShortContent = @ShortContent,
			Content_1	= @Content_1,
			Content_2	= @Content_2,
			Content_3	= @Content_3,
			Content_4	= @Content_4,
			Content_5	= @Content_5,
			Content_6	= @Content_6,
			Content_7	= @Content_7,
			Content_8	= @Content_8,
			ListContent = @ListContent,
			IsRec		= @IsRec,
			DataType		= @DataType,
			AdminText		= @AdminText,
			TestUrl		= @TestUrl,
			AdminUrl		= @AdminUrl,
			IsIndex		= @IsIndex
	WHERE	ID = @ID

	IF @ImgUrl <> ''''
	BEGIN
		UPDATE	Web_Product SET
				ImgUrl = @ImgUrl
		WHERE	ID = @ID
	END

	IF @SrcList_1 <> ''''
	BEGIN
		UPDATE	Web_Product SET
				SrcList_1 = @SrcList_1
		WHERE	ID = @ID
	END

	IF @SrcList_2 <> ''''
	BEGIN
		UPDATE	Web_Product SET
				SrcList_2 = @SrcList_2
		WHERE	ID = @ID
	END

	IF @ImgUrl_1 <> ''''
	BEGIN
		UPDATE	Web_Product SET
				ImgUrl_1 = @ImgUrl_1
		WHERE	ID = @ID
	END

	IF @ImgUrl_2 <> ''''
	BEGIN
		UPDATE	Web_Product SET
				ImgUrl_2 = @ImgUrl_2
		WHERE	ID = @ID
	END

	IF @SrcIndex <> ''''
	BEGIN
		UPDATE	Web_Product SET
				SrcIndex = @SrcIndex
		WHERE	ID = @ID
	END

	IF @SrcIndexShow <> ''''
	BEGIN
		UPDATE	Web_Product SET
				SrcIndexShow = @SrcIndexShow
		WHERE	ID = @ID
	END

	IF @Banner <> ''''
	BEGIN
		UPDATE	Web_Product SET
				Banner = @Banner
		WHERE	ID = @ID
	END

	If @IsDeletePic = ''True''
	BEGIN
		UPDATE	Web_Product SET
				SrcList_2 = ''''
		WHERE	ID = @ID
	END
END











' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetProductById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetProductById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Product
	WHERE		ID = @ID
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetProductAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetProductAll] 
	
AS
BEGIN
	SELECT		* 
	FROM		Web_Product
	WHERE		IsDel = 0
	ORDER BY	OrderID,
				ID DESC
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetMoneyByIdDate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[GetMoneyByIdDate] 25,''2008-4-1'',''2010-12-31''
-- =============================================
CREATE PROCEDURE [dbo].[GetMoneyByIdDate] 
	@ID			INT,
	@StartTime	NVARCHAR(50),
	@EndTime	NVARCHAR(50)
AS
BEGIN
	SELECT		m.*, 
				(
					SELECT	Price
					FROM	Web_Money
					WHERE	ID = m.ID
					AND		Price > 0
				) AS InPrice, 
				(
					SELECT	Price
					FROM	Web_Money
					WHERE	ID = m.ID
					AND		Price < 0
				) AS OutPrice,
				Ag.Name, 
				ISNULL(U.Name, ''未选择'') AS UserName,
				U.Url,
				(
					SELECT	SUM(Price)
					FROM	Web_Money
					WHERE	ID <= m.ID
					AND		AgentID = @ID
					AND		IsDel = 0
				) AS ResultPrice
	FROM		Web_Money m
	INNER JOIN	Web_Agent Ag
	ON			Ag.ID = m.AgentID
	LEFT JOIN   Web_User U
	ON			U.ID = M.UserID
	WHERE		m.AgentID = @ID
	AND			m.IsDel = 0
	AND			DATEDIFF(d,ActDate,@StartTime) <= 0 
	AND			DATEDIFF(d,ActDate,@EndTime) >= 0 
	ORDER BY	m.ID DESC
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetAgentById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetAgentById] 
	@ID		INT
AS
BEGIN
	SELECT		* ,
				Price = (
							SELECT	SUM(Price)
							FROM	Web_Money
							WHERE	AgentID = Ag.ID
							AND		IsDel = 0
						)
	FROM		Web_Agent Ag
	WHERE		ID = @ID
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetAgentAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetAgentAll] 
	
AS
BEGIN
	SELECT		* ,
				Price = (
							SELECT	SUM(Price)
							FROM	Web_Money
							WHERE	AgentID = Ag.ID
							AND		IsDel = 0
						)
	FROM		Web_Agent Ag
	WHERE		IsDel = 0
	ORDER BY	ID DESC
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewAgent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewAgent] 
	@LoginID	NVARCHAR(50),
	@Password	NVARCHAR(50),
	@Name		NVARCHAR(50),
	@Email		NVARCHAR(50),
	@Tel		NVARCHAR(50),
	@Address	NVARCHAR(150),
	@Sex		INT,
	@Price		DECIMAL(18,2),
	@Url		NVARCHAR(100),
	@Remark		NVARCHAR(250)
AS
BEGIN
	DECLARE @AgentID INT
	--插入会员表
	INSERT INTO Web_Agent
		(
			LoginID,
			Password,
			[Name],
			Email,
			Tel,
			Address,
			Sex,
			Url,
			Remark
		)
	VALUES
		(
			@LoginID,
			@Password,
			@Name,
			@Email,
			@Tel,
			@Address,
			@Sex,
			@Url,
			@Remark
		)
	-- 获取最新ID
	SELECT TOP 1 @AgentID = ID
	FROM	Web_Agent
	ORDER BY ID DESC 
	-- 插入基本配置表
	INSERT INTO Web_BaseConfig
		(
			Url,
			AgentID
		)	
	VALUES	
		(
			@Url,
			@AgentID
		)
	-- 插入充值表
	IF @Price <> 0 
	BEGIN
		INSERT INTO Web_Money
			(
				Price,
				AgentID,
				Remark
			)	
		VALUES	
			(
				@Price,
				@AgentID,
				''代理费''
			)
	END
END


' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewMoney]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewMoney] 
	@Price		DECIMAL(18,2),
	@Remark		NVARCHAR(250),
	@AgentID	INT,
	@UserID		INT
AS
BEGIN
	INSERT INTO Web_Money
		(
			Price,
			Remark,
			AgentID,
			UserID
		)
	VALUES
		(
			@Price,
			@Remark,
			@AgentID,
			@UserID
		)
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetMoneyById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[GetMoneyById] 25
-- =============================================
CREATE PROCEDURE [dbo].[GetMoneyById] 
	@ID		INT
AS
BEGIN
	SELECT		m.*, 
				(
					SELECT	Price
					FROM	Web_Money
					WHERE	ID = m.ID
					AND		Price > 0
				) AS InPrice, 
				(
					SELECT	Price
					FROM	Web_Money
					WHERE	ID = m.ID
					AND		Price < 0
				) AS OutPrice,
				Ag.Name, 
				ISNULL(U.Name, ''未选择'') AS UserName,
				U.Url,
				(
					SELECT	SUM(Price)
					FROM	Web_Money
					WHERE	ID <= m.ID
					AND		AgentID = @ID
					AND		IsDel = 0
				) AS ResultPrice
	FROM		Web_Money m
	INNER JOIN	Web_Agent Ag
	ON			Ag.ID = m.AgentID
	LEFT JOIN   Web_User U
	ON			U.ID = M.UserID
	WHERE		m.AgentID = @ID
	AND			m.IsDel = 0
	ORDER BY	m.ID DESC
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetConfigById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetConfigById] 
	@ID			INT
AS
BEGIN
	SELECT		* 
	FROM		Web_BaseConfig
	WHERE		AgentID = @ID
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateConfigById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateConfigById] 
	@ID			INT,
	@Name		NVARCHAR(100),
	@Address	NVARCHAR(150),
	@ICP		NVARCHAR(50),
	@ZIP		NVARCHAR(150),
	@Connect_1	NVARCHAR(250),
	@Connect_2	NVARCHAR(250),
	@Remark		NVARCHAR(250),
	@Logo		NVARCHAR(150),
	@Banner		NVARCHAR(150)
AS
BEGIN
	UPDATE	Web_BaseConfig SET
			[Name] = @Name,
			Address = @Address,
			ICP = @ICP,
			ZIP = @ZIP,
			Connect_1 = @Connect_1,
			Connect_2 = @Connect_2,
			Remark = @Remark
	WHERE	AgentID = @ID

	IF @LOGO <> ''''
	BEGIN
		UPDATE	Web_BaseConfig SET
				LOGO = @LOGO
		WHERE	AgentID = @ID
	END

	IF @Banner <> ''''
	BEGIN
		UPDATE	Web_BaseConfig SET
				Banner = @Banner
		WHERE	AgentID = @ID
	END
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewLink]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'







-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
Create PROCEDURE [dbo].[InsertNewLink] 
	@Title		NVARCHAR(150),
	@Href		NVARCHAR(150),
	@Src		NVARCHAR(150),
	@OrderID	INT,
	@IsPic		INT,
	@AgentID	INT
AS
BEGIN
	INSERT INTO Web_Link
		(
			Title,
			Href,
			Src,
			OrderID,
			IsPic,
			AgentID
		)
	VALUES
		(
			@Title,
			@Href,
			@Src,
			@OrderID,
			@IsPic,
			@AgentID
		)
END








' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetLinkAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetLinkAll] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Link
	WHERE		IsDel = 0
	AND			AgentID = @ID
	ORDER BY	OrderID, ID DESC
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateLinkById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'








-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateLinkById] 
	@ID			INT,
	@Title		NVARCHAR(150),
	@Href		NVARCHAR(150),
	@Src		NVARCHAR(150),
	@OrderID	INT,
	@IsPic		INT
AS
BEGIN
	UPDATE	Web_Link SET
			Title = @Title,
			Href = @Href,
			OrderID = @OrderID,
			IsPic = @IsPic
	WHERE	ID = @ID

	IF @Src <> ''''
	BEGIN
		UPDATE	Web_Link SET
				Src = @Src
		WHERE	ID = @ID
	END
END









' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetLinkById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'








-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetLinkById] 
	@ID			INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Link
	WHERE		ID = @ID
END









' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetLinkType]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetLinkType] 
	@ID			INT,
	@IsPic		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Link
	WHERE		IsDel = 0
	AND			AgentID = @ID
	AND			IsPic = @IsPic
	ORDER BY	OrderID, ID DESC
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetCustomerCount]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'










-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetCustomerCount] 
	@Count		INT
AS
BEGIN
	SELECT		TOP(@Count)	* 
	FROM		Web_Customer
	WHERE		IsDel = 0
	ORDER BY	OrderID,
				ID DESC
END











' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetCustomerAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'









-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetCustomerAll] 

AS
BEGIN
	SELECT		* 
	FROM		Web_Customer
	WHERE		IsDel = 0
	ORDER BY	OrderID,
				ID DESC
END










' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetCustomerById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetCustomerById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Customer
	WHERE		ID = @ID
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewCustomer]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewCustomer] 
	@Name		NVARCHAR(50),
	@Href		NVARCHAR(150),
	@Src		NVARCHAR(150),
	@OrderID	INT,
	@Content	NVARCHAR(500)
AS
BEGIN
	INSERT INTO Web_Customer
		(
			[Name],
			Href,
			Src,
			OrderID,
			[Content]
		)
	VALUES
		(
			@Name,
			@Href,
			@Src,
			@OrderID,
			@Content
		)
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateCustomerById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateCustomerById] 
	@ID			INT,
	@Name		NVARCHAR(50),
	@Href		NVARCHAR(150),
	@Src		NVARCHAR(150),
	@OrderID	INT,
	@Content	NVARCHAR(500)
AS
BEGIN
	UPDATE	Web_Customer SET
			[Name] = @Name,
			Href = @Href,
			Src = @Src,
			OrderID = @OrderID,
			[Content] = @Content
	WHERE	ID = @ID
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewLog]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewLog] 
	@ID			INT,
	@Remark		NVARCHAR(100),
	@IP			NVARCHAR(50)
AS
BEGIN
	INSERT INTO Web_Log
		(
			AgentID,
			Remark,
			IP
		)
	VALUES
		(
			@ID,
			@Remark,
			@IP
		)
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetLogById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'







-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetLogById] 
	@ID			INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Log
	WHERE		AgentID = @ID
	AND			IsDel = 0
	ORDER BY	ID DESC
END








' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetLogAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'






-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetLogAll] 
	
AS
BEGIN
	SELECT		* ,
				ag.Name
	FROM		Web_Log l
	INNER JOIN	Web_Agent ag
	ON			ag.ID = l.AgentID
	WHERE		l.IsDel = 0
	ORDER BY	l.ID DESC
END







' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateOrderById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateOrderById] 
	@ID			INT,
	@ProductID	INT,
	@UserID		INT,
	@Price		DECIMAL(18,2),
	@Remark		NVARCHAR(250)
AS
BEGIN
	UPDATE	Web_Order SET
			ProductID = @ProductID,
			UserID = @UserID,
			Price = @Price,
			Remark = @Remark
	WHERE	ID = @ID
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewOrder]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewOrder] 
	@ProductID	INT,
	@UserID		INT,
	@Price		DECIMAL(18,2),
	@Remark		NVARCHAR(250),
	@IsAdmin	INT,
	@AgentID	INT,
	@Number		NVARCHAR(50)
AS
BEGIN
	INSERT INTO Web_Order
		(
			ProductID,
			UserID,
			Price,
			Remark,
			IsAdmin,
			AgentID,
			Number
		)
	VALUES
		(
			@ProductID,
			@UserID,
			@Price,
			@Remark,
			@IsAdmin,
			@AgentID,
			@Number
		)
END












' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetOrderById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'







-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetOrderById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Order
	WHERE		ID = @ID
END








' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetNewsAllAgentCategory]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'








-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetNewsAllAgentCategory] 
	@ID			INT,
	@Category	INT
AS
BEGIN
	SELECT		n.*,
				ISNULL(c.Name, ''暂无分类'') AS CategoryName
	FROM		Web_News n

	LEFT JOIN	Web_Category c
		ON			c.ID = n.Category
		AND			c.IsDel = 0

	WHERE		n.IsDel = 0
	AND			n.Category = @Category
	AND			n.AgentID = @ID
		
	ORDER BY	n.OrderID ,n.ID DESC
END









' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetNewsIndexAgent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'








-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetNewsIndexAgent] 
	@ID			INT,
	@Category	INT,
	@Count		INT
AS
BEGIN
	SELECT		TOP(@Count) *
	FROM		Web_News

	WHERE		IsDel = 0
	AND			(
						AgentID = @ID 
					OR	AgentID = 0
				) 
	AND			Category = @Category
	
	ORDER BY	OrderID ,ID DESC
END









' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetNewsAllAgent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'







-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetNewsAllAgent] 
	@ID			INT
AS
BEGIN
	SELECT		n.*,
				ISNULL(c.Name, ''暂无分类'') AS CategoryName
	FROM		Web_News n

	LEFT JOIN	Web_Category c
		ON			c.ID = n.Category
		AND			c.IsDel = 0

	WHERE		n.IsDel = 0
	AND			n.AgentID = @ID
		
	ORDER BY	n.OrderID ,n.ID DESC
END








' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewNewsAgent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'







-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewNewsAgent] 
	@Title		NVARCHAR(100),
	@Hits		INT,
	@Content	NVARCHAR(500),
	@Color		NVARCHAR(50),
	@Bold		NVARCHAR(50),
	@OrderID	INT,
	@Category	INT,
	@AgentID	INT
AS
BEGIN
	INSERT INTO Web_News
		(
			Title,
			Hits,
			[Content],
			Color,
			Bold,
			OrderID,
			Category,
			AgentID
		)
	VALUES
		(
			@Title,
			@Hits,
			@Content,
			@Color,
			@Bold,
			@OrderID,
			@Category,
			@AgentID
		)
END








' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetNewsById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'







-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetNewsById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_News
	WHERE		ID = @ID
END








' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewNews]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'






-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewNews] 
	@Title		NVARCHAR(100),
	@Hits		INT,
	@Content	NVARCHAR(500),
	@Color		NVARCHAR(50),
	@Bold		NVARCHAR(50),
	@OrderID	INT,
	@Category	INT
AS
BEGIN
	INSERT INTO Web_News
		(
			Title,
			Hits,
			[Content],
			Color,
			Bold,
			OrderID,
			Category
		)
	VALUES
		(
			@Title,
			@Hits,
			@Content,
			@Color,
			@Bold,
			@OrderID,
			@Category
		)
END







' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateNewsById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateNewsById] 
	@ID			INT,
	@Title		NVARCHAR(100),
	@Hits		INT,
	@Content	NVARCHAR(500),
	@Color		NVARCHAR(50),
	@Bold		NVARCHAR(50),
	@OrderID	INT,
	@Category	INT
AS
BEGIN
	UPDATE		Web_News
	SET			Title = @Title,
				Hits = @Hits,
				[Content] = @Content,
				Color = @Color,
				Bold = @Bold,
				OrderID = @OrderID	,
				Category = @Category	
	WHERE		ID = @ID
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetNewsAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'







-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetNewsAll] 
	
AS
BEGIN
	SELECT		n.*,
				ISNULL(c.Name, ''暂无分类'') AS CategoryName,
				ISNULL(ag.LoginID, ''总站录入'') AS AgentName
	FROM		Web_News n

	LEFT JOIN	Web_Category c
		ON			c.ID = n.Category
		AND			c.IsDel = 0

	LEFT JOIN	Web_Agent ag
		ON			ag.ID = n.AgentID
		AND			ag.IsDel = 0

	WHERE		n.IsDel = 0
	ORDER BY	n.OrderID ,n.ID DESC
END








' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetCategoryAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetCategoryAll] 
	
AS
BEGIN
	SELECT		* 
	FROM		Web_Category
	WHERE		IsDel = 0
	ORDER BY	OrderID ,ID DESC
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetCategoryById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'






-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetCategoryById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Category
	WHERE		ID = @ID
END







' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewCategory]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewCategory] 
	@Name		NVARCHAR(50),
	@OrderID	INT,
	@IsAgent	INT
AS
BEGIN
	INSERT INTO Web_Category
		(
			[Name],
			OrderID,
			IsAgent
		)
	VALUES
		(
			@Name,
			@OrderID,
			@IsAgent
		)
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateCategoryByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateCategoryByID] 
	@ID			INT,
	@Name		NVARCHAR(50),
	@OrderID	INT,
	@IsAgent	INT
AS
BEGIN
	UPDATE	Web_Category SET
			[Name] = @Name,
			OrderID = @OrderID,
			IsAgent = @IsAgent
	WHERE	ID = @ID
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetCategoryAllAgent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetCategoryAllAgent] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Category
	WHERE		IsDel = 0
	AND			IsAgent = 1
	ORDER BY	OrderID ,ID DESC
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateUserByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateUserByID] 
	@ID			INT,
	@Name		NVARCHAR(50),
	@Email		NVARCHAR(50),
	@Tel		NVARCHAR(50),
	@Address	NVARCHAR(150),
	@Sex		INT,
	@Url		NVARCHAR(100),
	@Remark		NVARCHAR(250),
	@Version	NVARCHAR(50),
	@QQ			NVARCHAR(100),
	@MSN		NVARCHAR(100)
AS
BEGIN
	--修改资料
	UPDATE	Web_User SET
			[Name] = @Name,
			Email = @Email,
			Tel = @Tel,
			Address = @Address,
			Sex = @Sex,
			Url = @Url,
			Remark = @Remark,
			Version = @Version,
			QQ = @QQ,
			MSN = @MSN
	WHERE	ID = @ID
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewUserAdmin]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewUserAdmin] 
	@AgentID	INT,
	@Version	NVARCHAR(50),
	@Name		NVARCHAR(50),
	@Email		NVARCHAR(50),
	@Tel		NVARCHAR(50),
	@Address	NVARCHAR(150),
	@Sex		INT,
	@Url		NVARCHAR(100),
	@Remark		NVARCHAR(250),
	@QQ			NVARCHAR(100),
	@MSN		NVARCHAR(100)
AS
BEGIN
	INSERT INTO Web_User
		(
			AgentID,
			Version,
			[Name],
			Email,
			Tel,
			Address,
			Sex,
			Url,
			Remark,
			QQ,
			MSN,
			IsAdmin
		)
	VALUES
		(
			@AgentID,
			@Version,
			@Name,
			@Email,
			@Tel,
			@Address,
			@Sex,
			@Url,
			@Remark,
			@QQ,
			@MSN,
			1
		)
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetUserByIdSearch]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'






-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[GetUserByIdSearch] 25,''''
-- =============================================
CREATE PROCEDURE [dbo].[GetUserByIdSearch] 
	@ID		INT,
	@Key	NVARCHAR(50)
AS
BEGIN
	IF @Key <> ''''
		SELECT		* 
		FROM		Web_User
		WHERE		AgentID = @ID
		AND			[Name] LIKE ''%'' + @Key + ''%''
		AND			IsDel = 0
		ORDER BY	ID DESC
	ELSE
		SELECT		* 
		FROM		Web_User
		WHERE		AgentID = @ID
		AND			IsDel = 0
		ORDER BY	ID DESC
END







' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewUser]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewUser] 
	@AgentID	INT,
	@Version	NVARCHAR(50),
	@Name		NVARCHAR(50),
	@Email		NVARCHAR(50),
	@Tel		NVARCHAR(50),
	@Address	NVARCHAR(150),
	@Sex		INT,
	@Url		NVARCHAR(100),
	@Remark		NVARCHAR(250),
	@QQ			NVARCHAR(100),
	@MSN		NVARCHAR(100)
AS
BEGIN
	INSERT INTO Web_User
		(
			AgentID,
			Version,
			[Name],
			Email,
			Tel,
			Address,
			Sex,
			Url,
			Remark,
			QQ,
			MSN
		)
	VALUES
		(
			@AgentID,
			@Version,
			@Name,
			@Email,
			@Tel,
			@Address,
			@Sex,
			@Url,
			@Remark,
			@QQ,
			@MSN
		)
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetUserById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetUserById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_User
	WHERE		ID = @ID
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetNewUserId]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[GetMoneyById] 25
-- =============================================
CREATE PROCEDURE [dbo].[GetNewUserId] 

AS
BEGIN
		SELECT TOP 1 *
		FROM		Web_User
		ORDER BY	ID DESC
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetUsersById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'






-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	[GetMoneyById] 25
-- =============================================
CREATE PROCEDURE [dbo].[GetUsersById] 
	@ID		INT
AS
BEGIN
	IF @ID = 0 
		SELECT		*
		FROM		Web_User
		WHERE		IsDel = 0
		ORDER BY	ID DESC
	ELSE
		SELECT		*
		FROM		Web_User
		WHERE		AgentID = @ID
		AND			IsDel = 0
		ORDER BY	ID DESC
END







' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetNoticeAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetNoticeAll] 
	
AS
BEGIN
	SELECT		* 
	FROM		Web_Notice
	WHERE		IsDel = 0
	ORDER BY	ORDERID,
				ID DESC
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateNoticeById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateNoticeById] 
	@ID			INT,
	@Title		NVARCHAR(100),
	@Hits		INT,
	@Content	NVARCHAR(500),
	@Color		NVARCHAR(50),
	@Bold		NVARCHAR(50),
	@OrderID	INT
AS
BEGIN
	UPDATE		Web_Notice
	SET			Title = @Title,
				Hits = @Hits,
				[Content] = @Content,
				Color = @Color,
				Bold = @Bold,
				OrderID = @OrderID	
	WHERE		ID = @ID
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateNoticeHitsById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateNoticeHitsById] 
	@ID		INT
AS
BEGIN
	UPDATE		Web_Notice
	SET			Hits = Hits + 1
	WHERE		ID = @ID
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewNotice]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'





-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewNotice] 
	@Title		NVARCHAR(100),
	@Hits		INT,
	@Content	NVARCHAR(500),
	@Color		NVARCHAR(50),
	@Bold		NVARCHAR(50),
	@OrderID	INT
AS
BEGIN
	INSERT INTO Web_Notice
		(
			Title,
			Hits,
			[Content],
			Color,
			Bold,
			OrderID
		)
	VALUES
		(
			@Title,
			@Hits,
			@Content,
			@Color,
			@Bold,
			@OrderID
		)
END






' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateGbookRemarkByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateGbookRemarkByID] 
	@ID			INT,
	@Remark		NVARCHAR(250)
AS
BEGIN
	--修改资料
	UPDATE	Web_Gbook SET
			Remark = @Remark
	WHERE	ID = @ID

	UPDATE	Web_Gbook SET
			IsRemark = 1
	WHERE   ID = @ID
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetGbookDetailById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetGbookDetailById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Gbook
	WHERE		ID = @ID
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateGbookByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateGbookByID] 
	@ID			INT,
	@Title		NVARCHAR(150),
	@Content	NVARCHAR(500)
AS
BEGIN
	--修改资料
	UPDATE	Web_Gbook SET
			Title = @Title,
			[Content] = @Content
	WHERE	ID = @ID
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetGbookAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'








-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetGbookAll] 

AS
BEGIN
	SELECT		g.*,
				ag.LoginID
	FROM		Web_Gbook g
	INNER JOIN	Web_Agent ag
	ON			ag.ID = g.AgentID
	WHERE		g.IsDel = 0
	ORDER BY	g.ID DESC
END









' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewGbook]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewGbook] 
	@Title		NVARCHAR(100),
	@AgentID	INT,
	@Content	NVARCHAR(500)
AS
BEGIN
	INSERT INTO Web_Gbook
		(
			Title,
			AgentID,
			[Content]
		)
	VALUES
		(
			@Title,
			@AgentID,
			@Content
		)
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetGbookById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'






-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetGbookById] 
	@ID			INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Gbook
	WHERE		AgentID = @ID
	AND			IsDel = 0
	ORDER BY	ID DESC
END







' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetFlashById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'







-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetFlashById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Flash
	WHERE		ID = @ID
END








' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetFlashAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetFlashAll] 
	
AS
BEGIN
	SELECT		* 
	FROM		Web_Flash
	WHERE		IsDel = 0
	ORDER BY	OrderID ,ID DESC
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewFlash]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'








-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewFlash] 
	@Href		NVARCHAR(250),
	@Src		NVARCHAR(250),
	@OrderID	INT
AS
BEGIN
	INSERT INTO Web_Flash
		(
			Href,
			Src,
			OrderID
		)
	VALUES
		(
			@Href,
			@Src,
			@OrderID
		)
END









' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateFlashById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'








-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateFlashById] 
	@ID			INT,
	@Href		NVARCHAR(250),
	@Src		NVARCHAR(250),
	@OrderID	INT
AS
BEGIN
	UPDATE	Web_Flash SET
			Href = @Href,
			OrderID = @OrderID
	WHERE	ID = @ID

	IF @Src <> ''''
	BEGIN
		UPDATE	Web_Flash SET
				Src = @Src
		WHERE	ID = @ID
	END
END









' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetAgentIdByUrl]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetAgentIdByUrl] 
	@Url		NVARCHAR(150)
AS
BEGIN
	SELECT		ID
	FROM		Web_Agent
	WHERE		Url = @Url
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateAgentByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateAgentByID] 
	@ID			INT,
	@Password	NVARCHAR(50),
	@Name		NVARCHAR(50),
	@Email		NVARCHAR(50),
	@Tel		NVARCHAR(50),
	@Address	NVARCHAR(150),
	@Sex		INT,
	@Url		NVARCHAR(100),
	@Remark		NVARCHAR(250)
AS
BEGIN
	DECLARE @AgentID INT
	--修改资料
	UPDATE	Web_Agent SET
			[Name] = @Name,
			Email = @Email,
			Tel = @Tel,
			Address = @Address,
			Sex = @Sex,
			Url = @Url,
			Remark = @Remark
	WHERE	ID = @ID
	-- 修改密码
	IF @Password <> ''''
	BEGIN
		UPDATE	Web_Agent SET
			Password = @Password
		WHERE	ID = @ID	
	END
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetUserByIdPass]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'




-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetUserByIdPass] 
	@LoginID	NVARCHAR(50),
	@Password	NVARCHAR(50)
AS
BEGIN
	SELECT		* 
	FROM		Web_Agent
	WHERE		LoginID = @LoginID
	AND			Password = @Password
END





' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetDownloadById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetDownloadById] 
	@ID		INT
AS
BEGIN
	SELECT		* 
	FROM		Web_Download
	WHERE		ID = @ID
END




' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[InsertNewDownload]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewDownload] 
	@Name		NVARCHAR(50),
	@OrderID	INT,
	@Hits		INT,
	@Src		NVARCHAR(100),
	@Content	NVARCHAR(500)
AS
BEGIN
	INSERT INTO Web_Download
		(
			[Name],
			OrderID,
			Hits,
			Src,
			[Content]
		)
	VALUES
		(
			@Name,
			@OrderID,
			@Hits,
			@Src,
			@Content
		)
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UpdateDownloadById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[UpdateDownloadById] 
	@ID			INT,
	@Name		NVARCHAR(50),
	@OrderID	INT,
	@Hits		INT,
	@Src		NVARCHAR(100),
	@Content	NVARCHAR(500)
AS
BEGIN
	Update	Web_Download  SET
			[Name] = @Name,
			OrderID = @OrderID,
			Hits = @Hits,
			Src = @Src,
			[Content] = @Content
	WHERE	ID = @ID
END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[GetDownloadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'



-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	InsertNewAgent ''1111'',''2222''
-- =============================================
CREATE PROCEDURE [dbo].[GetDownloadAll] 
	
AS
BEGIN
	SELECT		* 
	FROM		Web_Download
	WHERE		IsDel = 0
	ORDER BY	OrderID,ID DESC
END




' 
END
