USE [master]
GO
IF NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'CMS_123')
BEGIN
CREATE DATABASE [CMS_123] ON  PRIMARY 
( NAME = N'CMS_1232_Data', FILENAME = N'E:\CMS_1232_Data.MDF' , SIZE = 3008KB , MAXSIZE = UNLIMITED, FILEGROWTH = 10%)
 LOG ON 
( NAME = N'CMS_1232_Log', FILENAME = N'E:\CMS_1232_Log.LDF' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 10%)
END

GO
EXEC dbo.sp_dbcmptlevel @dbname=N'CMS_123', @new_cmptlevel=80
GO
ALTER DATABASE [CMS_123] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [CMS_123] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [CMS_123] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [CMS_123] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [CMS_123] SET ARITHABORT OFF 
GO
ALTER DATABASE [CMS_123] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [CMS_123] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [CMS_123] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [CMS_123] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [CMS_123] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [CMS_123] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [CMS_123] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [CMS_123] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [CMS_123] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [CMS_123] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [CMS_123] SET  READ_WRITE 
GO
ALTER DATABASE [CMS_123] SET RECOVERY FULL 
GO
ALTER DATABASE [CMS_123] SET  MULTI_USER 
GO
ALTER DATABASE [CMS_123] SET TORN_PAGE_DETECTION ON 
USE [CMS_123]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_AdminOpt]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_AdminOpt](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[OptTime] [datetime] NULL CONSTRAINT [DF_T_Opt_OptTime]  DEFAULT (getdate()),
	[OptDes] [varchar](50) NULL,
	[OptUID] [int] NULL,
 CONSTRAINT [PK_T_AdminOpt] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'操作日志ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminOpt', @level2type=N'COLUMN', @level2name=N'ID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'操作日志时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminOpt', @level2type=N'COLUMN', @level2name=N'OptTime'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'操作描述' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminOpt', @level2type=N'COLUMN', @level2name=N'OptDes'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'操作人员名称' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminOpt', @level2type=N'COLUMN', @level2name=N'OptUID'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_AdminRole]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_AdminRole](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[RoleTitle] [nvarchar](50) NOT NULL,
	[Power] [nvarchar](2000) NULL,
	[MenuPower] [nvarchar](2000) NULL,
	[IsLock] [bit] NOT NULL CONSTRAINT [DF_T_AdminRole_IsLock]  DEFAULT (0),
	[IsDelete] [bit] NOT NULL CONSTRAINT [DF_T_AdminRole_IsDelete]  DEFAULT (0),
 CONSTRAINT [PK_T_AdminRole] 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'T_AdminRole', @level2type=N'COLUMN', @level2name=N'RoleTitle'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'权限' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminRole', @level2type=N'COLUMN', @level2name=N'Power'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否锁定(0)开放,(1)冻结' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminRole', @level2type=N'COLUMN', @level2name=N'IsLock'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否删除(0)存在(1)删除' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminRole', @level2type=N'COLUMN', @level2name=N'IsDelete'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_AdminUser]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_AdminUser](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[UserID] [nvarchar](50) NOT NULL,
	[PassWord] [nvarchar](50) NOT NULL,
	[UserName] [nvarchar](50) NULL,
	[LoginTimes] [int] NOT NULL CONSTRAINT [DF_T_AdminUser_LoginTimes]  DEFAULT (0),
	[LatestLoginTime] [datetime] NULL,
	[LatestLoginIP] [nvarchar](50) NULL,
	[RoleID] [bigint] NOT NULL CONSTRAINT [DF_T_AdminUser_RoleID]  DEFAULT (0),
	[Power] [nvarchar](2000) NULL,
	[MenuPower] [nvarchar](2000) NULL,
	[IsLock] [bit] NOT NULL CONSTRAINT [DF_T_AdminUser_IsLock]  DEFAULT (0),
	[IsDelete] [bit] NOT NULL CONSTRAINT [DF_T_AdminUser_IsDelete]  DEFAULT (0),
 CONSTRAINT [PK_T_AdminUser] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员ID序号' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'ID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'UserID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员密码' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'PassWord'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'管理员名字' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'UserName'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'登陆次数' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'LoginTimes'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'最后登陆时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'LatestLoginTime'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'最后登陆IP' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'LatestLoginIP'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'RoleID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'权限' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'Power'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'动态栏目的权限' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'MenuPower'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否锁定(0)开放(1)锁定 ' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'IsLock'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否删除(0)存在(1)删除' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_AdminUser', @level2type=N'COLUMN', @level2name=N'IsDelete'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_Advertisement]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_Advertisement](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) NOT NULL,
	[AdvPic] [nvarchar](50) NULL,
	[AdvUrl] [nvarchar](50) NULL,
	[ClickNum] [int] NULL CONSTRAINT [DF_T_Advertisement_ClickNum]  DEFAULT (0),
	[IsHidden] [bit] NULL CONSTRAINT [DF_T_Advertisement_IsHidden]  DEFAULT (0),
	[IsTop] [bit] NULL,
	[IsLeft] [bit] NULL CONSTRAINT [DF_T_Advertisement_IsLeft]  DEFAULT (0),
	[IsRight] [bit] NULL CONSTRAINT [DF_T_Advertisement_IsRight]  DEFAULT (0),
	[IsFloat] [bit] NULL,
	[IsPop] [bit] NULL CONSTRAINT [DF_T_Advertisement_IsPop]  DEFAULT (0),
 CONSTRAINT [PK_T_Advertisement] 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'T_Advertisement', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'广告图片地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Advertisement', @level2type=N'COLUMN', @level2name=N'AdvPic'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'广告地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Advertisement', @level2type=N'COLUMN', @level2name=N'AdvUrl'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'点击率' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Advertisement', @level2type=N'COLUMN', @level2name=N'ClickNum'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否隐藏' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Advertisement', @level2type=N'COLUMN', @level2name=N'IsHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否顶部广告' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Advertisement', @level2type=N'COLUMN', @level2name=N'IsTop'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否左边广告' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Advertisement', @level2type=N'COLUMN', @level2name=N'IsLeft'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否右边广告' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Advertisement', @level2type=N'COLUMN', @level2name=N'IsRight'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否浮动广告' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Advertisement', @level2type=N'COLUMN', @level2name=N'IsFloat'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否弹出广告' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Advertisement', @level2type=N'COLUMN', @level2name=N'IsPop'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_Config]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_Config](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[DefaultLanguageID] [int] NOT NULL CONSTRAINT [DF_T_Config_DefaultLanguageID]  DEFAULT (0),
	[LanguageIDList] [nvarchar](50) NULL,
	[CoverState] [bit] NOT NULL CONSTRAINT [DF_T_Config_CoverState]  DEFAULT (0),
	[CompanyName] [nvarchar](200) NULL,
	[CompanyNameCN] [nvarchar](200) NULL,
	[CompanyShortName] [nvarchar](100) NULL,
	[CompanyShortNameCN] [nvarchar](100) NULL,
	[CompanyAddress] [nvarchar](200) NULL,
	[CompanyAddressCN] [nvarchar](200) NULL,
	[CompanyTel] [nvarchar](50) NULL,
	[CompanyFax] [nvarchar](50) NULL,
	[CompanyEmail] [nvarchar](100) NULL,
	[CompanyHomepage] [nvarchar](100) NULL,
	[CompanyLogo] [nvarchar](100) NULL,
	[CopyrightInfo] [nvarchar](1000) NULL,
	[CopyrightInfoCN] [nvarchar](1000) NULL,
	[ICP] [nvarchar](50) NULL,
	[PageKeyWords] [nvarchar](100) NULL,
	[PageKeyWordsCN] [nvarchar](100) NULL,
	[PageDescription] [nvarchar](200) NULL,
	[PageDescriptionCN] [nvarchar](200) NULL,
	[TemplateCN] [nvarchar](255) NULL,
	[TemplateEN] [nvarchar](255) NULL,
	[CompanyBanner] [nvarchar](100) NULL,
	[Member] [bit] NULL CONSTRAINT [DF_T_Config_Member]  DEFAULT (0),
	[IsShowPowerBy] [bit] NULL CONSTRAINT [DF_T_Config_IsShowPowerBy]  DEFAULT (1),
	[CompanyNameFN] [nvarchar](200) NULL,
	[CompanyShortNameFN] [nvarchar](100) NULL,
	[CompanyAddressFN] [nvarchar](200) NULL,
	[CopyrightInfoFN] [nvarchar](1000) NULL,
	[PageKeyWordsFN] [nvarchar](100) NULL,
	[PageDescriptionFN] [nvarchar](200) NULL,
	[TemplateFN] [nvarchar](255) NULL,
 CONSTRAINT [PK_T_Config] 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'T_Config', @level2type=N'COLUMN', @level2name=N'DefaultLanguageID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'前台显示的语言版本列表。0,中文;1,英文' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Config', @level2type=N'COLUMN', @level2name=N'LanguageIDList'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'封面开关' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Config', @level2type=N'COLUMN', @level2name=N'CoverState'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Config', @level2type=N'COLUMN', @level2name=N'PageKeyWords'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'页面描述' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Config', @level2type=N'COLUMN', @level2name=N'PageDescription'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'中文模版' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Config', @level2type=N'COLUMN', @level2name=N'TemplateCN'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'英文模版' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Config', @level2type=N'COLUMN', @level2name=N'TemplateEN'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启动会员验证模式0不验证1验证' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Config', @level2type=N'COLUMN', @level2name=N'Member'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否显示Power By ，0为隐藏，1为显示，默认为显示' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Config', @level2type=N'COLUMN', @level2name=N'IsShowPowerBy'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_Home]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_Home](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[CateID] [bigint] NULL,
	[LanguageID] [int] NULL,
	[Title] [nvarchar](255) NULL,
	[Content] [ntext] NULL,
	[TemplateID] [bigint] NULL,
 CONSTRAINT [PK_T_Home] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=NULL ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Home', @level2type=N'COLUMN', @level2name=N'LanguageID'

GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_80_gBookDetail]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create PROCEDURE [dbo].[S_Get_T_80_gBookDetail]
@ID bigint
AS
select * from [T_80_gBook] where [ID]=@ID
' 
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].[T_Member]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_Member](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](50) NOT NULL,
	[Pass] [nvarchar](50) NOT NULL,
	[Sex] [tinyint] NULL CONSTRAINT [DF_Table_1_sex]  DEFAULT (0),
	[RealName] [nvarchar](50) NOT NULL,
	[Nation] [nvarchar](50) NULL,
	[Province] [nvarchar](50) NULL,
	[City] [nvarchar](50) NULL,
	[Address] [nvarchar](100) NULL,
	[Code] [nvarchar](50) NULL,
	[Phone] [nvarchar](50) NULL,
	[Email] [nvarchar](50) NULL,
	[Fax] [nvarchar](50) NULL,
	[Appearance] [bit] NULL CONSTRAINT [DF_T_User_Appearance]  DEFAULT (0),
 CONSTRAINT [PK_T_User] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'用户ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'ID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'UserName'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Pass'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'性别,０为保密，１为男性，２为女性' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Sex'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'真实姓名' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'RealName'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'国家' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Nation'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'省份' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Province'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'城市' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'City'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Address'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'邮编' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Code'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Phone'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'电子邮件' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Email'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'传真' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Fax'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'用户状态，０为未锁定，１为锁定' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Member', @level2type=N'COLUMN', @level2name=N'Appearance'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_order]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_order](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[RealName] [nvarchar](50) NULL,
	[Address] [nvarchar](100) NULL,
	[Tel] [nvarchar](50) NULL,
	[Email] [nvarchar](100) NULL,
	[orderTime] [datetime] NULL CONSTRAINT [DF_T_order_orderTime]  DEFAULT (getdate()),
	[orderID] [varchar](50) NULL,
	[allprice] [money] NULL,
	[Appearance] [int] NULL CONSTRAINT [DF_T_order_Appearance]  DEFAULT (0),
	[UserID] [int] NULL CONSTRAINT [DF_T_order_UserID]  DEFAULT (0)
) 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'T_order', @level2type=N'COLUMN', @level2name=N'RealName'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_order', @level2type=N'COLUMN', @level2name=N'Address'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_order', @level2type=N'COLUMN', @level2name=N'Tel'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'电子邮件' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_order', @level2type=N'COLUMN', @level2name=N'Email'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'订单的时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_order', @level2type=N'COLUMN', @level2name=N'orderTime'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'订单号' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_order', @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'T_order', @level2type=N'COLUMN', @level2name=N'allprice'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'0待处理1成交2作废' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_order', @level2type=N'COLUMN', @level2name=N'Appearance'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_orderDetail]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_orderDetail](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[orderID] [bigint] NULL,
	[ProductName] [nvarchar](50) NULL,
	[num] [int] NULL,
	[price] [money] NULL
) 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'T_orderDetail', @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'T_orderDetail', @level2type=N'COLUMN', @level2name=N'ProductName'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'产品数量' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_orderDetail', @level2type=N'COLUMN', @level2name=N'num'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'产品单价' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_orderDetail', @level2type=N'COLUMN', @level2name=N'price'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_QQOnline]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_QQOnline](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[QQ] [nvarchar](50) NOT NULL,
	[WebName] [nvarchar](50) NULL,
	[Message] [nvarchar](255) NULL,
	[IsHidden] [bit] NOT NULL CONSTRAINT [DF_T_QQOnline_IsHidden]  DEFAULT (0),
	[Pic] [int] NOT NULL CONSTRAINT [DF_T_QQOnline_Pic]  DEFAULT (1),
 CONSTRAINT [PK_T_QQOnline] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'QQ号码' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_QQOnline', @level2type=N'COLUMN', @level2name=N'QQ'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'网站名称' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_QQOnline', @level2type=N'COLUMN', @level2name=N'WebName'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'留言内容' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_QQOnline', @level2type=N'COLUMN', @level2name=N'Message'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否隐藏，０为隐藏，１为显示' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_QQOnline', @level2type=N'COLUMN', @level2name=N'IsHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'ＱＱ在线风格' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_QQOnline', @level2type=N'COLUMN', @level2name=N'Pic'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_SysLanguage]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_SysLanguage](
	[ID] [int] NOT NULL,
	[LanguageTitle] [nvarchar](50) NULL,
	[Folder] [nvarchar](50) NULL,
 CONSTRAINT [PK_T_SysLanguage] 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].[T_SysMenu]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_SysMenu](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[Code] [nvarchar](4000) NULL,
	[MenuTitle] [nvarchar](50) NULL,
	[Description] [text] NULL,
	[PageType] [int] NOT NULL CONSTRAINT [DF_T_SystemMenu_PageType]  DEFAULT (0),
	[IsOut] [bit] NOT NULL CONSTRAINT [DF_T_SystemMenu_IsOut]  DEFAULT (0),
	[OutURL] [nvarchar](200) NULL,
	[OpenType] [nvarchar](10) NULL,
	[IsDelete] [bit] NOT NULL CONSTRAINT [DF_T_SystemMenu_IsDelete]  DEFAULT (0),
	[IsEncrypt] [bit] NOT NULL CONSTRAINT [DF_T_SystemMenu_IsEncrypt]  DEFAULT (0),
	[IsHidden] [bit] NOT NULL CONSTRAINT [DF_T_SystemMenu_IsHidden]  DEFAULT (0),
	[IsShowHome] [bit] NOT NULL CONSTRAINT [DF_T_SystemMenu_IsShowHome]  DEFAULT (0),
	[LanguageID] [int] NOT NULL CONSTRAINT [DF_T_SystemMenu_LanguageID]  DEFAULT (0),
	[MenuType] [int] NULL CONSTRAINT [DF_T_SysMenu_MenuType]  DEFAULT (0),
	[Isin] [bit] NULL CONSTRAINT [DF_T_SysMenu_Isin]  DEFAULT (0),
	[inURL] [bigint] NULL,
 CONSTRAINT [PK_T_SystemMenu] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_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'T_SysMenu', @level2type=N'COLUMN', @level2name=N'Code'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'MenuTitle'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'Description'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'栏目类型（单页）或（新闻）' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'PageType'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否外部连接' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'IsOut'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'外部连接URl' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'OutURL'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'打开类型' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'OpenType'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否删除' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'IsDelete'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否是注册用户才能登陆' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'IsEncrypt'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否在隐藏' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'IsHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否显示在主页' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'IsShowHome'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'语言ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'LanguageID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'栏目类型' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'MenuType'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否内部连接' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'Isin'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'内部连接栏目ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysMenu', @level2type=N'COLUMN', @level2name=N'inURL'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_SysMenuType]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_SysMenuType](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](100) NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_T_SysMenuType] 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].[T_SysPageType]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_SysPageType](
	[ID] [int] NOT NULL,
	[Code] [nvarchar](4000) NULL,
	[PageTypeTitle] [nvarchar](50) NULL,
	[Description] [nvarchar](1000) NULL,
	[PageURL] [nvarchar](100) NULL,
	[AdminPage] [nvarchar](100) NULL,
	[IsHidden] [bit] NOT NULL CONSTRAINT [DF_T_SysPageType_IsHidden]  DEFAULT (0),
	[IsDelete] [bit] NOT NULL CONSTRAINT [DF_T_SysPageType_IsDelete]  DEFAULT (0),
 CONSTRAINT [PK_T_SysPageType] 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'T_SysPageType', @level2type=N'COLUMN', @level2name=N'PageTypeTitle'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'说明' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysPageType', @level2type=N'COLUMN', @level2name=N'Description'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=NULL ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysPageType', @level2type=N'COLUMN', @level2name=N'PageURL'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'管理页面地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_SysPageType', @level2type=N'COLUMN', @level2name=N'AdminPage'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_Template]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_Template](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[TemplateName] [nvarchar](50) NULL,
	[TypeId] [nvarchar](50) NULL,
	[Address] [nvarchar](255) NULL,
	[Explain] [text] NULL,
	[Image] [nvarchar](255) NULL,
	[Preview] [nvarchar](255) NULL,
	[TemplateCN] [bit] NOT NULL CONSTRAINT [DF_T_Template_TemplateCN]  DEFAULT (0),
	[TemplateEN] [bit] NOT NULL CONSTRAINT [DF_T_Template_TemplateEN]  DEFAULT (0),
	[TemplateFN] [bit] NULL CONSTRAINT [DF_T_Template_TemplateFN]  DEFAULT (0),
 CONSTRAINT [PK_T_Template] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_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'T_Template', @level2type=N'COLUMN', @level2name=N'TemplateName'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'类别ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Template', @level2type=N'COLUMN', @level2name=N'TypeId'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'模版地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Template', @level2type=N'COLUMN', @level2name=N'Address'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'说明' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Template', @level2type=N'COLUMN', @level2name=N'Explain'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'预览图片地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Template', @level2type=N'COLUMN', @level2name=N'Image'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'预览地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Template', @level2type=N'COLUMN', @level2name=N'Preview'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'中文模版' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Template', @level2type=N'COLUMN', @level2name=N'TemplateCN'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'英文模版' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Template', @level2type=N'COLUMN', @level2name=N'TemplateEN'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'繁體' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Template', @level2type=N'COLUMN', @level2name=N'TemplateFN'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_TemplateType]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_TemplateType](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[TypeName] [nvarchar](50) NULL,
	[FatherClassId] [bigint] NULL CONSTRAINT [DF_T_TemplateType_FatherClassId]  DEFAULT (0)
) 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'T_TemplateType', @level2type=N'COLUMN', @level2name=N'TypeName'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_Vote]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_Vote](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](255) NOT NULL,
	[LanguageID] [int] NOT NULL CONSTRAINT [DF_T_Vote_LanguageID]  DEFAULT (0),
	[IsHidden] [bit] NULL CONSTRAINT [DF_T_Vote_IsHidden]  DEFAULT (0),
	[IsCheck] [bit] NULL CONSTRAINT [DF_T_Vote_IsCheck]  DEFAULT (0),
	[VoteContent] [nvarchar](4000) NULL,
 CONSTRAINT [PK_T_Vote] 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'T_Vote', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'语言版本ID,0为中文,1为英文,默认为中文' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Vote', @level2type=N'COLUMN', @level2name=N'LanguageID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否隐藏,0为显示,1为隐藏,默认为显示' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Vote', @level2type=N'COLUMN', @level2name=N'IsHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否多选，０为单选，１为多选，默认为单选' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Vote', @level2type=N'COLUMN', @level2name=N'IsCheck'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'投票内容' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_Vote', @level2type=N'COLUMN', @level2name=N'VoteContent'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_VoteOption]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_VoteOption](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[CateID] [bigint] NOT NULL,
	[Vote_Option] [nvarchar](4000) NULL,
	[Vote_Num] [int] NULL CONSTRAINT [DF_T_VoteOption_Vote_Num]  DEFAULT (0),
 CONSTRAINT [PK_T_VoteOption] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'投票ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_VoteOption', @level2type=N'COLUMN', @level2name=N'CateID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'选项内容' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_VoteOption', @level2type=N'COLUMN', @level2name=N'Vote_Option'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'投票数' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_VoteOption', @level2type=N'COLUMN', @level2name=N'Vote_Num'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_gBook]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_update_gBook]
	@ID bigint,	--留言ID
	@Content text,	--留言内容
	@UserName nvarchar(50),	--留言人
	@Title nvarchar(50),	--标题
	@AddDate datetime,	--添加时间
	@Reply text	--回复内容
As
Begin
	If (@AddDate = '''')
		Set @AddDate = null
	UpDate [T_80_gBook]
		Set [UserName] = @UserName,[Content] = @Content,[Title] = @Title,[AddDate] = @AddDate,[Reply] = @Reply
		From [T_80_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].[T_eootv]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_eootv](
	[id] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
	[fcode] [varchar](4000) NULL,
	[icode] [varchar](4000) NULL,
	[IsHidden] [bit] NULL,
	[style] [int] NULL
) 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'T_eootv', @level2type=N'COLUMN', @level2name=N'IsHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'显示模式(1嵌入)(0浮动) ' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_eootv', @level2type=N'COLUMN', @level2name=N'style'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_80_gBook]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_80_gBook](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[CateID] [bigint] NULL,
	[UserName] [nvarchar](50) NULL,
	[Face] [nvarchar](50) NULL,
	[MSN] [nvarchar](255) NULL,
	[QQ] [nvarchar](50) NULL,
	[Source] [nvarchar](255) NULL,
	[HomePage] [nvarchar](50) NULL,
	[Email] [nvarchar](100) NULL,
	[Title] [nvarchar](50) NULL,
	[Content] [text] NULL,
	[IP] [nvarchar](50) NULL,
	[AddDate] [datetime] NULL CONSTRAINT [DF_T_80_gBook_AddDate]  DEFAULT (getdate()),
	[Heart] [nvarchar](50) NULL,
	[Hidden] [bit] NULL CONSTRAINT [DF_T_80_gBook_Hidden]  DEFAULT (0),
	[NewsID] [bigint] NULL,
	[Reply] [text] NULL,
	[Sex] [nvarchar](10) NULL,
	[company] [nvarchar](50) NULL,
	[Address] [nvarchar](50) NULL,
	[Fax] [nvarchar](50) NULL,
	[Tel] [nvarchar](50) NULL,
 CONSTRAINT [PK_T_80_gBook] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_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'T_80_gBook', @level2type=N'COLUMN', @level2name=N'UserName'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'图片' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Face'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'来源' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Source'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'网站' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'HomePage'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'电子邮件' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Email'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Content'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'AddDate'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'心情' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Heart'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'隐藏' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Hidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'新闻ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'NewsID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'回复' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Reply'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'0保密1男2女' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Sex'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'公司名称' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'company'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Address'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'传真' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Fax'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_80_gBook', @level2type=N'COLUMN', @level2name=N'Tel'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_85_Feedback]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_85_Feedback](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[CateID] [bigint] NULL,
	[UserName] [nvarchar](50) NULL,
	[Face] [nvarchar](50) NULL,
	[MSN] [nvarchar](255) NULL,
	[QQ] [nvarchar](50) NULL,
	[Source] [nvarchar](255) NULL,
	[HomePage] [nvarchar](50) NULL,
	[Email] [nvarchar](100) NULL,
	[Title] [nvarchar](50) NULL,
	[Content] [text] NULL,
	[IP] [nvarchar](50) NULL,
	[AddDate] [datetime] NULL CONSTRAINT [DF_T_85_Feedback_AddDate]  DEFAULT (getdate()),
	[Heart] [nvarchar](50) NULL,
	[Hidden] [bit] NULL CONSTRAINT [DF_T_85_Feedback_Hidden]  DEFAULT (0),
	[NewsID] [bigint] NULL,
	[Reply] [text] NULL,
	[Sex] [nvarchar](10) NULL CONSTRAINT [DF_T_85_Feedback_Sex]  DEFAULT (0),
	[company] [nvarchar](50) NULL,
	[address] [nvarchar](50) NULL,
	[Fax] [nvarchar](50) NULL,
	[Tel] [nvarchar](50) NULL,
 CONSTRAINT [PK_T_85_Feedback] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_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'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'UserName'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'图片' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'Face'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'来源' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'Source'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'网站' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'HomePage'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'电子邮件' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'Email'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'Content'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'AddDate'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'心情' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'Heart'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'隐藏' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'Hidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'新闻ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'NewsID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'回复' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'Reply'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'0保密1男2女' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'Sex'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'电话 ' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_85_Feedback', @level2type=N'COLUMN', @level2name=N'company'

GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_DataBack]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_DataBack]
@DAName Nvarchar(100),
@BackPath nvarchar(100)
 AS
backup database @DAName to Disk = @BackPath WITH init
' 
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].[S_Del_List]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Del_List]
	@Table nvarchar(255),	--表名
	@ID nvarchar(4000)	--ID列表
As
Begin
	Declare @Sql nvarchar(4000)
	Set @Sql = ''Delete '' + @Table +'' Where [ID] In ('' + @ID + '')''
	Exec (@Sql)
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_List]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_List]
	@TableName nvarchar(50), --表名
	@cateID bigint, --父级
	@ord nvarchar(50), --排序
	@Counts int OUTPUT   --总记录数
	
As
Begin
	declare @sql nvarchar(2000)
	set @sql  = ''select * from ''+ @TableName +'' where cateID= ''+convert(nvarchar,@cateID) + ''order by '' + @ord
	exec sp_executesql @sql
	set @sql = '' set @Counts = (select count(*) from ''+@TableName+''  where cateID=''+convert(nvarchar,@cateID) + '')'' 
	exec sp_executesql @sql,N''@counts int OUTPUT'',@counts OUTPUT--计算总页数
	select @counts
	
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_List2]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_List2]
	@TableName nvarchar(50), --表名
	@cateID bigint, --父级
	@Counts int OUTPUT   --总记录数
	
As
Begin
	declare @sql nvarchar(2000)
	set @sql  = ''select * from ''+ @TableName +'' where cateID= ''+convert(nvarchar,@cateID)
	exec sp_executesql @sql
	set @sql = '' set @Counts = (select count(*) from ''+@TableName+''  where cateID=''+convert(nvarchar,@cateID) + '')'' 
	exec sp_executesql @sql,N''@counts int OUTPUT'',@counts OUTPUT--计算总页数
	select @counts
	
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_List3]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Get_T_List3]
	@TableName nvarchar(50), --表名
	@Counts int OUTPUT   --总记录数
	
As
Begin
	declare @sql nvarchar(2000)
	set @sql  = ''select * from ''+ @TableName
	exec sp_executesql @sql
	set @sql = '' set @Counts = (select count(*) from ''+ @TableName + '')'' 
	exec sp_executesql @sql,N''@counts int OUTPUT'',@counts OUTPUT--计算总页数
	select @counts
	
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_List4]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_List4]
	@TableName nvarchar(50), --表名
	@ord nvarchar(50), --排序
	@Counts int OUTPUT   --总记录数
	
As
Begin
	declare @sql nvarchar(2000)
	set @sql  = ''select * from ''+ @TableName +  ''  order by '' + @ord
	exec sp_executesql @sql
	set @sql = '' set @Counts = (select count(*) from ''+@TableName + '')''
	exec sp_executesql @sql,N''@counts int OUTPUT'',@counts OUTPUT--计算总页数
	select @counts
	
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_GetTableById]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_GetTableById]
@TableName nvarchar(50),
@ID bigint
AS
 declare @sql nvarchar(300)
 set @sql = ''select * from '' + @TableName + '' where ID='' + convert(nvarchar,@ID)
 exec (@sql)
' 
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].[S_List_Operation]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_List_Operation]
	@ID int,	--列表ID
	@Table nvarchar(255),	--表名
	@Value int,	--值，0为False,1为True
	@Type nvarchar(30)	--操作类型:Top为固顶，Good为推荐，Hidden为状态
As
Begin
	Declare @Sql nvarchar(4000)
	Set @Sql = ''UpDate '' + @Table + '' Set ''
	--固顶
	If (@Type = ''Top'')
		Set @Sql = @Sql + ''[IsTop] = ''
	--推荐
	If (@Type = ''Good'')
		Set @Sql = @Sql + ''[IsGood] = ''
	--状态
	If (@Type = ''Hidden'')
		Set @Sql = @Sql + ''[IsHidden] = ''
	
	Set @Sql = @Sql + Convert(nvarchar(2),@Value) + '' Where [ID] = '' + Convert(nvarchar(255),@ID)
	Exec (@Sql)
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].[S_Page]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Page]
	@Table nvarchar(4000),	--表名
	@PageName nvarchar(4000),	--用于分页的字段
	@PageOrder nvarchar(4) = ''Asc'',	--分页的顺序，值为Asc(升序)或Desc(降序),默认为Asc
	@Page int = 1,	--当前页,默认为第一页
	@PageSize int = 10,	--每页大小，默认为10
	@Col	nvarchar(4000) = ''*'',	--要显示的字段,默认为全部
	@Where	nvarchar(4000) = Null,	--查询条件，为Null或''''时则表示没有条件，默认为Null
	@Order	nvarchar(4000) = Null,	--排序字段，为Null或''''时则表示不排序，默认为Null
	@Count int OutPut	--记录总条数
As
Begin
	Declare @Sql nvarchar(4000)	--Sql语句
	Declare @Where_Temp	nvarchar(4000)	--临时查询条件
	Declare @Order_Temp nvarchar(4000)	--临时排序字段
	If (RTrim(@Where)<>'''')
		Set @Where_Temp = '' Where ('' + Cast(@Where As nvarchar(4000)) + '')''
	Else
		Set @Where_Temp = '' Where 1=1''
	If (RTrim(@Order)<>'''')
		Set @Order_Temp = '' Order By '' + Cast(@Order As nvarchar(4000)) + '',''+ Cast(@PageName As nvarchar(4000)) + '' '' + Cast(@PageOrder As nvarchar(4))
	Else
		Set @Order_Temp = '' Order By '' + Cast(@PageName As nvarchar(4000)) + '' '' + Cast(@PageOrder As nvarchar(4))
	--取得记录总条数
	Set @Sql = ''Select @Count = Count(*) From '' + Cast(@Table As nvarchar(4000)) + Cast(@Where_Temp As nvarchar(4000))
	Exec sp_executesql @Sql,N''@Count int OutPut'',@Count OutPut
	--如果没有数据，则返回空记录集
	If @Count = 0
	Begin
		Set @Sql = ''Select '' + Cast(@Col As nvarchar(4000)) + '' From '' + Cast(@Table As nvarchar(4000)) + @Where_Temp
		Exec (@Sql)
		Return
	End
	
	--取得分页后的数据
	Set @Sql = ''Select Top '' + Cast(@PageSize As nvarchar(4000)) + '' '' + Cast(@Col As nvarchar(4000))
	If @Page = 1	--第一页
		Set @Sql = @Sql + '' From '' + Cast(@Table As nvarchar(4000)) + @Where_Temp + @Order_Temp
	Else	--非第一页
	Begin
		Set @Sql = @Sql + '' From '' + Cast(@Table As nvarchar(4000)) + @Where_Temp
		Set @Sql = @Sql + '' And '' + Cast(@PageName As nvarchar(4000)) + '' Not In(Select Top '' + Cast((@PageSize * (@Page - 1)) As nvarchar(4000)) + '' '' + Cast(@PageName As nvarchar(4000))
		Set @Sql = @Sql + '' From '' + Cast(@Table As nvarchar(4000)) + @Where_Temp + @Order_Temp
		Set @Sql = @Sql + '')'' + @Order_Temp 
	End
	
	Exec(@Sql)
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_LinkOrder]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_update_LinkOrder]
	@TableName nvarchar(50), --表名
	@ID bigint,--序号
	@cateID bigint, --父级
	@orderID int,--排序序号
	@ord nvarchar(50), --排序	
	@isTop bit --固顶
As
begin
	declare @sql nvarchar(4000)
	declare @preID int
if(@ord=0)--升序
begin
	set @sql ='' set @preID = (select top 1 orderID from ''+@TableName+''  where cateID=''
	+convert(nvarchar,@cateID) + '' and orderID<'' + convert(nvarchar,@orderID) + '' and isTop ='' + convert(nvarchar,@isTop) + ''
	 order by orderID desc)''
	set @sql =  @sql + '' if(len(@preID)!=0) begin''
	set @sql = @sql + '' update ''+ @TableName +'' set orderID= @preID where ID='' + convert(nvarchar,@ID)
	
	set @sql = @sql + '' update ''+@TableName+'' set orderID='' + convert(nvarchar,@orderID) +'' where orderID= @preID and ID!=''+ convert(nvarchar,@ID)
	
	set @sql = @sql + '' end''
	exec sp_executesql @sql,N''@preID int'',@preID
end
else --降序
begin
	set @sql ='' set @preID = (select top 1 orderID from ''+@TableName+''  where cateID=''
	+convert(nvarchar,@cateID) + '' and orderID>'' + convert(nvarchar,@orderID) + '' and isTop ='' + convert(nvarchar,@isTop) + ''
	 order by orderID)''
	set @sql =  @sql + '' if(len(@preID)!=0) begin''
	set @sql = @sql + '' update ''+ @TableName +'' set orderID= @preID where ID='' + convert(nvarchar,@ID)
	
	set @sql = @sql + '' update ''+@TableName+'' set orderID='' + convert(nvarchar,@orderID) +'' where orderID= @preID and ID!=''+ convert(nvarchar,@ID)
	
	set @sql = @sql + '' end''
	exec sp_executesql @sql,N''@preID int'',@preID
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].[T_00_Info]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_00_Info](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[CateID] [bigint] NOT NULL CONSTRAINT [DF_T_00_Info_CateID]  DEFAULT (0),
	[AddTime] [datetime] NULL CONSTRAINT [DF_T_00_Info_AddTime]  DEFAULT (getdate()),
	[Content] [text] NULL,
	[ViewNum] [int] NOT NULL CONSTRAINT [DF_T_00_Info_ViewNum]  DEFAULT (0),
 CONSTRAINT [PK_T_00_Info] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'类别ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_00_Info', @level2type=N'COLUMN', @level2name=N'CateID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_00_Info', @level2type=N'COLUMN', @level2name=N'AddTime'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_00_Info', @level2type=N'COLUMN', @level2name=N'Content'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览次数' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_00_Info', @level2type=N'COLUMN', @level2name=N'ViewNum'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_10_List]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_10_List](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[cateID] [bigint] NULL,
	[Title] [nvarchar](255) NOT NULL,
	[Author] [nvarchar](50) NULL,
	[picURL] [nvarchar](50) NULL,
	[Source] [nvarchar](50) NULL,
	[AddDate] [datetime] NULL CONSTRAINT [DF_T_10_List_AddDate]  DEFAULT (getdate()),
	[Content] [text] NULL,
	[ViewNum] [int] NOT NULL CONSTRAINT [DF_T_10_List_ViewNum]  DEFAULT (0),
	[IsTop] [bit] NOT NULL CONSTRAINT [DF_T_10_List_IsTop]  DEFAULT (0),
	[IsGood] [bit] NOT NULL CONSTRAINT [DF_T_10_List_IsGood]  DEFAULT (0),
	[KeyWord] [nvarchar](100) NULL,
	[IsHidden] [bit] NOT NULL CONSTRAINT [DF_T_10_List_IsHidden]  DEFAULT (1),
	[IsPic] [bit] NULL,
 CONSTRAINT [PK_T_10_List] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_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'T_10_List', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'作者' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'Author'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'图片地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'picURL'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'来源' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'Source'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'AddDate'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'Content'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览次数' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'ViewNum'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否置顶' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'IsTop'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否推荐' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'IsGood'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'KeyWord'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'IsHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否图片' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_10_List', @level2type=N'COLUMN', @level2name=N'IsPic'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_20_Product]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_20_Product](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[cateID] [bigint] NULL,
	[Title] [nvarchar](50) NULL,
	[partNumber] [nvarchar](100) NULL,
	[unit] [nvarchar](50) NULL,
	[price] [money] NULL,
	[Quanlity] [int] NULL,
	[spicUrl] [nvarchar](100) NULL,
	[picUrl] [nvarchar](100) NULL,
	[Description] [text] NULL,
	[parameter] [text] NULL,
	[viewnum] [int] NULL,
	[istop] [bit] NULL,
	[isgood] [bit] NULL,
	[ishidden] [bit] NULL,
	[orderID] [int] NULL,
	[isBuy] [bit] NULL,
	[adddate] [datetime] NULL CONSTRAINT [DF_T_20_Product_adddate]  DEFAULT (getdate())
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'父id' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'cateID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'型号' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'partNumber'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'单位' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'unit'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'单价' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'price'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'Quanlity'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'小图片' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'spicUrl'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'大图片' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'picUrl'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'Description'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'详细参数' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'parameter'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览次数' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'viewnum'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'固顶' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'istop'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'推荐' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'isgood'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'隐藏' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'ishidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @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'T_20_Product', @level2type=N'COLUMN', @level2name=N'isBuy'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_20_Product', @level2type=N'COLUMN', @level2name=N'adddate'

GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[sp_page]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_page]
  @tb         varchar(50), --表名
  @col        varchar(50), --按该字段来进行分页
  @coltype    int,         --@col字段的类型,0-数字类型,1-字符类型,2-日期时间类型
  @orderby    bit,         --排序,0-顺序,1-倒序
  @collist    varchar(800),--要查询出的字段列表,* 表示全部字段
  @pagesize   int,         --每页记录数
  @page       int,         --指定页
  @condition  varchar(800),--查询条件
  @counts      int OUTPUT   --总记录数
 
AS
DECLARE @sql nvarchar(4000),@where1 varchar(800),@where2 varchar(800)
IF @condition is null or rtrim(@condition)=''''
  BEGIN--没有查询条件
    SET @where1='' WHERE ''
    SET @where2=''  ''
  END
ELSE
  BEGIN--有查询条件
    SET @where1='' WHERE (''+@condition+'') AND ''--本来有条件再加上此条件
    SET @where2='' WHERE (''+@condition+'') ''--原本没有条件而加上此条件
END
SET @sql=''SELECT @counts=COUNT(*) FROM ''+@tb+@where2
EXEC sp_executesql @sql,N''@counts int OUTPUT'',@counts OUTPUT--计算总页数
IF @orderby=0
  SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''>(SELECT MAX(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'') t) ORDER BY ''+@col
ELSE
  SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''<(SELECT MIN(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'' DESC) t) ORDER BY ''+
           @col+'' DESC''
IF @page=1--第一页
  SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+'' FROM ''+@tb+
    @where2+''ORDER BY ''+@col+CASE @orderby WHEN 0 THEN '''' ELSE '' DESC'' END
EXEC(@sql)
' 
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].[T_25_PicList]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_25_PicList](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[cateID] [bigint] NULL,
	[Title] [nvarchar](50) NULL,
	[sPicUrl] [nvarchar](100) NULL,
	[picUrl] [nvarchar](100) NULL,
	[Discription] [text] NULL,
	[OrderID] [int] NULL CONSTRAINT [DF_T_25_PicList_OrderID]  DEFAULT (0),
	[IsTop] [bit] NULL,
	[IsGood] [bit] NULL,
	[IsHidden] [bit] NULL,
	[Parameter] [text] NULL,
	[AddDate] [datetime] NULL CONSTRAINT [DF_T_25_PicList_AddDate]  DEFAULT (getdate()),
	[ViewNum] [int] NULL,
 CONSTRAINT [PK_T_25_PicList] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'父ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'cateID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'微缩图片地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'sPicUrl'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'图片地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'picUrl'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'Discription'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @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'T_25_PicList', @level2type=N'COLUMN', @level2name=N'IsTop'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'推荐' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'IsGood'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'隐藏' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'IsHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'详细参数' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'Parameter'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'AddDate'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'浏览次数' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_25_PicList', @level2type=N'COLUMN', @level2name=N'ViewNum'

GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[sp_page2]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_page2]
/*
***************************************************************
** 千万数量级分页存储过程 **
***************************************************************
参数说明:
1.Tables :表名称,视图
2.PrimaryKey :主关键字
3.Sort :排序语句，不带Order By 比如：NewsID Desc,OrderRows Asc
4.CurrentPage :当前页码
5.PageSize :分页尺寸
6.Fields :查询出的字段
7.Filter :过滤语句，不带Where 
8.Group :Group语句,不带Group By
9.Counts OutPut: 总条数
***************************************************************/
(
@Tables varchar(1000),
@PrimaryKey varchar(100),
@Sort varchar(200) = NULL,
@CurrentPage int = 1,
@PageSize int = 10,
@Fields varchar(1000) = ''*'',
@Filter varchar(1000) = NULL,
@Group varchar(1000) = NULL,
@Counts      int OUTPUT   --总记录数
)
AS
/*默认排序*/
IF @Sort IS NULL OR @Sort = ''''
	SET @Sort = @PrimaryKey
DECLARE @SortTable varchar(100)
DECLARE @SortName varchar(100)
DECLARE @strSortColumn varchar(200)
DECLARE @operator char(2)
DECLARE @type varchar(100)
DECLARE @prec int
/*设定排序语句.*/
IF CHARINDEX(''DESC'',@Sort)>0
BEGIN
	SET @strSortColumn = REPLACE(@Sort, ''DESC'', '''')
	SET @operator = ''<=''
END
ELSE
BEGIN
	IF CHARINDEX(''ASC'', @Sort) = 0
		SET @strSortColumn = REPLACE(@Sort, ''ASC'', '''')
		SET @operator = ''>=''
END
IF CHARINDEX(''.'', @strSortColumn) > 0
BEGIN
	SET @SortTable = SUBSTRING(@strSortColumn, 0, CHARINDEX(''.'',@strSortColumn))
	SET @SortName = SUBSTRING(@strSortColumn, CHARINDEX(''.'',@strSortColumn) + 1, LEN(@strSortColumn))
END
ELSE
BEGIN
	SET @SortTable = @Tables
	SET @SortName = @strSortColumn
END
SELECT @type=t.name, @prec=c.prec
FROM sysobjects o 
	JOIN syscolumns c on o.id=c.id
	JOIN systypes t on c.xusertype=t.xusertype
	WHERE o.name = @SortTable AND c.name = @SortName
IF CHARINDEX(''char'', @type) > 0
	SET @type = @type + ''('' + CAST(@prec AS varchar) + '')''
DECLARE @strPageSize varchar(50)
DECLARE @strStartRow varchar(50)
DECLARE @strFilter varchar(1000)
DECLARE @strSimpleFilter varchar(1000)
DECLARE @strGroup varchar(1000)
/*默认当前页*/
IF @CurrentPage < 1
	SET @CurrentPage = 1
/*设置分页参数.*/
SET @strPageSize = CAST(@PageSize AS varchar(50))
SET @strStartRow = CAST(((@CurrentPage - 1)*@PageSize + 1) AS varchar(50))
/*筛选以及分组语句.*/
IF @Filter IS NOT NULL AND @Filter != ''''
BEGIN
	SET @strFilter = '' WHERE '' + @Filter + '' ''
	SET @strSimpleFilter = '' AND '' + @Filter + '' ''
END
ELSE
BEGIN
	SET @strSimpleFilter = ''''
	SET @strFilter = ''''
END
IF @Group IS NOT NULL AND @Group != ''''
	SET @strGroup = '' GROUP BY '' + @Group + '' ''
ELSE
	SET @strGroup = ''''
/*执行查询语句*/
Exec (
''
DECLARE @SortColumn '' + @type + ''
SET ROWCOUNT '' + @strStartRow + ''
SELECT @SortColumn='' + @strSortColumn + '' FROM '' + @Tables + @strFilter + '' '' + @strGroup + '' ORDER BY '' + @Sort + ''
SET ROWCOUNT '' + @strPageSize + ''
SELECT '' + @Fields + '' FROM '' + @Tables + '' WHERE '' + @strSortColumn + @operator + '' @SortColumn '' + @strSimpleFilter + '' '' + @strGroup + '' ORDER BY '' + @Sort + ''
''
)
DECLARE @sql nvarchar(4000)
SET @sql=''SELECT @counts=COUNT(*) FROM ''+@Tables+@strFilter + ''''
EXEC sp_executesql @sql,N''@counts int OUTPUT'',@counts OUTPUT--计算总页数
' 
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].[T_30_Download]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_30_Download](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[cateid] [bigint] NULL,
	[Title] [nvarchar](50) NULL,
	[picUrl] [nvarchar](100) NULL,
	[loadUrl] [nvarchar](100) NULL,
	[filesize] [nvarchar](50) NULL,
	[Discription] [text] NULL,
	[parameter] [text] NULL,
	[isTop] [bit] NULL,
	[isGood] [bit] NULL,
	[isHidden] [bit] NULL,
	[orderID] [int] NULL,
	[viewnum] [int] NULL,
	[adddate] [datetime] NULL CONSTRAINT [DF_T_30_Download_adddate]  DEFAULT (getdate()),
	[viesion] [nvarchar](50) NULL,
	[score] [int] NULL,
	[os] [nvarchar](100) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=NULL ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'id'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'(父id)' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'cateid'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'图片地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'picUrl'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'下载地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'loadUrl'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'文件大小' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'filesize'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'Discription'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'详细参数' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'parameter'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'固顶' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'isTop'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'推荐' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'isGood'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'隐藏' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'isHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @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'T_30_Download', @level2type=N'COLUMN', @level2name=N'viewnum'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'adddate'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'版本号码' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'viesion'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'评分' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'score'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'操作系统' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_30_Download', @level2type=N'COLUMN', @level2name=N'os'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[sp_page3]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_page3]
  @tb         varchar(50), --表名
  @col        varchar(50), --按该字段来进行分页
  @coltype    int,         --@col字段的类型,0-数字类型,1-字符类型,2-日期时间类型
  @orderby    bit,         --排序,0-顺序,1-倒序
  @collist    varchar(800),--要查询出的字段列表,* 表示全部字段
  @pagesize   int,         --每页记录数
  @page       int,         --指定页
  @condition  varchar(800),--查询条件
  @order		varchar(800),	--排序字段   
  @counts      int OUTPUT   --总记录数
AS
DECLARE @sql nvarchar(4000),@where1 varchar(800),@where2 varchar(800)
IF @condition is null or rtrim(@condition)=''''
  BEGIN--没有查询条件
    SET @where1='' WHERE ''
    SET @where2=''  ''
  END
ELSE
  BEGIN--有查询条件
    SET @where1='' WHERE (''+@condition+'') AND ''--本来有条件再加上此条件
    SET @where2='' WHERE (''+@condition+'') ''--原本没有条件而加上此条件
END
SET @sql=''SELECT @counts=COUNT(*) FROM ''+@tb+@where2
EXEC sp_executesql @sql,N''@counts int OUTPUT'',@counts OUTPUT--计算总页数
IF @orderby=0
Begin
	If @order Is Null Or RTrim(@order)=''''
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''>(SELECT MAX(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'') t) ORDER BY ''+@col
	Else
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''>(SELECT MAX(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'',''+@order+'') t) ORDER BY ''+@order+'',''+@col
End
ELSE
	If @order Is Null Or RTrim(@order)=''''
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''<(SELECT MIN(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'' DESC) t) ORDER BY ''+
           @col+'' DESC''
	Else
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''<(SELECT MIN(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'' DESC''+'',''+@order+'') t) ORDER BY ''+
           @order+'',''+@col+'' DESC''
IF @page=1--第一页
	If @order Is Null Or RTrim(@order)=''''
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+'' FROM ''+@tb+
			@where2+''ORDER BY ''+@col+CASE @orderby WHEN 0 THEN '''' ELSE '' DESC'' END
	Else
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+'' FROM ''+@tb+
			@where2+''ORDER BY ''+@col+CASE @orderby WHEN 0 THEN '''' ELSE '' DESC'' END +'',''+@order
--print @sql
EXEC(@sql)
' 
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].[T_70_QA]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_70_QA](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[Question] [nvarchar](4000) NOT NULL,
	[Answer] [nvarchar](4000) NULL,
	[LanguageID] [int] NOT NULL CONSTRAINT [DF_T_QA_LanguageID]  DEFAULT (0),
	[OrderID] [bigint] NULL,
	[IsTop] [bit] NOT NULL CONSTRAINT [DF_T_QA_IsTop]  DEFAULT (0),
	[IsHidden] [bit] NOT NULL CONSTRAINT [DF_T_QA_IsHidden]  DEFAULT (0),
	[CateID] [bigint] NOT NULL,
 CONSTRAINT [PK_T_QA] 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'T_70_QA', @level2type=N'COLUMN', @level2name=N'Question'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'答案' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_70_QA', @level2type=N'COLUMN', @level2name=N'Answer'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'语言版本ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_70_QA', @level2type=N'COLUMN', @level2name=N'LanguageID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'排序字段' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_70_QA', @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'T_70_QA', @level2type=N'COLUMN', @level2name=N'IsTop'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否隐藏' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_70_QA', @level2type=N'COLUMN', @level2name=N'IsHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'父ID' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_70_QA', @level2type=N'COLUMN', @level2name=N'CateID'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[sp_page4]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_page4]
  @tb         varchar(50), --表名
  @col        varchar(50), --按该字段来进行分页
  @coltype    int,         --@col字段的类型,0-数字类型,1-字符类型,2-日期时间类型
  @orderby    bit,         --排序,0-顺序,1-倒序
  @collist    varchar(800),--要查询出的字段列表,* 表示全部字段
  @pagesize   int,         --每页记录数
  @page       int,         --指定页
  @condition  varchar(800),--查询条件
  @order		varchar(800),	--排序字段   
  @counts      int OUTPUT   --总记录数
AS
DECLARE @sql nvarchar(4000),@where1 varchar(800),@where2 varchar(800)
IF @condition is null or rtrim(@condition)=''''
  BEGIN--没有查询条件
    SET @where1='' WHERE ''
    SET @where2=''  ''
  END
ELSE
  BEGIN--有查询条件
    SET @where1='' WHERE (''+@condition+'') AND ''--本来有条件再加上此条件
    SET @where2='' WHERE (''+@condition+'') ''--原本没有条件而加上此条件
END
SET @sql=''SELECT @counts=COUNT(*) FROM ''+@tb+@where2
EXEC sp_executesql @sql,N''@counts int OUTPUT'',@counts OUTPUT--计算总页数
IF @orderby=0
Begin
	If @order Is Null Or RTrim(@order)=''''
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''>(SELECT MAX(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'') t) ORDER BY ''+@col
	Else
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''>(SELECT MAX(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'') t) ORDER BY ''+@col+'',''+@order
End
ELSE
	If @order Is Null Or RTrim(@order)=''''
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''<(SELECT MIN(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'' DESC) t) ORDER BY ''+
           @col+'' DESC''
	Else
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''<(SELECT MIN(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize*(@page-1) AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'' DESC''+'') t) ORDER BY ''+
           @col+'' DESC''+'',''+@order
IF @page=1--第一页
	If @order Is Null Or RTrim(@order)=''''
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+'' FROM ''+@tb+
			@where2+''ORDER BY ''+@col+CASE @orderby WHEN 0 THEN '''' ELSE '' DESC'' END
	Else
		SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+
           '' FROM ''+@tb+@where1+@col+''<(SELECT MIN(''+@col+'') ''+
           '' FROM (SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+
           @col+'' FROM ''+@tb+@where2+''ORDER BY ''+@col+'' DESC''+'') t) ORDER BY ''+
           @col+'' DESC''+'',''+@order		
	--	SET @sql=''SELECT TOP ''+CAST(@pagesize AS varchar)+'' ''+@collist+'' FROM ''+@tb+
	--		@where2+''ORDER BY ''+@col+CASE @orderby WHEN 0 THEN '''' ELSE '' DESC'' END +'',''+@order
--print @sql
EXEC(@sql)
' 
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].[T_90_Link]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_90_Link](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[cateID] [bigint] NULL,
	[Title] [nvarchar](50) NULL,
	[Url] [nvarchar](100) NULL,
	[picUrl] [nvarchar](100) NULL,
	[IsGood] [bit] NULL,
	[IsHidden] [bit] NULL,
	[IsTop] [bit] NULL,
	[orderID] [int] NULL,
	[TypeID] [int] NULL,
 CONSTRAINT [PK_T_90_Link] 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'T_90_Link', @level2type=N'COLUMN', @level2name=N'ID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'父编号' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_90_Link', @level2type=N'COLUMN', @level2name=N'cateID'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_90_Link', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'连接地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_90_Link', @level2type=N'COLUMN', @level2name=N'Url'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'图片地址' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_90_Link', @level2type=N'COLUMN', @level2name=N'picUrl'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'推荐' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_90_Link', @level2type=N'COLUMN', @level2name=N'IsGood'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'隐藏' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_90_Link', @level2type=N'COLUMN', @level2name=N'IsHidden'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'固顶' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_90_Link', @level2type=N'COLUMN', @level2name=N'IsTop'

GO
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' ,@level0type=N'USER', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'T_90_Link', @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'T_90_Link', @level2type=N'COLUMN', @level2name=N'TypeID'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_AdminLogInfo]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_AdminLogInfo](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[LoginTime] [datetime] NULL CONSTRAINT [DF__T_AdminLo__Login__2EDAF651]  DEFAULT (getdate()),
	[UserID] [nvarchar](50) NULL,
	[AdminID] [int] NOT NULL CONSTRAINT [DF__T_AdminLo__Admin__2FCF1A8A]  DEFAULT (0),
	[Valid] [bit] NOT NULL CONSTRAINT [DF_T_AdminLogInfo_Valid]  DEFAULT (0),
	[IP] [nvarchar](50) NULL,
	[Reason] [nvarchar](50) NULL,
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].[T_AdminMenu]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[T_AdminMenu](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Code] [nvarchar](4000) NULL,
	[MenuTitle] [nvarchar](50) NULL,
	[URL] [nvarchar](100) NULL,
	[IsHidden] [bit] NOT NULL CONSTRAINT [DF_T_AdminMenu_IsHidden]  DEFAULT (0),
	[OrderID] [int] NULL,
 CONSTRAINT [PK_T_AdminMenu] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Del_AdminOpt]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Del_AdminOpt]
