if not exists(select * from syscolumns where id=object_id('SiteSetting') and name='CookieString')  
ALTER TABLE dbo.SiteSetting ADD CookieString nvarchar(4000) null
GO

if not exists(select * from syscolumns where id=object_id('SiteSetting') and name='EnableStatisticalCode')  
ALTER TABLE dbo.SiteSetting ADD EnableStatisticalCode bit not null default(1)
GO

if not exists(select * from syscolumns where id=object_id('SiteSetting') and name='WorkMode')  
ALTER TABLE dbo.SiteSetting ADD WorkMode int not null default(0)
GO

if not exists(select * from syscolumns where id=object_id('InternalSiteSearch') and name='ContentOutTemplate')  
ALTER TABLE dbo.InternalSiteSearch ADD ContentOutTemplate nvarchar(2000) null
GO

if not exists(select * from syscolumns where id=object_id('InternalSiteSearch') and name='RelatedKeywordExpression')  
ALTER TABLE dbo.InternalSiteSearch ADD RelatedKeywordExpression nvarchar(2000) null
GO

if not exists(select * from syscolumns where id=object_id('InternalSiteSearch') and name='Priority')  
ALTER TABLE dbo.InternalSiteSearch ADD Priority int not null default(10)
GO

if not exists(select * from syscolumns where id=object_id('Site') and name='CNZZCredentials')  
ALTER TABLE dbo.Site ADD CNZZCredentials nvarchar(200) null
GO

/******************************************************************
* 表名：InternalSiteSearch
* 时间：2012/12/30 19:24:03
* Made by Codematic
******************************************************************/