@DelAll bit = 0,
@ArrID nvarchar(1000)
AS
Declare @strSQL nvarchar(1100)
if (@DelAll = 1)
    begin
        delete from [T_AdminOpt]
    end
else
    begin
        set @strSQL = ''delete from [T_AdminOpt] where ID in (''+@ArrID+'')''
        exec(@strSQL)
    end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_WriteOpt]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_WriteOpt]
@OptDes nvarchar(50),
@OptUID int
 AS
insert into T_AdminOpt (OptDes,OptUID) values(@OptDes,@OptUID)
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_T_AdminRole]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE  [dbo].[S_update_T_AdminRole]
@Power nvarchar(2000),
@MenuPower nvarchar(2000),
@RoleTitle nvarchar(50),
@IsLock bit,
@ID bigint,
@T bit
 AS
if (@T=1)
begin
update T_AdminRole set [Power] = @Power,MenuPower=@MenuPower,RoleTitle=@RoleTitle,IsLock=@IsLock where [ID]=@ID
----更新所有组员的权限
update T_AdminUser set [Power] = @Power,MenuPower=@MenuPower where RoleID = @ID
end
else
begin
update T_AdminRole set [Power] = @Power,MenuPower=@MenuPower,RoleTitle=@RoleTitle,IsLock=@IsLock where [ID]=@ID
end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_del_T_AdminRole]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_del_T_AdminRole]
@ID bigint,
@T bit
 AS
if(@T=1)
begin ----真删除
select * from T_AdminUser where RoleID = @ID
if(@@RowCount<1)
begin 
delete from T_AdminRole where [ID]=@ID
end
end
else
begin
select * from T_AdminUser where RoleID = @ID and isdelete = 0
if(@@RowCount<1)
begin ------假删除
update T_AdminRole set isdelete =1 where [ID] = @ID
end
end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_insert_T_AdminRole]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_insert_T_AdminRole] ----添加角色
@Power nvarchar(2000),
@MenuPower nvarchar(2000),
@RoleTitle nvarchar(50),
@RoleID bigint output
 AS
select * from T_AdminRole where RoleTitle = @RoleTitle
if(@@RowCount<1)
begin
insert into T_AdminRole([Power],MenuPower,RoleTitle)values(@Power,@MenuPower,@RoleTitle)
set @RoleID = @@IDENTITY
end
else
begin
set @RoleID = -1
end
return @RoleID
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_insert_T_AdminUser]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_insert_T_AdminUser]
@UserID nvarchar(50),
@UserName nvarchar(50),
@PassWord nvarchar(50),
@RoleID bigint,
@UID bigint output
AS
declare @Power nvarchar(2000)
declare @MenuPower nvarchar(2000)
select * from T_AdminUser where UserID = @UserID
if(@@RowCount<1)
begin
select @MenuPower=MenuPower, @Power=[Power] from T_AdminRole where [ID] = @RoleID
insert into T_AdminUser (UserID,UserName,[PassWord],[Power],MenuPower,RoleID)values(@UserID,@UserName,@PassWord,@Power,@MenuPower,@RoleID)
set @UID = @@IDENTITY
end
else
begin
set @UID = -1
end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_AdminUser]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE  [dbo].[S_Get_T_AdminUser] 
@ID bigint
AS
if(@ID=-1)----所有的
begin
select T_AdminRole.RoleTitle,T_AdminUser.* from T_AdminUser left outer join T_AdminRole on T_AdminRole.[ID] =  T_AdminUser.RoleID 
end
else
begin
if(@ID=0)----存在的
begin 
select T_AdminRole.RoleTitle,T_AdminUser.* from T_AdminUser left outer join T_AdminRole on T_AdminRole.[ID] =  T_AdminUser.RoleID where T_AdminUser.isdelete=0 
end
else
begin 
select T_AdminRole.RoleTitle,T_AdminUser.* from T_AdminUser left outer join T_AdminRole on T_AdminRole.[ID] =  T_AdminUser.RoleID where T_AdminUser.isdelete=0 and T_AdminUser.[ID] = @ID
end
end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_AdminRole]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_AdminRole]
@ID bigint
 AS