if exists (select * from dbo.sysobjects where id = object_id(N'[InternalSiteSearch_GetMaxId]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [InternalSiteSearch_GetMaxId]
GO
------------------------------------
--用途：得到主键字段最大值 
--项目名称：
--说明：
--时间：2012/12/30 19:24:03
------------------------------------
CREATE PROCEDURE InternalSiteSearch_GetMaxId
AS
	DECLARE @TempID int
	SELECT @TempID = max([Id])+1 FROM [InternalSiteSearch]
	IF @TempID IS NULL
		RETURN 1
	ELSE
		RETURN @TempID

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[InternalSiteSearch_Exists]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [InternalSiteSearch_Exists]
GO
------------------------------------
--用途：是否已经存在 
--项目名称：
--说明：
--时间：2012/12/30 19:24:03
------------------------------------
CREATE PROCEDURE InternalSiteSearch_Exists
@Id int
AS
	DECLARE @TempID int
	SELECT @TempID = count(1) FROM [InternalSiteSearch] WHERE Id=@Id 
	IF @TempID = 0
		RETURN 0
	ELSE
		RETURN 1

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[InternalSiteSearch_ADD]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [InternalSiteSearch_ADD]
GO
------------------------------------
--用途：增加一条记录 
--项目名称：
--说明：
--时间：2012/12/30 19:24:03
------------------------------------
CREATE PROCEDURE InternalSiteSearch_ADD
@Id int output,
@SiteId int,
@Name nvarchar(20),
@Url nvarchar(1000),
@ContentExpression nvarchar(2000),
@ChildExpression nvarchar(2000),
@Encoding nvarchar(50),
@NoResultText nvarchar(60),
@ContentTemplate nvarchar(2000),
@ContentOutTemplate nvarchar(2000),
@RelatedKeywordExpression nvarchar(2000),
@IsEnable bit,
@IsDefault bit,
@Priority int,
@CreatedOn datetime,
@UpdatedOn datetime

 AS 
	INSERT INTO [InternalSiteSearch](
	[SiteId],[Name],[Url],[ContentExpression],[ChildExpression],[Encoding],[NoResultText],[ContentTemplate],[ContentOutTemplate],[RelatedKeywordExpression],[IsEnable],[IsDefault],[Priority],[CreatedOn],[UpdatedOn]
	)VALUES(
	@SiteId,@Name,@Url,@ContentExpression,@ChildExpression,@Encoding,@NoResultText,@ContentTemplate,@ContentOutTemplate,@RelatedKeywordExpression,@IsEnable,@IsDefault,@Priority,@CreatedOn,@UpdatedOn
	)
	SET @Id = @@IDENTITY

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[InternalSiteSearch_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [InternalSiteSearch_Update]
GO
------------------------------------
--用途：修改一条记录 
--项目名称：
--说明：
--时间：2012/12/30 19:24:03
------------------------------------
CREATE PROCEDURE InternalSiteSearch_Update
@Id int,
@SiteId int,
@Name nvarchar(20),
@Url nvarchar(1000),
@ContentExpression nvarchar(2000),
@ChildExpression nvarchar(2000),
@Encoding nvarchar(50),
@NoResultText nvarchar(60),
@ContentTemplate nvarchar(2000),
@ContentOutTemplate nvarchar(2000),
@RelatedKeywordExpression nvarchar(2000),
@IsEnable bit,
@IsDefault bit,
@Priority int,
@CreatedOn datetime,
@UpdatedOn datetime
 AS 
	UPDATE [InternalSiteSearch] SET 
	[SiteId] = @SiteId,[Name] = @Name,[Url] = @Url,[ContentExpression] = @ContentExpression,[ChildExpression] = @ChildExpression,[Encoding] = @Encoding,[NoResultText] = @NoResultText,[ContentTemplate] = @ContentTemplate,[ContentOutTemplate] = @ContentOutTemplate,[RelatedKeywordExpression] = @RelatedKeywordExpression,[IsEnable] = @IsEnable,[IsDefault] = @IsDefault,[Priority] = @Priority,[CreatedOn] = @CreatedOn,[UpdatedOn] = @UpdatedOn
	WHERE Id=@Id 

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[InternalSiteSearch_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [InternalSiteSearch_Delete]
GO
------------------------------------
--用途：删除一条记录 
--项目名称：
--说明：
--时间：2012/12/30 19:24:03
------------------------------------
CREATE PROCEDURE InternalSiteSearch_Delete
@Id int
 AS 
	DELETE [InternalSiteSearch]
	 WHERE Id=@Id 

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[InternalSiteSearch_GetModel]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [InternalSiteSearch_GetModel]
GO
------------------------------------
--用途：得到实体对象的详细信息 
--项目名称：
--说明：
--时间：2012/12/30 19:24:03
------------------------------------
CREATE PROCEDURE InternalSiteSearch_GetModel
@Id int
 AS 
	SELECT 
	Id,SiteId,Name,Url,ContentExpression,ChildExpression,Encoding,NoResultText,ContentTemplate,ContentOutTemplate,RelatedKeywordExpression,IsEnable,IsDefault,Priority,CreatedOn,UpdatedOn
	 FROM [InternalSiteSearch]
	 WHERE Id=@Id 

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[InternalSiteSearch_GetList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [InternalSiteSearch_GetList]
GO
------------------------------------
--用途：查询记录信息 
--项目名称：
--说明：
--时间：2012/12/30 19:24:03
------------------------------------
CREATE PROCEDURE InternalSiteSearch_GetList
 AS 
	SELECT 
	Id,SiteId,Name,Url,ContentExpression,ChildExpression,Encoding,NoResultText,ContentTemplate,ContentOutTemplate,RelatedKeywordExpression,IsEnable,IsDefault,Priority,CreatedOn,UpdatedOn
	 FROM [InternalSiteSearch]

GO

/******************************************************************
* 表名：Site
* 时间：2012/12/30 19:20:12
* Made by Codematic
******************************************************************/

if exists (select * from dbo.sysobjects where id = object_id(N'[Site_GetMaxId]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [Site_GetMaxId]
GO
------------------------------------
--用途：得到主键字段最大值 
--项目名称：
--说明：
--时间：2012/12/30 19:20:12
------------------------------------
CREATE PROCEDURE Site_GetMaxId
AS
	DECLARE @TempID int
	SELECT @TempID = max([SiteId])+1 FROM [Site]
	IF @TempID IS NULL
		RETURN 1
	ELSE
		RETURN @TempID

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[Site_Exists]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [Site_Exists]
GO
------------------------------------
--用途：是否已经存在 
--项目名称：
--说明：
--时间：2012/12/30 19:20:12
------------------------------------
CREATE PROCEDURE Site_Exists
@SiteId int
AS
	DECLARE @TempID int
	SELECT @TempID = count(1) FROM [Site] WHERE SiteId=@SiteId 
	IF @TempID = 0
		RETURN 0
	ELSE
		RETURN 1

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[Site_ADD]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [Site_ADD]
GO
------------------------------------
--用途：增加一条记录 
--项目名称：
--说明：
--时间：2012/12/30 19:20:12
------------------------------------
CREATE PROCEDURE Site_ADD
@SiteId int output,
@SiteName nvarchar(120),
@SiteProtoco nvarchar(50),
@SitePort int,
@SiteChildDomain nvarchar(60),
@SiteRootDomain nvarchar(60),
@Keyword nvarchar(120),
@Description nvarchar(255),
@ICPNumber nvarchar(60),
@TargetSiteProtoco nvarchar(50),
@TargetSitePort int,
@TargetSiteChildDomain nvarchar(60),
@TargetSiteRootDomain nvarchar(60),
@Email nvarchar(120),
@QQ nvarchar(60),
@ForumUserName nvarchar(60),
@CNZZCredentials nvarchar(200),
@SiteStatus bit,
@AuthorizedCode nvarchar(4000),
@CreatedOn datetime,
@UpdatedOn datetime

 AS 
	INSERT INTO [Site](
	[SiteName],[SiteProtoco],[SitePort],[SiteChildDomain],[SiteRootDomain],[Keyword],[Description],[ICPNumber],[TargetSiteProtoco],[TargetSitePort],[TargetSiteChildDomain],[TargetSiteRootDomain],[Email],[QQ],[ForumUserName],[CNZZCredentials],[SiteStatus],[AuthorizedCode],[CreatedOn],[UpdatedOn]
	)VALUES(
	@SiteName,@SiteProtoco,@SitePort,@SiteChildDomain,@SiteRootDomain,@Keyword,@Description,@ICPNumber,@TargetSiteProtoco,@TargetSitePort,@TargetSiteChildDomain,@TargetSiteRootDomain,@Email,@QQ,@ForumUserName,@CNZZCredentials,@SiteStatus,@AuthorizedCode,@CreatedOn,@UpdatedOn
	)
	SET @SiteId = @@IDENTITY

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[Site_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [Site_Update]
GO
------------------------------------
--用途：修改一条记录 
--项目名称：
--说明：
--时间：2012/12/30 19:20:12
------------------------------------
CREATE PROCEDURE Site_Update
@SiteId int,
@SiteName nvarchar(120),
@SiteProtoco nvarchar(50),
@SitePort int,
@SiteChildDomain nvarchar(60),
@SiteRootDomain nvarchar(60),
@Keyword nvarchar(120),
@Description nvarchar(255),
@ICPNumber nvarchar(60),
@TargetSiteProtoco nvarchar(50),
@TargetSitePort int,
@TargetSiteChildDomain nvarchar(60),
@TargetSiteRootDomain nvarchar(60),
@Email nvarchar(120),
@QQ nvarchar(60),
@ForumUserName nvarchar(60),
@CNZZCredentials nvarchar(200),
@SiteStatus bit,
@AuthorizedCode nvarchar(4000),
@CreatedOn datetime,
@UpdatedOn datetime
 AS 
	UPDATE [Site] SET 
	[SiteName] = @SiteName,[SiteProtoco] = @SiteProtoco,[SitePort] = @SitePort,[SiteChildDomain] = @SiteChildDomain,[SiteRootDomain] = @SiteRootDomain,[Keyword] = @Keyword,[Description] = @Description,[ICPNumber] = @ICPNumber,[TargetSiteProtoco] = @TargetSiteProtoco,[TargetSitePort] = @TargetSitePort,[TargetSiteChildDomain] = @TargetSiteChildDomain,[TargetSiteRootDomain] = @TargetSiteRootDomain,[Email] = @Email,[QQ] = @QQ,[ForumUserName] = @ForumUserName,[CNZZCredentials] = @CNZZCredentials,[SiteStatus] = @SiteStatus,[AuthorizedCode] = @AuthorizedCode,[CreatedOn] = @CreatedOn,[UpdatedOn] = @UpdatedOn
	WHERE SiteId=@SiteId 

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[Site_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [Site_Delete]
GO
------------------------------------
--用途：删除一条记录 
--项目名称：
--说明：
--时间：2012/12/30 19:20:12
------------------------------------
CREATE PROCEDURE Site_Delete
@SiteId int
 AS 
	DELETE [Site]
	 WHERE SiteId=@SiteId 

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[Site_GetModel]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [Site_GetModel]
GO
------------------------------------
--用途：得到实体对象的详细信息 
--项目名称：
--说明：
--时间：2012/12/30 19:20:12
------------------------------------
CREATE PROCEDURE Site_GetModel
@SiteId int
 AS 
	SELECT 
	SiteId,SiteName,SiteProtoco,SitePort,SiteChildDomain,SiteRootDomain,Keyword,Description,ICPNumber,TargetSiteProtoco,TargetSitePort,TargetSiteChildDomain,TargetSiteRootDomain,Email,QQ,ForumUserName,CNZZCredentials,SiteStatus,AuthorizedCode,CreatedOn,UpdatedOn
	 FROM [Site]
	 WHERE SiteId=@SiteId 

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[Site_GetList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [Site_GetList]
GO
------------------------------------
--用途：查询记录信息 
--项目名称：
--说明：
--时间：2012/12/30 19:20:12
------------------------------------
CREATE PROCEDURE Site_GetList
 AS 
	SELECT 
	SiteId,SiteName,SiteProtoco,SitePort,SiteChildDomain,SiteRootDomain,Keyword,Description,ICPNumber,TargetSiteProtoco,TargetSitePort,TargetSiteChildDomain,TargetSiteRootDomain,Email,QQ,ForumUserName,CNZZCredentials,SiteStatus,AuthorizedCode,CreatedOn,UpdatedOn
	 FROM [Site]

GO


/******************************************************************
* 表名：SiteSetting
* 时间：2012/12/30 19:22:31
* Made by Codematic
******************************************************************/

if exists (select * from dbo.sysobjects where id = object_id(N'[SiteSetting_GetMaxId]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [SiteSetting_GetMaxId]
GO
------------------------------------
--用途：得到主键字段最大值 
--项目名称：
--说明：
--时间：2012/12/30 19:22:31
------------------------------------
CREATE PROCEDURE SiteSetting_GetMaxId
AS
	DECLARE @TempID int
	SELECT @TempID = max([SettingId])+1 FROM [SiteSetting]
	IF @TempID IS NULL
		RETURN 1
	ELSE
		RETURN @TempID

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[SiteSetting_Exists]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [SiteSetting_Exists]
GO
------------------------------------
--用途：是否已经存在 
--项目名称：
--说明：
--时间：2012/12/30 19:22:31
------------------------------------
CREATE PROCEDURE SiteSetting_Exists
@SettingId int
AS
	DECLARE @TempID int
	SELECT @TempID = count(1) FROM [SiteSetting] WHERE SettingId=@SettingId 
	IF @TempID = 0
		RETURN 0
	ELSE
		RETURN 1

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[SiteSetting_ADD]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [SiteSetting_ADD]
GO
------------------------------------
--用途：增加一条记录 
--项目名称：
--说明：
--时间：2012/12/30 19:22:31
------------------------------------
CREATE PROCEDURE SiteSetting_ADD
@SettingId int output,
@SiteId int,
@Name nvarchar(20),
@IsActive bit,
@HeadCode nvarchar(MAX),
@BodyCode nvarchar(MAX),
@CacheExpireTime int,
@Charset nvarchar(20),
@ForbiddenFileType nvarchar(255),
@CollectImage bit,
@FakeOriginalTitle bit,
@FakeOriginalContent bit,
@StaticExtension nvarchar(20),
@EnableBillboard bit,
@CustomInternalLinkKeyword nvarchar(255),
@InternalSearchTemplate nvarchar(50),
@SupportPandomain bit,
@UseProxy bit,
@SynchronizeIECookie bit,
@CookieString nvarchar(4000),
@EnableErrorLog bit,
@EnableStatisticalCode bit,
@WorkMode int,
@CreatedOn datetime,
@UpdatedOn datetime

 AS 
	INSERT INTO [SiteSetting](
	[SiteId],[Name],[IsActive],[HeadCode],[BodyCode],[CacheExpireTime],[Charset],[ForbiddenFileType],[CollectImage],[FakeOriginalTitle],[FakeOriginalContent],[StaticExtension],[EnableBillboard],[CustomInternalLinkKeyword],[InternalSearchTemplate],[SupportPandomain],[UseProxy],[SynchronizeIECookie],[CookieString],[EnableErrorLog],[EnableStatisticalCode],[WorkMode],[CreatedOn],[UpdatedOn]
	)VALUES(
	@SiteId,@Name,@IsActive,@HeadCode,@BodyCode,@CacheExpireTime,@Charset,@ForbiddenFileType,@CollectImage,@FakeOriginalTitle,@FakeOriginalContent,@StaticExtension,@EnableBillboard,@CustomInternalLinkKeyword,@InternalSearchTemplate,@SupportPandomain,@UseProxy,@SynchronizeIECookie,@CookieString,@EnableErrorLog,@EnableStatisticalCode,@WorkMode,@CreatedOn,@UpdatedOn
	)
	SET @SettingId = @@IDENTITY

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[SiteSetting_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [SiteSetting_Update]
GO
------------------------------------
--用途：修改一条记录 
--项目名称：
--说明：
--时间：2012/12/30 19:22:31
------------------------------------
CREATE PROCEDURE SiteSetting_Update
@SettingId int,
@SiteId int,
@Name nvarchar(20),
@IsActive bit,
@HeadCode nvarchar(MAX),
@BodyCode nvarchar(MAX),
@CacheExpireTime int,
@Charset nvarchar(20),
@ForbiddenFileType nvarchar(255),
@CollectImage bit,
@FakeOriginalTitle bit,
@FakeOriginalContent bit,
@StaticExtension nvarchar(20),
@EnableBillboard bit,
@CustomInternalLinkKeyword nvarchar(255),
@InternalSearchTemplate nvarchar(50),
@SupportPandomain bit,
@UseProxy bit,
@SynchronizeIECookie bit,
@CookieString nvarchar(4000),
@EnableErrorLog bit,
@EnableStatisticalCode bit,
@WorkMode int,
@CreatedOn datetime,
@UpdatedOn datetime
 AS 
	UPDATE [SiteSetting] SET 
	[SiteId] = @SiteId,[Name] = @Name,[IsActive] = @IsActive,[HeadCode] = @HeadCode,[BodyCode] = @BodyCode,[CacheExpireTime] = @CacheExpireTime,[Charset] = @Charset,[ForbiddenFileType] = @ForbiddenFileType,[CollectImage] = @CollectImage,[FakeOriginalTitle] = @FakeOriginalTitle,[FakeOriginalContent] = @FakeOriginalContent,[StaticExtension] = @StaticExtension,[EnableBillboard] = @EnableBillboard,[CustomInternalLinkKeyword] = @CustomInternalLinkKeyword,[InternalSearchTemplate] = @InternalSearchTemplate,[SupportPandomain] = @SupportPandomain,[UseProxy] = @UseProxy,[SynchronizeIECookie] = @SynchronizeIECookie,[CookieString] = @CookieString,[EnableErrorLog] = @EnableErrorLog,[EnableStatisticalCode] = @EnableStatisticalCode,[WorkMode] = @WorkMode,[CreatedOn] = @CreatedOn,[UpdatedOn] = @UpdatedOn
	WHERE SettingId=@SettingId 

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[SiteSetting_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [SiteSetting_Delete]
GO
------------------------------------
--用途：删除一条记录 
--项目名称：
--说明：
--时间：2012/12/30 19:22:31
------------------------------------
CREATE PROCEDURE SiteSetting_Delete
@SettingId int
 AS 
	DELETE [SiteSetting]
	 WHERE SettingId=@SettingId 

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[SiteSetting_GetModel]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [SiteSetting_GetModel]
GO
------------------------------------
--用途：得到实体对象的详细信息 
--项目名称：
--说明：
--时间：2012/12/30 19:22:31
------------------------------------
CREATE PROCEDURE SiteSetting_GetModel
@SettingId int
 AS 
	SELECT 
	SettingId,SiteId,Name,IsActive,HeadCode,BodyCode,CacheExpireTime,Charset,ForbiddenFileType,CollectImage,FakeOriginalTitle,FakeOriginalContent,StaticExtension,EnableBillboard,CustomInternalLinkKeyword,InternalSearchTemplate,SupportPandomain,UseProxy,SynchronizeIECookie,CookieString,EnableErrorLog,EnableStatisticalCode,WorkMode,CreatedOn,UpdatedOn
	 FROM [SiteSetting]
	 WHERE SettingId=@SettingId 

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[SiteSetting_GetList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [SiteSetting_GetList]
GO
------------------------------------
--用途：查询记录信息 
--项目名称：
--说明：
--时间：2012/12/30 19:22:31
------------------------------------
CREATE PROCEDURE SiteSetting_GetList
 AS 
	SELECT 
	SettingId,SiteId,Name,IsActive,HeadCode,BodyCode,CacheExpireTime,Charset,ForbiddenFileType,CollectImage,FakeOriginalTitle,FakeOriginalContent,StaticExtension,EnableBillboard,CustomInternalLinkKeyword,InternalSearchTemplate,SupportPandomain,UseProxy,SynchronizeIECookie,CookieString,EnableErrorLog,EnableStatisticalCode,WorkMode,CreatedOn,UpdatedOn
	 FROM [SiteSetting]

GO