if(@ID=-1)
begin
select * from T_AdminRole 
end
else
begin
if(@ID=0)
begin
select * from T_AdminRole where isdelete=0 
end
else
begin
select * from T_AdminRole  where [ID] = @ID and isdelete=0
end
end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_editPassWord]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_editPassWord]
@ID bigint,
@NewPassWord nvarchar(50)
 AS
update T_AdminUser set [PassWord] = @NewPassWord where [ID]=@ID
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_del_T_AdminUser]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_del_T_AdminUser]
@ID bigint,
@T bit
 AS
if(@T=1)
begin ----真删除
delete from T_AdminUser where [ID]=@ID
end
else
begin ------假删除
update T_AdminUser set isdelete =1 where [ID] = @ID
end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_T_AdminUser]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_update_T_AdminUser]
@UserID nvarchar(50),
@UserName nvarchar(50),
@PassWord nvarchar(50),
@RoleID BigInt,
@Islock Bit,
@Power nvarchar(2000),
@MenuPower nvarchar(2000),
@ID BigInt
 AS
declare @i int
set @i = (select count([ID]) from T_AdminUser where UserID =@UserID)
if(@i<=1)
begin
update T_AdminUser set UserID=@UserID,UserName=@UserName,[PassWord]=@PassWord,RoleID=@RoleID,MenuPower=@MenuPower,[Power]=@Power,Islock=@Islock where [ID]=@ID
end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Login]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Login] 
@UserID nvarchar(50),
@PassWord nvarchar(50),
@IP nvarchar(50),
@Reason nvarchar(50) output,
@UserName nvarchar(50) output,
@UID BigInt output
AS
select @UserName = UserName,@UID = [ID] from T_AdminUser 
where UserID = @UserID and [PassWord] =@PassWord and Islock=0 and IsDelete=0
if(@@rowcount<1)
begin
select * from T_AdminUser where UserID = @UserID  and Islock=0 and IsDelete=0
if(@@rowcount<1)
begin
set @UID = -1
set @UserName = ''''
set @Reason = ''用户名错误或被冻结!''
end
else
begin
set @UID = -1
set @UserName = ''''
set @Reason = ''密码错误!''
end
end
else
begin
declare @loginTimes int
set @loginTimes = (select loginTimes  from T_AdminUser where UserID = @UserID and [PassWord] =@PassWord) + 1
update T_AdminUser set  loginTimes = @loginTimes ,LatestLoginTime = getdate(),LatestLoginIP = @IP 
where [ID] = (select [ID]  from T_AdminUser where UserID = @UserID and [PassWord] =@PassWord)  and [PassWord] =@PassWord and Islock=0 and IsDelete=0
set @Reason = ''登录成功!''
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].[S_UpDate_T_Advertisement]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_UpDate_T_Advertisement]
	@ID	bigint,
	@Title nvarchar(50),	--广告标题
	@AdvPic nvarchar(50),	--广告图片地址
	@AdvUrl	nvarchar(50),	--广告地址
	@IsHidden	bit = 0,	--是否隐藏，０为隐藏，１为显示
	@IsTop	bit = 0,	--是否是顶部广告
	@IsLeft	bit = 0,	--是否是左边广告
	@IsRight bit = 0,	--是否是右边广告
	@IsFloat bit = 0,	--是否是浮动广告
	@IsPop	bit = 0	--是否是弹出广告
As
	UpDate [T_Advertisement] Set [Title] = @Title,[AdvPic] = @AdvPic,[AdvUrl] = @AdvUrl,[IsHidden] = @IsHidden,[IsTop] = @IsTop,[IsLeft] = @IsLeft,[IsRight] = @IsRight,[IsFloat] = @IsFloat,[IsPop] = @IsPop
		Where [ID] = @ID
' 
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].[S_Insert_T_Advertisement]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Insert_T_Advertisement]
	@Title nvarchar(50),	--广告标题
	@AdvPic nvarchar(50),	--广告图片地址
	@AdvUrl	nvarchar(50),	--广告地址
	@IsHidden	bit = 0,	--是否隐藏，０为隐藏，１为显示
	@IsTop	bit = 0,	--是否是顶部广告
	@IsLeft	bit = 0,	--是否是左边广告
	@IsRight bit = 0,	--是否是右边广告
	@IsFloat bit = 0,	--是否是浮动广告
	@IsPop	bit = 0	--是否是弹出广告
As
	Insert Into
		[T_Advertisement]([Title],[AdvPic],[AdvUrl],[IsHidden],[IsTop],[IsLeft],[IsRight],[IsFloat],[IsPop])
		Values(@Title,@AdvPic,@AdvUrl,@IsHidden,@IsTop,@IsLeft,@IsRight,@IsFloat,@IsPop)
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_T_Config]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_update_T_Config]
@ID bigint,
@DefaultLanguageID int,
@LanguageIDList nvarchar(50),
@CompanyName nvarchar(200),
@CompanyNameCN nvarchar(200),
@CompanyNameFN nvarchar(200),
@CompanyShortName nvarchar(100),
@CompanyShortNameCN nvarchar(100),
@CompanyShortNameFN nvarchar(100),
@CompanyAddress nvarchar(200),
@CompanyAddressCn nvarchar(200),
@CompanyAddressFn nvarchar(200),
@CompanyTel nvarchar(50),
@Companyfax nvarchar(50),
@CompanyEmail nvarchar(100),
@CompanyHomePage nvarchar(100),
@CompanyLogo nvarchar(100),
@CompanyBanner nvarchar(100),
@CopyrightInfo nvarchar(1000),
@CopyrightInfoCN nvarchar(1000),
@CopyrightInfoFN nvarchar(1000),
@PageKeyWords nvarchar(100),
@PageKeyWordsCN nvarchar(100),
@PageKeyWordsFN nvarchar(100),
@PageDescription  nvarchar(200),
@PageDescriptionCN nvarchar(200),
@PageDescriptionFN nvarchar(200),
@Member bit,
@IsShowPowerBy bit
 AS
if(@id =0)
begin
insert into T_Config (DefaultLanguageID,LanguageIDList,CompanyName,CompanyNameCN,CompanyNameFN,CompanyShortName,CompanyShortNameCN,CompanyShortNameFN,
	CompanyAddress,CompanyAddressCn,CompanyAddressFn,CompanyTel,Companyfax,CompanyEmail,CompanyHomePage,CompanyLogo,CompanyBanner,
	CopyrightInfo,CopyrightInfoCN,CopyrightInfoFN,PageKeyWords,PageKeyWordsCN,PageKeyWordsFN,PageDescription,PageDescriptionCN,PageDescriptionFN,IsShowPowerBy) values
	  (@DefaultLanguageID,@LanguageIDList,@CompanyName,@CompanyNameCN,@CompanyNameFN,@CompanyShortName,@CompanyShortNameCN,@CompanyShortNameFN,
	@CompanyAddress,@CompanyAddressCn,@CompanyAddressFn,@CompanyTel,@Companyfax,@CompanyEmail,@CompanyHomePage,@CompanyLogo,@CompanyBanner,
	@CopyrightInfo,@CopyrightInfoCN,@CopyrightInfoFN,@PageKeyWords,@PageKeyWordsCN,@PageKeyWordsFN,@PageDescription,@PageDescriptionCN,@PageDescriptionFN,@IsShowPowerBy)
end
else
begin
	update T_Config set DefaultLanguageID=@DefaultLanguageID,LanguageIDList=@LanguageIDList,CompanyName=@CompanyName,
	CompanyNameCN=@CompanyNameCN,CompanyNameFN=@CompanyNameFN,CompanyShortName=@CompanyShortName,CompanyShortNameFN=@CompanyShortNameFN,CompanyShortNameCN=@CompanyShortNameCN,
	CompanyAddress=@CompanyAddress,CompanyAddressCn=@CompanyAddressCn,CompanyAddressFn=@CompanyAddressFn,CompanyTel=@CompanyTel,Companyfax=@Companyfax,
	CompanyEmail=@CompanyEmail,CompanyHomePage=@CompanyHomePage,CompanyLogo=@CompanyLogo,CompanyBanner=@CompanyBanner,
	CopyrightInfo=@CopyrightInfo,CopyrightInfoCN=@CopyrightInfoCN,CopyrightInfoFN=@CopyrightInfoFN,PageKeyWords=@PageKeyWords,PageKeyWordsCN=@PageKeyWordsCN,PageKeyWordsFN=@PageKeyWordsFN,
	PageDescription=@PageDescription,PageDescriptionCN=@PageDescriptionCN,PageDescriptionFN=@PageDescriptionFN,Member=@Member,IsShowPowerBy = @IsShowPowerBy where [ID]=@ID
end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_Config]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_Config]
AS
select Top 1 * from T_Config
' 
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].[S_Get_T_Config_Language_Template]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Get_T_Config_Language_Template]
	@LanguageID int = 0	--语言ID
As
	Select Top 1 [LanguageIDList] From [T_Config]
' 
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].[S_Get_T_Config_Template]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_Config_Template]
	@LanguageID int = 0	--语言ID
As
Begin
	If (@LanguageID = 0)
		Select Top 1 [LanguageIDList],[CoverState],[CompanyNameCN] As CompanyName,[CompanyShortNameCN] As CompanyShortName,[CompanyAddressCN] As CompanyAddress,[CompanyTel],[CompanyFax],[CompanyEmail],[CompanyHomepage],[CompanyLogo],[CopyrightInfoCN] As CopyrightInfo,[ICP],[PageKeyWordsCN] As PageKeyWords,[PageDescriptionCN] As PageDescription,[CompanyBanner],''UTF-8'' As PageCharset,''0'' As PagelanguageId,[IsShowPowerBy]
			From [T_Config]
	Else If (@LanguageID = 1)
		Select Top 1 [LanguageIDList],[CoverState],[CompanyName],[CompanyShortName],[CompanyAddress],[CompanyTel],[CompanyFax],[CompanyEmail],[CompanyHomepage],[CompanyLogo],[CopyrightInfo],[ICP],[PageKeyWords],[PageDescription],[CompanyBanner],''UTF-8'' As PageCharset,''1'' As PagelanguageId,[IsShowPowerBy]
			From [T_Config]
	Else If (@LanguageID = 25)
		Select Top 1 [LanguageIDList],[CoverState],[CompanyNameFN] As CompanyName,[CompanyShortNameFN] As CompanyShortName,[CompanyAddressFN] As CompanyAddress,[CompanyTel],[CompanyFax],[CompanyEmail],[CompanyHomepage],[CompanyLogo],[CopyrightInfoFN] As CopyrightInfo,[ICP],[PageKeyWordsFN] As PageKeyWords,[PageDescriptionFN] As PageDescription,[CompanyBanner],''UTF-8'' As PageCharset,''25'' As PagelanguageId,[IsShowPowerBy]
			From [T_Config]
End
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_Home]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_Home]
	@LanguageID int	--语言ID,0为中文，1为英文
As
Begin
	Declare @TemplateID int	--模版ID
	Select @TemplateID = [ID] From [T_Template] Where (Case @LanguageID When 0 Then [TemplateCN] When 25 Then [TemplateFN] Else [TemplateEN] End) = 1
	Select [ID],[CateID],[LanguageID],[Title],[Content],[TemplateID] From [T_Home] Where [LanguageID] = @LanguageID And [TemplateID] = @TemplateID
End' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Del_T_Template]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Del_T_Template]
	@ID bigint	--模版ID
As
Begin
	Delete from  [T_Template] Where [TemplateCN] = 0 And [TemplateEN] = 0 And [TemplateFN] = 0 And [ID] = @ID
	Delete from  [T_Home] Where [TemplateID] = @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].[S_Get_T_Home_Info]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_Home_Info]
	@ID bigint
As
	Select Top 1 [ID],[CateID],[LanguageID],[Title],[Content] From [T_Home] Where [ID] = @ID
' 
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].[S_Update_T_Home]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Update_T_Home]
	@ID bigint,
	@Title nvarchar(255),	--标题
	@Content ntext	--内容
As
	Update [T_Home] Set [Title] = @Title,[Content] = @Content Where [ID] = @ID
' 
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].[S_Insert_T_Template]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Insert_T_Template] 
	@TemplateName nvarchar(50),	--模版名称
	@TypeId nvarchar(50),	--模版类型
	@Address nvarchar(255),	--模版地址
	@Explain ntext,	--说明
	@Image nvarchar(255),	--缩略图地址
	@Preview nvarchar(255)--预览地址
As
Begin
	Declare @i int	--块ID
	Declare @TemplateID bigint	--模版ID
	Set @i = 1
	Insert Into 
		[T_Template]([TemplateName],[TypeId],[Address],[Explain],[Image],[Preview])
		Values(@TemplateName,@TypeId,@Address,@Explain,@Image,@Preview)
	Set @TemplateID = @@IDENTITY
	If (@TemplateID > 0)
		While @i <= 4
		Begin
			Insert Into 
				[T_Home]([CateID],[LanguageID],[TemplateID])
				Values(@i,0,@TemplateID)
			Insert Into 
				[T_Home]([CateID],[LanguageID],[TemplateID])
				Values(@i,1,@TemplateID)
			Insert Into 
				[T_Home]([CateID],[LanguageID],[TemplateID])
				Values(@i,25,@TemplateID)
			Set @i = @i + 1
		End
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_memberLogin]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_memberLogin]
@UserName nvarchar(50),
@pass nvarchar(50),
@return int output
 AS
select * from T_member where UserName=@UserName and Pass=@pass and Appearance = 0
if(@@rowcount<1)
begin
 select * from T_member where userName=@username and Appearance = 0
 if(@@rowcount<1)
 begin
  set @return = 1 --找不到用户
 end
 else
 begin
  set @return = 2--密码错误
 end
end
else
begin
 set @return = 0 --成功
end
return @return
' 
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].[S_insert_Member]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_insert_Member]
	@UserName nvarchar(50),	--用户名
	@Pass nvarchar(255),	--密码
	@RealName nvarchar(50),	--真实姓名
	@Sex tinyint = 0,	--性别,0为保密，１为男性，２为女性
	@Nation nvarchar(50),	--国家
	@Province nvarchar(50),	--省份
	@City nvarchar(50),	--城市
	@Address nvarchar(255),	--地址
	@Code nvarchar(50),	--邮编
	@Phone nvarchar(50),	--电话
	@Fax nvarchar(20),	--传真
	@Email nvarchar(50),	--电子邮件
	@ID bigint output	--会员ID
As
Begin
	Select @ID = [ID] From [T_Member] Where [UserName] = @UserName
	If (@@RowCount < 1)
	Begin
		Insert Into 
			[T_Member]([UserName],[Pass],[RealName],[Sex],[Nation],[Province],[City],[Address],[Code],[Phone],[Fax],[Email])
			Values(@UserName,@Pass,@RealName,@Sex,@Nation,@Province,@City,@Address,@Code,@Phone,@Fax,@Email)
	Set @ID = @@IDENTITY
	End
	Return @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].[S_Get_T_Member]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Get_T_Member]
	@ID int	--会员ID
As
Begin
	Select Top 1 * From [T_Member] 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].[S_update_T_Member_Appearance]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_update_T_Member_Appearance]
	@ID bigint,	--会员ID
	@Appearance bit	--会员状态，０为解冻，１为冻结
As
Begin
	Update [T_Member] Set [Appearance] = @Appearance 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].[S_update_T_Member]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_update_T_Member]
	@ID int,	--会员ID
	@Pass nvarchar(255),	--会员密码
	@Sex tinyint,	--性别，０为保密，１为男性，２为女性
	@RealName nvarchar(50),	--会员姓名
	@Nation nvarchar(50),	--国家
	@Province nvarchar(50),	--省份
	@City nvarchar(50),	--城市
	@Address nvarchar(255),	--地址
	@Code nvarchar(50),	--邮编
	@Phone nvarchar(50),	--电话
	@Email nvarchar(50),	--电子邮件
	@Fax nvarchar(50)	--传真
As
Begin
	Update [T_Member]
		Set [Sex] = @Sex,
			[RealName] = @RealName,
			[Nation] = @Nation,
			[Province] = @Province,
			[City] = @City,
			[Address] = @Address,
			[Code] = @Code,
			[Phone] = @Phone,
			[Email] = @Email,
			[Fax] = @Fax
		Where [ID] = @ID
	If (@Pass <> '''')
		Update [T_Member] Set [Pass] = @Pass 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].[S_Insert_T_Order]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Insert_T_Order]
	@RealName nvarchar(5),	--真实姓名　
	@Address nvarchar(100),	--地址
	@Tel nvarchar(50),	--电话
	@Email nvarchar(100),	--电子邮件
	@OrderID nvarchar(50),	--订单号
	@AllPrice money,	--总价
	@UserID int,		--用户ID
	@ID bigint output
As
Begin
	Insert Into [T_Order]([RealName],[Address],[Tel],[Email],[OrderID],[AllPrice],[UserID])
		Values(@RealName,@Address,@Tel,@Email,@OrderID,@AllPrice,@UserID)
	Set @ID = @@IDENTITY
	Return @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].[S_Insert_T_OrderDetail]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Insert_T_OrderDetail]
	@OrderID bigint,	--订单ID
	@Num int,	--产品数量
	@ProductID bigint	--产品ID
As
Begin
	Declare @ProductName nvarchar(50)	--产品名称
	Declare @Price money	--产品单价
	Select Top 1 @ProductName = [Title],@Price = [Price] From [T_20_Product] Where [ID] = @ProductID
	Insert Into
		[T_OrderDetail]([OrderID],[ProductName],[Num],[Price])
		Values(@OrderID,@ProductName,@Num,@Price)
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].[S_Insert_T_QQOnline]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Insert_T_QQOnline]
	@QQ nvarchar(50),	--QQ号码
	@WebName nvarchar(50),	--留言的网站名称
	@Message nvarchar(255),	--图片旁的留言内容
	@IsHidden bit,	--是否隐藏，０为隐藏，１为显示
	@Pic	int	--QQ在线状态风格
As
	Insert Into
		[T_QQOnline]([QQ],[WebName],[Message],[IsHidden],[Pic])
		Values(@QQ,@WebName,@Message,@IsHidden,@Pic)
' 
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].[S_Get_T_QQOnline]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Get_T_QQOnline]
As
	Select * From [T_QQOnline]
' 
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].[S_UpDate_T_QQOnline]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_UpDate_T_QQOnline]
	@ID bigint,
	@QQ nvarchar(50),	--QQ号码
	@WebName nvarchar(50),	--留言的网站名称
	@Message nvarchar(255),	--图片旁的留言内容
	@IsHidden bit,	--是否隐藏，０为隐藏，１为显示
	@Pic	int	--QQ在线状态风格
As
	UpDate [T_QQOnline] Set [QQ] = @QQ,[WebName] = @WebName,[Message] = @Message,[IsHidden] = @IsHidden,[Pic] = @Pic
		Where [ID] = @ID
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_T_SysMenu]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE  [dbo].[S_update_T_SysMenu]
@ID int,
@Code nvarchar(4000),
@MenuTitle nvarchar(50),
@Description text,
@PageType int,
@IsOut bit,
@OutURL nvarchar(200),
@OpenType nvarchar(10),
@IsHidden bit,
@IsShowHome bit,
@LanguageID int,
@IsEncrypt bit,
@MenuType int,
@Isin bit,
@inURL bigint
AS
declare @oldCode nvarchar(4000)-----原始级别编码
Declare @Hidden bit	--父级显示状态
Set @Hidden = 0
	--判断父级显示状态，如果是隐藏，则其显示状态将为隐藏
	Select Top 1 @Hidden = [IsHidden] From [T_SysMenu] Where [Code] = (Select Top 1 Left([Code],Len([Code]) -4) From [T_SysMenu] Where [ID] = @ID) And [LanguageID] = @LanguageID
	If (@Hidden = 1)
		Set @IsHidden = 1
	select @oldCode = code from T_SysMenu where [ID]=@ID
	 
	update T_SysMenu set MenuTitle=@MenuTitle,
	[Description]=@Description,PageType=@PageType,
	IsOut=@IsOut,OutURL=@OutURL,OpenType=@OpenType,IsHidden=@IsHidden,IsShowHome=@IsShowHome,IsEncrypt=@IsEncrypt,Isin=@Isin,inURL=@inURL
	,LanguageID=@LanguageID,MenuType=@MenuType where [ID]=@ID
	--隐藏子级
	If (@IsHidden = 1)
		Update [T_SysMenu] Set [IsHidden] = @IsHidden Where [Code] Like (Select Top 1 [Code] From [T_SysMenu] Where [ID] = @ID) + ''%'' And [LanguageID] = @LanguageID
 
if(left(@oldCode,len(@oldCode)-4) != @Code)
begin----改变父级的时候所有的子级都要跟着改变
	declare @MaxCode varchar(4000)-----新父级下的子级最大的code
	select top 1 @MaxCode=code from T_SysMenu 
	where len(code) = len(@code)+4 and left(code,len(@code))=@code order by code desc
	if(@@rowcount<1)
	begin
		update T_SysMenu set code = STUFF(code,1,len(@oldCode),@code+''0001'') 
		 where left(code,len(@oldCode)) = @oldCode and LanguageID=@LanguageID
	end
	else
	begin
		set @MaxCode = right(@MaxCode,4)
		declare @size int
		select @size = @MaxCode + 1
		set @MaxCode = REPLICATE(''0'',4 - len(@size)) + convert(varchar(4000),@size)
		update T_SysMenu set code = STUFF(code,1,len(@oldCode),@code+@MaxCode)
		 where left(code,len(@oldCode)) = @oldCode and LanguageID=@LanguageID
	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].[S_Move]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Move]
	@intMoveType int,	--移动类型，０为上移，１为下移
	@strCode nvarchar(4000), --要移动的栏目编码
	@intLanguageID int	--语言ID,0为中文，1为英文
As
Begin
	Declare @strSql nvarchar(4000)
	Declare @strTemp nvarchar(4000)	--临时变量，值为上（下）栏目的编码
	Declare @intLength bigint	--栏目编码长度
	Declare @strTemp1 nvarchar(4000)
	Set @strTemp = ''''
	Set @intLength = Len(@strCode)
	Set @strTemp1 = Replicate(''0'',@intLength)
	--取得上（下）栏目的编码
	If (@intMoveType = 0)
	Begin
		Select Top 1 @strTemp = [Code] 
			From [T_SysMenu] 
			Where [LanguageID] = @intLanguageID And [IsDelete] = 0 And Len([Code]) = @intLength And Left([Code],@intLength - 4) = Left(@strCode,@intLength - 4) And [Code] < @strCode
			Order By [Code] Desc
	End
	If(@intMoveType = 1)
	Begin
		Select Top 1 @strTemp = [Code] 
			From [T_SysMenu] 
			Where [LanguageID] = @intLanguageID And [IsDelete] = 0 And Len([Code]) = @intLength And Left([Code],@intLength - 4) = Left(@strCode,@intLength - 4) And [Code] > @strCode
			Order By [Code]
	End
	--如果是尽头，则不更新
	If (@strTemp = '''')
		Return
	--临时把上（下）栏目的编码变为@intLength个0
	UpDate [T_SysMenu] Set [Code] = Stuff([Code],1,@intLength,@strTemp1)
		Where Left([Code],@intLength) = @strTemp And [LanguageID] = @intLanguageID And [IsDelete] = 0
	--更新要移动的栏目编码
	UpDate [T_SysMenu] Set [Code] = Stuff([Code],1,@intLength,@strTemp)
		Where Left([Code],@intLength) = @strCode And [LanguageID] = @intLanguageID And [IsDelete] = 0
	--更新上（下）栏目编码
	UpDate [T_SysMenu] Set [Code] = Stuff([Code],1,@intLength,@strCode)
		Where Left([Code],@intLength) = @strTemp1 And [LanguageID] = @intLanguageID And [IsDelete] = 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].[S_Del_SysMenu]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Del_SysMenu]
	@ID int,	--栏目ID
	@DeleteType int	--删除类型，0为假删除，1为真删除
AS
Begin
	Declare @I int
	Declare @Code nvarchar(4000)
	Declare @intLength int
	Declare @Language int
	Select Top 1 @Code = [Code],@Language = [LanguageID] From [T_SysMenu] Where [ID] = @ID
	Set @intLength = Len(@Code)
	Select @I = Count([ID])
		From [T_SysMenu]
		Where Left([Code],@intLength) = @Code And [IsDelete] = 0 And [LanguageID] = @Language
	--如果有子级，则不能删除
	If (@I > 1)
		Return
	If (@DeleteType = 0)
	Begin
		UpDate [T_SysMenu] Set [IsDelete] = 1 Where [ID] = @ID
		Return
	End
	If (@DeleteType = 1)
		Delete From [T_SysMenu] Where [ID] = @ID
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_SysMenu]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_SysMenu]
@SelectType int
AS
if(@SelectType=-1)
begin 
select T_SysMenu.*,T_SysPageType.* from T_SysMenu 
left outer join T_SysPageType on T_SysMenu.PageType = T_SysPageType.[ID]   order by T_SysMenu.code
end
else
begin
if(@SelectType=0)--查询所有
begin
select T_SysMenu.*,T_SysPageType.* from T_SysMenu
left outer join T_SysPageType on T_SysMenu.PageType = T_SysPageType.[ID] 
where T_SysMenu.isdelete =0 order by T_SysMenu.code
end
else 
begin 
if(@SelectType=1)--查询中文
begin 
select T_SysMenu.*,T_SysPageType.* from T_SysMenu 
left outer join T_SysPageType on T_SysMenu.PageType = T_SysPageType.[ID] 
where T_SysMenu.LanguageID=0 and T_SysMenu.isdelete =0 order by T_SysMenu.code
end
else if(@SelectType=2)--查询英文
begin
select T_SysMenu.*,T_SysPageType.* from T_SysMenu
left outer join T_SysPageType on T_SysMenu.PageType = T_SysPageType.[ID] 
where T_SysMenu.LanguageID=1 and T_SysMenu.isdelete =0 order by T_SysMenu.code
end
else if(@SelectType=26)--查询繁体
begin
select T_SysMenu.*,T_SysPageType.* from T_SysMenu
left outer join T_SysPageType on T_SysMenu.PageType = T_SysPageType.[ID] 
where T_SysMenu.LanguageID=25 and T_SysMenu.isdelete =0 order by T_SysMenu.code
end
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].[S_Get_T_SysMenu_Home]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_SysMenu_Home]
	@LanguageID int = 0,	--语言ID,0为中文，1为英文
	@PageType int,	--页面类型
	@Code nvarchar(4000)	--栏目编码
As
If (@Code = ''0000'')
	Select [ID]
		From [T_SysMenu]
		Where [PageType] = @PageType And [IsDelete] = 0 And [IsHidden] = 0 And [IsShowHome] = 1 And [LanguageID] = @LanguageID
Else
Select [ID]
		From [T_SysMenu]
		Where [PageType] = @PageType And [IsDelete] = 0 And [IsHidden] = 0 And [IsShowHome] = 1 And [LanguageID] = @LanguageID And [Code] Like @Code + ''%''
' 
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].[S_Get_T_SysMenu_SubMenu]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_SysMenu_SubMenu]
	@LanguageID int = 0,	--语言ID,0为中文，1为英文
	@Code nvarchar(4000)	--菜单编码
As
Begin
	Select [T_SysMenu].[ID] As ID,[T_SysMenu].[Code] As Code, [T_SysMenu].[MenuTitle] As MenuTitle,[T_SysMenu].[PageType] As PageType,[T_SysMenu].[IsOut] As IsOut,[T_SysMenu].[OutURL] As OutURL,[T_SysMenu].[OpenType] As OpenType,[T_SysMenu].[IsEncrypt] As IsEncrypt,[T_SysMenu].[IsShowHome] As IsShowHome,[T_SysPageType].[PageURL] As PageURL,[T_SysMenu].[Isin] As Isin,[T_SysMenu].[inURL] As inURL
		From [T_SysMenu]
		Left Join [T_SysPageType]
		On	[T_SysPageType].[ID] = [T_SysMenu].[PageType]
		Where [T_SysMenu].[IsDelete] = 0 And [T_SysMenu].[IsHidden] = 0 And [T_SysMenu].[LanguageID] = @LanguageID And [T_SysMenu].[Code] Like @Code + ''%''
		Order By [T_SysMenu].[Code]
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].[S_Get_T_SysMenu_Template]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_SysMenu_Template]
	@LanguageID int = 0,	--语言ID
	@MenuType int = 1	--菜单类型，1为上菜单，２为下菜单
As
Select [T_SysMenu].[ID] As ID,[T_SysMenu].[Code] As Code,[T_SysMenu].[MenuTitle] As MenuTitle,[T_SysMenu].[PageType] As PageType,[T_SysMenu].[IsOut] As IsOut,[T_SysMenu].[OutURL] As OutURL,[T_SysMenu].[OpenType] As OpenType,[T_SysMenu].[IsEncrypt] As IsEncrypt,[T_SysMenu].[IsShowHome] As IsShowHome,[T_SysPageType].[PageURL] As PageURL,[T_SysMenu].[Isin] As Isin,[T_SysMenu].[inURL] As inURL
		From [T_SysMenu]
		Left Join [T_SysPageType]
		On	[T_SysPageType].[ID] = [T_SysMenu].[PageType]
		Where [T_SysMenu].[IsDelete] = 0 And [T_SysMenu].[IsHidden] = 0 And [T_SysMenu].[LanguageID] = @LanguageID And [T_SysMenu].[MenuType] = @MenuType
		Order By [T_SysMenu].[Code]
' 
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].[S_insert_T_SysMenu]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE  [dbo].[S_insert_T_SysMenu]
@Code nvarchar(4000),
@MenuTitle nvarchar(50),
@Description text,
@PageType int,
@IsOut bit,
@OutURL nvarchar(200),
@OpenType nvarchar(10),
@IsHidden bit,
@IsShowHome bit,
@LanguageID int,
@IsEncrypt bit,
@MenuType int,
@Isin bit,
@inURL bigint
AS
Declare @Hidden bit	--父级隐藏状态
Set @Hidden = 0
If (Len(@Code) > 4)
Begin
	Select Top 1 @Hidden = [IsHidden] From [T_SysMenu] Where [Code] = Left(@Code,Len(Code) - 4) And [LanguageID] = @LanguageID
	If (@Hidden = 1)
		Set @IsHidden = 1
End
insert into T_SysMenu(Code,MenuTitle,[Description],PageType,IsOut,OutURL,OpenType,IsHidden,IsShowHome,LanguageID,MenuType,IsEncrypt,Isin,inURL)
values (@Code,@MenuTitle,@Description,@PageType,@IsOut,@OutURL,@OpenType,@IsHidden,@IsShowHome,@LanguageID,@MenuType,@IsEncrypt,@Isin,@inURL)
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_SysMenuType]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_SysMenuType] AS
select * from T_SysMenuType
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_SysPageType]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_SysPageType] AS
select * from T_SysPageType where IsHidden = 0  order by [ID]
' 
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].[S_Get_T_SysPageType_Template]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_SysPageType_Template]
	@PageType int	--页面类型
As
Begin
	Select Top 1 [PageURL] 
		From [T_SysPageType] 
		Where [ID] = @PageType
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].[S_Get_Template_Address]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_Template_Address]
	@LanguageID int	--语言ID,0为中文，1为英文
As
Begin
	If (@LanguageID = 0)
		Select Top 1 [Address] From [T_Template] Where [TemplateCN] = 1
	Else If (@LanguageID = 1)
		Select Top 1 [Address] From [T_Template] Where [TemplateEN] = 1
	Else If (@LanguageID = 25)
		Select Top 1 [Address] From [T_Template] Where [TemplateFN] = 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].[S_update_T_Template]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_update_T_Template]
	@ID bigint,	--模版ID
	@TemplateCN bit = 0,	--中文模版，选中为１
	@TemplateEN bit = 0,	--英文模版，选中为１
	@TemplateFN bit = 0		--繁体模版，选中为１
As
Begin
	If (@TemplateCN = 1)
	Begin
		UpDate [T_Template] Set [TemplateCN] = 0 Where [TemplateCN] = 1
		UPDate [T_Template] Set [TemplateCN] = 1 Where [ID] = @ID
	End
	If (@TemplateEN = 1)
	Begin
		UpDate [T_Template] Set [TemplateEN] = 0 Where [TemplateEN] = 1
		UPDate [T_Template] Set [TemplateEN] = 1 Where [ID] = @ID
	End
	If (@TemplateFN = 1)
	Begin
		UpDate [T_Template] Set [TemplateFN] = 0 Where [TemplateFN] = 1
		UPDate [T_Template] Set [TemplateFN] = 1 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].[S_Get_TemplateType_Main]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Get_TemplateType_Main]
As
	Select [ID],[TypeName] From [T_TemplateType] Where [FatherClassId] = 0
' 
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].[S_Get_TemplateType_Son]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Get_TemplateType_Son]
	@FatherClassId bigint	--父ID
As
	Select [ID],[TypeName] From [T_TemplateType] Where [FatherClassId] = @FatherClassId
' 
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].[S_Get_T_TemplateType]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Get_T_TemplateType]
As
	Select [ID],[TypeName],[FatherClassId] From [T_TemplateType]
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_insert_T_80_gBook]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_insert_T_80_gBook]
@cateID bigint,
@UserName nvarchar(50),
@Title nvarchar(50),
@Email nvarchar(100),
@Content text,
@QQ nvarchar(50),
@MSN nvarchar(255),
@HomePage nvarchar(50),
@IP nvarchar(50),
@Face nvarchar(50),
@Source nvarchar(255),
@Heart nvarchar(50),
@Sex nvarchar(10),
@Company nvarchar(50),
@Address nvarchar(50),
@Fax nvarchar(50),
@Tel nvarchar(50)
 AS
insert into T_80_gBook (cateID,UserName,Title,Email,Content,QQ,MSN,HomePage,IP,Face,Source,Heart,Sex,Company,Address,Fax,Tel) values
(@cateID,@UserName,@Title,@Email,@Content,@QQ,@MSN,@HomePage,@IP,@Face,@Source,@Heart,@Sex,@Company,@Address,@Fax,@Tel)' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_insert_T_85_Feedback]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_insert_T_85_Feedback]
@cateID bigint,
@UserName nvarchar(50),
@Title nvarchar(50),
@Email nvarchar(100),
@Content text,
@QQ nvarchar(50),
@MSN nvarchar(255),
@HomePage nvarchar(50),
@IP nvarchar(50),
@Face nvarchar(50),
@Source nvarchar(255),
@Heart nvarchar(50),
@Sex nvarchar(10),
@Company nvarchar(50),
@Address nvarchar(50),
@Fax nvarchar(50),
@Tel nvarchar(50)
 AS
insert into T_85_Feedback (cateID,UserName,Title,Email,Content,QQ,MSN,HomePage,IP,Face,Source,Heart,Sex,Company,Address,Fax,Tel) values
(@cateID,@UserName,@Title,@Email,@Content,@QQ,@MSN,@HomePage,@IP,@Face,@Source,@Heart,@Sex,@Company,@Address,@Fax,@Tel)' 
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].[S_Get_T_10_List]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE Proc [dbo].[S_Get_T_10_List] 
	@Table varchar(50) = ''T_10_List'',	--表名
	@Coloum varchar(50) = ''ID'',	--按该字段来进行分页
	@ColoumType int = 0,		--@col字段的类型,0-数字类型,1-字符类型,2-日期时间类型
	@OrderType bit = 1,	--排序,0-顺序,1-倒序
	@ColoumList varchar(800) = ''*'',	--要查询出的字段列表,* 表示全部字段
	@PageSize int = 20,	--每页记录数
	@Page int = 1,	--指定页
	@Filter varchar(800) = Null,	--查询条件
	@Order varchar(800) = Null,	--排序字段 
	@Counts int OutPut	--总记录数
As
Begin
	Declare @PageOrder nvarchar(4)	--排序类型
	If (@OrderType = 0)
		Set @PageOrder = ''Asc''
	Else
		Set @PageOrder = ''Desc''
	Exec [S_Page] @Table,@Coloum,@PageOrder,@Page,@PageSize,@ColoumList,@Filter,@Order,@Counts OutPut	
	--Exec [sp_page3] @Table,@Coloum,@ColoumType,@OrderType,@ColoumList,@PageSize,@Page,@Filter,@Order,@Counts OutPut
	Return @Counts
End' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_insert_Info]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE  [dbo].[S_insert_Info]
@cateID bigint,
@content text,
@ID bigint output
AS
select @ID=[ID] from T_00_Info where cateID = @cateID
if(@@rowcount<1)
begin
insert into T_00_Info(cateID,content) values(@cateID,@content)
set @ID = @@IDENTITY
end
else
begin
update T_00_Info set content=@content where cateID=@cateID
end
return @ID
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_00_Info]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_00_Info]
@cateID bigint
 AS
select * from T_00_Info where cateID=@cateID
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_10_ListDetail]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_10_ListDetail]
@ID bigint
AS
select * from T_10_List where [ID]=@ID
' 
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].[S_insert_T_10_list]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_insert_T_10_list] 
	@cateID BigInt,
	@Title Nvarchar(255),
	@Author Nvarchar(50),
	@Source Nvarchar(50),
	@picURL Nvarchar(50),
	@KeyWord Nvarchar(100),
	@IsTop Bit,
	@IsGood Bit,
	@IsHidden Bit,
	@IsPic Bit,
	@Content Text,
	@ID Bigint output
AS
	insert into T_10_list (cateID,Title,KeyWord,Author,Source,picURL,IsTop,IsGood,IsHidden,IsPic,Content) 
	values (@cateID,@Title,@KeyWord,@Author,@Source,@picURL,@IsTop,@IsGood,@IsHidden,@IsPic,@Content) 
	set @ID = @@IDENTITY
	return @ID
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_T_10_list]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_update_T_10_list] 
	@ID Bigint,
	@cateID BigInt,
	@Title Nvarchar(255),
	@Author Nvarchar(50),
	@Source Nvarchar(50),
	@picURL Nvarchar(50),
	@KeyWord Nvarchar(100),
	@IsTop Bit,
	@IsGood Bit,
	@IsHidden Bit,
	@IsPic Bit,
	@Content Text
AS
	update T_10_list set cateID=@cateID,Title=@Title,KeyWord=@KeyWord,
	Author=@Author,Source=@Source,picURL=@picURL,IsTop=@IsTop,IsGood=@IsGood,
	IsHidden=@IsHidden,IsPic=@IsPic,Content=@Content where [ID] =@ID
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_T_20_Product]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_update_T_20_Product]
@ID bigint,
@cateID bigint,
@Title nvarchar(50),
@picUrl nvarchar(100),
@spicUrl nvarchar(100),
@partNumber nvarchar(100),
@isTop bit,
@isGood bit,
@isHidden bit,
@Description text,
@parameter text,
@unit nvarchar(50),
@isBuy bit,
@Quanlity int,
@price money
AS
if(@ID=0)--添加
begin
declare @newOrderID int
set @newOrderID = (select max([orderID]) from T_20_Product where cateID=@cateID) + 1 
if @newOrderID=null
set @newOrderID = 0
insert into T_20_Product (cateID,Title,picUrl,spicUrl,partNumber,istop,isgood,ishidden,[description],parameter,unit,isbuy,quanlity,price,orderID,viewnum)  values
 (@cateID,@Title,@picUrl,@spicUrl,@partNumber,@istop,@isgood,@ishidden,@description,@parameter,@unit,@isbuy,@quanlity,@price,@newOrderID,0)
end
else
begin
update T_20_Product  set cateID=@cateID,Title=@Title,picUrl=@picUrl,spicUrl=@spicUrl,partNumber=@partNumber,istop=@istop,isgood=@isgood,
ishidden=@ishidden,[description]=@description,parameter=@parameter,unit=@unit,isbuy=@isbuy,quanlity=@quanlity,price=@price 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].[S_Get_T_20_Product_Price]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create Proc [dbo].[S_Get_T_20_Product_Price]
	@ProductId bigint	--产品ID
As
	Select Top 1 [Price] From [T_20_Product] Where [ID] = @ProductID
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_AdminLogInfo]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_AdminLogInfo]
@CurrentPage int =1,
@PageSize int = 20,
@Counts int OUTPUT   --总记录数
AS
exec sp_page ''T_AdminLogInfo'',''ID'',0,1,''ID, LoginTime, UserID, AdminID, Valid, IP, Reason,(SELECT username FROM t_adminuser WHERE t_adminuser.id = adminid) AS username'',@PageSize,@CurrentPage,'''',@Counts output
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_AdminOpt]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_AdminOpt]
@CurrentPage int =1,
@PageSize int = 20,
@Counts int OUTPUT   --总记录数
AS
exec sp_page ''T_AdminOpt'',''ID'',0,1,''ID, OptTime, OptDes, OptUID, (SELECT username FROM t_adminuser WHERE t_adminuser.id = OptUID) AS username,(SELECT UserID FROM t_adminuser WHERE t_adminuser.id = OptUID) AS userid'',@PageSize,@CurrentPage,'''',@Counts output
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_Template]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_Template]
@CurrentPage int =1,
@PageSize int = 20,
@TypeId nvarchar(50),
@Counts int OUTPUT   --总记录数
AS
Begin
Declare @condition nvarchar(800)
If (@TypeId = '',0,'')
Begin
	exec sp_page ''[T_Template]'',''[ID]'',0,0,''[ID],[TemplateName],[Address],[Explain],[Image],[Preview],[TemplateCN],[TemplateEN],[TemplateFN]'',@PageSize,@CurrentPage,'''',@Counts output
End
Else 
Begin
	Set @condition = ''[TypeId] Like ''''%'' + @TypeId + ''%''''''
	exec sp_page ''[T_Template]'',''[ID]'',0,0,''[ID],[TemplateName],[Address],[Explain],[Image],[Preview],[TemplateCN],[TemplateEN],[TemplateFN]'',@PageSize,@CurrentPage,@condition,@Counts output
End
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_T_25_PicList]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_update_T_25_PicList]
@ID bigint,
@cateID bigint,
@Title nvarchar(50),
@spicUrl nvarchar(100),
@picUrl nvarchar(100),
@Discription text,
@isTop bit,
@isGood bit,
@isHidden bit,
@parameter text
 AS
if(@id=0)--添加
begin
declare @newOrderID int
set @newOrderID = (select max([orderID]) from T_25_PicList where cateID=@cateID) + 1 
if @newOrderID=null
set @newOrderID = 0
insert into T_25_PicList (cateID,Title,spicUrl,picUrl,Discription,orderID,isTop,isGood,ishidden,Parameter,ViewNum) values
(@cateID,@Title,@spicUrl,@picUrl,@Discription,@newOrderID,@isTop,@isGood,@ishidden,@Parameter,0)
end
else -- 修改
begin
update T_25_PicList set cateID=@cateID ,Title=@Title,spicUrl=@spicUrl,picUrl=@picUrl,Discription=@Discription,isTop=@isTop,isGood=@isGood,
isHidden=@isHidden,parameter=@parameter where [id]=@id
end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_T_30_Download]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_update_T_30_Download]
@ID bigint,
@cateID bigint,
@Title nvarchar(50),
@picUrl nvarchar(100),
@loadUrl nvarchar(100),
@isTop bit,
@isGood bit,
@isHidden bit,
@Discription text,
@parameter text,
@filesize nvarchar(50),
@score int,
@os nvarchar(100),
@viesion nvarchar(50)
AS
if(@ID=0)--添加
begin
declare @newOrderID int
set @newOrderID = (select max([orderID]) from T_30_Download where cateID=@cateID) + 1 
if @newOrderID=null
set @newOrderID = 0
insert into T_30_Download (cateID,Title,picUrl,loadUrl,orderID,istop,isgood,isHidden,Discription,parameter,score,os,viesion,filesize,viewnum)
values (@cateID,@Title,@picUrl,@loadUrl,@newOrderID,@istop,@isgood,@isHidden,@Discription,@parameter,@score,@os,@viesion,@filesize,0)
end
else
begin
update T_30_Download  set cateID=@cateID,Title=@Title,picUrl=@picUrl,loadUrl=@loadUrl
,istop=@isTop,isgood=@isgood,isHidden=@ishidden,Discription=@Discription,
parameter=@parameter,score=@score,os=@os,viesion=@viesion,filesize=@filesize 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].[S_update_T_70_QA]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'Create PROCEDURE [dbo].[S_update_T_70_QA] 
	@ID bigint,
	@Question nvarchar(4000),	--问题
	@Answer nvarchar(4000),	--答案
	@IsTop bit=0,	--固顶
	@IsHidden bit=0	--隐藏
AS
Begin
Update [T_70_QA] Set [Question]=@Question,[Answer]=@Answer,[IsTop]=@IsTop,[IsHidden]=@IsHidden Where [ID]=@ID
return 
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].[S_insert_T_70_QA]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_insert_T_70_QA] 
	@Question nvarchar(4000),	--问题
	@Answer nvarchar(4000),	--答案
	@IsTop bit=0,	--固顶
	@IsHidden bit=0,	--隐藏
	@CateID bigint
AS
Begin
Declare @OrderID bigint
set @OrderID=(Select Max([OrderID])From [T_70_QA] Where [CateID]=@CateID)+1
If @OrderID Is Null Or @OrderID = ''''
	Set @OrderID=0
insert into T_70_QA ([Question],[Answer],[OrderID],[IsTop],[IsHidden],[CateID]) 
	values (@Question,@Answer,@OrderID,@IsTop,@IsHidden,@CateID) 
return 
End
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_update_Link]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_update_Link]
@ID bigint,
@cateID bigint,
@Title nvarchar(50),
@url nvarchar(100),
@picUrl nvarchar(100),
@IsGood bit,
@IsTop bit,
@IsHidden bit,
@orderID int,
@TypeID int
as
if(@ID=0)
	begin
		declare @newOrderID int
		set @newOrderID = (select max([orderID]) from T_90_Link where cateID=@cateID) + 1 
		if @newOrderID=null
		set @newOrderID = 0
		insert into T_90_Link (cateID,Title,url,picurl,isgood,istop,ishidden,orderID,TypeID) values 
		(@cateID,@Title,@url,@picurl,@isgood,@istop,@ishidden,@newOrderID,@TypeID)
	end
	else
	begin
		update T_90_Link set cateID=@cateID,Title=@Title,url=@url,picurl=@picurl,isgood=@isgood,
		istop=@istop,ishidden=@ishidden,orderID=@orderID,
		TypeID=@TypeID where [ID]=@ID
	end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_WriteLog]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_WriteLog]
@UserID nvarchar(50),
@AdminID int,
@Valid bit,
@IP nvarchar(50),
@Reason nvarchar(50)
 AS
insert into T_AdminLogInfo(UserID,AdminID,Valid,IP,Reason) values(@UserID,@AdminID,@Valid,@IP,@Reason)
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Del_AdminLogInfo]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Del_AdminLogInfo]
@DelAll bit = 0,
@AdminID bigint = 0,
@ArrID nvarchar(1000)
AS
if (@DelAll = 1)
    begin
        delete from [T_AdminLogInfo]
    end
else if (@AdminID =0)
    begin
        delete from [T_AdminLogInfo] where AdminID = @AdminID
    end
else
    begin
        delete from [T_AdminLogInfo] where ID in (@ArrID)
    end
' 
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[S_Get_T_AdminMenu]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[S_Get_T_AdminMenu]
AS
select * from T_AdminMenu order by code
' 
END

/***************添加基础数据********************/
 SET IDENTITY_INSERT [T_AdminMenu] ON

 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 1 , '0001' , '中文版管理' , 'MenuManage/menulist.aspx' , 0 , 5 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 2 , '0002' , '英文版管理' , 'MenuManage/menulist.aspx' , 0 , 4 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 3 , '0003' , '系统设置' , 'UserManage/UserList.aspx' , 0 , 2 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 4 , '00030001' , '角色管理' , 'UserManage/RolesList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 5 , '00030002' , '角色用户管理' , 'UserManage/UserList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 6 , '00010001' , '中文版栏目管理' , 'MenuManage/menulist.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 7 , '00010002' , '中文版首页内容' , 'HomeManage/Homelist.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 8 , '00010003' , '中文版模版' , 'TemplateManage/TemplateList.aspx?TypeId=0' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 9 , '00020001' , '英文版栏目管理' , 'MenuManage/menulist.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 10 , '00020002' , '英文版首页内容' , 'HomeManage/Homelist.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 11 , '00020003' , '英文版模版' , 'TemplateManage/TemplateList.aspx?TypeId=0' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 12 , '00030004' , '登录日志' , 'AdminLog/AdminLog.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 13 , '00030005' , '操作日志' , 'AdminLog/AdminOpt.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 14 , '00030006' , '数据备份' , 'backup/DAManage.aspx' , 1 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [IsHidden] , [OrderID] ) VALUES ( 15 , '0004' , '资源管理器' , 0 , 1 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 16 , '00030003' , '会员管理' , '../Member/userlist.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 17 , '00030007' , 'ICP备案号' , 'ICP.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 18 , '00030008' , '模版管理' , 'TemplateManage/TemplateList.aspx?TypeId=0' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 19 , '00030009' , '网站基本信息设置' , 'BaseSetting.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 20 , '00010004' , '订单列表' , 'order/orderList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 21 , '00020004' , '订单列表' , 'order/orderList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 22 , '00030010' , 'QQ在线管理' , 'QQOnline/QQOnlineList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 23 , '00030011' , '广告管理' , 'AdvManage/AdvList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 24 , '00010005' , '投票管理' , 'VoteManage/VoteList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 25 , '00020005' , '投票管理' , 'VoteManage/VoteList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 26 , '0005' , '繁体版管理' , 'MenuManage/menulist.aspx' , 0 , 3 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 27 , '00050001' , '繁体版栏目管理' , 'MenuManage/menulist.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 28 , '00050002' , '繁体版首页内容' , 'HomeManage/Homelist.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 29 , '00050003' , '繁文版模版' , 'TemplateManage/TemplateList.aspx?TypeId=0' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 30 , '00050004' , '订单列表' , 'order/orderList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 31 , '00050005' , '投票管理' , 'VoteManage/VoteList.aspx' , 0 , 0 )
 INSERT [T_AdminMenu] ( [ID] , [Code] , [MenuTitle] , [URL] , [IsHidden] , [OrderID] ) VALUES ( 32 , '00030012' , '富码企业电视' , 'eootv/eootv.aspx' , 0 , 0 )

 SET IDENTITY_INSERT [T_AdminMenu] OFF

 SET IDENTITY_INSERT [T_AdminRole] ON

 INSERT [T_AdminRole] ( [ID] , [RoleTitle] , [Power] , [MenuPower] , [IsLock] , [IsDelete] ) VALUES ( 1 , '管理员' , '1,6,7,8,20,2,9,10,11,21,3,4,5,16,12,13,14,17,18,19,22,23,15,' , '' , 0 , 0 )

 SET IDENTITY_INSERT [T_AdminRole] OFF

 SET IDENTITY_INSERT [T_AdminUser] ON

 INSERT [T_AdminUser] ( [ID] , [UserID] , [PassWord] , [UserName] , [LoginTimes] , [LatestLoginTime] , [LatestLoginIP] , [RoleID] , [Power] , [IsLock] , [IsDelete] ) VALUES ( 1 , 'admin' , 'F6FDFFE48C908DEB0F4C3BD36C032E72' , '管理员' , 536 , '2006-12-06 14:50:06.810' , '192.168.0.181' , 0 , '1,6,7,8,20,2,9,10,11,21,3,4,5,16,12,13,14,17,18,19,26,27,28,29,30,31' , 0 , 0 )

 SET IDENTITY_INSERT [T_AdminUser] OFF

 INSERT [T_SysLanguage] ( [ID] , [LanguageTitle] , [Folder] ) VALUES ( 0 , 'Chinese' , 'CN' )
 INSERT [T_SysLanguage] ( [ID] , [LanguageTitle] , [Folder] ) VALUES ( 1 , 'English' , 'EN' )

 SET IDENTITY_INSERT [T_SysMenuType] ON

 INSERT [T_SysMenuType] ( [ID] , [Title] , [Description] ) VALUES ( 1 , '顶部的菜单(针对一级栏目)' , '顶部的菜单' )
 INSERT [T_SysMenuType] ( [ID] , [Title] , [Description] ) VALUES ( 2 , '底部的菜单(针对一级栏目)' , '底部的菜单' )

 SET IDENTITY_INSERT [T_SysMenuType] OFF

 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [Description] , [PageURL] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 0 , '0001' , '单页图文' , '用于建立只有单一网页的栏目；如企业介绍、联系方法等' , 'Info.aspx' , 'PageType/Info.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [Description] , [PageURL] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 10 , '0002' , '新闻文章' , '文章栏目，用于新闻、文章、资料等文字性栏目；可建多层分类' , 'List.aspx' , 'PageType/ListInfo.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [Description] , [PageURL] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 20 , '0003' , '产品类别' , '仅仅用于产品栏目；' , 'ProductList.aspx' , 'PageType/ProductList.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [Description] , [PageURL] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 25 , '0004' , '图片集' , '图文栏目，如产品、证书、业绩展示等图片展示性栏目；可建多层分类' , 'PicList.aspx' , 'PageType/PicList.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [PageURL] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 30 , '0005' , '下载' , 'Download.aspx' , 'PageType/LoadList.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [Description] , [PageURL] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 70 , '0006' , 'QA' , '问题问答管理' , 'QA.aspx' , 'PageType/QA.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [Description] , [PageURL] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 80 , '0007' , '留言板' , '用于建立网站留言板' , 'gBook.aspx' , 'PageType/LeaveWordList.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [Description] , [PageURL] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 85 , '0008' , '反馈' , '' , 'Feedback.aspx' , 'PageType/Feedback.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [PageURL] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 90 , '0009' , '友情连接' , 'LinkList.aspx' , 'PageType/LinkList.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 95 , '0011' , '内部链接' , 'MenuManage/editsysMenu.aspx' , 0 , 0 )
 INSERT [T_SysPageType] ( [ID] , [Code] , [PageTypeTitle] , [AdminPage] , [IsHidden] , [IsDelete] ) VALUES ( 99 , '0010' , '外部连接' , 'MenuManage/editsysMenu.aspx' , 0 , 0 )

 SET IDENTITY_INSERT [T_TemplateType] ON

 INSERT [T_TemplateType] ( [ID] , [TypeName] , [FatherClassId] ) VALUES ( 1 , '示例模版' , 0 )

 SET IDENTITY_INSERT [T_TemplateType] OFF