If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Ad]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Ad]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_AdCategory]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_AdCategory]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Admin]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Admin]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Anomaly]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Anomaly]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Article]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Article]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Card]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Card]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Channel]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Channel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Collection]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Collection]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_CollectionAddress]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_CollectionAddress]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Column]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Column]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Controller]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Controller]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_CountDay]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_CountDay]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_CountMonth]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_CountMonth]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_CountWeek]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_CountWeek]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_CountYear]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_CountYear]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_CustomForm]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_CustomForm]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_CustomFormField]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_CustomFormField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Dictionary]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Dictionary]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Dig]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Dig]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_DownLoadAddress]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_DownLoadAddress]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_DownLoadData]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_DownLoadData]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_DownLoadServerData]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_DownLoadServerData]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_DownLoadServerType]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_DownLoadServerType]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Enterprise]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Enterprise]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_ExpireArticle]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_ExpireArticle]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_ExtendContent]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_ExtendContent]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_FeedBack]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_FeedBack]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Form_Mayor]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Form_Mayor]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_HireInfo]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_HireInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Image]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Image]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_LabelContent]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_LabelContent]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_LbCategory]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_LbCategory]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Link]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Link]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_ListStyleContent]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_ListStyleContent]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Log]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Log]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Model]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Model]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_ModelField]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_ModelField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Notice]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Notice]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_PowerColumn]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_PowerColumn]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_PowerGroup]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_PowerGroup]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Property]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Property]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_RechargeRecord]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_RechargeRecord]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Report]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Report]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Review]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Review]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_SalesProject]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_SalesProject]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_SinglePage]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_SinglePage]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Special]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Special]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Style]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Style]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_StyleCategory]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_StyleCategory]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_SubSite]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_SubSite]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_SuperLabel]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_SuperLabel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Superior]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Superior]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Tag]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Tag]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_TagCategory]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_TagCategory]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_TempTable]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_TempTable]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserAlbum]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserAlbum]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserCate]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserCate]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserFavorite]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserFavorite]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserFriend]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserFriend]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserFriendGroup]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserFriendGroup]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserGroup]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserGroup]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserGroupModel]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserGroupModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserGroupModelField]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserGroupModelField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserLog]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserLog]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserMessage]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserMessage]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserPhoto]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserPhoto]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_UserSpace]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_UserSpace]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_User_Business]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_User_Business]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_User_Personal]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_User_Personal]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Users]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Users]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_ViewLog]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_ViewLog]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_Vote]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_Vote]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_VoteCategory]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_VoteCategory]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_VoteSubject]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_VoteSubject]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_WebMessage]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_WebMessage]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Qianbo_WorkFlow]')
                  And OBJECTPROPERTY(id, N'IsUserTable') = 1)
  Drop Table [dbo].[Qianbo_WorkFlow]
GO
Create Table [dbo].[Qianbo_Ad]
  (
     [AdId]       [int] Identity (1, 1) Not Null,
     [CategoryId] [varchar] (100) Collate Chinese_PRC_CI_AS Null,
     [AdName]     [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [AdType]     [int] Null,
     [Content]    [nvarchar] (1000) Collate Chinese_PRC_CI_AS Null,
     [EndTime]    [datetime] Null,
     [Weight]     [int] Null,
     [HitCount]   [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_AdCategory]
  (
     [AdCategoryId] [int] Identity (1, 1) Not Null,
     [CategoryName] [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [IsDisabled]   [int] Null,
     [WidthHeigth]  [varchar] (12) Collate Chinese_PRC_CI_AS Null,
     [DisplayType]  [int] Null,
     [Description]  [nvarchar] (50) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Admin]
  (
     [UserId]          [int] Identity (1, 1) Not Null,
     [LoginName]       [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [UserName]        [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [Password]        [varchar] (200) Collate Chinese_PRC_CI_AS Null,
     [LastLoginIP]     [varchar] (11) Collate Chinese_PRC_CI_AS Null,
     [LastLoginTime]   [datetime] Null,
     [LastLogoutTime]  [datetime] Null,
     [LoginTime]       [int] Null,
     [AllowMultiLogin] [bit] Null,
     [CheckCount]      [int] Null,
     [AddCount]        [int] Null,
     [RejectCount]     [int] Null,
     [GroupId]         [int] Null,
     [GroupName]       [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [RandNumber]      [varchar] (30) Collate Chinese_PRC_CI_AS Null,
     [SiteId]          [int] Null,
     [Contact]         [nvarchar] (300) Collate Chinese_PRC_CI_AS Null,
     [Locked]          [bit] Null,
     [IsSiteManage]    [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Anomaly]
  (
     [Id]      [int] Identity (1, 1) Not Null,
     [InfoId]  [int] Null,
     [ChId]    [int] Null,
     [ColName] [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Title]   [varchar] (200) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Article]
  (
     [Id]                [int] Identity (1, 1) Not Null,
     [ChId]              [int] Null,
     [ColId]             [int] Not Null,
     [Title]             [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [TitleColor]        [nvarchar] (6) Collate Chinese_PRC_CI_AS Null,
     [TitleFontType]     [int] Null,
     [TitleType]         [int] Null,
     [TitleImgPath]      [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [UId]               [int] Not Null,
     [UName]             [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [UserType]          [int] Not Null,
     [AdminUId]          [int] Null,
     [AdminUName]        [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [Status]            [int] Null,
     [HitCount]          [int] Null,
     [AddTime]           [datetime] Not Null,
     [UpdateTime]        [datetime] Not Null,
     [TemplatePath]      [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [PageType]          [int] Null,
     [IsCreated]         [bit] Null,
     [UserCateId]        [int] Null,
     [PointCount]        [int] Null,
     [ChargeType]        [int] Null,
     [ChargeHourCount]   [int] Null,
     [ChargeViewCount]   [int] Null,
     [IsOpened]          [int] Null,
     [GroupIdStr]        [varchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsDeleted]         [bit] Null,
     [IsRecommend]       [bit] Null,
     [IsTop]             [bit] Null,
     [IsFocus]           [bit] Null,
     [IsSideShow]        [bit] Null,
     [IsAllowComment]    [bit] Null,
     [TagIdStr]          [varchar] (300) Collate Chinese_PRC_CI_AS Null,
     [TagNameStr]        [nvarchar] (300) Collate Chinese_PRC_CI_AS Null,
     [SpecialIdStr]      [varchar] (200) Collate Chinese_PRC_CI_AS Null,
     [LongTitle]         [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [Content]           [ntext] Collate Chinese_PRC_CI_AS Null,
     [ShortContent]      [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [OuterUrl]          [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [Author]            [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Source]            [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [IsHeader]          [bit] Null,
     [HeaderFont]        [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [HeaderImgPath]     [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [StarLevel]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [IsShowCommentLink] [bit] Null,
     [IsIrregular]       [bit] Null,
     [IrregularId]       [int] Null,
     [ViewUName]         [ntext] Collate Chinese_PRC_CI_AS Null,
     [ViewUName2]        [ntext] Collate Chinese_PRC_CI_AS Null,
     [ViewEndTime]       [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [ExpireTime]        [datetime] Not Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_Card]
  (
     [ID]          [int] Identity (1, 1) Not Null,
     [Type]        [int] Null,
     [CardAccount] [varchar] (20) Collate Chinese_PRC_CI_AS Null,
     [Password]    [varchar] (200) Collate Chinese_PRC_CI_AS Not Null,
     [IsUsed]      [bit] Null,
     [CardPoint]   [int] Null,
     [CardDay]     [int] Null,
     [AdminID]     [int] Null,
     [AdminName]   [varchar] (50) Collate Chinese_PRC_CI_AS Null,
     [UserID]      [int] Null,
     [UserName]    [nvarchar] (18) Collate Chinese_PRC_CI_AS Null,
     [OverdueDate] [datetime] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Channel]
  (
     [ChId]                [int] Identity (1, 1) Not Null,
     [ChName]              [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [Description]         [nvarchar] (255) Collate Chinese_PRC_CI_AS Null,
     [TemplatePath]        [nvarchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [IsChildSite]         [bit] Null,
     [ChildSiteUrl]        [nvarchar] (255) Collate Chinese_PRC_CI_AS Null,
     [IsOpenLink]          [bit] Null,
     [ModelType]           [int] Not Null,
     [DirName]             [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [TypeName]            [nvarchar] (10) Collate Chinese_PRC_CI_AS Not Null,
     [TypeUnit]            [nvarchar] (10) Collate Chinese_PRC_CI_AS Not Null,
     [IsDisabled]          [bit] Null,
     [IsOpened]            [bit] Null,
     [GroupIdStr]          [varchar] (500) Collate Chinese_PRC_CI_AS Null,
     [VerifyType]          [int] Null,
     [Notice1]             [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [Notice2]             [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [Keyword]             [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Content]             [nvarchar] (300) Collate Chinese_PRC_CI_AS Null,
     [MiniHitCount]        [int] Not Null,
     [IsStaticType]        [bit] Not Null,
     [ColumnSortType]      [int] Not Null,
     [InfoSortType]        [int] Not Null,
     [FileNameType]        [int] Not Null,
     [ChannelPageType]     [int] Null,
     [ColumnPageType]      [int] Null,
     [InfoPageType]        [int] Null,
     [AddTime]             [datetime] Not Null,
     [Sort]                [int] Null,
     [ColumnTemplatePath]  [nvarchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [InfoTemplatePath]    [nvarchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [CommentTemplatePath] [nvarchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [IsDeleted]           [bit] Not Null,
     [ChType]              [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Collection]
  (
     [Id]                   [int] Identity (1, 1) Not Null,
     [ObjectName]           [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [WebSite]              [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [ColId]                [int] Null,
     [SpecialId]            [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [CharSet]              [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [ListPageUrl]          [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [ObjectDemo]           [text] Collate Chinese_PRC_CI_AS Null,
     [ListStartCode]        [ntext] Collate Chinese_PRC_CI_AS Null,
     [ListEndCode]          [ntext] Collate Chinese_PRC_CI_AS Null,
     [LinkStartCode]        [ntext] Collate Chinese_PRC_CI_AS Null,
     [LinkEndCode]          [ntext] Collate Chinese_PRC_CI_AS Null,
     [PageSet]              [nvarchar] (1000) Collate Chinese_PRC_CI_AS Null,
     [ContentPageSet]       [nvarchar] (1000) Collate Chinese_PRC_CI_AS Null,
     [FieldListSet]         [ntext] Collate Chinese_PRC_CI_AS Null,
     [SimpleFilterRule]     [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [ComplexityFilterRule] [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [ProterySet]           [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [StarLevel]            [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [HiteCount]            [int] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_CollectionAddress]
  (
     [Id]            [int] Identity (1, 1) Not Null,
     [ColectionId]   [int] Null,
     [CollectionUrl] [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [State]         [bit] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Column]
  (
     [ColId]               [int] Identity (1, 1) Not Null,
     [ChId]                [int] Not Null,
     [ColName]             [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [ColDirName]          [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [ColParentId]         [int] Not Null,
     [IsOuterColumn]       [bit] Null,
     [OuterColumnUrl]      [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [ColumnImgPath]       [nvarchar] (255) Collate Chinese_PRC_CI_AS Null,
     [Description]         [nvarchar] (255) Collate Chinese_PRC_CI_AS Null,
     [Keyword]             [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Content]             [nvarchar] (300) Collate Chinese_PRC_CI_AS Null,
     [IsAllowAddInfo]      [bit] Null,
     [ColumnTemplatePath]  [nvarchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [InfoTemplatePath]    [nvarchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [CommentTemplatePath] [nvarchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [Sort]                [int] Null,
     [IsAllowComment]      [bit] Null,
     [IsCheckComment]      [bit] Null,
     [InfoTableName]       [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [ScoreReward]         [int] Null,
     [PointCount]          [int] Null,
     [ChargeType]          [int] Null,
     [ChargeHourCount]     [int] Null,
     [ChargeViewCount]     [int] Null,
     [IsOpened]            [bit] Null,
     [GroupIdStr]          [varchar] (500) Collate Chinese_PRC_CI_AS Null,
     [ColumnPageType]      [int] Null,
     [InfoPageType]        [int] Null,
     [IsDeleted]           [bit] Null,
     [AddTime]             [datetime] Null,
     [IsParentHtml]        [bit] Null,
     [IsUserHtml]          [bit] Null,
     [UserHtml]            [ntext] Collate Chinese_PRC_CI_AS Null,
     [IsSystemHtml]        [bit] Null,
     [SystemHtml]          [ntext] Collate Chinese_PRC_CI_AS Null,
     [FieldOrder]          [ntext] Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_Controller]
  (
     [ControllerId]   [int] Identity (1, 1) Not Null,
     [ControllerName] [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [LinkURI]        [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [OrderNum]       [int] Null,
     [UserId]         [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_CountDay]
  (
     [0]    [int] Null,
     [1]    [int] Null,
     [2]    [int] Null,
     [3]    [int] Null,
     [4]    [int] Null,
     [5]    [int] Null,
     [6]    [int] Null,
     [7]    [int] Null,
     [8]    [int] Null,
     [9]    [int] Null,
     [10]   [int] Null,
     [11]   [int] Null,
     [12]   [int] Null,
     [13]   [int] Null,
     [14]   [int] Null,
     [15]   [int] Null,
     [16]   [int] Null,
     [17]   [int] Null,
     [18]   [int] Null,
     [19]   [int] Null,
     [20]   [int] Null,
     [21]   [int] Null,
     [22]   [int] Null,
     [23]   [int] Null,
     [Flag] [nvarchar] (10) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_CountMonth]
  (
     [1]    [int] Null,
     [2]    [int] Null,
     [3]    [int] Null,
     [4]    [int] Null,
     [5]    [int] Null,
     [6]    [int] Null,
     [7]    [int] Null,
     [8]    [int] Null,
     [9]    [int] Null,
     [10]   [int] Null,
     [11]   [int] Null,
     [12]   [int] Null,
     [13]   [int] Null,
     [14]   [int] Null,
     [15]   [int] Null,
     [16]   [int] Null,
     [17]   [int] Null,
     [18]   [int] Null,
     [19]   [int] Null,
     [20]   [int] Null,
     [21]   [int] Null,
     [22]   [int] Null,
     [23]   [int] Null,
     [24]   [int] Null,
     [25]   [int] Null,
     [26]   [int] Null,
     [27]   [int] Null,
     [28]   [int] Null,
     [29]   [int] Null,
     [30]   [int] Null,
     [31]   [int] Null,
     [Flag] [nvarchar] (10) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_CountWeek]
  (
     [1]    [int] Null,
     [2]    [int] Null,
     [3]    [int] Null,
     [4]    [int] Null,
     [5]    [int] Null,
     [6]    [int] Null,
     [7]    [int] Null,
     [Flag] [nvarchar] (10) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_CountYear]
  (
     [1]    [int] Null,
     [2]    [int] Null,
     [3]    [int] Null,
     [4]    [int] Null,
     [5]    [int] Null,
     [6]    [int] Null,
     [7]    [int] Null,
     [8]    [int] Null,
     [9]    [int] Null,
     [10]   [int] Null,
     [11]   [int] Null,
     [12]   [int] Null,
     [Flag] [nvarchar] (10) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_CustomForm]
  (
     [CustomFormId] [int] Identity (1, 1) Not Null,
     [ShowForm]     [int] Null,
     [FormName]     [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [TableName]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [UploadPath]   [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [UploadSize]   [int] Null,
     [FormDesc]     [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsUnlockTime] [bit] Null,
     [StartTime]    [datetime] Null,
     [EndTime]      [datetime] Null,
     [UserGroup]    [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [IsSubmitNum]  [bit] Null,
     [Money]        [int] Null,
     [IsValidate]   [bit] Null,
     [AddTime]      [datetime] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_CustomFormField]
  (
     [FieldId]      [int] Identity (1, 1) Not Null,
     [CustomFormId] [int] Null,
     [Name]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Alias]        [nvarchar] (150) Collate Chinese_PRC_CI_AS Null,
     [Description]  [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsNotNull]    [bit] Null,
     [IsSearchForm] [bit] Null,
     [Type]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Content]      [ntext] Collate Chinese_PRC_CI_AS Null,
     [OrderId]      [int] Null,
     [IsList]       [bit] Null,
     [IsUserInsert] [bit] Null,
     [AddDate]      [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_Dictionary]
  (
     [ID]       [int] Identity (1, 1) Not Null,
     [ParentId] [int] Not Null,
     [DicName]  [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [Sort]     [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Dig]
  (
     [Id]       [int] Identity (1, 1) Not Null,
     [InfoId]   [int] Null,
     [ModelId]  [int] Null,
     [DigCount] [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_DownLoadAddress]
  (
     [AddressId]        [int] Identity (1, 1) Not Null,
     [DownLoadDataId]   [int] Not Null,
     [AddressNum]       [int] Null,
     [DownLoadServerID] [int] Null,
     [AddressName]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [AddressPath]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_DownLoadData]
  (
     [Id]                   [int] Identity (1, 1) Not Null,
     [ChId]                 [int] Null,
     [ColId]                [int] Not Null,
     [Title]                [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [TitleColor]           [nvarchar] (6) Collate Chinese_PRC_CI_AS Null,
     [TitleFontType]        [int] Null,
     [TitleType]            [int] Null,
     [TitleImgPath]         [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [UId]                  [int] Not Null,
     [UName]                [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [UserType]             [int] Not Null,
     [AdminUId]             [int] Null,
     [AdminUName]           [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [Status]               [int] Null,
     [HitCount]             [int] Null,
     [AddTime]              [datetime] Not Null,
     [UpdateTime]           [datetime] Not Null,
     [TemplatePath]         [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [PageType]             [int] Null,
     [IsCreated]            [bit] Null,
     [UserCateId]           [int] Null,
     [PointCount]           [int] Null,
     [ChargeType]           [int] Null,
     [ChargeHourCount]      [int] Null,
     [ChargeViewCount]      [int] Null,
     [IsOpened]             [int] Null,
     [GroupIdStr]           [varchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsDeleted]            [bit] Null,
     [IsRecommend]          [bit] Null,
     [IsTop]                [bit] Null,
     [IsFocus]              [bit] Null,
     [IsSideShow]           [bit] Null,
     [IsAllowComment]       [bit] Null,
     [TagIdStr]             [varchar] (300) Collate Chinese_PRC_CI_AS Null,
     [TagNameStr]           [nvarchar] (300) Collate Chinese_PRC_CI_AS Null,
     [SpecialIdStr]         [varchar] (200) Collate Chinese_PRC_CI_AS Null,
     [Content]              [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [Edition]              [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [PlayAddress]          [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [DownLoadDownNum]      [int] Null,
     [DownLoadDownMonthNum] [int] Null,
     [DownLoadDownWeekNum]  [int] Null,
     [DownLoadDownDayNum]   [int] Null,
     [DownLoadOS]           [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [DownLoadServerDataId] [int] Null,
     [Language]             [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [WarrantType]          [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [DownLoadSize]         [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [RegAddress]           [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Plugin]               [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [DownLoadStarLevel]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [DownLoadDisplePwd]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [DownLoadType]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [MonthCountTime]       [datetime] Null,
     [WeekCountTime]        [datetime] Null,
     [DayCountTime]         [datetime] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_DownLoadServerData]
  (
     [DownLoadServerDataId] [int] Identity (1, 1) Not Null,
     [TypeId]               [int] Null,
     [DownLoadServerName]   [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [DownLoadServerDir]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [IsOpened]             [bit] Null,
     [IsOuter]              [int] Null,
     [UnionId]              [text] Collate Chinese_PRC_CI_AS Null,
     [DayDownNum]           [int] Null,
     [AllDownNum]           [int] Null,
     [AddTime]              [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_DownLoadServerType]
  (
     [TypeId]   [int] Identity (1, 1) Not Null,
     [TypeName] [nvarchar] (100) Collate Chinese_PRC_CI_AS Not Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Enterprise]
  (
     [Id]       [int] Identity (1, 1) Not Null,
     [UserId]   [int] Null,
     [TypeId]   [int] Null,
     [Title]    [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [Conetent] [text] Collate Chinese_PRC_CI_AS Null,
     [AddTime]  [nvarchar] (50) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_ExpireArticle]
  (
     [Id]                [int] Not Null,
     [ColId]             [int] Not Null,
     [Title]             [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [TitleColor]        [nvarchar] (6) Collate Chinese_PRC_CI_AS Null,
     [TitleFontType]     [int] Null,
     [TitleType]         [int] Null,
     [TitleImgPath]      [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [UId]               [int] Not Null,
     [UName]             [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [UserType]          [int] Not Null,
     [AdminUId]          [int] Null,
     [AdminUName]        [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [Status]            [int] Null,
     [HitCount]          [int] Null,
     [AddTime]           [datetime] Not Null,
     [UpdateTime]        [datetime] Not Null,
     [TemplatePath]      [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [PageType]          [int] Null,
     [IsCreated]         [bit] Null,
     [UserCateId]        [int] Null,
     [PointCount]        [int] Null,
     [ChargeType]        [int] Null,
     [ChargeHourCount]   [int] Null,
     [ChargeViewCount]   [int] Null,
     [IsOpened]          [int] Null,
     [GroupIdStr]        [varchar] (1000) Collate Chinese_PRC_CI_AS Null,
     [IsDeleted]         [bit] Null,
     [IsRecommend]       [bit] Null,
     [IsTop]             [bit] Null,
     [IsFocus]           [bit] Null,
     [IsSideShow]        [bit] Null,
     [IsAllowComment]    [bit] Null,
     [TagIdStr]          [varchar] (300) Collate Chinese_PRC_CI_AS Null,
     [TagNameStr]        [nvarchar] (300) Collate Chinese_PRC_CI_AS Null,
     [SpecialIdStr]      [varchar] (500) Collate Chinese_PRC_CI_AS Null,
     [LongTitle]         [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Content]           [ntext] Collate Chinese_PRC_CI_AS Null,
     [ShortContent]      [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [OuterUrl]          [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [Author]            [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Source]            [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [IsHeader]          [bit] Null,
     [HeaderFont]        [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [HeaderImgPath]     [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [StarLevel]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [IsShowCommentLink] [bit] Null,
     [IsIrregular]       [bit] Null,
     [IrregularId]       [int] Null,
     [ViewUName]         [ntext] Collate Chinese_PRC_CI_AS Null,
     [ViewUName2]        [ntext] Collate Chinese_PRC_CI_AS Null,
     [ViewEndTime]       [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [ExpireTime]        [datetime] Not Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_ExtendContent]
  (
     [Id]        [int] Identity (1, 1) Not Null,
     [ChId]      [int] Null,
     [ColId]     [int] Null,
     [ModelId]   [int] Null,
     [InfoId]    [int] Null,
     [FieldId]   [int] Null,
     [FieldName] [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Nvarchar]  [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [DateTime]  [datetime] Null,
     [Ntext]     [ntext] Collate Chinese_PRC_CI_AS Null,
     [Bit]       [bit] Null,
     [Decimal]   [decimal](18, 2) Null,
     [Int]       [int] Null,
     [AddTime]   [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_FeedBack]
  (
     [ID]         [int] Identity (1, 1) Not Null,
     [ParentId]   [int] Null,
     [title]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Not Null,
     [author]     [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [reward]     [int] Null,
     [scoring]    [int] Null,
     [categoryId] [int] Null,
     [content]    [ntext] Collate Chinese_PRC_CI_AS Null,
     [state]      [int] Null,
     [replyDate]  [datetime] Null,
     [EndDate]    [datetime] Null,
     [IP]         [nvarchar] (15) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_Form_Mayor]
  (
     [Id]           [int] Identity (1, 1) Not Null,
     [UId]          [int] Null,
     [UName]        [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Ip]           [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [AddTime]      [datetime] Null,
     [bianhao]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [xingming]     [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [dizhi]        [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [dianhua]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [shenfenzheng] [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [youxiang]     [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [leibie_Id]    [int] Null,
     [leibie]       [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [gongkai_Id]   [int] Null,
     [gongkai]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [zhuti]        [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [neirong]      [ntext] Collate Chinese_PRC_CI_AS Null,
     [huifu]        [ntext] Collate Chinese_PRC_CI_AS Null,
     [huifutime]    [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [zhuangtai_Id] [int] Null,
     [zhuangtai]    [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [shouli_Id]    [int] Null,
     [shouli]       [nvarchar] (100) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_HireInfo]
  (
     [ID]       [int] Identity (1, 1) Not Null,
     [UId]      [int] Null,
     [UserName] [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [UnitId]   [int] Null,
     [UnitName] [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [UserType] [int] Null,
     [Status]   [int] Null,
     [AddTime]  [datetime] Null,
     [JobId]    [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Image]
  (
     [Id]              [int] Identity (1, 1) Not Null,
     [ChId]            [int] Null,
     [ColId]           [int] Not Null,
     [Title]           [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [TitleColor]      [nvarchar] (6) Collate Chinese_PRC_CI_AS Null,
     [TitleFontType]   [int] Null,
     [TitleType]       [int] Null,
     [TitleImgPath]    [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [UId]             [int] Not Null,
     [UName]           [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [UserType]        [int] Not Null,
     [AdminUId]        [int] Null,
     [AdminUName]      [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [Status]          [int] Null,
     [HitCount]        [int] Null,
     [AddTime]         [datetime] Not Null,
     [UpdateTime]      [datetime] Not Null,
     [TemplatePath]    [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [PageType]        [int] Null,
     [IsCreated]       [bit] Null,
     [UserCateId]      [int] Null,
     [PointCount]      [int] Null,
     [ChargeType]      [int] Null,
     [ChargeHourCount] [int] Null,
     [ChargeViewCount] [int] Null,
     [IsOpened]        [int] Null,
     [GroupIdStr]      [varchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsDeleted]       [bit] Not Null,
     [IsRecommend]     [bit] Null,
     [IsTop]           [bit] Null,
     [IsFocus]         [bit] Null,
     [IsSideShow]      [bit] Null,
     [TagIdStr]        [varchar] (300) Collate Chinese_PRC_CI_AS Null,
     [IsAllowComment]  [bit] Null,
     [TagNameStr]      [nvarchar] (300) Collate Chinese_PRC_CI_AS Null,
     [SpecialIdStr]    [varchar] (200) Collate Chinese_PRC_CI_AS Null,
     [Content]         [ntext] Collate Chinese_PRC_CI_AS Null,
     [ImgPath]         [ntext] Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_LabelContent]
  (
     [LabelCategoryID] [int] Identity (1, 1) Not Null,
     [Name]            [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Content]         [text] Collate Chinese_PRC_CI_AS Null,
     [AnomalyStyle]    [text] Collate Chinese_PRC_CI_AS Null,
     [LbCategoryId]    [int] Null,
     [ModeType]        [int] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_LbCategory]
  (
     [LbCategoryID] [int] Identity (1, 1) Not Null,
     [Name]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [ParentID]     [int] Not Null,
     [Desc]         [nvarchar] (100) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Link]
  (
     [LinkId]       [int] Identity (1, 1) Not Null,
     [LinkType]     [int] Null,
     [LinkCategory] [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [SiteName]     [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [SiteUrl]      [varchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [SiteLogo]     [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [OwnerName]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Email]        [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [Description]  [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [AddTime]      [datetime] Null,
     [Status]       [int] Not Null,
     [IsDisable]    [bit] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_ListStyleContent]
  (
     [ModelId] [int] Not Null,
     [Content] [ntext] Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_Log]
  (
     [LogId]       [int] Identity (1, 1) Not Null,
     [Description] [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [UserId]      [int] Null,
     [UserName]    [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [LogTime]     [datetime] Null,
     [IpAddress]   [varchar] (15) Collate Chinese_PRC_CI_AS Null,
     [LogType]     [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Model]
  (
     [ModelId]    [int] Identity (1, 1) Not Null,
     [ModelName]  [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [ModelDesc]  [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [TableName]  [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [UploadPath] [varchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [UploadSize] [int] Null,
     [IsSystem]   [bit] Not Null,
     [AddTime]    [datetime] Not Null,
     [ModelHtml]  [ntext] Collate Chinese_PRC_CI_AS Null,
     [IsHtml]     [bit] Null,
     [ModelSort]  [int] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_ModelField]
  (
     [FieldId]      [int] Identity (1, 1) Not Null,
     [ModelId]      [int] Null,
     [ColId]        [int] Null,
     [Name]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Alias]        [nvarchar] (150) Collate Chinese_PRC_CI_AS Null,
     [Description]  [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsNotNull]    [bit] Null,
     [IsSearchForm] [bit] Null,
     [Type]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Content]      [ntext] Collate Chinese_PRC_CI_AS Null,
     [OrderId]      [int] Null,
     [IsChild]      [bit] Null,
     [IsList]       [bit] Null,
     [IsUserInsert] [bit] Null,
     [AddDate]      [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_Notice]
  (
     [NoticeId]    [int] Identity (1, 1) Not Null,
     [Title]       [nvarchar] (150) Collate Chinese_PRC_CI_AS Null,
     [Content]     [ntext] Collate Chinese_PRC_CI_AS Null,
     [UserId]      [int] Null,
     [UserName]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [OverdueDate] [datetime] Null,
     [IsPriority]  [int] Null,
     [IsState]     [nvarchar] (10) Collate Chinese_PRC_CI_AS Null,
     [AddDate]     [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_PowerColumn]
  (
     [PCId]             [int] Identity (1, 1) Not Null,
     [PowerColumnName]  [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [ColumnErrorCodes] [nvarchar] (500) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_PowerGroup]
  (
     [PowerId]       [int] Identity (1, 1) Not Null,
     [SiteId]        [int] Null,
     [PowerName]     [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [PowerFunction] [ntext] Collate Chinese_PRC_CI_AS Null,
     [AllChannel]    [ntext] Collate Chinese_PRC_CI_AS Null,
     [AllColumn]     [ntext] Collate Chinese_PRC_CI_AS Null,
     [PowerColumn]   [ntext] Collate Chinese_PRC_CI_AS Null,
     [PowerChannel]  [ntext] Collate Chinese_PRC_CI_AS Null,
     [PowerAuditing] [ntext] Collate Chinese_PRC_CI_AS Null,
     [PowerModel]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [PowerContent]  [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [IsSystem]      [int] Null,
     [AddDate]       [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_Property]
  (
     [Id]               [int] Identity (1, 1) Not Null,
     [ParentId]         [int] Null,
     [ModelId]          [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [FormId]           [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [UserId]           [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [PropertyCName]    [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [PropertyEName]    [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [PropertyKeyword]  [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [PropertyContent]  [text] Collate Chinese_PRC_CI_AS Null,
     [PropertyExtName]  [int] Null,
     [PropertyPic]      [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [PropertyTemplate] [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [PropertyDir]      [int] Null,
     [PropertyOrder]    [int] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_RechargeRecord]
  (
     [ID]           [int] Identity (1, 1) Not Null,
     [UserId]       [int] Not Null,
     [CardAccount]  [varchar] (15) Collate Chinese_PRC_CI_AS Not Null,
     [CardPoint]    [int] Null,
     [CardDay]      [int] Null,
     [RechargeDate] [datetime] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Report]
  (
     [ReportId]   [int] Identity (1, 1) Not Null,
     [Content]    [nvarchar] (1000) Collate Chinese_PRC_CI_AS Not Null,
     [Url]        [varchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [UserId]     [int] Not Null,
     [UserName]   [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [IsComplete] [int] Not Null,
     [AddTime]    [datetime] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Review]
  (
     [Id]            [int] Identity (1, 1) Not Null,
     [ModelType]     [int] Not Null,
     [InfoId]        [int] Not Null,
     [ReviewTitle]   [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [IsArgue]       [bit] Null,
     [IsSquare]      [tinyint] Null,
     [BrarNum]       [int] Null,
     [FightNum]      [int] Null,
     [IsElite]       [bit] Null,
     [ReviewContent] [ntext] Collate Chinese_PRC_CI_AS Null,
     [ReviewTime]    [datetime] Null,
     [UserNum]       [nvarchar] (18) Collate Chinese_PRC_CI_AS Null,
     [ReviewIP]      [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [IsCheck]       [bit] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_SalesProject]
  (
     [Id]                [int] Identity (1, 1) Not Null,
     [Name]              [nvarchar] (250) Collate Chinese_PRC_CI_AS Null,
     [ValidityStartTime] [datetime] Null,
     [ValidityEndTime]   [datetime] Null,
     [PriceStart]        [decimal](18, 0) Null,
     [PreceEnd]          [decimal](18, 0) Null,
     [Content]           [ntext] Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_SinglePage]
  (
     [SingleId]     [int] Identity (1, 1) Not Null,
     [Name]         [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [FolderPath]   [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [FileName]     [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [FileExtend]   [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [TemplatePath] [nvarchar] (150) Collate Chinese_PRC_CI_AS Null,
     [Content]      [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [AddTime]      [datetime] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Special]
  (
     [ID]             [int] Identity (1, 1) Not Null,
     [ParentID]       [int] Null,
     [SiteID]         [int] Null,
     [SpecialCName]   [nvarchar] (30) Collate Chinese_PRC_CI_AS Null,
     [SpecialEName]   [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [SpecialDomain]  [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [SpecialRemark]  [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsLock]         [bit] Null,
     [IsCommand]      [bit] Null,
     [SpecialAddTime] [datetime] Null,
     [MetaKeyWord]    [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [MetaRemark]     [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [SpecialTemplet] [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [SpecialItemNum] [int] Null,
     [SpecialContent] [ntext] Collate Chinese_PRC_CI_AS Null,
     [SaveDirType]    [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsDeleted]      [int] Null,
     [Extension]      [varchar] (50) Collate Chinese_PRC_CI_AS Null,
     [PicSavePath]    [nvarchar] (200) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_Style]
  (
     [StyleID]         [int] Identity (1, 1) Not Null,
     [StyleCategoryId] [int] Null,
     [Name]            [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [Content]         [text] Collate Chinese_PRC_CI_AS Null,
     [Type]            [int] Not Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_StyleCategory]
  (
     [StyleCategoryID] [int] Identity (1, 1) Not Null,
     [Name]            [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [ParentID]        [int] Null,
     [Desc]            [nvarchar] (100) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_SubSite]
  (
     [Id]            [int] Identity (1, 1) Not Null,
     [Name]          [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [FirstChar]     [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [EnName]        [varchar] (200) Collate Chinese_PRC_CI_AS Not Null,
     [Domain]        [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [LOGO]          [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [Sort]          [int] Null,
     [Status]        [int] Null,
     [AddTime]       [datetime] Null,
     [Remark]        [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [OpenTime]      [varchar] (50) Collate Chinese_PRC_CI_AS Null,
     [DbServer]      [varchar] (50) Collate Chinese_PRC_CI_AS Null,
     [DbName]        [varchar] (50) Collate Chinese_PRC_CI_AS Null,
     [DbUid]         [varchar] (50) Collate Chinese_PRC_CI_AS Null,
     [DbPwd]         [varchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Permision]     [varchar] (500) Collate Chinese_PRC_CI_AS Null,
     [CallName]      [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [CallPass]      [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [IsCreateModel] [bit] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_SuperLabel]
  (
     [SuperId]        [int] Identity (1, 1) Not Null,
     [Name]           [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [LbCategoryName] [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [LbCategoryId]   [int] Null,
     [DataBaseType]   [int] Null,
     [SuperDes]       [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [IsUnlockPage]   [bit] Null,
     [PageSize]       [int] Null,
     [HostTable]      [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [GuestTable]     [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [SqlStr]         [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [Content]        [ntext] Collate Chinese_PRC_CI_AS Null,
     [AddTime]        [datetime] Null,
     [NumColumns]     [int] Null,
     [IsHtml]         [bit] Null,
     [DataBaseConn]   [nvarchar] (300) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_Superior]
  (
     [id]        [int] Identity (1, 1) Not Null,
     [Name]      [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [StartCode] [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [EndCode]   [nvarchar] (500) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Tag]
  (
     [TagId]                [bigint] Identity (1, 1) Not Null,
     [Name]                 [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [TagCategoryId]        [int] Not Null,
     [ModelType]            [int] Not Null,
     [DaySearchCount]       [int] Null,
     [YesterdaySearchCount] [int] Null,
     [TotalSearchCount]     [int] Null,
     [UserId]               [int] Null,
     [UserName]             [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [CountTime]            [datetime] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_TagCategory]
  (
     [TagCategoryId] [int] Identity (1, 1) Not Null,
     [Name]          [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [Desc]          [nvarchar] (100) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_TempTable]
  (
     [Id]                 [int] Identity (1, 1) Not Null,
     [ChId]               [int] Not Null,
     [ColId]              [int] Not Null,
     [Title]              [nvarchar] (400) Collate Chinese_PRC_CI_AS Null,
     [TitleColor]         [nvarchar] (12) Collate Chinese_PRC_CI_AS Null,
     [TitleFontType]      [int] Null,
     [TitleType]          [int] Null,
     [TitleImgPath]       [varchar] (255) Collate Chinese_PRC_CI_AS Null,
     [UId]                [int] Not Null,
     [UName]              [nvarchar] (40) Collate Chinese_PRC_CI_AS Not Null,
     [UserType]           [int] Not Null,
     [AdminUId]           [int] Null,
     [AdminUName]         [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Status]             [int] Null,
     [HitCount]           [int] Null,
     [AddTime]            [datetime] Not Null,
     [UpdateTime]         [datetime] Not Null,
     [TemplatePath]       [varchar] (255) Collate Chinese_PRC_CI_AS Not Null,
     [PageType]           [int] Null,
     [IsCreated]          [bit] Null,
     [UserCateId]         [int] Null,
     [PointCount]         [int] Null,
     [ChargeType]         [int] Null,
     [ChargeHourCount]    [int] Null,
     [ChargeViewCount]    [int] Null,
     [IsOpened]           [int] Null,
     [OuterUrl]           [nvarchar] (600) Collate Chinese_PRC_CI_AS Null,
     [GroupIdStr]         [varchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsDeleted]          [bit] Null,
     [IsRecommend]        [bit] Null,
     [IsTop]              [bit] Null,
     [IsFocus]            [bit] Null,
     [IsSideShow]         [bit] Null,
     [TagIdStr]           [varchar] (300) Collate Chinese_PRC_CI_AS Null,
     [TagNameStr]         [nvarchar] (600) Collate Chinese_PRC_CI_AS Null,
     [IsAllowComment]     [bit] Null,
     [SpecialIdStr]       [varchar] (200) Collate Chinese_PRC_CI_AS Null,
     [ViewUName]          [ntext] Collate Chinese_PRC_CI_AS Null,
     [ViewUName2]         [ntext] Collate Chinese_PRC_CI_AS Null,
     [ExtendContentTable] [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [InputDateOuthor]    [int] Null,
     [SubSiteId]          [int] Null,
     [IsSend]             [bit] Null,
     [SendTime]           [datetime] Null,
     [InfoId]             [int] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserAlbum]
  (
     [Id]               [int] Identity (1, 1) Not Null,
     [AlbumName]        [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [AlbumCate]        [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [AlbumDescription] [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [ImgCount]         [int] Null,
     [Logo]             [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [IsOpened]         [int] Null,
     [AlbumPassword]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [AddTime]          [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [UserId]           [int] Null,
     [UserName]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserCate]
  (
     [UserCateId]  [int] Identity (1, 1) Not Null,
     [UserId]      [int] Not Null,
     [CateName]    [varchar] (50) Collate Chinese_PRC_CI_AS Null,
     [ModelType]   [int] Not Null,
     [Discription] [text] Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserFavorite]
  (
     [id]      [int] Identity (1, 1) Not Null,
     [UserId]  [int] Null,
     [Title]   [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Url]     [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [AddDate] [datetime] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserFriend]
  (
     [ID]            [int] Identity (1, 1) Not Null,
     [UserId]        [int] Not Null,
     [FriendId]      [int] Not Null,
     [FriendGroupId] [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserFriendGroup]
  (
     [FriendGroupId]   [int] Identity (1, 1) Not Null,
     [FriendGroupName] [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [IsUserId]        [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserGroup]
  (
     [UserGroupId]      [int] Identity (1, 1) Not Null,
     [UserGroupName]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [UserGroupContent] [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [TypeId]           [int] Null,
     [GroupPower]       [ntext] Collate Chinese_PRC_CI_AS Null,
     [AllChannel]       [ntext] Collate Chinese_PRC_CI_AS Null,
     [AllColumn]        [ntext] Collate Chinese_PRC_CI_AS Null,
     [ChannelPower]     [ntext] Collate Chinese_PRC_CI_AS Null,
     [ColumnPower]      [ntext] Collate Chinese_PRC_CI_AS Null,
     [IsSystem]         [int] Null,
     [AddDate]          [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserGroupModel]
  (
     [Id]          [int] Identity (1, 1) Not Null,
     [Name]        [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [TableName]   [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Content]     [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [IsHtml]      [bit] Null,
     [ModelHtml]   [ntext] Collate Chinese_PRC_CI_AS Null,
     [IsValidate]  [bit] Null,
     [UserGroupId] [int] Null,
     [AddTime]     [datetime] Null,
     [SpaceTypeId] [int] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserGroupModelField]
  (
     [FieldId]      [int] Identity (1, 1) Not Null,
     [ModelId]      [int] Null,
     [Name]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Alias]        [nvarchar] (150) Collate Chinese_PRC_CI_AS Null,
     [Description]  [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [IsNotNull]    [bit] Null,
     [IsSearchForm] [bit] Null,
     [Type]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Content]      [ntext] Collate Chinese_PRC_CI_AS Null,
     [OrderId]      [int] Null,
     [IsList]       [bit] Null,
     [IsUserInsert] [bit] Null,
     [AddDate]      [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserLog]
  (
     [ID]          [int] Identity (1, 1) Not Null,
     [UserId]      [int] Not Null,
     [UserName]    [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [Description] [nvarchar] (1000) Collate Chinese_PRC_CI_AS Null,
     [InfoId]      [int] Not Null,
     [ModelType]   [int] Not Null,
     [Point]       [int] Null,
     [AddTime]     [datetime] Not Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserMessage]
  (
     [Id]            [int] Identity (1, 1) Not Null,
     [Title]         [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Content]       [text] Collate Chinese_PRC_CI_AS Null,
     [UserId]        [int] Null,
     [AnounName]     [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [HomePage]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [IsPrivacy]     [bit] Null,
     [IsResume]      [bit] Null,
     [ResumeContent] [text] Collate Chinese_PRC_CI_AS Null,
     [PostTime]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [ResumeTime]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserPhoto]
  (
     [PhotoId]     [int] Identity (1, 1) Not Null,
     [AlbumId]     [int] Not Null,
     [FileName]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [FilePath]    [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Description] [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [PostTime]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [VisitNum]    [int] Null,
     [UserId]      [int] Null,
     [UserName]    [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [FileSize]    [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_UserSpace]
  (
     [Id]               [int] Identity (1, 1) Not Null,
     [SpaceName]        [nvarchar] (50) Collate Chinese_PRC_CI_AS Not Null,
     [SpaceDescription] [nvarchar] (500) Collate Chinese_PRC_CI_AS Null,
     [PrevPower]        [int] Null,
     [Password]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [AddTime]          [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [UserId]           [int] Not Null,
     [UserName]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [TemplateId]       [int] Null,
     [UserType]         [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_User_Business]
  (
     [Id]                [int] Identity (1, 1) Not Null,
     [UId]               [int] Null,
     [AddTime]           [datetime] Null,
     [UpdateTime]        [datetime] Null,
     [EmployNumber]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [License]           [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [TaxCertificates]   [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [OtherCertificates] [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [ContactPersonal]   [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Telephone]         [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [CompanyEmail]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Fax]               [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Address]           [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Zip]               [int] Null,
     [HomePage]          [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [LOGO]              [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Introduce]         [ntext] Collate Chinese_PRC_CI_AS Null,
     [name]              [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [lx]                [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [tID]               [int] Null,
     [tName]             [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [area_Id]           [int] Null,
     [area]              [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Geographical_Id]   [int] Null,
     [Geographical]      [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [lx_Id]             [int] Null,
     [EmployNumber_Id]   [int] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_User_Personal]
  (
     [Id]              [int] Identity (1, 1) Not Null,
     [UId]             [int] Null,
     [AddTime]         [datetime] Null,
     [UpdateTime]      [datetime] Null,
     [TrueName]        [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [area_Id]         [int] Null,
     [area]            [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Geographical_Id] [int] Null,
     [Geographical]    [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Address]         [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Phone]           [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [qq]              [int] Null,
     [Email]           [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [Picture]         [nvarchar] (100) Collate Chinese_PRC_CI_AS Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Users]
  (
     [UserID]         [int] Identity (1, 1) Not Null,
     [LogName]        [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [UserPwd]        [nvarchar] (200) Collate Chinese_PRC_CI_AS Null,
     [Email]          [varchar] (100) Collate Chinese_PRC_CI_AS Null,
     [TypeId]         [int] Null,
     [GroupID]        [int] Null,
     [Question]       [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Answer]         [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Integral]       [int] Null,
     [YellowBoy]      [decimal](10, 2) Null,
     [IsLock]         [bit] Null,
     [LoginNum]       [int] Null,
     [LastLoginIP]    [nvarchar] (20) Collate Chinese_PRC_CI_AS Null,
     [RegTime]        [datetime] Null,
     [LastLoginTime]  [datetime] Null,
     [Secret]         [tinyint] Null,
     [ErrorNum]       [int] Null,
     [ErrorTime]      [datetime] Null,
     [ExpireTime]     [datetime] Null,
     [ConfirmRegCode] [varchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Status]         [int] Null,
     [SiteId]         [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_ViewLog]
  (
     [Id]        [int] Identity (1, 1) Not Null,
     [UserId]    [int] Not Null,
     [UserName]  [nvarchar] (20) Collate Chinese_PRC_CI_AS Not Null,
     [ModelType] [int] Not Null,
     [InfoId]    [int] Not Null,
     [AddTime]   [datetime] Not Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_Vote]
  (
     [VoteId]      [int] Identity (1, 1) Not Null,
     [SubjectId]   [int] Null,
     [VoteTitle]   [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [DisplayType] [int] Null,
     [IsMore]      [bit] Null,
     [ModelType]   [int] Not Null,
     [ItemTitle1]  [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [ItemNum1]    [int] Null,
     [ItemTitle2]  [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [ItemNum2]    [int] Null,
     [ItemTitle3]  [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [ItemNum3]    [int] Null,
     [ItemTitle4]  [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [ItemNum4]    [int] Null,
     [ItemTitle5]  [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [ItemNum5]    [int] Null,
     [ItemTitle6]  [nvarchar] (100) Collate Chinese_PRC_CI_AS Null,
     [ItemNum6]    [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_VoteCategory]
  (
     [CategoryId] [int] Identity (1, 1) Not Null,
     [Name]       [nvarchar] (200) Collate Chinese_PRC_CI_AS Not Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_VoteSubject]
  (
     [VoteSubjectId] [int] Identity (1, 1) Not Null,
     [Subject]       [nvarchar] (200) Collate Chinese_PRC_CI_AS Not Null,
     [StartDate]     [datetime] Null,
     [EndDate]       [datetime] Null,
     [RequireLogin]  [bit] Null,
     [CategoryId]    [int] Null
  )
On [PRIMARY]
GO
Create Table [dbo].[Qianbo_WebMessage]
  (
     [WMId]         [int] Identity (1, 1) Not Null,
     [ReceiverId]   [int] Null,
     [ReceiverName] [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [SendId]       [int] Null,
     [SendName]     [nvarchar] (50) Collate Chinese_PRC_CI_AS Null,
     [Title]        [nvarchar] (150) Collate Chinese_PRC_CI_AS Null,
     [Content]      [ntext] Collate Chinese_PRC_CI_AS Null,
     [IsSend]       [int] Null,
     [IsRead]       [int] Null,
     [ReceiverDel]  [int] Null,
     [SendDel]      [int] Null,
     [AllUser]      [int] Null,
     [UserGroupId]  [int] Null,
     [OverdueDate]  [datetime] Null,
     [AddDate]      [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Create Table [dbo].[Qianbo_WorkFlow]
  (
     [Id]         [int] Identity (1, 1) Not Null,
     [Name]       [nvarchar] (150) Collate Chinese_PRC_CI_AS Null,
     [Auditing]   [int] Null,
     [PowerIdStr] [ntext] Collate Chinese_PRC_CI_AS Null,
     [AddDate]    [datetime] Null,
     [UpdateDate] [datetime] Null
  )
On [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Ad]
  With Nocheck Add Constraint [PK_Qianbo_Ad] Primary Key Clustered ( [AdId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_AdCategory]
  With Nocheck Add Constraint [PK_Qianbo_AdCategory] Primary Key Clustered ( [AdCategoryId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Admin]
  With Nocheck Add Constraint [PK__Qianbo_Admin__76CBA758] Primary Key Clustered ( [UserId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Anomaly]
  With Nocheck Add Constraint [PK_Qianbo_Anomaly] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Article]
  With Nocheck Add Constraint [PK_Qianbo_Article] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Card]
  With Nocheck Add Constraint [PK_Qianbo_Card] Primary Key Clustered ( [ID] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Channel]
  With Nocheck Add Constraint [PK_Qianbo_Channel] Primary Key Clustered ( [ChId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Collection]
  With Nocheck Add Constraint [PK_Qianbo_Collection] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_CollectionAddress]
  With Nocheck Add Constraint [PK_CollectionAddress] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Column]
  With Nocheck Add Constraint [PK_Qianbo_Column] Primary Key Clustered ( [ColId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Controller]
  With Nocheck Add Constraint [PK_Qianbo_Controller] Primary Key Clustered ( [ControllerId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_CustomForm]
  With Nocheck Add Constraint [PK_Qianbo_CustomForm] Primary Key Clustered ( [CustomFormId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_CustomFormField]
  With Nocheck Add Constraint [PK_Qianbo_CustomFormField] Primary Key Clustered ( [FieldId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Dictionary]
  With Nocheck Add Constraint [PK_Qianbo_Dictionary] Primary Key Clustered ( [ID] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Dig]
  With Nocheck Add Constraint [PK_Qianbo_Dig] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_DownLoadAddress]
  With Nocheck Add Constraint [PK_Qianbo_DownLoadAddress_1] Primary Key Clustered ( [AddressId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_DownLoadData]
  With Nocheck Add Constraint [PK_Qianbo_DownLoadData] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_DownLoadServerData]
  With Nocheck Add Constraint [PK_Qianbo_DownLoadServerData] Primary Key Clustered ( [DownLoadServerDataId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_DownLoadServerType]
  With Nocheck Add Constraint [PK_Qianbo_DownLoadServerType] Primary Key Clustered ( [TypeId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Enterprise]
  With Nocheck Add Constraint [PK_Qianbo_Enterprise] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_ExtendContent]
  With Nocheck Add Constraint [PK_Qianbo_ExtendContent] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_FeedBack]
  With Nocheck Add Constraint [PK_Qianbo_Communit] Primary Key Clustered ( [ID] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Form_Mayor]
  With Nocheck Add Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Image]
  With Nocheck Add Constraint [PK_Qianbo_Image] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_LabelContent]
  With Nocheck Add Constraint [PK_Qianbo_LabelContent] Primary Key Clustered ( [LabelCategoryID] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_LbCategory]
  With Nocheck Add Constraint [PK_Qianbo_LbCategory] Primary Key Clustered ( [LbCategoryID] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Link]
  With Nocheck Add Constraint [PK_Qianbo_Link] Primary Key Clustered ( [LinkId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_ListStyleContent]
  With Nocheck Add Constraint [PK_Qianbo_ListStyleContent] Primary Key Clustered ( [ModelId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Log]
  With Nocheck Add Constraint [PK__Qianbo_Log__7C8480AE] Primary Key Clustered ( [LogId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Model]
  With Nocheck Add Constraint [PK_Qianbo_Model] Primary Key Clustered ( [ModelId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_ModelField]
  With Nocheck Add Constraint [PK_Qianbo_ModelField] Primary Key Clustered ( [FieldId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Notice]
  With Nocheck Add Constraint [PK_Qianbo_Notice] Primary Key Clustered ( [NoticeId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_PowerColumn]
  With Nocheck Add Constraint [PK_Qianbo_PowerColumu] Primary Key Clustered ( [PCId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_PowerGroup]
  With Nocheck Add Constraint [PK_Qianbo_PowerGroup] Primary Key Clustered ( [PowerId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Property]
  With Nocheck Add Constraint [PK_Qianbo_Property] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_RechargeRecord]
  With Nocheck Add Constraint [PK_Qianbo_RechargeRecord] Primary Key Clustered ( [ID] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Report]
  With Nocheck Add Constraint [PK_Qianbo_Report] Primary Key Clustered ( [ReportId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Review]
  With Nocheck Add Constraint [PK_Qianbo_Review] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_SalesProject]
  With Nocheck Add Constraint [PK_SalesProject] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_SinglePage]
  With Nocheck Add Constraint [PK_Qianbo_SinglePage] Primary Key Clustered ( [SingleId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Style]
  With Nocheck Add Constraint [PK_Qianbo_Style] Primary Key Clustered ( [StyleID] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_StyleCategory]
  With Nocheck Add Constraint [PK_Qianbo_StyleCategory] Primary Key Clustered ( [StyleCategoryID] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_SubSite]
  With Nocheck Add Constraint [PK_Qianbo_SubSite] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_SuperLabel]
  With Nocheck Add Constraint [PK_Qianbo_SuperLabel] Primary Key Clustered ( [SuperId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Superior]
  With Nocheck Add Constraint [PK_Qianbo_Superior] Primary Key Clustered ( [id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Tag]
  With Nocheck Add Constraint [PK_Qianbo_TagKeyword] Primary Key Clustered ( [TagId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_TagCategory]
  With Nocheck Add Constraint [PK_Qianbo_Tag] Primary Key Clustered ( [TagCategoryId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserAlbum]
  With Nocheck Add Constraint [PK_Qianbo_UserAlbum] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserCate]
  With Nocheck Add Constraint [PK_Qianbo_UserCate] Primary Key Clustered ( [UserCateId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserFavorite]
  With Nocheck Add Constraint [PK_Qianbo_UserFavorite] Primary Key Clustered ( [id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserFriend]
  With Nocheck Add Constraint [PK_Qianbo_UserFriend] Primary Key Clustered ( [UserId], [FriendId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserFriendGroup]
  With Nocheck Add Constraint [PK_Qianbo_UserFriendGroup] Primary Key Clustered ( [FriendGroupId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserGroup]
  With Nocheck Add Constraint [PK_Qianbo_UserGroup] Primary Key Clustered ( [UserGroupId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserGroupModel]
  With Nocheck Add Constraint [PK_Qianbo_UserGroupModel] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserGroupModelField]
  With Nocheck Add Constraint [PK_Qianbo_UserGroupModelField] Primary Key Clustered ( [FieldId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserMessage]
  With Nocheck Add Constraint [PK_Qianbo_UserMessage] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserPhoto]
  With Nocheck Add Constraint [PK_Qianbo_User_Photo] Primary Key Clustered ( [PhotoId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserSpace]
  With Nocheck Add Constraint [PK_Qianbo_UserSpace] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_User_Business]
  With Nocheck Add Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_User_Personal]
  With Nocheck Add Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Users]
  With Nocheck Add Constraint [PK_Qianbo_Users] Primary Key Clustered ( [UserID] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_ViewLog]
  With Nocheck Add Constraint [PK_Qianbo_ViewLog] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Vote]
  With Nocheck Add Constraint [PK_Qianbo_Vote_1] Primary Key Clustered ( [VoteId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_VoteCategory]
  With Nocheck Add Constraint [PK_Qianbo_VoteCategory] Primary Key Clustered ( [CategoryId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_VoteSubject]
  With Nocheck Add Constraint [PK_Qianbo_VoteSubject] Primary Key Clustered ( [VoteSubjectId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_WebMessage]
  With Nocheck Add Constraint [PK_Qianbo_WebMessage] Primary Key Clustered ( [WMId] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_WorkFlow]
  With Nocheck Add Constraint [PK_Qianbo_AuditingFlow] Primary Key Clustered ( [Id] ) On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Ad]
  Add Constraint [DF_Qianbo_Ad_AdName] Default ('') For [AdName], Constraint [DF_Qianbo_Ad_AdType] Default (1) For [AdType], Constraint [DF_Table2_DisplayType] Default (getdate()) For [EndTime], Constraint [DF_Qianbo_Ad_Weight] Default (10) For [Weight], Constraint [DF_Table2_Click] Default (0) For [HitCount]
GO
Alter Table [dbo].[Qianbo_AdCategory]
  Add Constraint [DF_Qianbo_AdCategory_IsDisabled] Default (1) For [IsDisabled], Constraint [DF_Qianbo_AdCategory_Width] Default (468 | 60) For [WidthHeigth], Constraint [DF_Qianbo_AdCategory_DisplayType] Default (1) For [DisplayType], Constraint [DF_Qianbo_AdCategory_Description] Default ('') For [Description]
GO
Alter Table [dbo].[Qianbo_Admin]
  Add Constraint [DF_Qianbo_Admin_LoginTime] Default (0) For [LoginTime], Constraint [DF_Qianbo_Admin_AllowMultiLogin] Default (1) For [AllowMultiLogin], Constraint [DF_Qianbo_Admin_CheckCount] Default (0) For [CheckCount], Constraint [DF_Qianbo_Admin_AddCount] Default (0) For [AddCount], Constraint [DF_Qianbo_Admin_RejectCount] Default (0) For [RejectCount], Constraint [DF_Qianbo_Admin_RandNumber] Default (0) For [RandNumber], Constraint [DF_Qianbo_Admin_SiteId] Default (0) For [SiteId], Constraint [DF_Qianbo_Admin_Locked] Default (0) For [Locked], Constraint [DF_Qianbo_Admin_IsSiteManage] Default (0) For [IsSiteManage]
GO
Alter Table [dbo].[Qianbo_Article]
  Add Constraint [DF_Qianbo_Article_ChId] Default (0) For [ChId], Constraint [DF_Qianbo_Article_ColId] Default (0) For [ColId], Constraint [DF_Qianbo_Article_Title] Default ('') For [Title], Constraint [DF_Qianbo_Article_TitleColor] Default ('') For [TitleColor], Constraint [DF_Qianbo_Article_TitleFontType] Default ('') For [TitleFontType], Constraint [DF_Qianbo_Article_TitleType] Default (0) For [TitleType], Constraint [DF_Qianbo_Article_TitleImgPath] Default ('') For [TitleImgPath], Constraint [DF_Qianbo_Article_AdminUName] Default ('') For [AdminUName], Constraint [DF_Qianbo_Article_Status] Default (0) For [Status], Constraint [DF_Qianbo_Article_HitsCount] Default (0) For [HitCount], Constraint [DF_Qianbo_Article_TemplatePath] Default ('') For [TemplatePath], Constraint [DF_Qianbo_Article_PageType] Default (1) For [PageType], Constraint [DF_Qianbo_Article_IsCreated] Default (0) For [IsCreated], Constraint [DF_Qianbo_Article_UserCateId] Default (0) For [UserCateId], Constraint
  [DF_Qianbo_Article_PointCount] Default (0) For [PointCount], Constraint [DF_Qianbo_Article_ChargeType] Default (1) For [ChargeType], Constraint [DF_Qianbo_Article_ChargeHourCount] Default (0) For [ChargeHourCount], Constraint [DF_Qianbo_Article_ChargeViewCount] Default (0) For [ChargeViewCount], Constraint [DF_Qianbo_Article_IsOpened] Default (2) For [IsOpened], Constraint [DF_Qianbo_Article_GroupIdStr] Default ('') For [GroupIdStr], Constraint [DF_Qianbo_Article_IsDeleted] Default (0) For [IsDeleted], Constraint [DF_Qianbo_Article_IsRecommend] Default (0) For [IsRecommend], Constraint [DF_Qianbo_Article_IsTop] Default (0) For [IsTop], Constraint [DF_Qianbo_Article_IsFocus] Default (0) For [IsFocus], Constraint [DF_Qianbo_Article_IsSideShow] Default (0) For [IsSideShow], Constraint [DF_Qianbo_Article_IsAllowComment] Default (0) For [IsAllowComment], Constraint [DF_Qianbo_Article_TagIdStr] Default ('') For [TagIdStr], Constraint [DF_Qianbo_Article_TagNameStr] Default ('') For
  [TagNameStr], Constraint [DF_Qianbo_Article_SpecialIdStr] Default ('') For [SpecialIdStr], Constraint [DF_Qianbo_Article_LongTitle] Default ('') For [LongTitle], Constraint [DF_Qianbo_Article_Content] Default ('') For [Content], Constraint [DF_Qianbo_Article_ShortContent] Default ('') For [ShortContent], Constraint [DF_Qianbo_Article_OuterUrl] Default ('') For [OuterUrl], Constraint [DF_Qianbo_Article_Author] Default ('') For [Author], Constraint [DF_Qianbo_Article_Source] Default ('') For [Source], Constraint [DF_Qianbo_Article_IsHeader] Default (0) For [IsHeader], Constraint [DF_Qianbo_Article_HeaderFont] Default ('') For [HeaderFont], Constraint [DF_Qianbo_Article_HeaderImgPath] Default ('') For [HeaderImgPath], Constraint [DF_Qianbo_Article_StarLevel] Default ('') For [StarLevel], Constraint [DF_Qianbo_Article_IsShowCommentLink] Default (0) For [IsShowCommentLink], Constraint [DF_Qianbo_Article_IsIrregular] Default (0) For [IsIrregular], Constraint
  [DF_Qianbo_Article_IrregularId] Default (0) For [IrregularId], Constraint [DF_Qianbo_Article_ViewUName1] Default ('') For [ViewUName], Constraint [DF_Qianbo_Article_ViewUName2] Default ('') For [ViewUName2], Constraint [DF_Qianbo_Article_ViewEndTime] Default ('') For [ViewEndTime]
GO
Create Index [IX_Qianbo_Article_ColId]
  On [dbo].[Qianbo_Article]([ColId])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_Article_AddTime]
  On [dbo].[Qianbo_Article]([AddTime])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_Article_ExpireTime]
  On [dbo].[Qianbo_Article]([ExpireTime])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_Article_SpecialIdStr]
  On [dbo].[Qianbo_Article]([SpecialIdStr])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_Article_TagIdStr]
  On [dbo].[Qianbo_Article]([TagIdStr])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_Article_ChId]
  On [dbo].[Qianbo_Article]([ChId])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Channel]
  Add Constraint [DF_Qianbo_Channel_Description] Default ('') For [Description], Constraint [DF_Qianbo_Channel_IsChildSite] Default (0) For [IsChildSite], Constraint [DF_Qianbo_Channel_ChildSiteUrl] Default ('') For [ChildSiteUrl], Constraint [DF_Qianbo_Channel_IsOpenLink] Default (0) For [IsOpenLink], Constraint [DF_Qianbo_Channel_IsDisabled] Default (0) For [IsDisabled], Constraint [DF_Qianbo_Channel_IsOpened] Default (1) For [IsOpened], Constraint [DF_Qianbo_Channel_GroupIdStr] Default ('') For [GroupIdStr], Constraint [DF_Qianbo_Channel_VerifyType] Default (0) For [VerifyType], Constraint [DF_Qianbo_Channel_Notice1] Default ('') For [Notice1], Constraint [DF_Qianbo_Channel_Notice2] Default ('') For [Notice2], Constraint [DF_Qianbo_Channel_Keyword] Default ('') For [Keyword], Constraint [DF_Qianbo_Channel_Content] Default ('') For [Content], Constraint [DF_Qianbo_Channel_MiniHitCount] Default (500) For [MiniHitCount], Constraint [DF_Qianbo_Channel_IsStaticType] Default (1) For
  [IsStaticType], Constraint [DF_Qianbo_Channel_ColumnSortType] Default (1) For [ColumnSortType], Constraint [DF_Qianbo_Channel_InfoSortType] Default (1) For [InfoSortType], Constraint [DF_Qianbo_Channel_ChannelExtNameType] Default (1) For [ChannelPageType], Constraint [DF_Qianbo_Channel_ColumnExtName] Default (1) For [ColumnPageType], Constraint [DF_Qianbo_Channel_InfoPageType] Default (1) For [InfoPageType], Constraint [DF_Qianbo_Channel_Sort] Default (1) For [Sort], Constraint [DF_Qianbo_Channel_ColumnTemplatePath] Default ('') For [ColumnTemplatePath], Constraint [DF_Qianbo_Channel_InfoTemplatePath] Default ('') For [InfoTemplatePath], Constraint [DF_Qianbo_Channel_CommentTemplatePath] Default ('') For [CommentTemplatePath], Constraint [DF_Qianbo_Channel_IsDeleted] Default (0) For [IsDeleted], Constraint [DF_Qianbo_Channel_ChType] Default (0) For [ChType]
GO
Create Index [IX_Qianbo_Channel_ModelType]
  On [dbo].[Qianbo_Channel]([ModelType])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Column]
  Add Constraint [DF_Qianbo_Column_IsOuterColumnUrl] Default (0) For [IsOuterColumn], Constraint [DF_Qianbo_Column_IsAllowAddInfo] Default (1) For [IsAllowAddInfo], Constraint [DF_Qianbo_Column_Sort] Default (1) For [Sort], Constraint [DF_Qianbo_Column_IsAllowCount] Default (1) For [IsAllowComment], Constraint [DF_Qianbo_Column_IsCheckComment] Default (0) For [IsCheckComment], Constraint [DF_Qianbo_Column_InfoTableName] Default ('') For [InfoTableName], Constraint [DF_Qianbo_Column_ScoreReward] Default (0) For [ScoreReward], Constraint [DF_Qianbo_Column_PointCount] Default (0) For [PointCount], Constraint [DF_Qianbo_Column_ChargeType] Default (1) For [ChargeType], Constraint [DF_Qianbo_Column_ChargeHourCount] Default (0) For [ChargeHourCount], Constraint [DF_Qianbo_Column_ChargeViewCount] Default (0) For [ChargeViewCount], Constraint [DF_Qianbo_Column_GroupIdStr] Default ('') For [GroupIdStr], Constraint [DF_Qianbo_Column_ColumnPageType] Default (1) For [ColumnPageType], Constraint
  [DF_Qianbo_Column_InfoPageType] Default (1) For [InfoPageType], Constraint [DF_Qianbo_Column_IsDeleted] Default (0) For [IsDeleted], Constraint [DF_Qianbo_Column_IsParentHtml_1] Default (0) For [IsParentHtml], Constraint [DF_Qianbo_Column_IsUserHtml_1] Default (0) For [IsUserHtml], Constraint [DF_Qianbo_Column_IsSystemHtml_1] Default (0) For [IsSystemHtml]
GO
Create Index [IX_Qianbo_Column_chid]
  On [dbo].[Qianbo_Column]([ChId])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_CountDay]
  Add Constraint [DF_Qianbo_CountDay_0] Default (0) For [0], Constraint [DF_Qianbo_CountDay_1] Default (0) For [1], Constraint [DF_Qianbo_CountDay_2] Default (0) For [2], Constraint [DF_Qianbo_CountDay_3] Default (0) For [3], Constraint [DF_Qianbo_CountDay_4] Default (0) For [4], Constraint [DF_Qianbo_CountDay_5] Default (0) For [5], Constraint [DF_Qianbo_CountDay_6] Default (0) For [6], Constraint [DF_Qianbo_CountDay_7] Default (0) For [7], Constraint [DF_Qianbo_CountDay_8] Default (0) For [8], Constraint [DF_Qianbo_CountDay_9] Default (0) For [9], Constraint [DF_Qianbo_CountDay_10] Default (0) For [10], Constraint [DF_Qianbo_CountDay_11] Default (0) For [11], Constraint [DF_Qianbo_CountDay_12] Default (0) For [12], Constraint [DF_Qianbo_CountDay_13] Default (0) For [13], Constraint [DF_Qianbo_CountDay_14] Default (0) For [14], Constraint [DF_Qianbo_CountDay_15] Default (0) For [15], Constraint [DF_Qianbo_CountDay_16] Default (0) For [16], Constraint [DF_Qianbo_CountDay_17] Default (
  0) For [17], Constraint [DF_Qianbo_CountDay_18] Default (0) For [18], Constraint [DF_Qianbo_CountDay_19] Default (0) For [19], Constraint [DF_Qianbo_CountDay_20] Default (0) For [20], Constraint [DF_Qianbo_CountDay_21] Default (0) For [21], Constraint [DF_Qianbo_CountDay_22] Default (0) For [22], Constraint [DF_Qianbo_CountDay_23] Default (0) For [23]
GO
Alter Table [dbo].[Qianbo_CountMonth]
  Add Constraint [DF_Qianbo_CountMonth_1] Default (0) For [1], Constraint [DF_Qianbo_CountMonth_2] Default (0) For [2], Constraint [DF_Qianbo_CountMonth_3] Default (0) For [3], Constraint [DF_Qianbo_CountMonth_4] Default (0) For [4], Constraint [DF_Qianbo_CountMonth_5] Default (0) For [5], Constraint [DF_Qianbo_CountMonth_6] Default (0) For [6], Constraint [DF_Qianbo_CountMonth_7] Default (0) For [7], Constraint [DF_Qianbo_CountMonth_8] Default (0) For [8], Constraint [DF_Qianbo_CountMonth_9] Default (0) For [9], Constraint [DF_Qianbo_CountMonth_10] Default (0) For [10], Constraint [DF_Qianbo_CountMonth_11] Default (0) For [11], Constraint [DF_Qianbo_CountMonth_12] Default (0) For [12], Constraint [DF_Qianbo_CountMonth_13] Default (0) For [13], Constraint [DF_Qianbo_CountMonth_14] Default (0) For [14], Constraint [DF_Qianbo_CountMonth_15] Default (0) For [15], Constraint [DF_Qianbo_CountMonth_16] Default (0) For [16], Constraint [DF_Qianbo_CountMonth_17] Default (0) For [17],
  Constraint [DF_Qianbo_CountMonth_18] Default (0) For [18], Constraint [DF_Qianbo_CountMonth_19] Default (0) For [19], Constraint [DF_Qianbo_CountMonth_20] Default (0) For [20], Constraint [DF_Qianbo_CountMonth_21] Default (0) For [21], Constraint [DF_Qianbo_CountMonth_22] Default (0) For [22], Constraint [DF_Qianbo_CountMonth_23] Default (0) For [23], Constraint [DF_Qianbo_CountMonth_24] Default (0) For [24], Constraint [DF_Qianbo_CountMonth_25] Default (0) For [25], Constraint [DF_Qianbo_CountMonth_26] Default (0) For [26], Constraint [DF_Qianbo_CountMonth_27] Default (0) For [27], Constraint [DF_Qianbo_CountMonth_28] Default (0) For [28], Constraint [DF_Qianbo_CountMonth_29] Default (0) For [29], Constraint [DF_Qianbo_CountMonth_30] Default (0) For [30], Constraint [DF_Qianbo_CountMonth_31] Default (0) For [31]
GO
Alter Table [dbo].[Qianbo_CountWeek]
  Add Constraint [DF_Qianbo_CountWeek_1] Default (0) For [1], Constraint [DF_Qianbo_CountWeek_2] Default (0) For [2], Constraint [DF_Qianbo_CountWeek_3] Default (0) For [3], Constraint [DF_Qianbo_CountWeek_4] Default (0) For [4], Constraint [DF_Qianbo_CountWeek_5] Default (0) For [5], Constraint [DF_Qianbo_CountWeek_6] Default (0) For [6], Constraint [DF_Qianbo_CountWeek_7] Default (0) For [7]
GO
Alter Table [dbo].[Qianbo_CountYear]
  Add Constraint [DF_Qianbo_CountYear_1] Default (0) For [1], Constraint [DF_Qianbo_CountYear_2] Default (0) For [2], Constraint [DF_Qianbo_CountYear_3] Default (0) For [3], Constraint [DF_Qianbo_CountYear_4] Default (0) For [4], Constraint [DF_Qianbo_CountYear_5] Default (0) For [5], Constraint [DF_Qianbo_CountYear_6] Default (0) For [6], Constraint [DF_Qianbo_CountYear_7] Default (0) For [7], Constraint [DF_Qianbo_CountYear_8] Default (0) For [8], Constraint [DF_Qianbo_CountYear_9] Default (0) For [9], Constraint [DF_Qianbo_CountYear_10] Default (0) For [10], Constraint [DF_Qianbo_CountYear_11] Default (0) For [11], Constraint [DF_Qianbo_CountYear_12] Default (0) For [12]
GO
Alter Table [dbo].[Qianbo_CustomForm]
  Add Constraint [DF_Qianbo_CustomForm_UploadSize] Default (0) For [UploadSize]
GO
Alter Table [dbo].[Qianbo_CustomFormField]
  Add Constraint [DF_Qianbo_CustomFormField_OrderId] Default (0) For [OrderId]
GO
Alter Table [dbo].[Qianbo_Dictionary]
  Add Constraint [DF_Qianbo_Dictionary2_Sort] Default (5) For [Sort]
GO
Alter Table [dbo].[Qianbo_Dig]
  Add Constraint [DF_Qianbo_Dig_DigCount] Default (0) For [DigCount]
GO
Create Index [DownLoadServerID]
  On [dbo].[Qianbo_DownLoadAddress]([DownLoadServerID])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_DownLoadData]
  Add Constraint [DF_Qianbo_DownLoadData_ChId] Default (0) For [ChId], Constraint [DF_Qianbo_DownLoadData_ColId] Default (0) For [ColId], Constraint [DF_Qianbo_DownLoadData_Title] Default ('') For [Title], Constraint [DF_Qianbo_DownLoadData_TitleColor] Default ('') For [TitleColor], Constraint [DF_Qianbo_DownLoadData_TitleFontType] Default ('') For [TitleFontType], Constraint [DF_Qianbo_DownLoadData_TitleType] Default (0) For [TitleType], Constraint [DF_Qianbo_DownLoadData_TitleImgPath] Default ('') For [TitleImgPath], Constraint [DF_Qianbo_DownLoadData_AdminUName] Default ('') For [AdminUName], Constraint [DF_Qianbo_DownLoadData_Status] Default (0) For [Status], Constraint [DF_Qianbo_DownLoadData_HitCount] Default (0) For [HitCount], Constraint [DF_Qianbo_DownLoadData_TemplatePath] Default ('') For [TemplatePath], Constraint [DF_Qianbo_DownLoadData_PageType] Default (1) For [PageType], Constraint [DF_Qianbo_DownLoadData_IsCreated] Default (0) For [IsCreated], Constraint
  [DF_Qianbo_DownLoadData_UserCateId] Default (0) For [UserCateId], Constraint [DF_Qianbo_DownLoadData_PointCount] Default (0) For [PointCount], Constraint [DF_Qianbo_DownLoadData_ChargeType] Default (1) For [ChargeType], Constraint [DF_Qianbo_DownLoadData_ChargeHourCount] Default (0) For [ChargeHourCount], Constraint [DF_Qianbo_DownLoadData_ChargeViewCount] Default (0) For [ChargeViewCount], Constraint [DF_Qianbo_DownLoadData_IsOpened] Default (2) For [IsOpened], Constraint [DF_Qianbo_DownLoadData_GroupIdStr] Default ('') For [GroupIdStr], Constraint [DF_Qianbo_DownLoadData_IsDeleted] Default (0) For [IsDeleted], Constraint [DF_Qianbo_DownLoadData_IsRecommend] Default (0) For [IsRecommend], Constraint [DF_Qianbo_DownLoadData_IsTop] Default (0) For [IsTop], Constraint [DF_Qianbo_DownLoadData_IsFocus] Default (0) For [IsFocus], Constraint [DF_Qianbo_DownLoadData_IsSideShow] Default (0) For [IsSideShow], Constraint [DF_Qianbo_DownLoadData_IsAllowComment] Default (0) For [IsAllowComment]
  , Constraint [DF_Qianbo_DownLoadData_TagIdStr] Default ('') For [TagIdStr], Constraint [DF_Qianbo_DownLoadData_TagNameStr] Default ('') For [TagNameStr], Constraint [DF_Qianbo_DownLoadData_SpecialIdStr] Default ('') For [SpecialIdStr], Constraint [DF_Qianbo_DownLoadData_CountTime] Default (getdate()) For [MonthCountTime], Constraint [DF_Qianbo_DownLoadData_WeekCountTime] Default (getdate()) For [WeekCountTime], Constraint [DF_Qianbo_DownLoadData_DayCountTime] Default (getdate()) For [DayCountTime]
GO
Create Index [IX_Qianbo_DownLoadData_ColId]
  On [dbo].[Qianbo_DownLoadData]([ColId])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_DownLoadData_AddTime]
  On [dbo].[Qianbo_DownLoadData]([AddTime])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_DownLoadData_SpecialIdStr]
  On [dbo].[Qianbo_DownLoadData]([SpecialIdStr])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_DownLoadData_TagIdStr]
  On [dbo].[Qianbo_DownLoadData]([TagIdStr])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_DownLoadData_ChId]
  On [dbo].[Qianbo_DownLoadData]([ChId])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_DownLoadServerData]
  Add Constraint [DF_Qianbo_DownLoadServerData_IsOpened] Default (0) For [IsOpened], Constraint [DF_Qianbo_DownLoadServerData_IsOuter] Default (0) For [IsOuter]
GO
Create Index [TypeId]
  On [dbo].[Qianbo_DownLoadServerData]([DownLoadServerDataId])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_DownLoadServerType]
  Add Constraint [DF_Qianbo_DownLoadServerType_TypeName] Default ('') For [TypeName]
GO
Alter Table [dbo].[Qianbo_Enterprise]
  Add Constraint [DF_Qianbo_Enterprise_TypeId] Default (0) For [TypeId]
GO
Alter Table [dbo].[Qianbo_ExpireArticle]
  Add Constraint [DF_Qianbo_ExpirtArticle_Title] Default ('') For [Title], Constraint [DF_Qianbo_ExpirtArticle_TitleColor] Default ('') For [TitleColor], Constraint [DF_Qianbo_ExpirtArticle_TitleFontType] Default ('') For [TitleFontType], Constraint [DF_Qianbo_ExpirtArticle_TitleType] Default (0) For [TitleType], Constraint [DF_Qianbo_ExpirtArticle_TitleImgPath] Default ('') For [TitleImgPath], Constraint [DF_Qianbo_ExpirtArticle_AdminUName] Default ('') For [AdminUName], Constraint [DF_Qianbo_ExpirtArticle_Status] Default (0) For [Status], Constraint [DF_Qianbo_ExpirtArticle_HitCount] Default (0) For [HitCount], Constraint [DF_Qianbo_ExpirtArticle_TemplatePath] Default ('') For [TemplatePath], Constraint [DF_Qianbo_ExpirtArticle_PageType] Default (1) For [PageType], Constraint [DF_Qianbo_ExpirtArticle_IsCreated] Default (0) For [IsCreated], Constraint [DF_Qianbo_ExpirtArticle_UserCateId] Default (0) For [UserCateId], Constraint [DF_Qianbo_ExpirtArticle_PointCount] Default (0) For
  [PointCount], Constraint [DF_Qianbo_ExpirtArticle_ChargeType] Default (1) For [ChargeType], Constraint [DF_Qianbo_ExpirtArticle_ChargeHourCount] Default (0) For [ChargeHourCount], Constraint [DF_Qianbo_ExpirtArticle_ChargeViewCount] Default (0) For [ChargeViewCount], Constraint [DF_Qianbo_ExpirtArticle_IsOpened] Default (2) For [IsOpened], Constraint [DF_Qianbo_ExpirtArticle_GroupIdStr] Default ('') For [GroupIdStr], Constraint [DF_Qianbo_ExpirtArticle_IsDeleted] Default (0) For [IsDeleted], Constraint [DF_Qianbo_ExpirtArticle_IsRecommend] Default (0) For [IsRecommend], Constraint [DF_Qianbo_ExpirtArticle_IsTop] Default (0) For [IsTop], Constraint [DF_Qianbo_ExpirtArticle_IsFocus] Default (0) For [IsFocus], Constraint [DF_Qianbo_ExpirtArticle_IsSideShow] Default (0) For [IsSideShow], Constraint [DF_Qianbo_ExpirtArticle_IsAllowComment] Default (0) For [IsAllowComment], Constraint [DF_Qianbo_ExpirtArticle_TagIdStr] Default ('') For [TagIdStr], Constraint
  [DF_Qianbo_ExpirtArticle_TagNameStr] Default ('') For [TagNameStr], Constraint [DF_Qianbo_ExpirtArticle_SpecialIdStr] Default ('') For [SpecialIdStr], Constraint [DF_Qianbo_ExpirtArticle_LongTitle] Default ('') For [LongTitle], Constraint [DF_Qianbo_ExpirtArticle_Content] Default ('') For [Content], Constraint [DF_Qianbo_ExpirtArticle_ShortContent] Default ('') For [ShortContent], Constraint [DF_Qianbo_ExpirtArticle_OuterUrl] Default ('') For [OuterUrl], Constraint [DF_Qianbo_ExpirtArticle_Author] Default ('') For [Author], Constraint [DF_Qianbo_ExpirtArticle_Source] Default ('') For [Source], Constraint [DF_Qianbo_ExpirtArticle_IsHeader] Default (0) For [IsHeader], Constraint [DF_Qianbo_ExpirtArticle_HeaderFont] Default ('') For [HeaderFont], Constraint [DF_Qianbo_ExpirtArticle_HeaderImgPath] Default ('') For [HeaderImgPath], Constraint [DF_Qianbo_ExpirtArticle_StarLevel] Default ('') For [StarLevel], Constraint [DF_Qianbo_ExpirtArticle_IsShowCommentLink] Default (0) For
  [IsShowCommentLink], Constraint [DF_Qianbo_ExpirtArticle_IsIrregular] Default (0) For [IsIrregular], Constraint [DF_Qianbo_ExpirtArticle_IrregularId] Default (0) For [IrregularId], Constraint [DF_Qianbo_ExpirtArticle_ViewUName] Default ('') For [ViewUName], Constraint [DF_Qianbo_ExpirtArticle_ViewUName2] Default ('') For [ViewUName2], Constraint [DF_Qianbo_ExpirtArticle_ViewEndTime] Default ('') For [ViewEndTime]
GO
Create Index [IX_Qianbo_ExpirtArticle_ExpirtTime]
  On [dbo].[Qianbo_ExpireArticle]([ExpireTime])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_FeedBack]
  Add Constraint [DF_Qianbo_FeedBack_title] Default ('') For [title], Constraint [DF_Qianbo_FeedBack_author] Default ('') For [author], Constraint [DF_Qianbo_FeedBack_reward] Default (0) For [reward], Constraint [DF_Qianbo_FeedBack_scoring] Default (0) For [scoring], Constraint [DF_Qianbo_FeedBack_category] Default (5) For [categoryId], Constraint [DF_Qianbo_FeedBack_content] Default ('') For [content], Constraint [DF_Qianbo_FeedBack_state] Default (0) For [state], Constraint [DF_Qianbo_FeedBack_replyDate] Default (getdate()) For [replyDate], Constraint [DF_Qianbo_FeedBack_IP] Default ('') For [IP]
GO
Alter Table [dbo].[Qianbo_Form_Mayor]
  Add Constraint [DF__Qianbo_Fo__bianh__390E6C01] Default ('') For [bianhao], Constraint [DF__Qianbo_Fo__xingm__3A02903A] Default ('') For [xingming], Constraint [DF__Qianbo_Fo__dizhi__3AF6B473] Default ('') For [dizhi], Constraint [DF__Qianbo_Fo__dianh__3BEAD8AC] Default ('') For [dianhua], Constraint [DF__Qianbo_Fo__shenf__3CDEFCE5] Default ('') For [shenfenzheng], Constraint [DF__Qianbo_Fo__youxi__3DD3211E] Default ('') For [youxiang], Constraint [DF__Qianbo_Fo__leibi__3EC74557] Default ('') For [leibie], Constraint [DF__Qianbo_Fo__gongk__3FBB6990] Default ('') For [gongkai], Constraint [DF__Qianbo_Fo__zhuti__40AF8DC9] Default ('') For [zhuti], Constraint [DF__Qianbo_Fo__huifu__4297D63B] Default ('') For [huifutime], Constraint [DF__Qianbo_Fo__zhuan__457442E6] Default ('') For [zhuangtai], Constraint [DF__Qianbo_Fo__shoul__44801EAD] Default ('') For [shouli]
GO
Create Index [IX_Qianbo_Form_Mayor_UId]
  On [dbo].[Qianbo_Form_Mayor]([UId])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Image]
  Add Constraint [DF_Qianbo_Image_ChId] Default (0) For [ChId], Constraint [DF_Qianbo_Image_ColId] Default (0) For [ColId], Constraint [DF_Qianbo_Image_Title] Default ('') For [Title], Constraint [DF_Qianbo_Image_TitleColor] Default (0) For [TitleColor], Constraint [DF_Qianbo_Image_TitleFontType] Default (0) For [TitleFontType], Constraint [DF_Qianbo_Image_TitleType] Default (0) For [TitleType], Constraint [DF_Qianbo_Image_TitleImgPath] Default ('') For [TitleImgPath], Constraint [DF_Qianbo_Image_AdminUName] Default ('') For [AdminUName], Constraint [DF_Qianbo_Image_Status] Default (0) For [Status], Constraint [DF_Qianbo_Image_HitsCount] Default (0) For [HitCount], Constraint [DF_Qianbo_Image_TemplatePath] Default ('') For [TemplatePath], Constraint [DF_Qianbo_Image_PageType] Default (1) For [PageType], Constraint [DF_Qianbo_Image_IsCreated] Default (0) For [IsCreated], Constraint [DF_Qianbo_Image_UserCateId] Default (0) For [UserCateId], Constraint [DF_Qianbo_Image_PointCount]
  Default (0) For [PointCount], Constraint [DF_Qianbo_Image_ChargeType] Default (1) For [ChargeType], Constraint [DF_Qianbo_Image_ChargeHourCount] Default (0) For [ChargeHourCount], Constraint [DF_Qianbo_Image_ChargeViewCount] Default (0) For [ChargeViewCount], Constraint [DF_Qianbo_Image_IsOpened] Default (2) For [IsOpened], Constraint [DF_Qianbo_Image_GroupIdStr] Default ('') For [GroupIdStr], Constraint [DF_Qianbo_Image_IsDeleted] Default (0) For [IsDeleted], Constraint [DF_Qianbo_Image_IsRecommend] Default (0) For [IsRecommend], Constraint [DF_Qianbo_Image_IsTop] Default (0) For [IsTop], Constraint [DF_Qianbo_Image_IsFocus] Default (0) For [IsFocus], Constraint [DF_Qianbo_Image_IsSideShow] Default (0) For [IsSideShow], Constraint [DF_Qianbo_Image_TagIdStr] Default ('') For [TagIdStr], Constraint [DF_Qianbo_Image_IsAllowComment] Default (0) For [IsAllowComment], Constraint [DF_Qianbo_Image_TagNameStr] Default ('') For [TagNameStr], Constraint [DF_Qianbo_Image_SpecialIdStr] Default
  ('') For [SpecialIdStr], Constraint [DF_Qianbo_Image_Content] Default ('') For [Content], Constraint [DF_Qianbo_Image_ImgPath] Default ('') For [ImgPath]
GO
Create Index [IX_Qianbo_Image_AddTime]
  On [dbo].[Qianbo_Image]([AddTime])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_Image_SpecialIdStr]
  On [dbo].[Qianbo_Image]([SpecialIdStr])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_Image_TagIdStr]
  On [dbo].[Qianbo_Image]([TagIdStr])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_Image_ColId]
  On [dbo].[Qianbo_Image]([ColId])
  On [PRIMARY]
GO
Create Index [IX_Qianbo_Image_ChId]
  On [dbo].[Qianbo_Image]([ChId])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_LbCategory]
  Add Constraint [DF_Qianbo_LbCategory_ParentID] Default (0) For [ParentID]
GO
Alter Table [dbo].[Qianbo_Link]
  Add Constraint [DF_Qianbo_Link_LinkType] Default (1) For [LinkType], Constraint [DF_Qianbo_Link_LinkCategory] Default ('') For [LinkCategory], Constraint [DF_Qianbo_Link_SiteName] Default ('') For [SiteName], Constraint [DF_Qianbo_Link_SiteLogo] Default ('') For [SiteLogo], Constraint [DF_Qianbo_Link_OwnerName] Default ('') For [OwnerName], Constraint [DF_Qianbo_Link_Description] Default ('') For [Description], Constraint [DF_Qianbo_Link_Status] Default (1) For [Status], Constraint [DF_Qianbo_Link_IsDisable] Default (0) For [IsDisable]
GO
Alter Table [dbo].[Qianbo_ListStyleContent]
  Add Constraint [DF_Qianbo_ListStyleContent_Content] Default ('') For [Content]
GO
Create Index [idx_1]
  On [dbo].[Qianbo_Log]([LogTime], [UserId])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Model]
  Add Constraint [DF_Qianbo_Model_ModelDesc] Default ('') For [ModelDesc], Constraint [DF_Qianbo_Model_UploadSize] Default (0) For [UploadSize], Constraint [DF_Qianbo_Model_IsSystem] Default (0) For [IsSystem], Constraint [DF_Qianbo_Model_AddTime] Default (getdate()) For [AddTime], Constraint [DF_Qianbo_Model_IsHtml] Default (0) For [IsHtml], Constraint [DF_Qianbo_Model_ModelSort] Default (1) For [ModelSort]
GO
Alter Table [dbo].[Qianbo_ModelField]
  Add Constraint [DF_Qianbo_ModelField_ColId_1] Default (0) For [ColId], Constraint [DF_Qianbo_ModelField_OrderId] Default (0) For [OrderId], Constraint [DF_Qianbo_ModelField_IsChild_1] Default (0) For [IsChild], Constraint [DF_Qianbo_ModelField_IsList_1] Default (0) For [IsList], Constraint [DF_Qianbo_ModelField_IsUserInsert_1] Default (0) For [IsUserInsert]
GO
Alter Table [dbo].[Qianbo_PowerGroup]
  Add Constraint [DF_Qianbo_PowerGroup_SiteId] Default (0) For [SiteId], Constraint [DF_Qianbo_PowerGroup_IsSystem] Default (0) For [IsSystem]
GO
Alter Table [dbo].[Qianbo_Report]
  Add Constraint [DF_Qianbo_Report_IsComplete] Default (0) For [IsComplete], Constraint [DF_Qianbo_Report_AddTime] Default (getdate()) For [AddTime]
GO
Create Index [IX_Qianbo_Review]
  On [dbo].[Qianbo_Review]([ModelType])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_StyleCategory]
  Add Constraint [DF_Qianbo_StyleCategory_ParentID] Default (0) For [ParentID]
GO
Alter Table [dbo].[Qianbo_SubSite]
  Add Constraint [DF_Qianbo_SubSite_Name] Default ('') For [Name], Constraint [DF_Qianbo_SubSite_LOGO] Default ('') For [LOGO], Constraint [DF_Qianbo_SubSite_Sort] Default (1) For [Sort], Constraint [DF_Qianbo_SubSite_Status] Default (0) For [Status], Constraint [DF_Qianbo_SubSite_AddTime] Default (getdate()) For [AddTime], Constraint [DF_Qianbo_SubSite_Remark] Default ('') For [Remark], Constraint [DF_Qianbo_SubSite_OpenTime] Default ('-') For [OpenTime], Constraint [DF__Qianbo_SubSite__IsCre__28CDE297] Default (0) For [IsCreateModel]
GO
Alter Table [dbo].[Qianbo_SuperLabel]
  Add Constraint [DF_Qianbo_SuperLabel_PageSize] Default (10) For [PageSize], Constraint [DF_Qianbo_SuperLabel_NumColumns] Default (1) For [NumColumns], Constraint [DF__Qianbo_SuperLa__IsHtm__59D10CA5] Default (1) For [IsHtml]
GO
Alter Table [dbo].[Qianbo_Tag]
  Add Constraint [DF_Qianbo_TagKeyword_DaySearchCount] Default (0) For [DaySearchCount], Constraint [DF_Qianbo_TagKeyword_YesterdaySearchCount] Default (0) For [YesterdaySearchCount], Constraint [DF_Qianbo_TagKeyword_TotalSearchCount] Default (0) For [TotalSearchCount], Constraint [DF_Qianbo_TagKeyword_UserId] Default (0) For [UserId], Constraint [DF_Qianbo_Tag_CountTime] Default (getdate()) For [CountTime]
GO
Create Index [IX_Qianbo_Tag]
  On [dbo].[Qianbo_Tag]([TotalSearchCount] Desc, [TagId] Desc )
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_UserFriendGroup]
  Add Constraint [DF_Qianbo_UserFriendGroup_IsSystem] Default (0) For [IsUserId]
GO
Alter Table [dbo].[Qianbo_UserGroupModelField]
  Add Constraint [DF_Qianbo_UserGroupModelField_OrderId] Default (0) For [OrderId]
GO
Alter Table [dbo].[Qianbo_UserLog]
  Add Constraint [DF_Qianbo_UserLog_Point] Default (0) For [Point]
GO
Alter Table [dbo].[Qianbo_UserMessage]
  Add Constraint [DF_Qianbo_UserMessage_UserHome] Default (N'http://') For [HomePage]
GO
Alter Table [dbo].[Qianbo_UserPhoto]
  Add Constraint [DF_Qianbo_UserPhoto_VisitNum] Default (0) For [VisitNum], Constraint [DF_Qianbo_UserPhoto_FileSize] Default (0) For [FileSize]
GO
Alter Table [dbo].[Qianbo_User_Business]
  Add Constraint [DF__Qianbo_User_B__Emplo__2A02C949] Default ('5') For [EmployNumber], Constraint [DF__Qianbo_User_B__Licen__2BA02DA1] Default ('') For [License], Constraint [DF__Qianbo_User_B__TaxCe__2C9451DA] Default ('') For [TaxCertificates], Constraint [DF__Qianbo_User_B__Other__2D887613] Default ('') For [OtherCertificates], Constraint [DF__Qianbo_User_B__Conta__2E7C9A4C] Default ('') For [ContactPersonal], Constraint [DF__Qianbo_User_B__Telep__2F70BE85] Default ('') For [Telephone], Constraint [DF__Qianbo_User_B__Compa__3064E2BE] Default ('') For [CompanyEmail], Constraint [DF__Qianbo_User_Bus__Fax__315906F7] Default ('') For [Fax], Constraint [DF__Qianbo_User_B__Addre__324D2B30] Default ('') For [Address], Constraint [DF__Qianbo_User_B__HomeP__33414F69] Default ('') For [HomePage], Constraint [DF__Qianbo_User_Bu__LOGO__343573A2] Default ('') For [LOGO], Constraint [DF__Qianbo_User_Bu__name__36DCD623] Default ('') For [name], Constraint [DF__Qianbo_User_Busi__lx__2AF6ED82]
  Default ('培训机构') For [lx], Constraint [DF_Qianbo_User_Business_tID] Default (0) For [tID], Constraint [DF__Qianbo_User_B__tName__381BDE76] Default ('') For [tName], Constraint [DF__Qianbo_User_Bu__area__54B81D24] Default ('') For [area], Constraint [DF__Qianbo_User_B__Geogr__55AC415D] Default ('') For [Geographical], Constraint [DF__Qianbo_User_B__lx_Id__0393079E] Default (0) For [lx_Id], Constraint [DF__Qianbo_User_B__Emplo__04872BD7] Default (0) For [EmployNumber_Id]
GO
Create Index [IX_Qianbo_User_Business_UId]
  On [dbo].[Qianbo_User_Business]([UId])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_User_Personal]
  Add Constraint [DF__Qianbo_User_P__TrueN__4D61141F] Default ('') For [TrueName], Constraint [DF__Qianbo_User_Pe__area__4E553858] Default ('') For [area], Constraint [DF__Qianbo_User_P__Geogr__4F495C91] Default ('') For [Geographical], Constraint [DF__Qianbo_User_P__Addre__503D80CA] Default ('') For [Address], Constraint [DF__Qianbo_User_P__Phone__5131A503] Default ('') For [Phone], Constraint [DF__Qianbo_User_P__Email__5225C93C] Default ('') For [Email], Constraint [DF__Qianbo_User_P__Pictu__269C4CB9] Default ('') For [Picture]
GO
Create Index [IX_Qianbo_User_Personal_UId]
  On [dbo].[Qianbo_User_Personal]([UId])
  On [PRIMARY]
GO
Alter Table [dbo].[Qianbo_Users]
  Add Constraint [DF_Qianbo_Users_YellowBoy] Default (0) For [YellowBoy], Constraint [DF_Qianbo_Users_IsLock] Default (0) For [IsLock], Constraint [DF_Qianbo_Users_LoginNum] Default (1) For [LoginNum], Constraint [DF_Qianbo_Users_RegTime] Default (getdate()) For [RegTime], Constraint [DF_Qianbo_Users_LastLoginTime] Default (getdate()) For [LastLoginTime], Constraint [DF_Qianbo_Users_ErrorNum] Default (0) For [ErrorNum], Constraint [DF_Qianbo_Users_ErrorTime] Default (getdate()) For [ErrorTime], Constraint [DF_Qianbo_Users_ExpireTime] Default (getdate()) For [ExpireTime], Constraint [DF_Qianbo_Users_SiteId] Default (0) For [SiteId]
GO
Alter Table [dbo].[Qianbo_ViewLog]
  Add Constraint [DF_Qianbo_ViewLog_AddTime] Default (getdate()) For [AddTime]
GO
Alter Table [dbo].[Qianbo_Vote]
  Add Constraint [DF_Qianbo_Vote_DisplayType] Default (1) For [DisplayType], Constraint [DF_Qianbo_Vote_ModelType] Default (1) For [ModelType]
GO
Alter Table [dbo].[Qianbo_WebMessage]
  Add Constraint [DF_Qianbo_WebMessage_IsSend] Default (0) For [IsSend], Constraint [DF_Qianbo_WebMessage_IsRead] Default (0) For [IsRead], Constraint [DF_Qianbo_WebMessage_IsDel] Default (0) For [ReceiverDel], Constraint [DF_Qianbo_WebMessage_AllUser] Default (0) For [AllUser], Constraint [DF_Qianbo_WebMessage_UserGroupId] Default (0) For [UserGroupId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_AdCategory_Get]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_AdCategory_Get]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_AdCategory_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_AdCategory_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Ad_Get]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Ad_Get]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Ad_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Ad_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_GetAdminCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_GetAdminCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_GetAdminList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_GetAdminList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_GetAdminListByGroupId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_GetAdminListByGroupId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_GetInfoById]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_GetInfoById]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_GetInfoByNameAndPass]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_GetInfoByNameAndPass]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_GetSiteModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_GetSiteModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Admin_UpdateState]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Admin_UpdateState]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Anomaly_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Anomaly_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Anomaly_CheckHas]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Anomaly_CheckHas]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Anomaly_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Anomaly_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Anomaly_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Anomaly_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Article_GetExpireArticleCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Article_GetExpireArticleCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Article_MoveExpireArticle]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Article_MoveExpireArticle]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Article_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Article_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Article_SetViewer]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Article_SetViewer]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Card_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Card_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Card_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Card_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Card_GetCard]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Card_GetCard]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Card_GetCards]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Card_GetCards]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Card_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Card_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Channel_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Channel_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Channel_CompleteDelete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Channel_CompleteDelete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Channel_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Channel_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Channel_GetAll]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Channel_GetAll]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Channel_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Channel_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Channel_SetDisaled]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Channel_SetDisaled]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Channel_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Channel_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsCount_AddDayCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsCount_AddDayCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsCount_AddMonthCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsCount_AddMonthCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsCount_AddWeekCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsCount_AddWeekCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsCount_AddYearCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsCount_AddYearCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsShopBrand_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsShopBrand_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsShopBrand_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsShopBrand_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsShopBrand_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsShopBrand_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsShopProcuder_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsShopProcuder_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsShopProducer_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsShopProducer_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsShopProducer_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsShopProducer_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CmsShopProducer_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CmsShopProducer_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Cms_CheckHas]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Cms_CheckHas]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Cms_CheckHasOnUpdate]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Cms_CheckHasOnUpdate]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CollectionAddress_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CollectionAddress_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CollectionAddress_CheckAddress]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CollectionAddress_CheckAddress]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CollectionAddress_DeleteCollId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CollectionAddress_DeleteCollId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CollectionAddress_GetCollIdList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CollectionAddress_GetCollIdList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CollectionAddress_GetCollidByAddress]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CollectionAddress_GetCollidByAddress]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CollectionAddress_UpdateState]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CollectionAddress_UpdateState]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Collection_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Collection_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Collection_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Collection_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Collection_GetIdByCollection]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Collection_GetIdByCollection]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Collection_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Collection_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Collection_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Collection_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Column_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Column_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Column_CompleteDelete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Column_CompleteDelete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Column_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Column_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Column_GetAll]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Column_GetAll]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Column_Move]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Column_Move]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Column_SetInfoTemplate]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Column_SetInfoTemplate]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Column_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Column_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Column_UpdateHtml]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Column_UpdateHtml]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Column_Update_Template]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Column_Update_Template]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Controller_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Controller_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Controller_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Controller_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Controller_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Controller_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Controller_Set_Default]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Controller_Set_Default]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_Article_HeaderList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_Article_HeaderList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_Ch_GetSpecialInfoCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_Ch_GetSpecialInfoCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_Ch_GetSpecialInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_Ch_GetSpecialInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetAll_Info]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetAll_Info]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetChannel_Column_InfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetChannel_Column_InfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetChannel_FinallyInfoCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetChannel_FinallyInfoCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetChannel_FinallyInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetChannel_FinallyInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetChannel_InfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetChannel_InfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetCloseInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetCloseInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetColumn_ChildCol_InfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetColumn_ChildCol_InfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetColumn_FinallyInfoCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetColumn_FinallyInfoCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetColumn_FinallyInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetColumn_FinallyInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetColumn_FlashInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetColumn_FlashInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetColumn_Info]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetColumn_Info]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetColumn_InfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetColumn_InfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetDateRange_Info]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetDateRange_Info]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetDigCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetDigCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetIdRange_Info]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetIdRange_Info]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetId_Info]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetId_Info]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetNewRange_Info]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetNewRange_Info]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetPropertyCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetPropertyCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_GetPropertyList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_GetPropertyList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_InfoRecordCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_InfoRecordCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_Info_RelationInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_Info_RelationInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_Irregular_GetInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_Irregular_GetInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_ListInfoCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_ListInfoCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Create_SetDigCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Create_SetDigCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomField_SubmitNum]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomField_SubmitNum]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomFormField_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomFormField_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomFormField_Del]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomFormField_Del]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomFormField_GetIsUserList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomFormField_GetIsUserList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomFormField_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomFormField_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomFormField_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomFormField_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomFormField_GetTitleList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomFormField_GetTitleList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomFormField_MoveField]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomFormField_MoveField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomFormField_SelectPropertyTrue]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomFormField_SelectPropertyTrue]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomFormField_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomFormField_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomForm_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomForm_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomForm_AddTable]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomForm_AddTable]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomForm_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomForm_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomForm_GetAll]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomForm_GetAll]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomForm_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomForm_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomForm_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomForm_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_CustomTable_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_CustomTable_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Dictionary_Get]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Dictionary_Get]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Dictionary_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Dictionary_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadAddress_GetGroupAddresList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadAddress_GetGroupAddresList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadAddress_GetInfoBySoftId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadAddress_GetInfoBySoftId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadAddress_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadAddress_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadData_ClearDownCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadData_ClearDownCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadData_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadData_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadData_GetDataById]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadData_GetDataById]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadData_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadData_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadServerData_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadServerData_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadServerData_GetInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadServerData_GetInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadServerData_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadServerData_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadServerData_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadServerData_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadServerData_SetIsOpened]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadServerData_SetIsOpened]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadServerType_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadServerType_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadServerType_GetInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadServerType_GetInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadServerType_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadServerType_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoadServerType_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoadServerType_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoad_GetAddressPath]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoad_GetAddressPath]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoad_GetDownCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoad_GetDownCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoad_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoad_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoad_IsAllowDeleteType]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoad_IsAllowDeleteType]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_DownLoad_SetDownCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_DownLoad_SetDownCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_EnterPrise_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_EnterPrise_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Enterprise_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Enterprise_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Enterprise_GetById]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Enterprise_GetById]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Enterprise_GetByUserId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Enterprise_GetByUserId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ExtendContent_Del]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ExtendContent_Del]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ExtendContent_List]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ExtendContent_List]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_FeedBack_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_FeedBack_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_FeedBack_Count]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_FeedBack_Count]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_FeedBack_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_FeedBack_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_FeedBack_GetFeedBack]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_FeedBack_GetFeedBack]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_FeedBack_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_FeedBack_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_FeedBack_UpdateState]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_FeedBack_UpdateState]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Group_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Group_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Group_GetAdminGroupUserCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Group_GetAdminGroupUserCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_HireInfo_Get]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_HireInfo_Get]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_HireInfo_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_HireInfo_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Image_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Image_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Image_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Image_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_InfoModel_GetTextType]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_InfoModel_GetTextType]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_AddHitCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_AddHitCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_Auditing]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_Auditing]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_Cancel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_Cancel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_CompleteDeleteInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_CompleteDeleteInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_DeleteToRecycle]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_DeleteToRecycle]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_GetHitCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_GetHitCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_GetInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_GetInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_GetInfoCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_GetInfoCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_GetInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_GetInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_GetInfo_CustomForm]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_GetInfo_CustomForm]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_GetRecycleInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_GetRecycleInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_GetUserInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_GetUserInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_MassMoveInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_MassMoveInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_MassSetInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_MassSetInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_SetInfoSpecial]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_SetInfoSpecial]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_SetProperty]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_SetProperty]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_UpdateIsCreated]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_UpdateIsCreated]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_User_DeleteInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_User_DeleteInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_User_GetInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_User_GetInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_User_IsExistsInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_User_IsExistsInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Info_User_Publish]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Info_User_Publish]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_ConByName]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_ConByName]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_GetContent]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_GetContent]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_GetInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_GetInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_GetLabelByModelId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_GetLabelByModelId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_GetLbCategoryIdList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_GetLbCategoryIdList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_GetLbCategoryNameList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_GetLbCategoryNameList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LabelContent_UpdateModelId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LabelContent_UpdateModelId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LbCategory_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LbCategory_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LbCategory_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LbCategory_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LbCategory_GetIdData]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LbCategory_GetIdData]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LbCategory_GetParentIDList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LbCategory_GetParentIDList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LbCategory_ID]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LbCategory_ID]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LbCategory_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LbCategory_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_LbContent_DeleteLbCategoryId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_LbContent_DeleteLbCategoryId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Link_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Link_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Link_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Link_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Link_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Link_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Link_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Link_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Link_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Link_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Log_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Log_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Log_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Log_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Log_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Log_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_AddField]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_AddField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_Del]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_Del]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_DelField]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_DelField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_GetAllTable]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_GetAllTable]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_GetList_Col]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_GetList_Col]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_GetList_FieldOrder]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_GetList_FieldOrder]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_GetList_Model]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_GetList_Model]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_GetSearchField]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_GetSearchField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_GetTableAllField]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_GetTableAllField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_GetTableAllFieldAndType]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_GetTableAllFieldAndType]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_InField]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_InField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_InModelId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_InModelId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_IsNotField]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_IsNotField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_MoveField]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_MoveField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_SelectPropertyTrue]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_SelectPropertyTrue]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ModelField_UpdateFieldDefault]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ModelField_UpdateFieldDefault]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_AddTable]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_AddTable]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_AddTableGIPS]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_AddTableGIPS]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_AddTableShop]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_AddTableShop]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_CheckExistsChannel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_CheckExistsChannel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_CheckTableValidate]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_CheckTableValidate]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_CheckUploadPathValidate]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_CheckUploadPathValidate]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_ExtendTable]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_ExtendTable]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_GetInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_GetInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_InfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_InfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_ModelHtml]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_ModelHtml]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_Out]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_Out]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Model_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Model_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Notice]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Notice]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Notice_GetTop]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Notice_GetTop]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_PlanAssignMent_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_PlanAssignMent_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_PlanAssignMent_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_PlanAssignMent_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_PlanAssignMent_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_PlanAssignMent_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_PlanAssignMent_List]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_PlanAssignMent_List]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_PlanAssignMent_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_PlanAssignMent_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_PowerColumn_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_PowerColumn_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_PowerGroup]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_PowerGroup]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_PowerGroup_BySiteId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_PowerGroup_BySiteId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Property_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Property_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Property_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Property_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Property_GetAllList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Property_GetAllList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Property_GetAllSubProperty]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Property_GetAllSubProperty]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Property_GetIdStrList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Property_GetIdStrList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Property_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Property_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Property_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Property_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Property_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Property_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Property_UpdatePropertyArea]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Property_UpdatePropertyArea]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Recycle_Restore]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Recycle_Restore]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Report_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Report_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Report_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Report_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Report_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Report_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Report_SetStatus]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Report_SetStatus]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Review_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Review_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Review_GetManageList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Review_GetManageList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Review_GetMoreList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Review_GetMoreList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Review_GetTop5List]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Review_GetTop5List]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Review_Oper]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Review_Oper]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Rss_GetInfoList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Rss_GetInfoList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SelectAll]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SelectAll]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SinglePage_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SinglePage_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SinglePage_Del]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SinglePage_Del]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SinglePage_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SinglePage_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SinglePage_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SinglePage_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SinglePage_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SinglePage_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Site_Count]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Site_Count]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Special_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Special_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Special_CompleteDelete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Special_CompleteDelete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Special_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Special_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Special_GetAll]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Special_GetAll]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Special_GetChSpecialList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Special_GetChSpecialList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Special_GetSpecial]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Special_GetSpecial]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Special_GetSpecials]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Special_GetSpecials]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Special_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Special_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_StyleCategoryId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_StyleCategoryId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_StyleCategory_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_StyleCategory_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_StyleCategory_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_StyleCategory_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_StyleCategory_GetIdData]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_StyleCategory_GetIdData]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_StyleCategory_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_StyleCategory_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_StyleCategory_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_StyleCategory_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_StyleContent_GetLbCategoryNameList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_StyleContent_GetLbCategoryNameList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_AddSearchStyle]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_AddSearchStyle]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_ConById]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_ConById]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_DeleteAndStyleCategoryId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_DeleteAndStyleCategoryId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_GetAll]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_GetAll]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_GetByModelId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_GetByModelId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_GetHasRows]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_GetHasRows]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_GetId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_GetId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_GetSearchStyle]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_GetSearchStyle]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_StyleIDGetStylegoryId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_StyleIDGetStylegoryId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_UpdateModelId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_UpdateModelId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Style_UpdateSearchStyle]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Style_UpdateSearchStyle]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SubSite_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SubSite_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SubSite_DelAdmin]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SubSite_DelAdmin]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SubSite_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SubSite_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SubSite_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SubSite_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SubSite_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SubSite_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SubSite_GetModel_EnName]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SubSite_GetModel_EnName]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SubSite_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SubSite_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SuperLabel_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SuperLabel_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SuperLabel_CheckName]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SuperLabel_CheckName]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SuperLabel_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SuperLabel_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SuperLabel_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SuperLabel_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SuperLabel_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SuperLabel_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SuperLabel_GetSuperId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SuperLabel_GetSuperId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SuperLabel_IsModelTable]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SuperLabel_IsModelTable]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SuperLabel_Out]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SuperLabel_Out]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_SuperLabel_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_SuperLabel_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Superior_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Superior_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Superior_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Superior_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Superior_GetIdBySuperiorl]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Superior_GetIdBySuperiorl]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Superior_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Superior_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Superior_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Superior_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TagCategory_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TagCategory_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TagCategory_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TagCategory_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TagCateogry_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TagCateogry_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TagNotice_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TagNotice_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Tag_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Tag_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Tag_AddTagStr]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Tag_AddTagStr]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Tag_Clear]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Tag_Clear]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Tag_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Tag_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Tag_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Tag_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Tag_SetSearchCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Tag_SetSearchCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TempTablePage_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TempTablePage_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TempTableSimple_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TempTableSimple_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TempTable_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TempTable_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TempTable_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TempTable_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TempTable_Exists]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TempTable_Exists]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TempTable_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TempTable_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TempTable_IsSend]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TempTable_IsSend]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TempTable_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TempTable_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_TempTable_UpdateSate]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_TempTable_UpdateSate]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UpdateMoney]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UpdateMoney]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserAlbum_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserAlbum_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserAlbum_GetById]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserAlbum_GetById]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserAlbum_GetByUserId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserAlbum_GetByUserId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserAlbum_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserAlbum_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserCate_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserCate_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserCate_GetById]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserCate_GetById]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserCate_GetByUser]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserCate_GetByUser]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserCate_GetCountByUserId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserCate_GetCountByUserId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserCate_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserCate_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserCate_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserCate_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserFavorite]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserFavorite]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserFavorite_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserFavorite_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroup]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroup]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModelField_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModelField_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModelField_Del]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModelField_Del]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModelField_GetIsUserList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModelField_GetIsUserList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModelField_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModelField_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModelField_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModelField_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModelField_GetTitleList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModelField_GetTitleList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModelField_MoveField]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModelField_MoveField]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModelField_SelectPropertyTrue]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModelField_SelectPropertyTrue]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModelField_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModelField_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModel_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModel_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModel_AddTable]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModel_AddTable]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModel_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModel_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModel_GetAll]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModel_GetAll]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModel_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModel_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModel_GetTextType]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModel_GetTextType]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModel_ModelHtml]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModel_ModelHtml]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModel_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModel_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroupModel_UpdateUserGroupId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroupModel_UpdateUserGroupId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroup_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroup_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroup_GetNameAndId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroup_GetNameAndId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserGroup_ManageList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserGroup_ManageList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserLog_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserLog_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserLog_CheckIsPay]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserLog_CheckIsPay]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserLog_ListLog]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserLog_ListLog]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserLog_ReducePoint]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserLog_ReducePoint]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserMessage_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserMessage_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserMessage_GetById]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserMessage_GetById]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserMessage_GetByUserId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserMessage_GetByUserId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserMessage_Resume]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserMessage_Resume]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserMessage_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserMessage_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserPhoto_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserPhoto_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserPhoto_GetById]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserPhoto_GetById]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserPhoto_GetByPhotoId]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserPhoto_GetByPhotoId]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserPhoto_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserPhoto_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserSpace_GetById]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserSpace_GetById]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserSpace_GetPrevPower]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserSpace_GetPrevPower]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_UserSpace_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_UserSpace_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_AddFriend]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_AddFriend]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_Changepwd]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_Changepwd]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_CheckMultiIdentity]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_CheckMultiIdentity]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_DeleteFriend]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_DeleteFriend]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_GetAllInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_GetAllInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_GetUserCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_GetUserCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_ListGroupMember]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_ListGroupMember]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_Login]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_Login]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_Recharge]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_Recharge]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_RechargeRecord]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_RechargeRecord]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_SetFriend]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_SetFriend]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_SetFriendGroup]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_SetFriendGroup]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_User_UpdateRegCode]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_User_UpdateRegCode]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_GetUser]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_GetUser]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_GetUserList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_GetUserList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_Login_Error]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_Login_Error]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_Login_OnErrorNum]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_Login_OnErrorNum]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_Login_Success]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_Login_Success]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_ModifyOtherBasicInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_ModifyOtherBasicInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_ModifyPwd]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_ModifyPwd]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_ModifyQuestion]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_ModifyQuestion]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_SetLockStatus]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_SetLockStatus]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Users_SetStatus]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Users_SetStatus]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ViewLog_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ViewLog_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_ViewLog_GetViewCount]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_ViewLog_GetViewCount]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_VoteCategory_Get]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_VoteCategory_Get]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_VoteCategory_Set]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_VoteCategory_Set]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_VoteSubject_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_VoteSubject_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_VoteSubject_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_VoteSubject_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_VoteSubject_Get]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_VoteSubject_Get]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_VoteSubject_GetAll]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_VoteSubject_GetAll]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_VoteSubject_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_VoteSubject_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Vote_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Vote_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Vote_GetVoteIdByInfo]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Vote_GetVoteIdByInfo]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_Vote_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_Vote_Update]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_WebMessage]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_WebMessage]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_WebMessage_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_WebMessage_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_WorkFlow_Add]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_WorkFlow_Add]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_WorkFlow_Delete]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_WorkFlow_Delete]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_WorkFlow_GetList]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_WorkFlow_GetList]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_WorkFlow_GetModel]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_WorkFlow_GetModel]
GO
If Exists (Select *
           From   dbo.sysobjects
           Where  id = object_id(N'[dbo].[Proc_WorkFlow_Update]')
                  And OBJECTPROPERTY(id, N'IsProcedure') = 1)
  Drop Procedure [dbo].[Proc_WorkFlow_Update]
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_AdCategory_Get @Type         Int,
                                     @AdCategoryId Int,
                                     @PageSize     Int=20,
                                     @PageIndex    Int=1,
                                     @WhereString  Nvarchar(500)
As
  Declare @SqlStr Nvarchar(2000)
  Declare @Filter Nvarchar(2000)
  If( @WhereString = '' )
    Begin
        Set @WhereString=' where '
        Set @Filter=''
    End
  Else
    Begin
        Set @Filter=' where ' + @WhereString
        Set @WhereString=' where ' + @WhereString + ' and '
    End
  If( @Type = 1 )
    Begin
        Select *
        From   Qianbo_AdCategory
        Where  AdCategoryId = @AdCategoryId
    End
  If( @Type = 2 )
    Begin
        If( @PageIndex = 1 )
          Begin
              Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_AdCategory ' + @Filter + ' order by AdCategoryId desc'
          End
        Else
          Begin
              Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_AdCategory ' + @WhereString + ' AdCategoryId < (select min(AdCategoryId) from(select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' * from Qianbo_AdCategory  ' + @Filter + ' order by AdCategoryId desc)O) order by AdCategoryId desc'
          End
        Print @SqlStr
        Execute Sp_ExecuteSql @SqlStr
        Set @SqlStr = 'select Count(*) from Qianbo_AdCategory ' + @Filter
        Execute Sp_ExecuteSql @SqlStr
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_AdCategory_Set @Type         Int,
                                     @AdCategoryId Int,
                                     @CategoryName Nvarchar(100),
                                     @IsDisabled   Int,
                                     @WidthHeigth  Varchar(12),
                                     @DisplayType  Int,
                                     @Description  Nvarchar(100)
As
  If( @Type = 1 )
    Begin
        Insert Into Qianbo_AdCategory
                    ([CategoryName],
                     [IsDisabled],
                     [WidthHeigth],
                     [DisplayType],
                     [Description])
        Values      ( @CategoryName,
                      @IsDisabled,
                      @WidthHeigth,
                      @DisplayType,
                      @Description )
    End
  If( @Type = 2 )
    Begin
        Update Qianbo_AdCategory
        Set    [CategoryName] = @CategoryName,
               [IsDisabled] = @IsDisabled,
               [WidthHeigth] = @WidthHeigth,
               [DisplayType] = @DisplayType,
               [Description] = @Description
        Where  [AdCategoryId] = @AdCategoryId
    End
  If( @Type = 3 )
    Begin
        Delete Qianbo_AdCategory
        Where  [AdCategoryId] = @AdCategoryId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Ad_Get @Type        Int,
                             @AdId        Int,
                             @PageSize    Int=20,
                             @PageIndex   Int=1,
                             @WhereString Nvarchar(500)
As
  Declare @SqlStr Nvarchar(2000)
  Declare @Filter Nvarchar(2000)
  If( @WhereString = '' )
    Begin
        Set @WhereString=' where '
        Set @Filter=''
    End
  Else
    Begin
        Set @Filter=' where ' + @WhereString
        Set @WhereString=' where ' + @WhereString + ' and '
    End
  If( @Type = 1 )
    Begin
        Select *
        From   Qianbo_Ad
        Where  AdId = @AdId
    End
  If( @Type = 2 )
    Begin
        If( @PageIndex = 1 )
          Begin
              Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' Qianbo_Ad.*,Qianbo_AdCategory.CategoryName from Qianbo_Ad left join Qianbo_AdCategory on Qianbo_Ad.CategoryId = Qianbo_AdCategory.AdCategoryId ' + @Filter + ' order by AdId desc'
          End
        Else
          Begin
              Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' Qianbo_Ad.*,Qianbo_AdCategory.CategoryName from Qianbo_Ad  left join Qianbo_AdCategory on Qianbo_Ad.CategoryId = Qianbo_AdCategory.AdCategoryId ' + @WhereString + ' AdId < (select min(AdId) from(select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' * from Qianbo_Ad  ' + @Filter + ' order by AdId desc)O) order by AdId desc'
          End
        Execute Sp_ExecuteSql @SqlStr
        Set @SqlStr = 'select Count(*) from Qianbo_Ad ' + @Filter
        Execute Sp_ExecuteSql @SqlStr
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Ad_Set @Type       Int,
                             @AdId       Int,
                             @CategoryId Varchar(100),
                             @AdName     Nvarchar(100),
                             @AdType     Int,
                             @Content    Nvarchar(2000),
                             @EndTime    Datetime,
                             @Weight     Int,
                             @HitCount   Int
As
  If( @Type = 1 )
    Begin
        Insert Into Qianbo_Ad
                    ([CategoryId],
                     [AdName],
                     [AdType],
                     [Content],
                     [EndTime],
                     [Weight],
                     [HitCount])
        Values      ( @CategoryId,
                      @AdName,
                      @AdType,
                      @Content,
                      @EndTime,
                      @Weight,
                      @HitCount )
    End
  If( @Type = 2 )
    Begin
        Update Qianbo_Ad
        Set    [CategoryId] = @CategoryId,
               [AdName] = @AdName,
               [AdType] = @AdType,
               [Content] = @Content,
               [EndTime] = @EndTime,
               [Weight] = @Weight,
               [HitCount] = @HitCount
        Where  [AdId] = @AdId
    End
  If( @Type = 3 )
    Begin
        Delete Qianbo_Ad
        Where  [AdId] = @AdId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Admin_Add @LogName         Nvarchar(20),
                                @UserName        Nvarchar(20),
                                @Password        Varchar(200),
                                @GroupId         Int,
                                @GroupName       Nvarchar(50),
                                @AllowMultiLogin Bit,
                                @SiteId          Int,
                                @Contact         Nvarchar(150),
                                @Locked          Bit,
                                @IsSiteManage    Int,
                                @output          Bit output
As
  If Exists(Select *
            From   Qianbo_Admin
            Where  LoginName = @LogName
                    Or UserName = @UserName)
    Set @output=0
  Else
    Begin
        Insert Into Qianbo_Admin
                    (LoginName,
                     UserName,
                     Password,
                     GroupId,
                     GroupName,
                     AllowMultiLogin,
                     SiteId,
                     Contact,
                     Locked,
                     IsSiteManage)
        Values      (@LogName,
                     @UserName,
                     @Password,
                     @GroupId,
                     @GroupName,
                     @AllowMultiLogin,
                     @SiteId,
                     @Contact,
                     @Locked,
                     @IsSiteManage)
        Set @output=1
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Admin_Delete @UserId Int
As
  Delete dbo.Qianbo_Admin
  Where  UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Admin_GetAdminCount @GroupId Int
As
  Select Count(*)
  From   Qianbo_Admin
  Where  GroupId = @GroupId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Admin_GetAdminList
As
  Select *
  From   Qianbo_Admin
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Admin_GetAdminListByGroupId @GroupId Int
As
  Select UserId,
         UserName,
         GroupName,
         AllowMultiLogin,
         LastLoginIP,
         LastLoginTime,
         LoginTime
  From   Qianbo_Admin
  Where  GroupId = @GroupId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Admin_GetInfoById @UserId Int
As
  Select *
  From   [Qianbo_Admin]
  Where  UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Admin_GetInfoByNameAndPass @LoginName Nvarchar(20),
                                                 @Password  Varchar(200)
As
  Select *
  From   Qianbo_Admin
  Where  LoginName = @LoginName
         And [Password] = @Password
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Admin_GetSiteModel @SiteId Int
As
  Select *
  From   [Qianbo_Admin]
  Where  SiteId = @SiteId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Admin_Update @UserId          Int,
                              @Password        Varchar(200),
                              @AllowMultiLogin Bit,
                              @GroupId         Int,
                              @GroupName       Nvarchar(50),
                              @UserName        Nvarchar(50),
                              @SiteId          Int,
                              @Contact         Nvarchar(150),
                              @Locked          Bit,
                              @IsSiteManage    Int
As
  Update Qianbo_Admin
  Set    [Password] = ( Case @Password
                          When '' Then [Password]
                          Else @Password
                        End ),
         AllowMultiLogin = @AllowMultiLogin,
         GroupId = @GroupId,
         GroupName = @GroupName,
         UserName = @UserName,
         SiteId = @SiteId,
         Contact = @Contact,
         Locked = @Locked,
         IsSiteManage = @IsSiteManage
  Where  UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Admin_UpdateState @LastLoginIP   Varchar(11),
                                        @LastLoginTime Datetime,
                                        @RandNumber    Varchar(30),
                                        @LoginName     Varchar(50)
As
  Update Qianbo_Admin
  Set    LastLoginIP = @LastLoginIp,
         LastLoginTime = @LastLoginTime,
         LoginTime = LoginTime + 1,
         RandNumber = @RandNumber
  Where  LoginName = @LoginName
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Anomaly_Add @InfoId  Int,
                                  @ChId    Int,
                                  @ColName Nvarchar(100),
                                  @Title   Varchar(200)
As
  Insert Into Qianbo_Anomaly
              ([InfoId],
               [ChId],
               [ColName],
               [Title])
  Values      ( @InfoId,
                @ChId,
                @ColName,
                @Title )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Anomaly_CheckHas @chid   Int,
                                       @infoid Int
As
  Select [Id]
  From   Qianbo_Anomaly
  Where  Chid = @chid
         And InfoId = @infoid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Anomaly_Delete @Id Int
As
  Delete Qianbo_Anomaly
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Anomaly_GetList @chid        Int,
                                 @pageindex   Int,
                                 @pagesize    Int,
                                 @recordcount Int output
As
  Declare @sqlstr Nvarchar(2000)
  If( @pageindex = 1 )
    Set @sqlstr=N'select top ' + Convert(Nvarchar(15), @pagesize) + ' * from Qianbo_Anomaly where [chid] = ' + Convert(Nvarchar(15), @chid) + ' order by id desc'
  Else
    Set @sqlstr=N'select top ' + Convert(Nvarchar(15), @pagesize) + ' * from Qianbo_Anomaly where [chid] = ' + Convert(Nvarchar(15), @chid) + ' and id < (select min(id) from (select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' id from Qianbo_Anomaly where [chid] = ' + Convert(Nvarchar(15), @chid) + ' order by id desc)o) order by id desc'
  Execute Sp_executeSql @sqlstr
  Set @recordcount =(Select Count(chid)
                     From   Qianbo_Anomaly
                     Where  chid = @chid)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Article_GetExpireArticleCount @chid  Int,
                                               @colid Int
As
  If @colid = 0
    Select Count([id])
    From   [Qianbo_Article] i
           Join [Qianbo_Column] co
             On i.colid = co.colid
    Where  co.chid = @chid
           And expiretime < getdate()
  Else
    Select Count([id])
    From   [Qianbo_Article] i
           Join [Qianbo_Column] co
             On i.colid = co.colid
    Where  co.chid = @chid
           And i.colid = @colid
           And expiretime < getdate()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Article_MoveExpireArticle @chid  Int,
                                           @colid Int
As
  If( @colid = 0 )
    Begin
        Insert Into Qianbo_ExpireArticle
                    ([Id],
                     ColId,
                     Title,
                     TitleColor,
                     TitleFontType,
                     TitleType,
                     TitleImgPath,
                     UId,
                     UName,
                     UserType,
                     AdminUId,
                     AdminUName,
                     Status,
                     HitCount,
                     AddTime,
                     UpdateTime,
                     TemplatePath,
                     PageType,
                     IsCreated,
                     UserCateId,
                     PointCount,
                     ChargeType,
                     ChargeHourCount,
                     ChargeViewCount,
                     IsOpened,
                     GroupIdStr,
                     IsDeleted,
                     IsRecommend,
                     IsTop,
                     IsFocus,
                     IsSideShow,
                     TagIdStr,
                     TagNameStr,
                     SpecialIdStr,
                     LongTitle,
                     Content,
                     ShortContent,
                     OuterUrl,
                     Author,
                     Source,
                     IsHeader,
                     HeaderFont,
                     HeaderImgPath,
                     StarLevel,
                     IsShowCommentLink,
                     IsIrregular,
                     IrregularId,
                     ViewUName,
                     ViewUName2,
                     ViewEndTime,
                     IsAllowComment,
                     ExpireTime)
        Select i.[Id],
               i.ColId,
               i.Title,
               i.TitleColor,
               i.TitleFontType,
               i.TitleType,
               i.TitleImgPath,
               i.UId,
               i.UName,
               i.UserType,
               i.AdminUId,
               i.AdminUName,
               i.Status,
               i.HitCount,
               i.AddTime,
               i.UpdateTime,
               i.TemplatePath,
               i.PageType,
               i.IsCreated,
               i.UserCateId,
               i.PointCount,
               i.ChargeType,
               i.ChargeHourCount,
               i.ChargeViewCount,
               i.IsOpened,
               i.GroupIdStr,
               i.IsDeleted,
               i.IsRecommend,
               i.IsTop,
               i.IsFocus,
               i.IsSideShow,
               i.TagIdStr,
               i.TagNameStr,
               i.SpecialIdStr,
               i.LongTitle,
               i.Content,
               i.ShortContent,
               i.OuterUrl,
               i.Author,
               i.Source,
               i.IsHeader,
               i.HeaderFont,
               i.HeaderImgPath,
               i.StarLevel,
               i.IsShowCommentLink,
               i.IsIrregular,
               i.IrregularId,
               i.ViewUName,
               i.ViewUName2,
               i.ViewEndTime,
               i.IsAllowComment,
               i.ExpireTime
        From   Qianbo_Article i
               Join Qianbo_Column co
                 On i.colid = co.colid
        Where  co.chid = @chid
               And i.expiretime < getdate()
        Delete i
        From   Qianbo_Article i
               Join Qianbo_Column co
                 On i.colid = co.colid
        Where  co.chid = @chid
               And i.expiretime < getdate();
        Delete i
        From   Qianbo_Article i
               Join Qianbo_Column co
                 On i.colid = co.colid
        Where  co.chid = @chid
               And i.expiretime < getdate();
    End
  Else
    Begin
        Insert Into Qianbo_ExpireArticle
                    ([Id],
                     ColId,
                     Title,
                     TitleColor,
                     TitleFontType,
                     TitleType,
                     TitleImgPath,
                     UId,
                     UName,
                     UserType,
                     AdminUId,
                     AdminUName,
                     Status,
                     HitCount,
                     AddTime,
                     UpdateTime,
                     TemplatePath,
                     PageType,
                     IsCreated,
                     UserCateId,
                     PointCount,
                     ChargeType,
                     ChargeHourCount,
                     ChargeViewCount,
                     IsOpened,
                     GroupIdStr,
                     IsDeleted,
                     IsRecommend,
                     IsTop,
                     IsFocus,
                     IsSideShow,
                     TagIdStr,
                     TagNameStr,
                     SpecialIdStr,
                     LongTitle,
                     Content,
                     ShortContent,
                     OuterUrl,
                     Author,
                     Source,
                     IsHeader,
                     HeaderFont,
                     HeaderImgPath,
                     StarLevel,
                     IsShowCommentLink,
                     IsIrregular,
                     IrregularId,
                     ViewUName,
                     ViewUName2,
                     ViewEndTime,
                     IsAllowComment,
                     ExpireTime)
        Select i.[Id],
               i.ColId,
               i.Title,
               i.TitleColor,
               i.TitleFontType,
               i.TitleType,
               i.TitleImgPath,
               i.UId,
               i.UName,
               i.UserType,
               i.AdminUId,
               i.AdminUName,
               i.Status,
               i.HitCount,
               i.AddTime,
               i.UpdateTime,
               i.TemplatePath,
               i.PageType,
               i.IsCreated,
               i.UserCateId,
               i.PointCount,
               i.ChargeType,
               i.ChargeHourCount,
               i.ChargeViewCount,
               i.IsOpened,
               i.GroupIdStr,
               i.IsDeleted,
               i.IsRecommend,
               i.IsTop,
               i.IsFocus,
               i.IsSideShow,
               i.TagIdStr,
               i.TagNameStr,
               i.SpecialIdStr,
               i.LongTitle,
               i.Content,
               i.ShortContent,
               i.OuterUrl,
               i.Author,
               i.Source,
               i.IsHeader,
               i.HeaderFont,
               i.HeaderImgPath,
               i.StarLevel,
               i.IsShowCommentLink,
               i.IsIrregular,
               i.IrregularId,
               i.ViewUName,
               i.ViewUName2,
               i.ViewEndTime,
               i.IsAllowComment,
               i.ExpireTime
        From   Qianbo_Article i
               Join Qianbo_Column co
                 On i.colid = co.colid
        Where  co.chid = @chid
               And i.colid = @colid
               And i.expiretime < getdate()
        Delete i
        From   Qianbo_Article i
               Join Qianbo_Column co
                 On i.colid = co.colid
        Where  co.chid = @chid
               And i.colid = @colid
               And i.expiretime < getdate();
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Article_Set @Id                Int output,
                                  @ColId             Int,
                                  @ChId              Int,
                                  @Title             Nvarchar(200),
                                  @TitleColor        Nvarchar(6) ='',
                                  @TitleFontType     Int,
                                  @TitleType         Int,
                                  @TitleImgPath      Varchar(255)='',
                                  @UId               Int,
                                  @UName             Nvarchar(20) ='',
                                  @UserType          Int,
                                  @AdminUId          Int,
                                  @AdminUName        Nvarchar(20)='',
                                  @Status            Int,
                                  @HitCount          Int,
                                  @AddTime           Datetime,
                                  @UpdateTime        Datetime,
                                  @TemplatePath      Varchar(255)='',
                                  @PageType          Int,
                                  @IsCreated         Bit,
                                  @UserCateId        Int,
                                  @PointCount        Int,
                                  @ChargeType        Int,
                                  @ChargeHourCount   Int,
                                  @ChargeViewCount   Int,
                                  @IsOpened          Int,
                                  @GroupIdStr        Varchar(200)='',
                                  @IsDeleted         Bit,
                                  @IsRecommend       Bit,
                                  @IsTop             Bit,
                                  @IsFocus           Bit,
                                  @IsSideShow        Bit,
                                  @TagIdStr          Varchar(300) ='',
                                  @TagNameStr        Nvarchar(300) ='',
                                  @SpecialIdStr      Varchar(200)='',
                                  @LongTitle         Nvarchar(500) ='',
                                  @Content           Ntext='',
                                  @ShortContent      Nvarchar(200) ='',
                                  @OuterUrl          Varchar(255)='',
                                  @Author            Nvarchar(50) ='',
                                  @Source            Nvarchar(50) ='',
                                  @IsHeader          Bit,
                                  @HeaderFont        Nvarchar(100) ='',
                                  @HeaderImgPath     Varchar(255) ='',
                                  @StarLevel         Nvarchar(20) ='',
                                  @IsShowCommentLink Bit,
                                  @IsIrregular       Bit,
                                  @IrregularId       Int,
                                  @ViewUName         Ntext ='',
                                  @ViewUName2        Ntext='',
                                  @ViewEndTime       Nvarchar(20) ='',
                                  @IsAllowComment    Bit,
                                  @ExpireTime        Datetime
As
  If( @Id = 0 )
    Begin
        Insert Into Qianbo_Article
                    ([ChId],
                     [ColId],
                     [Title],
                     [TitleColor],
                     [TitleFontType],
                     [TitleType],
                     [TitleImgPath],
                     [UId],
                     [UName],
                     [UserType],
                     [AdminUId],
                     [AdminUName],
                     [Status],
                     [HitCount],
                     [AddTime],
                     [UpdateTime],
                     [TemplatePath],
                     [PageType],
                     [IsCreated],
                     [UserCateId],
                     [PointCount],
                     [ChargeType],
                     [ChargeHourCount],
                     [ChargeViewCount],
                     [IsOpened],
                     [GroupIdStr],
                     [IsDeleted],
                     [IsRecommend],
                     [IsTop],
                     [IsFocus],
                     [IsSideShow],
                     [TagIdStr],
                     [TagNameStr],
                     [SpecialIdStr],
                     [LongTitle],
                     [Content],
                     [ShortContent],
                     [OuterUrl],
                     [Author],
                     [Source],
                     [IsHeader],
                     [HeaderFont],
                     [HeaderImgPath],
                     [StarLevel],
                     [IsShowCommentLink],
                     [IsIrregular],
                     [IrregularId],
                     [ViewUName],
                     [ViewUName2],
                     [ViewEndTime],
                     [IsAllowComment],
                     [ExpireTime])
        Values      (@ChId,
                     @ColId,
                     @Title,
                     @TitleColor,
                     @TitleFontType,
                     @TitleType,
                     @TitleImgPath,
                     @UId,
                     @UName,
                     @UserType,
                     @AdminUId,
                     @AdminUName,
                     @Status,
                     @HitCount,
                     @AddTime,
                     @UpdateTime,
                     @TemplatePath,
                     @PageType,
                     @IsCreated,
                     @UserCateId,
                     @PointCount,
                     @ChargeType,
                     @ChargeHourCount,
                     @ChargeViewCount,
                     @IsOpened,
                     @GroupIdStr,
                     @IsDeleted,
                     @IsRecommend,
                     @IsTop,
                     @IsFocus,
                     @IsSideShow,
                     @TagIdStr,
                     @TagNameStr,
                     @SpecialIdStr,
                     @LongTitle,
                     @Content,
                     @ShortContent,
                     @OuterUrl,
                     @Author,
                     @Source,
                     @IsHeader,
                     @HeaderFont,
                     @HeaderImgPath,
                     @StarLevel,
                     @IsShowCommentLink,
                     @IsIrregular,
                     @IrregularId,
                     @ViewUName,
                     @ViewUName2,
                     @ViewEndTime,
                     @IsAllowComment,
                     @ExpireTime )
        Set @Id=Scope_identity()
    End
  Else
    Begin
        Update Qianbo_Article
        Set    [AddTime] = @AddTime,
               [ChId] = @ChId,
               [ColId] = @ColId,
               [Title] = @Title,
               [TitleColor] = @TitleColor,
               [TitleFontType] = @TitleFontType,
               [TitleType] = @TitleType,
               [TitleImgPath] = @TitleImgPath,
               [UpdateTime] = @UpdateTime,
               [TemplatePath] = @TemplatePath,
               [PageType] = @PageType,
               [IsCreated] = @IsCreated,
               [PointCount] = @PointCount,
               [ChargeType] = @ChargeType,
               [ChargeHourCount] = @ChargeHourCount,
               [ChargeViewCount] = @ChargeViewCount,
               [IsOpened] = @IsOpened,
               [GroupIdStr] = @GroupIdStr,
               [IsRecommend] = @IsRecommend,
               [IsTop] = @IsTop,
               [IsFocus] = @IsFocus,
               [IsSideShow] = @IsSideShow,
               [TagIdStr] = @TagIdStr,
               [TagNameStr] = @TagNameStr,
               [SpecialIdStr] = @SpecialIdStr,
               [LongTitle] = @LongTitle,
               [Content] = @Content,
               [ShortContent] = @ShortContent,
               [OuterUrl] = @OuterUrl,
               [Author] = @Author,
               [Source] = @Source,
               [IsHeader] = @IsHeader,
               [HeaderFont] = @HeaderFont,
               [HeaderImgPath] = @HeaderImgPath,
               [StarLevel] = @StarLevel,
               [IsShowCommentLink] = @IsShowCommentLink,
               [IsIrregular] = @IsIrregular,
               [IrregularId] = @IrregularId,
               [ViewUName] = @ViewUName,
               [ViewEndTime] = @ViewEndTime,
               [IsAllowComment] = @IsAllowComment,
               [ExpireTime] = @ExpireTime,
               [HitCount] = @HitCount
        Where  [Id] = @Id
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Article_SetViewer @id         Int,
                                        @viewername Nvarchar(50)
As
  Update Qianbo_Article
  Set    viewuname2 = @viewername
  Where  id = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Card_Add @Type        Int,
                               @CardAccount Varchar(20),
                               @Password    Varchar(200),
                               @IsUsed      Bit,
                               @CardPoint   Int,
                               @CardDay     Int,
                               @AdminID     Int,
                               @AdminName   Varchar(50),
                               @OverdueDate Datetime
As
  Begin
      Insert Into Qianbo_Card
                  ([Type],
                   [Password],
                   [IsUsed],
                   [CardPoint],
                   [CardDay],
                   [AdminID],
                   [AdminName],
                   [OverdueDate])
      Values      ( @Type,
                    @Password,
                    @IsUsed,
                    @CardPoint,
                    @CardDay,
                    @AdminID,
                    @AdminName,
                    @OverdueDate )
      If @@rowcount > 0
        Begin
            Declare @ID Int
            Set @ID = Scope_Identity()
            Set @CardAccount = @CardAccount + Convert(Varchar(10), @ID)
            Update Qianbo_Card
            Set    CardAccount = @CardAccount
            Where  [id] = @ID
        End
      Select @CardAccount As Account
  End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Card_Delete @CardAccount Varchar(15)
As
  Delete Qianbo_Card
  Where  [CardAccount] = @CardAccount
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Card_GetCard @Account Varchar(15)
As
  Select [Type],
         [Password],
         [IsUsed],
         [CardPoint],
         [CardDay],
         [AdminID],
         [AdminName],
         [UserID],
         [UserName],
         [OverdueDate]
  From   Qianbo_Card
  Where  [CardAccount] = @Account
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Card_GetCards (@PageSize  Int=20,
                                     @PageIndex Int=1,
                                     @WhereStr  Varchar(100),
                                     @Total     Int=0 output)
As
  Begin
      Declare @SqlStr Nvarchar(2000)
      Declare @fff Nvarchar(100)
      If( @WhereStr = '' )
        Begin
            Set @WhereStr=' where '
            Set @fff=''
        End
      Else
        Begin
            Set @fff=' where ' + @WhereStr
            Set @WhereStr=' where ' + @WhereStr + ' and '
        End
      If( @PageIndex = 1 )
        Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_Card ' + @fff + ' order by ID desc'
      Else
        Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_Card ' + @WhereStr + ' ID < (select min(ID) from(select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' * from Qianbo_Card  ' + @fff + ' order by ID desc)O) order by ID desc'
  End
Print @SqlStr
Execute Sp_ExecuteSql @SqlStr
Set @SqlStr ='select @TRecord =count(ID) from Qianbo_Card ' + @fff
Declare @Parm Nvarchar(50)
Set @Parm = '@TRecord int output';
Exec Sp_ExecuteSql
  @SqlStr,
  @Parm,
  @TRecord = @Total output;
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Card_Update @Type        Int,
                                  @CardAccount Varchar(20),
                                  @Password    Varchar(200),
                                  @IsUsed      Bit,
                                  @CardPoint   Int,
                                  @CardDay     Int,
                                  @AdminID     Int,
                                  @AdminName   Varchar(50),
                                  @UserID      Int,
                                  @UserName    Nvarchar(36),
                                  @OverdueDate Datetime
As
  Update Qianbo_Card
  Set    [Type] = @Type,
         [Password] = @Password,
         [IsUsed] = @IsUsed,
         [CardPoint] = @CardPoint,
         [CardDay] = @CardDay,
         [AdminID] = @AdminID,
         [AdminName] = @AdminName,
         [UserID] = @UserID,
         [UserName] = @UserName,
         [OverdueDate] = @OverdueDate
  Where  [CardAccount] = @CardAccount
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [Proc_Channel_Add] @ChName              Nvarchar(50),
                                    @Description         Nvarchar(255),
                                    @TemplatePath        Nvarchar(255),
                                    @IsChildSite         Bit,
                                    @ChildSiteUrl        Nvarchar(255),
                                    @IsOpenLink          Bit,
                                    @ModelType           Int,
                                    @DirName             Nvarchar(50),
                                    @TypeName            Nvarchar(10),
                                    @TypeUnit            Nvarchar(10),
                                    @IsDisabled          Bit,
                                    @IsOpened            Bit,
                                    @GroupIdStr          Varchar(500),
                                    @VerifyType          Int,
                                    @Notice1             Nvarchar(500),
                                    @Notice2             Nvarchar(500),
                                    @Keyword             Nvarchar(100),
                                    @Content             Nvarchar(300),
                                    @MiniHitCount        Int,
                                    @IsStaticType        Bit,
                                    @ColumnSortType      Int,
                                    @InfoSortType        Int,
                                    @FileNameType        Int,
                                    @ChannelPageType     Int,
                                    @ColumnPageType      Int,
                                    @InfoPageType        Int,
                                    @AddTime             Datetime,
                                    @Sort                Int,
                                    @ColumnTemplatePath  Nvarchar(255),
                                    @InfoTemplatePath    Nvarchar(255),
                                    @CommentTemplatePath Nvarchar(255),
                                    @IsDeleted           Bit,
                                    @ChType              Int
As
  Insert Into Qianbo_Channel
              ([ChName],
               [Description],
               [TemplatePath],
               [IsChildSite],
               [ChildSiteUrl],
               [IsOpenLink],
               [ModelType],
               [DirName],
               [TypeName],
               [TypeUnit],
               [IsDisabled],
               [IsOpened],
               [GroupIdStr],
               [VerifyType],
               [Notice1],
               [Notice2],
               [Keyword],
               [Content],
               [MiniHitCount],
               [IsStaticType],
               [ColumnSortType],
               [InfoSortType],
               [FileNameType],
               [ChannelPageType],
               [ColumnPageType],
               [InfoPageType],
               [AddTime],
               [Sort],
               [ColumnTemplatePath],
               [InfoTemplatePath],
               [CommentTemplatePath],
               [IsDeleted],
               [ChType])
  Values      ( @ChName,
                @Description,
                @TemplatePath,
                @IsChildSite,
                @ChildSiteUrl,
                @IsOpenLink,
                @ModelType,
                @DirName,
                @TypeName,
                @TypeUnit,
                @IsDisabled,
                @IsOpened,
                @GroupIdStr,
                @VerifyType,
                @Notice1,
                @Notice2,
                @Keyword,
                @Content,
                @MiniHitCount,
                @IsStaticType,
                @ColumnSortType,
                @InfoSortType,
                @FileNameType,
                @ChannelPageType,
                @ColumnPageType,
                @InfoPageType,
                @AddTime,
                @Sort,
                @ColumnTemplatePath,
                @InfoTemplatePath,
                @CommentTemplatePath,
                @IsDeleted,
                @ChType )
  Select Scope_identity()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Channel_CompleteDelete @chid Int
As
  Declare @tablename Nvarchar(50)
  Set @tablename = (Select tablename
                    From   Qianbo_Channel ch
                           Join Qianbo_Model m
                             On ch.modeltype = m.modelid
                    Where  ch.chid = @chid)
  Declare @sqlstr Nvarchar(2000)
  Declare @param Nvarchar(200)
  Set @param = '@tchid int'
  Set @sqlstr = 'delete i from [' + @tablename + '] i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid where ch.chid = @tchid'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
  Set @sqlstr = 'delete co from Qianbo_Column co join Qianbo_Channel ch on co.chid = ch.chid where ch.chid = @tchid '
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
  Set @sqlstr = 'delete from Qianbo_Channel where chid = @tchid'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Channel_Delete @chid Int
As
  Set Xact_Abort On
  Begin Tran
  Declare @modeltype Int
  Set @modeltype=(Select ModelType
                  From   Qianbo_Channel
                  Where  ChId = @ChId);
  Declare @tablename Nvarchar(50)
  Set @tablename = (Select TableName
                    From   Qianbo_Model
                    Where  ModelId = @ModelType)
  Declare @sqlstr Nvarchar(2000)
  Declare @param Nvarchar(500)
  Set @param = '@tchid int'
  Set @sqlstr = 'update i set i.[isdeleted] = 1 from [' + @tablename + '] i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid where ch.chid = @tchid';
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
  Set @sqlstr = 'update co set co.[isdeleted] = 1 from Qianbo_Column co join Qianbo_Channel ch on co.chid = ch.chid where ch.chid = @tchid'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
  Set @sqlstr = 'update ch set ch.[isdeleted] = 1 from Qianbo_Channel ch where ch.chid = @tchid';
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
  Commit Tran
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Channel_GetAll
As
  Select *
  From   Qianbo_Channel a,
         Qianbo_Model b
  Where  a.ModelType = b.ModelId
  Order  By ModelType,
            Sort Asc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Channel_GetList @pageSize  Int,
                                      @pageIndex Int,
                                      @strWhere  Nvarchar(2000)
As
  Declare @sql Nvarchar(2000)
  Declare @Filter Nvarchar(2000)
  If( @strWhere = '' )
    Begin
        Set @strWhere=' where '
        Set @Filter=''
    End
  Else
    Begin
        Set @Filter=' where ' + @strWhere
        Set @strWhere=' where ' + @strWhere + ' and '
    End
  If( @PageIndex = 1 )
    Begin
        Set @sql = N'select top ' + Convert(Nvarchar(10), @pageSize) + ' * from Qianbo_Channel a,Qianbo_Model b ' + @Filter + ' order by ModelType,Sort asc'
    End
  Else
    Begin
        Set @sql = N'select top ' + Convert(Nvarchar(10), @pageSize) + ' * from Qianbo_Channel a,Qianbo_Model b ' + @strWhere + ' [ChId] > (select max([ChId]) from(select top ' + Convert(Nvarchar(10), (@pageIndex-1) * @pageSize) + ' [ChId] from Qianbo_Channel a,Qianbo_Model b  ' + @Filter + ' order by ModelType,Sort asc)U) order by ModelType,Sort asc'
    End
  Execute Sp_ExecuteSql @sql
  Print @sql
  Set @sql = 'select Count(*) from Qianbo_Channel a,Qianbo_Model b ' + @Filter
  Execute Sp_ExecuteSql @sql
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Channel_SetDisaled @ChId       Int,
                                         @IsDisabled Bit
As
  Update Qianbo_Channel
  Set    IsDisabled = @IsDisabled
  Where  ChId = @ChId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [Proc_Channel_Update] @ChId                Int,
                                       @ChName              Nvarchar(50),
                                       @Description         Nvarchar(255),
                                       @TemplatePath        Nvarchar(255),
                                       @IsChildSite         Bit,
                                       @ChildSiteUrl        Nvarchar(255),
                                       @IsOpenLink          Bit,
                                       @ModelType           Int,
                                       @DirName             Nvarchar(50),
                                       @TypeName            Nvarchar(10),
                                       @TypeUnit            Nvarchar(10),
                                       @IsDisabled          Bit,
                                       @IsOpened            Bit,
                                       @GroupIdStr          Varchar(500),
                                       @VerifyType          Int,
                                       @Notice1             Nvarchar(500),
                                       @Notice2             Nvarchar(500),
                                       @Keyword             Nvarchar(100),
                                       @Content             Nvarchar(300),
                                       @MiniHitCount        Int,
                                       @IsStaticType        Bit,
                                       @ColumnSortType      Int,
                                       @InfoSortType        Int,
                                       @FileNameType        Int,
                                       @ChannelPageType     Int,
                                       @ColumnPageType      Int,
                                       @InfoPageType        Int,
                                       @Sort                Int,
                                       @ColumnTemplatePath  Nvarchar(255),
                                       @InfoTemplatePath    Nvarchar(255),
                                       @CommentTemplatePath Nvarchar(255),
                                       @ChType              Int
As
  Update Qianbo_Channel
  Set    [ChName] = @ChName,
         [Description] = @Description,
         [TemplatePath] = @TemplatePath,
         [IsChildSite] = @IsChildSite,
         [ChildSiteUrl] = @ChildSiteUrl,
         [IsOpenLink] = @IsOpenLink,
         [ModelType] = @ModelType,
         [DirName] = @DirName,
         [TypeName] = @TypeName,
         [TypeUnit] = @TypeUnit,
         [IsDisabled] = @IsDisabled,
         [IsOpened] = @IsOpened,
         [GroupIdStr] = @GroupIdStr,
         [VerifyType] = @VerifyType,
         [Notice1] = @Notice1,
         [Notice2] = @Notice2,
         [Keyword] = @Keyword,
         [Content] = @Content,
         [MiniHitCount] = @MiniHitCount,
         [IsStaticType] = @IsStaticType,
         [ColumnSortType] = @ColumnSortType,
         [InfoSortType] = @InfoSortType,
         [FileNameType] = @FileNameType,
         [ChannelPageType] = @ChannelPageType,
         [ColumnPageType] = @ColumnPageType,
         [InfoPageType] = @InfoPageType,
         [Sort] = @Sort,
         [ColumnTemplatePath] = @ColumnTemplatePath,
         [InfoTemplatePath] = @InfoTemplatePath,
         [CommentTemplatePath] = @CommentTemplatePath,
         [ChType] = @ChType
  Where  [ChId] = @ChId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsCount_AddDayCount @CurrHour Varchar(2),
                                           @CurrDay  Varchar(10)
As
  Declare @SqlStr Nvarchar(2000)
  If Exists(Select *
            From   Qianbo_CountDay
            Where  Flag = @CurrDay)
    Set @SqlStr = N'update Qianbo_CountDay set [' + @CurrHour + '] = [' + @CurrHour + '] + 1  where Flag = ''' + @CurrDay + '''';
  Else
    Set @SqlStr = N'insert into Qianbo_CountDay ([' + @CurrHour + '],Flag)values(1,''' + @CurrDay + ''')';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'update Qianbo_CountDay set [' + @CurrHour + '] = [' + @CurrHour + '] + 1 where Flag = ''Total''';
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsCount_AddMonthCount @CurrDay   Varchar(2),
                                             @CurrMonth Varchar(7)
As
  Declare @SqlStr Nvarchar(2000)
  If Exists(Select *
            From   Qianbo_CountMonth
            Where  Flag = @CurrMonth)
    Set @SqlStr = N'update Qianbo_CountMonth set [' + @CurrDay + '] = [' + @CurrDay + '] + 1  where Flag = ''' + @CurrMonth + '''';
  Else
    Set @SqlStr = N'insert into Qianbo_CountMonth ([' + @CurrDay + '],Flag)values(1,''' + @CurrMonth + ''')';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'update Qianbo_CountMonth set [' + @CurrDay + '] = [' + @CurrDay + '] + 1 where Flag = ''Total''';
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsCount_AddWeekCount @CurrDate    Varchar(10),
                                            @CurrWeekDay Varchar(1)
As
  Declare @SqlStr Nvarchar(2000)
  Declare @param Nvarchar(400)
  If Not Exists(Select *
                From   Qianbo_CountWeek
                Where  flag <> 'total')
    Begin
        Set @sqlstr = 'insert into Qianbo_CountWeek([1],[2],[3],[4],[5],[6],[7],flag)values(0,0,0,0,0,0,0,@tCurrDate)'
        Set @param = '@tcurrdate nvarchar(10)'
        Execute Sp_ExecuteSql
          @SqlStr,
          @param,
          @tcurrdate = @currdate
    End
  If( @CurrDate != ''
      And Not Exists(Select *
                     From   Qianbo_CountWeek
                     Where  Flag = @CurrDate) )
    Begin
        Set @SqlStr = N'update Qianbo_CountWeek set [1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,Flag = ''' + @CurrDate + ''' where Flag <> ''Total'''
        Execute Sp_ExecuteSql @SqlStr
    End
  Set @SqlStr = N'update Qianbo_CountWeek set [' + @CurrWeekDay + '] = [' + @CurrWeekDay + '] + 1'
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsCount_AddYearCount @CurrMonth Varchar(2),
                                            @CurrYear  Varchar(4)
As
  Declare @SqlStr Nvarchar(2000)
  If Exists(Select *
            From   Qianbo_CountYear
            Where  Flag = @CurrYear)
    Set @SqlStr = N'update Qianbo_CountYear set [' + @CurrMonth + '] = [' + @CurrMonth + '] + 1  where Flag = ''' + @CurrYear + '''';
  Else
    Set @SqlStr = N'insert into Qianbo_CountYear ([' + @CurrMonth + '],Flag)values(1,''' + @CurrYear + ''')';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'update Qianbo_CountYear set [' + @CurrMonth + '] = [' + @CurrMonth + '] + 1 where Flag = ''Total''';
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsShopBrand_Delete @IdStr Nvarchar(1000)
As
  Delete Qianbo_ShopBrand
  Where  BrandId In ( @IdStr )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsShopBrand_GetList @PageIndex    Int,
                                           @PageSize     Int,
                                           @RecordCount  Int=0 output,
                                           @ProducerType Int,
                                           @Filter       Nvarchar(4000)
As
  Declare @sqlstr Nvarchar(4000)
  If( @PageIndex = 1 )
    Set @sqlstr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_ShopProcuder where @FileTer order by procuderid desc'
  Else
    Set @sqlstr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_ShopProcuder where @Fileter and id < (select min(o,id) from (select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' id from Qianbo_ShopProcuder where @Filter order by procuderid desc)o) order by procuderid desc'
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsShopBrand_GetModel @Id Int
As
  Select *
  From   Qianbo_ShopBrand
  Where  [BrandId] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsShopProcuder_GetList @PageIndex    Int,
                                              @PageSize     Int,
                                              @RecordCount  Int=0 output,
                                              @ProducerType Int,
                                              @Filter       Nvarchar(4000)
As
  Declare @sqlstr Nvarchar(4000)
  If( @PageIndex = 1 )
    Set @sqlstr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_ShopProcuder where @FileTer order by procuderid desc'
  Else
    Set @sqlstr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_ShopProcuder where @Fileter and id < (select min(o,id) from (select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' id from Qianbo_ShopProcuder where @Filter order by procuderid desc)o) order by procuderid desc'
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsShopProducer_Delete @IdStr Nvarchar(1000)
As
  Delete Qianbo_ShopProcuder
  Where  ProcuderId In ( @IdStr )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsShopProducer_GetModel @Id Int
As
  Select *
  From   Qianbo_ShopProducer
  Where  [ProducerId] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CmsShopProducer_Set @ProducerId        Int output,
                                          @ProducerType      Int,
                                          @ProducerName      Nvarchar(200),
                                          @ProducerShortName Nvarchar(50),
                                          @ProducerPhoto     Nvarchar(255),
                                          @AddTime           Datetime,
                                          @Address           Nvarchar(255),
                                          @Postcode          Nvarchar(10),
                                          @Phone             Nvarchar(50),
                                          @Fax               Nvarchar(50),
                                          @Email             Nvarchar(50),
                                          @Homepage          Nvarchar(50),
                                          @ProducerIntro     Ntext,
                                          @LastUpdateTime    Datetime,
                                          @IsPassed          Bit,
                                          @IsTop             Bit,
                                          @IsRecommend       Bit,
                                          @HitCount          Int
As
  If( @ProducerId = 0 )
    Begin
        Insert Into Qianbo_ShopProducer
                    ([ProducerType],
                     [ProducerName],
                     [ProducerShortName],
                     [ProducerPhoto],
                     [AddTime],
                     [Address],
                     [Postcode],
                     [Phone],
                     [Fax],
                     [Email],
                     [Homepage],
                     [ProducerIntro],
                     [IsPassed],
                     [IsTop],
                     [IsRecommend],
                     [HitCount])
        Values      ( @ProducerType,
                      @ProducerName,
                      @ProducerShortName,
                      @ProducerPhoto,
                      @AddTime,
                      @Address,
                      @Postcode,
                      @Phone,
                      @Fax,
                      @Email,
                      @Homepage,
                      @ProducerIntro,
                      @IsPassed,
                      @IsTop,
                      @IsRecommend,
                      @HitCount )
        Set @ProducerId = scope_identity()
    End
  Else
    Update Qianbo_ShopProducer
    Set    [ProducerType] = @ProducerType,
           [ProducerName] = @ProducerName,
           [ProducerShortName] = @ProducerShortName,
           [ProducerPhoto] = @ProducerPhoto,
           [Address] = @Address,
           [Postcode] = @Postcode,
           [Phone] = @Phone,
           [Fax] = @Fax,
           [Email] = @Email,
           [Homepage] = @Homepage,
           [ProducerIntro] = @ProducerIntro,
           [LastUpdateTime] = @LastUpdateTime,
           [IsPassed] = @IsPassed,
           [IsTop] = @IsTop,
           [IsRecommend] = @IsRecommend,
           [HitCount] = @HitCount
    Where  [ProducerId] = @ProducerId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Cms_CheckHas @Input      Nvarchar(500),
                                   @FileldName Nvarchar(100),
                                   @TableName  Nvarchar(100)
As
  Declare @SqlStr Nvarchar(2000)
  Set @SqlStr = N'If Exists(select 1 from ' + @TableName + ' where ' + @FileldName + '=''' + Replace(@Input, '''', '''''') + ''') Select 1 Else Select 0'
  Execute SP_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Cms_CheckHasOnUpdate @Input      Nvarchar(500),
                                           @FileldName Nvarchar(100),
                                           @TableName  Nvarchar(100),
                                           @KeyValue   Nvarchar(1000),
                                           @KeyName    Nvarchar(100)
As
  Declare @SqlStr Nvarchar(2000)
  Set @SqlStr = N'If Exists(select 1 from ' + @TableName + ' where ' + @FileldName + '=''' + Replace(@Input, '''', '''''') + ''' and [' + @KeyName + '] !=' + @KeyValue + ') Select 1 Else Select 0'
  Execute SP_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_CollectionAddress_Add @ColectionId   Int,
                                            @CollectionUrl Nvarchar(1000),
                                            @State         Bit
As
  Insert Into Qianbo_CollectionAddress
              ([ColectionId],
               [CollectionUrl],
               [State])
  Values      ( @ColectionId,
                @CollectionUrl,
                @State )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_CollectionAddress_CheckAddress @collectionaddress Nvarchar(500)
As
  Select CollectionUrl
  From   Qianbo_CollectionAddress
  Where  CollectionUrl = @collectionaddress
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_CollectionAddress_DeleteCollId @collid Int,
                                                     @state  Bit
As
  Delete From Qianbo_CollectionAddress
  Where  ColectionId = @collid
         And State = @state
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_CollectionAddress_GetCollIdList @collid      Int,
                                                 @state       Bit,
                                                 @pageindex   Int,
                                                 @pagesize    Int,
                                                 @recordcount Int output
As
  Declare @sqlstr Nvarchar(2000);
  If( @pageindex = 1 )
    Set @sqlstr=N'select top ' + Convert(Nvarchar(15), @pagesize) + ' * from Qianbo_CollectionAddress where ColectionId = ' + Convert(Nvarchar (15), @collid) + ' and state = ' + Convert(Nvarchar(15), @state) + '  order by id desc'
  Else
    Set @sqlstr=N'select top ' + Convert(Nvarchar(15), @pagesize) + ' * from Qianbo_CollectionAddress where id < (select min(id) from (select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' id from Qianbo_CollectionAddress where ColectionId =  ' + Convert(Nvarchar(15), @collid) + ' and state = ' + Convert(Nvarchar(15), @state) + ' order by id desc)o) and ColectionId = ' + Convert(Nvarchar(15), @collid) + ' and state = ' + Convert(Nvarchar(15), @state) + ' order by id desc'
  Execute Sp_executeSql @sqlstr
  Set @recordcount=(Select Count(id)
                    From   Qianbo_CollectionAddress
                    Where  ColectionId = @collid
                           And State = @state)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_CollectionAddress_GetCollidByAddress @collectionid Int
As
  Select CollectionUrl
  From   Qianbo_CollectionAddress
  Where  ColectionId = @collectionid
         And state = 0
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_CollectionAddress_UpdateState @collectionaddress Nvarchar(500)
As
  Update Qianbo_CollectionAddress
  Set    State = 1
  Where  CollectionUrl = @collectionaddress
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Collection_Add @ObjectName           Nvarchar(100),
                                     @WebSite              Nvarchar(1000),
                                     @ColId                Int,
                                     @SpecialId            Nvarchar(1000),
                                     @CharSet              Nvarchar(100),
                                     @ListPageUrl          Nvarchar(1000),
                                     @ObjectDemo           Text,
                                     @ListStartCode        Ntext,
                                     @ListEndCode          Ntext,
                                     @LinkStartCode        Ntext,
                                     @LinkEndCode          Ntext,
                                     @PageSet              Nvarchar(2000),
                                     @ContentPageSet       Nvarchar(2000),
                                     @FieldListSet         Ntext,
                                     @SimpleFilterRule     Nvarchar(100),
                                     @ComplexityFilterRule Nvarchar(100),
                                     @ProterySet           Nvarchar(100),
                                     @StarLevel            Nvarchar(100),
                                     @HiteCount            Int
As
  Insert Into Qianbo_Collection
              ([ObjectName],
               [WebSite],
               [ColId],
               [SpecialId],
               [CharSet],
               [ListPageUrl],
               [ObjectDemo],
               [ListStartCode],
               [ListEndCode],
               [LinkStartCode],
               [LinkEndCode],
               [PageSet],
               [ContentPageSet],
               [FieldListSet],
               [SimpleFilterRule],
               [ComplexityFilterRule],
               [ProterySet],
               [StarLevel],
               [HiteCount])
  Values      ( @ObjectName,
                @WebSite,
                @ColId,
                @SpecialId,
                @CharSet,
                @ListPageUrl,
                @ObjectDemo,
                @ListStartCode,
                @ListEndCode,
                @LinkStartCode,
                @LinkEndCode,
                @PageSet,
                @ContentPageSet,
                @FieldListSet,
                @SimpleFilterRule,
                @ComplexityFilterRule,
                @ProterySet,
                @StarLevel,
                @HiteCount )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Collection_Delete @Id Int
As
  Delete Qianbo_Collection
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Collection_GetIdByCollection @Id Int
As
  Select [Id],
         [ObjectName],
         [WebSite],
         [ColId],
         [SpecialId],
         [CharSet],
         [ListPageUrl],
         [ObjectDemo],
         [ListStartCode],
         [ListEndCode],
         [LinkStartCode],
         [LinkEndCode],
         [PageSet],
         [ContentPageSet],
         [FieldListSet],
         [SimpleFilterRule],
         [ComplexityFilterRule],
         [ProterySet],
         [StarLevel],
         [HiteCount]
  From   Qianbo_Collection
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Collection_GetList
As
  Select [Id],
         [ObjectName],
         [WebSite],
         [ColId],
         [SpecialId],
         [CharSet],
         [ListPageUrl],
         [ObjectDemo],
         [ListStartCode],
         [ListEndCode],
         [LinkStartCode],
         [LinkEndCode],
         [PageSet],
         [ContentPageSet],
         [FieldListSet],
         [SimpleFilterRule],
         [ComplexityFilterRule],
         [ProterySet],
         [StarLevel],
         [HiteCount]
  From   Qianbo_Collection
  Order  By [id] Desc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Collection_Update @Id                   Int,
                                        @ObjectName           Nvarchar(100),
                                        @WebSite              Nvarchar(1000),
                                        @ColId                Int,
                                        @SpecialId            Nvarchar(1000),
                                        @CharSet              Nvarchar(100),
                                        @ListPageUrl          Nvarchar(1000),
                                        @ObjectDemo           Text,
                                        @ListStartCode        Ntext,
                                        @ListEndCode          Ntext,
                                        @LinkStartCode        Ntext,
                                        @LinkEndCode          Ntext,
                                        @PageSet              Nvarchar(2000),
                                        @ContentPageSet       Nvarchar(2000),
                                        @FieldListSet         Ntext,
                                        @SimpleFilterRule     Nvarchar(100),
                                        @ComplexityFilterRule Nvarchar(100),
                                        @ProterySet           Nvarchar(100),
                                        @StarLevel            Nvarchar(100),
                                        @HiteCount            Int
As
  Update Qianbo_Collection
  Set    [ObjectName] = @ObjectName,
         [WebSite] = @WebSite,
         [ColId] = @ColId,
         [SpecialId] = @SpecialId,
         [CharSet] = @CharSet,
         [ListPageUrl] = @ListPageUrl,
         [ObjectDemo] = @ObjectDemo,
         [ListStartCode] = @ListStartCode,
         [ListEndCode] = @ListEndCode,
         [LinkStartCode] = @LinkStartCode,
         [LinkEndCode] = @LinkEndCode,
         [PageSet] = @PageSet,
         [ContentPageSet] = @ContentPageSet,
         [FieldListSet] = @FieldListSet,
         [SimpleFilterRule] = @SimpleFilterRule,
         [ComplexityFilterRule] = @ComplexityFilterRule,
         [ProterySet] = @ProterySet,
         [StarLevel] = @StarLevel,
         [HiteCount] = @HiteCount
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Column_Add @ChId                Int,
                                 @ColName             Nvarchar(50),
                                 @ColDirName          Nvarchar(50),
                                 @ColParentId         Int,
                                 @IsOuterColumn       Bit,
                                 @OuterColumnUrl      Varchar(255),
                                 @ColumnImgPath       Nvarchar(510),
                                 @Description         Nvarchar(510),
                                 @Keyword             Nvarchar(100),
                                 @Content             Nvarchar(300),
                                 @IsAllowAddInfo      Bit,
                                 @ColumnTemplatePath  Nvarchar(255),
                                 @InfoTemplatePath    Nvarchar(255),
                                 @CommentTemplatePath Nvarchar(255),
                                 @Sort                Int,
                                 @IsAllowComment      Bit,
                                 @IsCheckComment      Bit,
                                 @InfoTableName       Nvarchar(50),
                                 @ScoreReward         Int,
                                 @PointCount          Int,
                                 @ChargeType          Int,
                                 @ChargeHourCount     Int,
                                 @ChargeViewCount     Int,
                                 @IsOpened            Bit,
                                 @GroupIdStr          Varchar(500),
                                 @ColumnPageType      Int,
                                 @InfoPageType        Int,
                                 @IsDeleted           Bit,
                                 @AddTime             Datetime,
                                 @IsParentHtml        Bit
As
  Insert Into Qianbo_Column
              ([ChId],
               [ColName],
               [ColDirName],
               [ColParentId],
               [IsOuterColumn],
               [OuterColumnUrl],
               [ColumnImgPath],
               [Description],
               [Keyword],
               [Content],
               [IsAllowAddInfo],
               [ColumnTemplatePath],
               [InfoTemplatePath],
               [CommentTemplatePath],
               [Sort],
               [IsAllowComment],
               [IsCheckComment],
               [InfoTableName],
               [ScoreReward],
               [PointCount],
               [ChargeType],
               [ChargeHourCount],
               [ChargeViewCount],
               [IsOpened],
               [GroupIdStr],
               [ColumnPageType],
               [InfoPageType],
               [IsDeleted],
               [AddTime],
               [IsParentHtml])
  Values      ( @ChId,
                @ColName,
                @ColDirName,
                @ColParentId,
                @IsOuterColumn,
                @OuterColumnUrl,
                @ColumnImgPath,
                @Description,
                @Keyword,
                @Content,
                @IsAllowAddInfo,
                @ColumnTemplatePath,
                @InfoTemplatePath,
                @CommentTemplatePath,
                @Sort,
                @IsAllowComment,
                @IsCheckComment,
                @InfoTableName,
                @ScoreReward,
                @PointCount,
                @ChargeType,
                @ChargeHourCount,
                @ChargeViewCount,
                @IsOpened,
                @GroupIdStr,
                @ColumnPageType,
                @InfoPageType,
                @IsDeleted,
                @AddTime,
                @IsParentHtml )
  Select Scope_Identity()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Column_CompleteDelete @colid Int
As
  Declare @tablename Nvarchar(50)
  Set @tablename = (Select tablename
                    From   Qianbo_Column co
                           Join Qianbo_Channel ch
                             On co.chid = ch.chid
                           Join Qianbo_Model m
                             On ch.modeltype = m.modelid
                    Where  co.colid = @colid)
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'declare @tb table(id int)  ' + 'insert into @tb select @tcolid  while exists(select * from Qianbo_Column where (colparentid in(select [id] from @tb)) and (colid not in(select [id] from @tb)))
begin
        insert into @tb select colid from Qianbo_Column where (colparentid in(select [id] from @tb)) and (colid not in(select [id] from @tb))
end  ' + 'delete i from [' + @tablename + '] i join @tb t on i.colid = t.[id] ' + 'delete co from Qianbo_Column co join @tb t on co.colid = t.[id]'
  Declare @param Nvarchar(200)
  Set @param='@tcolid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tcolid = @colid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Column_Delete @chid     Int,
                                    @colidstr Nvarchar(2000)
As
  Set Xact_Abort On
  Begin Tran
  Declare @modeltype Int
  Set @modeltype=(Select ModelType
                  From   Qianbo_Channel
                  Where  chid = @chid);
  Declare @tablename Nvarchar(50)
  Set @tablename = (Select tablename
                    From   Qianbo_Model
                    Where  ModelId = @modeltype)
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'update i set i.[isdeleted] = 1 from [' + @tablename + '] i where i.colid in(' + @colidstr + ')'
  Execute sp_executesql @sqlstr
  Set @sqlstr = 'update co set co.[isdeleted] = 1 from Qianbo_Column co where co.colid in(' + @colidstr + ')'
  Execute sp_executesql @sqlstr
  Commit Tran
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Column_GetAll
As
  Select *
  From   Qianbo_Column
  Order  By sort Asc,
            colid Asc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Column_Move @ColId      Int,
                                  @TargetId   Int,
                                  @IsChannel  Bit,
                                  @ChildIdStr Nvarchar(1000)
As
  Declare @SqlStr Nvarchar(2000)
  If( @IsChannel = 1 )
    Begin
        Update Qianbo_Column
        Set    ChId = @TargetId,
               ColParentId = 0
        Where  ColId = @ColId;
        Set @SqlStr = N'update Qianbo_Column set ChId = ' + Convert(Nvarchar(15), @TargetId) + ' where ColId in(' + @ChildIdStr + ')'
        Execute Sp_ExecuteSql @SqlStr
    End
  Else
    Begin
        Declare @ChId Int
        Set @ChId=(Select ChId
                   From   Qianbo_Column
                   Where  ColId = @TargetId);
        Update Qianbo_Column
        Set    ChId = @ChId,
               ColParentId = @TargetId
        Where  ColId = @ColId;
        Set @SqlStr = N'update Qianbo_Column set ChId = ' + Convert(Nvarchar(15), @ChId) + ' where ColId in(' + @ChildIdStr + ')'
        Execute Sp_ExecuteSql @SqlStr
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Column_SetInfoTemplate @colid            Int,
                                             @tablename        Nvarchar(50),
                                             @InfoTemplatePath Varchar(255)
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'update [' + @tablename + '] set templatepath = @ttemplatepath where colid = @tcolid'
  Declare @param Nvarchar(400)
  Set @param = '@ttemplatepath varchar(255),@tcolid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @ttemplatepath = @InfoTemplatePath,
    @tcolid = @colid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Column_Update @ColId               Int,
                                    @ChId                Int,
                                    @ColName             Nvarchar(50),
                                    @ColDirName          Nvarchar(50),
                                    @ColParentId         Int,
                                    @IsOuterColumn       Bit,
                                    @OuterColumnUrl      Varchar(255),
                                    @ColumnImgPath       Nvarchar(255),
                                    @Description         Nvarchar(510),
                                    @Keyword             Nvarchar(100),
                                    @Content             Nvarchar(300),
                                    @IsAllowAddInfo      Bit,
                                    @ColumnTemplatePath  Nvarchar(255),
                                    @InfoTemplatePath    Nvarchar(255),
                                    @CommentTemplatePath Nvarchar(255),
                                    @Sort                Int,
                                    @IsAllowComment      Bit,
                                    @IsCheckComment      Bit,
                                    @InfoTableName       Nvarchar(50),
                                    @ScoreReward         Int,
                                    @PointCount          Int,
                                    @ChargeType          Int,
                                    @ChargeHourCount     Int,
                                    @ChargeViewCount     Int,
                                    @IsOpened            Bit,
                                    @GroupIdStr          Varchar(500),
                                    @ColumnPageType      Int,
                                    @InfoPageType        Int,
                                    @IsParentHtml        Bit
As
  Update Qianbo_Column
  Set    [ChId] = @ChId,
         [ColName] = @ColName,
         [ColDirName] = @ColDirName,
         [ColParentId] = @ColParentId,
         [IsOuterColumn] = @IsOuterColumn,
         [OuterColumnUrl] = @OuterColumnUrl,
         [ColumnImgPath] = @ColumnImgPath,
         [Description] = @Description,
         [Keyword] = @Keyword,
         [Content] = @Content,
         [IsAllowAddInfo] = @IsAllowAddInfo,
         [ColumnTemplatePath] = @ColumnTemplatePath,
         [InfoTemplatePath] = @InfoTemplatePath,
         [CommentTemplatePath] = @CommentTemplatePath,
         [Sort] = @Sort,
         [IsAllowComment] = @IsAllowComment,
         [IsCheckComment] = @IsCheckComment,
         [InfoTableName] = @InfoTableName,
         [ScoreReward] = @ScoreReward,
         [PointCount] = @PointCount,
         [ChargeType] = @ChargeType,
         [ChargeHourCount] = @ChargeHourCount,
         [ChargeViewCount] = @ChargeViewCount,
         [IsOpened] = @IsOpened,
         [GroupIdStr] = @GroupIdStr,
         [ColumnPageType] = @ColumnPageType,
         [InfoPageType] = @InfoPageType,
         [IsParentHtml] = @IsParentHtml
  Where  [ColId] = @ColId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Column_UpdateHtml @ColId        Int,
                                            @IsUserHtml   Bit,
                                            @UserHtml     Ntext,
                                            @IsSystemHtml Bit,
                                            @SystemHtml   Ntext,
                                            @FieldOrder   Ntext,
                                            @TypeId       Nvarchar(20)
As
  If( @TypeId = '0' )
    Update [Qianbo_Column]
    Set    [FieldOrder] = @FieldOrder
    Where  [ColId] = @ColId
  Else
    If( @TypeId = '1' )
      Update [Qianbo_Column]
      Set    [UserHtml] = @UserHtml,
             [IsUserHtml] = @IsUserHtml
      Where  [ColId] = @ColId
    Else
      If( @TypeId = '2' )
        Update [Qianbo_Column]
        Set    [SystemHtml] = @SystemHtml,
               [IsSystemHtml] = @IsSystemHtml
        Where  [ColId] = @ColId
      Else
        If( @TypeId = '01' )
          Update [Qianbo_Column]
          Set    [FieldOrder] = @FieldOrder,
                 [UserHtml] = @UserHtml
          Where  [ColId] = @ColId
        Else
          If( @TypeId = '02' )
            Update [Qianbo_Column]
            Set    [FieldOrder] = @FieldOrder,
                   [SystemHtml] = @SystemHtml
            Where  [ColId] = @ColId
          Else
            If( @TypeId = '12' )
              Update [Qianbo_Column]
              Set    [UserHtml] = @UserHtml,
                     [SystemHtml] = @SystemHtml
              Where  [ColId] = @ColId
            Else
              If( @TypeId = '012' )
                Update [Qianbo_Column]
                Set    [FieldOrder] = @FieldOrder,
                       [UserHtml] = @UserHtml,
                       [SystemHtml] = @SystemHtml
                Where  [ColId] = @ColId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Column_Update_Template @ColId               Int output,
                                             @ColumnTemplatePath  Nvarchar(510),
                                             @InfoTemplatePath    Nvarchar(510),
                                             @CommentTemplatePath Nvarchar(510)
As
  Update Qianbo_Column
  Set    [ColumnTemplatePath] = ( Case @ColumnTemplatePath
                                    When '' Then [ColumnTemplatePath]
                                    Else @ColumnTemplatePath
                                  End ),
         [InfoTemplatePath] = ( Case @InfoTemplatePath
                                  When '' Then [InfoTemplatePath]
                                  Else @InfoTemplatePath
                                End ),
         [CommentTemplatePath] = ( Case @CommentTemplatePath
                                     When '' Then [CommentTemplatePath]
                                     Else @CommentTemplatePath
                                   End )
  Where  [ColId] = @ColId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Controller_Delete @ControllerId Int,
                                        @UserId       Int
As
  Delete From Qianbo_Controller
  Where  ControllerId = @ControllerId
         And UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Controller_GetList @UserId Int
As
  If Not Exists(Select *
                From   Qianbo_Controller
                Where  UserId = @UserId)
    Begin
        Insert Into Qianbo_Controller
                    (ControllerName,
                     LinkURI,
                     OrderNum,
                     UserId)
        Select ControllerName,
               LinkURI,
               OrderNum,
               @UserId
        From   Qianbo_Controller
        Where  UserId = 0
    End
  Select *
  From   Qianbo_Controller
  Where  UserId = @UserId
  Order  By OrderNum Asc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Controller_Set @ControllerId   Int,
                                     @ControllerName Nvarchar(50),
                                     @LinkURI        Varchar(255),
                                     @OrderNum       Int,
                                     @UserId         Int
As
  If( @ControllerId = 0 )
    Begin
        Insert Into Qianbo_Controller
                    (ControllerName,
                     LinkURI,
                     OrderNum,
                     UserId)
        Values      (@ControllerName,
                     @LinkURI,
                     @OrderNum,
                     @UserId)
    End
  Else
    Begin
        Update Qianbo_Controller
        Set    ControllerName = @ControllerName,
               LinkURI = @LinkURI,
               OrderNum = @OrderNum
        Where  ControllerId = @ControllerId
               And UserId = @UserId
               And UserId != 0
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Controller_Set_Default @UserId Int
As
  Delete From Qianbo_Controller
  Where  UserId = @UserId
         And UserId != 0
  Insert Into Qianbo_Controller
              (ControllerName,
               LinkURI,
               OrderNum,
               UserId)
  Select ControllerName,
         LinkURI,
         OrderNum,
         @UserId
  From   Qianbo_Controller
  Where  UserId = 0
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_Article_HeaderList @infocount Int,
                                                @colid     Int,
                                                @isimg     Bit
As
  Declare @wherestr Nvarchar(500)
  If( @isimg = 0 )
    Set @wherestr = ' isheader=1 and headerfont<>'''' '
  Else
    Set @wherestr = ' isheader=1 and headerimgpath<>'''' '
  Set @wherestr = +' i.status = 3 and i.isdeleted = 0 and i.colid = @tcolid and ' + @wherestr
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [Qianbo_Article] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr='select top ' + Convert(Nvarchar(15), @infocount) + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + 'order by i.[id] desc'
  Declare @param Nvarchar(400)
  Set @param = '@tcolid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tcolid = @colid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_Ch_GetSpecialInfoCount @tablename    Nvarchar(50),
                                               @infocount    Int,
                                               @specialidstr Nvarchar(3000),
                                               @datestr      Datetime
As
  Declare @fieldstr Nvarchar(500)
  Set @fieldstr = ' i.[id] '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(4000)
  Set @wherestr = ''
  If( @datestr != '' )
    Set @wherestr = @wherestr + ' i.addtime >= @tdatestr and '
  Set @wherestr = @wherestr + @specialidstr + ' i.status = 3 and i.isdeleted = 0 '
  Declare @topnum Nvarchar(50)
  Set @topnum = '';
  If( @infocount != 0 )
    Set @topnum = ' top ' + Convert(Nvarchar(15), @infocount) + ' '
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'select ' + @topnum + @fieldstr + 'from' + @tablestr + 'where' + @wherestr
  Declare @param Nvarchar(500)
  Set @param='@tdatestr datetime'
  Declare @countstr Nvarchar(4000)
  Set @countstr = 'select Count(*) from (' + @sqlstr + ')o'
  Execute sp_executesql
    @countstr,
    @param,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_Ch_GetSpecialInfoList @tablename    Nvarchar(50),
                                              @infocount    Int,
                                              @specialidstr Nvarchar(3000),
                                              @datestr      Datetime,
                                              @orderstr     Nvarchar(100)
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(4000)
  Set @wherestr = ''
  If( @datestr != '' )
    Set @wherestr = @wherestr + ' i.addtime >= @tdatestr and '
  Set @wherestr = @wherestr + @specialidstr + ' i.status = 3 and i.isdeleted = 0 '
  Declare @topnum Nvarchar(50)
  Set @topnum = '';
  If( @infocount != 0 )
    Set @topnum = ' top ' + Convert(Nvarchar(15), @infocount) + ' '
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'select ' + @topnum + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr
  Declare @param Nvarchar(500)
  Set @param='@tdatestr datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_GetAll_Info @CursorPage Int,
                                    @PageSize   Int,
                                    @tableName  Nvarchar(50)
As
  Declare @SqlStr Nvarchar(2000);
  Declare @fieldstr Nvarchar(500);
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(200)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  If( @CursorPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + @fieldstr + ' from' + @tablestr + ' where i.status = 3 and i.isdeleted = 0 order by i.[id] desc'
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + @fieldstr + ' from' + @tablestr + ' where i.status = 3 and i.isdeleted = 0 and i.Id < (select min(id) from(select top ' + Convert(Nvarchar(15), (@CursorPage - 1) * @PageSize) + ' i.[id] from ' + @tablestr + ' where i.status = 3 and i.isdeleted = 0 order by i.Id desc)O) order by i.[id] desc '
  Execute SP_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_GetChannel_Column_InfoList @chid     Int,
                                                        @colcount Int,
                                                        @colidstr Nvarchar(1000)
As
  Declare @topnum Nvarchar(50)
  Set @topnum = '';
  Declare @wherestr Nvarchar(1000)
  Set @wherestr = ' co.chid = @tchid and co.colparentid=0 ';
  If( @colcount != 0
      And @colidstr = '' )
    Set @topnum = ' top ' + Convert(Nvarchar(15), @colcount) + ' '
  Else
    If( @colidstr != '' )
      Set @wherestr = @wherestr + ' and colid in(' + @colidstr + ') '
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'select ' + @topnum + ' co.colid,co.colname,co.colid,co.columnimgpath from Qianbo_Column co where ' + @wherestr + ' and co.isdeleted = 0 order by co.sort asc'
  Declare @param Nvarchar(500)
  Set @param = '@tchid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Create_GetChannel_FinallyInfoCount @tablename Nvarchar(50),
                                                             @chidstr   Nvarchar(1000),
                                                             @datestr   Nvarchar(50)
As
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Channel ch on i.chid=ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(500)
  Set @wherestr=''
  If( @datestr != '' )
    Set @wherestr = @wherestr + ' i.[addtime] >= @tdatestr and '
  Set @wherestr = @wherestr + ' i.chid in(' + @chidstr + ') and i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'select Count(i.[id]) from' + @tablestr + 'where' + @wherestr
  Declare @param Nvarchar(50)
  Set @param='@tdatestr datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Create_GetChannel_FinallyInfoList @tablename Nvarchar(50),
                                                            @chidstr   Nvarchar(1000),
                                                            @datestr   Nvarchar(50),
                                                            @orderstr  Nvarchar(50),
                                                            @ispadding Bit,
                                                            @pageindex Int,
                                                            @pagesize  Int
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.typeunit,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] i join Qianbo_Channel ch on i.chid=ch.chid join Qianbo_Model m on ch.modeltype = m.modelid left outer join Qianbo_Column co on i.colid = co.colid '
  Declare @wherestr Nvarchar(500)
  Set @wherestr = '';
  If( @datestr != '' )
    Set @wherestr=' i.[addtime] >= @tdatestr and '
  Set @wherestr = @wherestr + ' i.chid in(' + @chidstr + ') and i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(4000)
  If( @ispadding = 0 )
    Set @sqlstr = 'select' + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr
  Else
    Begin
        If( @pageindex = 1 )
          Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr
        Else
          Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where i.[id] not in(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr + ') and ' + @wherestr + ' order by ' + @orderstr
    End
  Declare @param Nvarchar(50)
  Set @param='@tdatestr datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_GetChannel_InfoList @tablename Nvarchar(50),
                                                 @infocount Int,
                                                 @chid      Int,
                                                 @typestr   Nvarchar(1000),
                                                 @datestr   Datetime,
                                                 @orderstr  Nvarchar(50)
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @topnum Nvarchar(50)
  Set @topnum = '';
  If( @infocount != '' )
    Set @topnum = ' top ' + Convert(Nvarchar(15), @infocount) + ' ';
  Declare @wherestr Nvarchar(2000)
  Set @wherestr = '';
  If( @typestr != '' )
    Set @wherestr = @wherestr + @typestr + ' and '
  If( @datestr != '' )
    Set @wherestr = @wherestr + ' i.addtime >= @tdatestr and '
  Set @wherestr = @wherestr + ' co.chid = @tchid and i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(1000)
  Set @sqlstr = 'select ' + @topnum + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr
  Declare @param Nvarchar(500)
  Set @param = '@tchid int,@tdatestr datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_GetCloseInfo @tablename Nvarchar(50),
                                     @id        Int,
                                     @colid     Int,
                                     @direct    Nvarchar(10)
As
  Declare @sqlstr Nvarchar(2000)
  Declare @param Nvarchar(500)
  If( @direct = 'pre' )
    Set @sqlstr = 'if exists(select [id] from [' + @tablename + '] where [id] < @tid and colid = @tcolid and status = 3 and isdeleted = 0) ' + 'select top 1 [id],title from [' + @tablename + '] where [id] < @tid and colid = @tcolid and status = 3 and  isdeleted = 0 order by id desc ' + 'else ' + 'select [id] = 0'
  Else
    Set @sqlstr = 'if exists(select [id] from [' + @tablename + '] where [id] > @tid and colid = @tcolid and status = 3 and isdeleted = 0) ' + 'select top 1 [id],title from [' + @tablename + '] where [id] > @tid and colid = @tcolid and status = 3 and isdeleted = 0 order by id asc ' + 'else ' + 'select [id] = 0'
  Set @param = '@tid int,@tcolid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tid = @id,
    @tcolid = @colid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_GetColumn_ChildCol_InfoList @colid    Int,
                                                         @colcount Int
As
  Declare @topnum Nvarchar(50)
  Set @topnum = '';
  If( @colcount != 0 )
    Set @topnum = ' top ' + Convert(Nvarchar(15), @colcount) + ' '
  Declare @wherestr Nvarchar(500)
  Set @wherestr = ' co.colparentid = @tcolid and co.isdeleted = 0 '
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'select ' + @topnum + ' co.colid,co.colname,co.colid from Qianbo_Column co where' + @wherestr + ' order by co.sort asc'
  Declare @param Nvarchar(50)
  Set @param = '@tcolid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tcolid = @colid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_GetColumn_FinallyInfoCount @tablename Nvarchar(50),
                                                   @colidstr  Nvarchar(1000),
                                                   @datestr   Nvarchar(50)
As
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(500)
  Set @wherestr=''
  If( @datestr != '' )
    Set @wherestr = @wherestr + ' i.[addtime] >= @tdatestr and '
  Set @wherestr = @wherestr + ' i.colid in(' + @colidstr + ') and i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'select Count(i.[id]) from' + @tablestr + 'where' + @wherestr
  Declare @param Nvarchar(50)
  Set @param='@tdatestr datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_GetColumn_FinallyInfoList @tablename Nvarchar(50),
                                                  @colidstr  Nvarchar(1000),
                                                  @datestr   Nvarchar(50),
                                                  @orderstr  Nvarchar(50),
                                                  @ispadding Bit,
                                                  @pageindex Int,
                                                  @pagesize  Int
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.typeunit,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(500)
  Set @wherestr = '';
  If( @datestr != '' )
    Set @wherestr=' i.[addtime] >= @tdatestr and '
  Set @wherestr = @wherestr + ' i.colid in(' + @colidstr + ') and i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(4000)
  If( @ispadding = 0 )
    Set @sqlstr = 'select' + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr
  Else
    Begin
        If( @pageindex = 1 )
          Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr
        Else
          Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where i.[id] not in(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr + ') and ' + @wherestr + ' order by ' + @orderstr
    End
  Declare @param Nvarchar(50)
  Set @param='@tdatestr datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_GetColumn_FlashInfoList @tablename Nvarchar(50),
                                                @chid      Int,
                                                @colidstr  Varchar(1000),
                                                @infocount Int
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @sqlstr Nvarchar(4000)
  Declare @wherestr Nvarchar(1000)
  Set @wherestr = '';
  If( @chid != 0 )
    Set @wherestr = @wherestr + ' ch.chid = @tchid and '
  If( @colidstr != '' )
    Set @wherestr = @wherestr + ' i.colid in(' + @colidstr + ') and '
  Set @wherestr = @wherestr + ' i.status = 3 and i.isdeleted = 0 and issideshow=1 '
  Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @infocount) + @fieldstr + 'from' + @tablestr + 'where ' + @wherestr + ' order by i.[id] desc'
  Declare @param Nvarchar(400)
  Set @param = '@tchid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_GetColumn_Info @tablename Nvarchar(50),
                                            @colidstr  Nvarchar(2000),
                                            @pageindex Int,
                                            @pagesize  Int
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(2000)
  Set @wherestr = ' i.colid in(' + @colidstr + ') and i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(2000)
  If( @pageindex = 1 )
    Set @sqlstr ='select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + 'order by i.[id] desc'
  Else
    Set @sqlstr ='select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where i.[id] < (select min(o.[id]) from(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from' + @tablestr + 'where' + @wherestr + 'order by i.[id] desc)o) and ' + @wherestr + 'order by i.[id] desc'
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_GetColumn_InfoList @tablename Nvarchar(50),
                                                @infocount Int,
                                                @colidstr  Nvarchar(1000),
                                                @typestr   Nvarchar(1000),
                                                @datestr   Datetime,
                                                @orderstr  Nvarchar(50)
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @topnum Nvarchar(50)
  Set @topnum = '';
  If( @infocount != '' )
    Set @topnum = ' top ' + Convert(Nvarchar(15), @infocount) + ' ';
  Declare @wherestr Nvarchar(2000)
  Set @wherestr = '';
  If( @typestr != '' )
    Set @wherestr = @wherestr + @typestr + ' and '
  If( @datestr != '' )
    Set @wherestr = @wherestr + ' i.addtime >= @tdatestr and '
  Set @wherestr = @wherestr + ' i.colid in(' + @colidstr + ') and i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(1000)
  Set @sqlstr = 'select ' + @topnum + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr
  Declare @param Nvarchar(500)
  Set @param = '@tdatestr datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_GetDateRange_Info @tablename Nvarchar(50),
                                               @startdate Nvarchar(15),
                                               @enddate   Nvarchar(15),
                                               @pageindex Int,
                                               @pagesize  Int
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(400)
  Set @wherestr = ' (i.addtime >= @tstartdate and i.addtime <= @tenddate) and i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(2000)
  If( @pageindex = 1 )
    Set @sqlstr ='select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + 'order by i.[id] desc'
  Else
    Set @sqlstr ='select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where i.[id] < (select min(o.[id]) from(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from' + @tablestr + 'where' + @wherestr + 'order by i.[id] desc)o) and ' + @wherestr + 'order by i.[id] desc'
  Declare @param Nvarchar(400)
  Set @param = '@tstartdate datetime,@tenddate datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tstartdate = @startdate,
    @tenddate = @enddate
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_GetDigCount @modelid Int,
                                    @infoid  Int
As
  Select digcount
  From   Qianbo_Dig
  Where  modelid = @modelid
         And infoid = @infoid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_GetIdRange_Info @tablename Nvarchar(50),
                                             @startid   Int,
                                             @endid     Int,
                                             @pageindex Int,
                                             @pagesize  Int
As
  Declare @sqlstr Nvarchar(4000);
  Declare @wherestr Nvarchar(2000)
  Set @wherestr = ' i.status = 3 and i.isdeleted = 0 and i.[id] in(select [id] from [' + @tablename + '] where [id] >= @tstartid and [id] <= @tendid) '
  Declare @fieldstr Nvarchar(500);
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  If( @pageindex = 1 )
    Set @sqlstr='select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + 'order by i.[id] desc'
  Else
    Set @sqlstr='select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + 'and i.[id] < (select min(id) from(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from' + @tablestr + 'where' + @wherestr + ' order by i.[id] desc )o) order by i.[id] desc'
  Declare @param Nvarchar(400)
  Set @param = '@tstartid int,@tendid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tstartid = @startid,
    @tendid = @endid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_GetId_Info @tablename Nvarchar(50),
                                        @id        Int
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.isdisabled,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr='select ' + @fieldstr + ' from ' + @tablestr + ' where i.[id] = @tid and i.isdeleted = 0'
  Declare @param Nvarchar(200)
  Set @param = '@tid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tid = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Create_GetNewRange_Info @tablename Nvarchar(50),
                                              @topnum    Int,
                                              @pageIndex Int,
                                              @pagesize  Int
As
  Declare @sqlstr Nvarchar(2000);
  Declare @fieldstr Nvarchar(500);
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(400)
  Set @wherestr = ' where i.status = 3 and i.isdeleted = 0 '
  Declare @subsqlstr Nvarchar(1000)
  Set @subsqlstr = 'select top ' + Convert(Nvarchar(15), @topnum) + @fieldstr + 'from' + @tablestr + @wherestr + ' order by i.[id] desc '
  If( @pageindex = 1 )
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + ' * from(' + @subsqlstr + ')o order by o.[id] desc'
  Else
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + ' * from(' + @subsqlstr + ')o where o.[id] < (select min([id]) from(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' k.[id] from (' + @subsqlstr + ')k)p) order by o.[id] desc'
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_GetPropertyCount @tablename Nvarchar(50),
                                         @prowhe    Nvarchar(1000),
                                         @datestr   Nvarchar(50)
As
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(500)
  Set @wherestr=''
  If( @prowhe != '' )
    Set @wherestr=' ' + @prowhe + ' and '
  If( @datestr != '' )
    Set @wherestr = @wherestr + ' i.[addtime] >= @tdatestr and '
  Set @wherestr = @wherestr + ' i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'select Count(i.[id]) as recordCount from' + @tablestr + 'where' + @wherestr
  Declare @param Nvarchar(50)
  Set @param='@tdatestr datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_GetPropertyList @tablename Nvarchar(50),
                                        @infocount Int,
                                        @prowhe    Nvarchar(500),
                                        @datestr   Nvarchar(50),
                                        @orderstr  Nvarchar(50),
                                        @ispadding Bit,
                                        @pageindex Int,
                                        @pagesize  Int
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.typeunit,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(500)
  Set @wherestr = '';
  If( @prowhe != '' )
    Set @wherestr=' ' + @prowhe + ' and '
  If( @datestr != '' )
    Set @wherestr=' i.[addtime] >= @tdatestr and '
  Set @wherestr = @wherestr + ' i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(4000)
  If( @ispadding = 0 )
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @infocount) + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr
  Else
    Begin
        If( @pageindex = 1 )
          Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr
        Else
          Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @fieldstr + 'from' + @tablestr + 'where i.[id] not in(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from' + @tablestr + 'where' + @wherestr + ' order by ' + @orderstr + ') and ' + @wherestr + ' order by ' + @orderstr
    End
  Declare @param Nvarchar(50)
  Set @param='@tdatestr datetime'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tdatestr = @datestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_InfoRecordCount @InputStr    Nvarchar(2000),
                                        @tableName   Nvarchar(200),
                                        @RecordCount Int output
As
  Declare @WhereStr Nvarchar(2000);
  Declare @SqlStr Nvarchar(2000);
  Declare @Param Nvarchar(50)
  Set @Param=N'@TRecordCount int output'
  Set @WhereStr=Convert(Nvarchar(200), @tableName) + ' as i,Qianbo_Channel as ch,Qianbo_Column as co where co.Chid = ch.ChId and i.colid = co.colid and i.status = 3 and i.isdeleted = 0 ';
  Set @SqlStr=N'select @TRecordCount = Count(i.Id) from ' + @WhereStr + Convert(Nvarchar(2000), @InputStr);
  Execute SP_ExecuteSql
    @SqlStr,
    @Param,
    @TRecordCount = @RecordCount output
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_Info_RelationInfoList @tablename Nvarchar(50),
                                              @infocount Int,
                                              @wherestr  Nvarchar(2000)
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @infocount) + @fieldstr + 'from' + @tablestr + 'where i.status = 3 and i.isdeleted = 0 ' + @wherestr + ' order by i.[id] desc'
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_Irregular_GetInfoList @chid      Int,
                                              @tablename Nvarchar(50),
                                              @pageindex Int,
                                              @pagesize  Int
As
  Declare @wherestr Nvarchar(400)
  Set @wherestr = '';
  If( @tablename = 'Qianbo_Article' )
    Set @wherestr = ' ch.chid = @tchid and i.isirregular = 1 and i.status = 3 and i.isdeleted = 0 '
  Else
    Set @wherestr = ' ch.chid = @tchid and i.status = 3 and i.isdeleted = 0  '
  Declare @sqlstr Nvarchar(3000)
  Declare @param Nvarchar(400)
  Declare @tablestr Nvarchar(500)
  Set @tablestr = ' [' + @tablename + '] i join Qianbo_Column co on i.[colid] = co.[colid] join Qianbo_Channel ch on co.[chid] = ch.[chid] '
  Set @param = '@tchid int'
  If( @pageindex = 1 )
    Set @sqlstr='select top ' + Convert(Nvarchar(15), @pagesize) + ' co.colname,i.id,i.colid,i.title,i.addtime from ' + @tablestr + '  where ' + @wherestr + ' order by i.addtime desc'
  Else
    Set @sqlstr='select top ' + Convert(Nvarchar(15), @pagesize) + ' co.colname,i.id,i.colid,i.title,i.addtime from ' + @tablestr + ' where ' + @wherestr + ' and i.[id] < (select min(o.id) from(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from ' + @tablestr + ' where ' + @wherestr + ' order by i.addtime desc)o) order by i.addtime desc'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
  Set @sqlstr = 'select Count(*) from ' + @tablestr + ' where ' + @wherestr
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_ListInfoCount @tablename Nvarchar(50),
                                      @topnum    Int
As
  Declare @recordcount Int
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'select Count(i.[id]) from(select top ' + Convert(Nvarchar(15), @topnum) + ' [id] from [' + @tablename + '] where status = 3 and isdeleted = 0 order by id desc)i'
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Create_SetDigCount @modelid Int,
                                    @infoid  Int
As
  If Exists(Select *
            From   Qianbo_Dig
            Where  modelid = @modelid
                   And infoid = @infoid)
    Update Qianbo_Dig
    Set    digcount = digcount + 1
    Where  modelid = @modelid
           And infoid = @infoid
  Else
    Insert Into Qianbo_Dig
                (modelid,
                 infoid,
                 digcount)
    Select @modelid,
           @infoid,
           1
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomField_SubmitNum @TableName Nvarchar(50),
                                            @UId       Int
As
  Declare @sqlstr Nvarchar(500)
  Set @sqlstr='select * from [' + @TableName + '] where UId = ' + Convert(Nvarchar(100), @UId) + ' order by Id desc'
  Execute sp_executesql @sqlstr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomFormField_Add @CustomFormId Int,
                                          @Name         Nvarchar(100),
                                          @Alias        Nvarchar(300),
                                          @Description  Nvarchar(400),
                                          @IsNotNull    Bit,
                                          @IsSearchForm Bit,
                                          @Type         Nvarchar(100),
                                          @Content      Ntext,
                                          @IsList       Bit,
                                          @IsUserInsert Bit,
                                          @AddDate      Datetime
As
  Declare @OrderId Int;
  Set @OrderId=(Select max(OrderId)
                From   [Qianbo_CustomFormField]
                Where  CustomFormId = @CustomFormId)
  If @OrderId Is Null
    Set @OrderId=0
  Else
    Set @OrderId = @OrderId + 1
  Insert Into [Qianbo_CustomFormField]
              ([CustomFormId],
               [Name],
               [Alias],
               [Description],
               [IsNotNull],
               [IsSearchForm],
               [Type],
               [Content],
               [AddDate],
               [OrderId],
               [IsList],
               [IsUserInsert])
  Values      (@CustomFormId,
               @Name,
               @Alias,
               @Description,
               @IsNotNull,
               @IsSearchForm,
               @Type,
               @Content,
               @AddDate,
               @OrderId,
               @IsList,
               @IsUserInsert)
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomFormField_Del @FieldId Int
As
  Delete From [Qianbo_CustomFormField]
  Where  FieldId = @FieldId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomFormField_GetIsUserList @CustomFormId Int
As
  Select *
  From   [Qianbo_CustomFormField]
  Where  CustomFormId = @CustomFormId
         And IsUserInsert = 1
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomFormField_GetList @CustomFormId Int
As
  Select *
  From   [Qianbo_CustomFormField]
  Where  CustomFormId = @CustomFormId
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomFormField_GetModel @FieldId      Int=0,
                                               @CustomFormId Int=0,
                                               @Name         Nvarchar(50)=" ",
                                               @TypeId       Int
As
  If @TypeId = 1
    Select *
    From   [Qianbo_CustomFormField]
    Where  FieldId = @FieldId
  Else
    Select *
    From   [Qianbo_CustomFormField]
    Where  CustomFormId = @CustomFormId
           And [Name] = @Name
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomFormField_GetTitleList @CustomFormId Int
As
  Select *
  From   [Qianbo_CustomFormField]
  Where  IsList = 1
         And CustomFormId = @CustomFormId
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomFormField_MoveField @CustomFormId Int,
                                                @FieldId      Int,
                                                @MoveType     Nvarchar(20)
As
  Declare @OrderId Int;
  Declare @NewFieldId Int;
  Declare @NewOrderId Int;
  If @MoveType = 'UpMove'
    Begin
        Declare @MinOrderId Int;
        Set @MinOrderId=(Select min(OrderId)
                         From   [Qianbo_CustomFormField]
                         Where  CustomFormId = @CustomFormId)
        Set @OrderId=(Select OrderId
                      From   [Qianbo_CustomFormField]
                      Where  CustomFormId = @CustomFormId
                             And FieldId = @FieldId)
        If @OrderId != @MinOrderId
          Begin
              Set @NewFieldId=(Select Top 1 FieldId
                               From   [Qianbo_CustomFormField]
                               Where  CustomFormId = @CustomFormId
                                      And OrderId < @OrderId
                               Order  By OrderId Desc)
              Set @NewOrderId=(Select OrderId
                               From   [Qianbo_CustomFormField]
                               Where  CustomFormId = @CustomFormId
                                      And FieldId = @NewFieldId)
              Update [Qianbo_CustomFormField]
              Set    OrderId = @OrderId
              Where  FieldId = @NewFieldId
                     And CustomFormId = @CustomFormId
              Update [Qianbo_CustomFormField]
              Set    OrderId = @NewOrderId
              Where  FieldId = @FieldId
                     And CustomFormId = @CustomFormId
          End
    End
  If @MoveType = 'DownMove'
    Begin
        Declare @MaxOrderId Int;
        Set @MaxOrderId=(Select max(OrderId)
                         From   [Qianbo_CustomFormField]
                         Where  CustomFormId = @CustomFormId)
        Set @OrderId=(Select OrderId
                      From   [Qianbo_CustomFormField]
                      Where  CustomFormId = @CustomFormId
                             And FieldId = @FieldId)
        If @OrderId != @MaxOrderId
          Begin
              Set @NewFieldId=(Select Top 1 FieldId
                               From   [Qianbo_CustomFormField]
                               Where  CustomFormId = @CustomFormId
                                      And OrderId > @OrderId
                               Order  By OrderId)
              Set @NewOrderId=(Select OrderId
                               From   [Qianbo_CustomFormField]
                               Where  CustomFormId = @CustomFormId
                                      And FieldId = @NewFieldId)
              Update [Qianbo_CustomFormField]
              Set    OrderId = @OrderId
              Where  FieldId = @NewFieldId
                     And CustomFormId = @CustomFormId
              Update [Qianbo_CustomFormField]
              Set    OrderId = @NewOrderId
              Where  FieldId = @FieldId
                     And CustomFormId = @CustomFormId
          End
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomFormField_SelectPropertyTrue @CustomFormId Nvarchar(50)
As
  Select *
  From   [Qianbo_CustomFormField]
  Where  CustomFormId = @CustomFormId
         And Type = 'RadioType'
         And Content Like '%Property=True%'
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomFormField_Update @FieldId      Int,
                                             @CustomFormId Int,
                                             @Alias        Nvarchar(300),
                                             @Description  Nvarchar(400),
                                             @IsNotNull    Bit,
                                             @IsSearchForm Bit,
                                             @Content      Ntext,
                                             @IsList       Bit,
                                             @IsUserInsert Bit,
                                             @AddDate      Datetime
As
  Update Qianbo_CustomFormField
  Set    [Alias] = @Alias,
         [Description] = @Description,
         [IsNotNull] = @IsNotNull,
         [IsSearchForm] = @IsSearchForm,
         [Content] = @Content,
         [IsList] = @IsList,
         [IsUserInsert] = @IsUserInsert,
         [AddDate] = @AddDate
  Where  [FieldId] = @FieldId
         And CustomFormId = @CustomFormId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomForm_Add @ShowForm     Int,
                                     @FormName     Nvarchar(100),
                                     @TableName    Nvarchar(100),
                                     @UploadPath   Nvarchar(100),
                                     @FormDesc     Nvarchar(400),
                                     @IsUnlockTime Bit,
                                     @StartTime    Datetime,
                                     @EndTime      Datetime,
                                     @UserGroup    Nvarchar(200),
                                     @IsSubmitNum  Bit,
                                     @Money        Int,
                                     @IsValidate   Bit,
                                     @AddTime      Datetime
As
  Insert Into [Qianbo_CustomForm]
              ([ShowForm],
               [FormName],
               [TableName],
               [UploadPath],
               [FormDesc],
               [IsUnlockTime],
               [StartTime],
               [EndTime],
               [UserGroup],
               [IsSubmitNum],
               [Money],
               [IsValidate],
               [AddTime])
  Values      (@ShowForm,
               @FormName,
               @TableName,
               @UploadPath,
               @FormDesc,
               @IsUnlockTime,
               @StartTime,
               @EndTime,
               @UserGroup,
               @IsSubmitNum,
               @Money,
               @IsValidate,
               @AddTime)
  Select scope_identity()
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [dbo].[Proc_CustomForm_AddTable] @TableName Nvarchar(50)
As
  Declare @sqlstr Nvarchar(500)
  Set @sqlstr=N'
CREATE TABLE [dbo].[' + @TableName + ']
(
[Id] [int] IDENTITY (1, 1) PRIMARY Key NOT NULL,
[UId] [int] NULL ,
[UName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
[Ip] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[AddTime] [datetime] NULL)
CREATE  INDEX [IX_' + @TableName + '_UId] ON [' + @TableName + ']([UId]) ON [PRIMARY]'
  Exec sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomForm_Delete @CustomFormId Int
As
  Declare @tablename Nvarchar(50)
  Set @tablename=''
  Set @tablename=(Select TableName
                  From   [Qianbo_CustomForm]
                  Where  [CustomFormId] = @CustomFormId)
  Declare @sqlstr Nvarchar(500)
  If( @tablename != '' )
    Begin
        Set @sqlstr = N'delete from [Qianbo_CustomForm] where [CustomFormId] = ' + Convert(Nvarchar(15), @CustomFormId)
        Exec sp_executesql @sqlstr
        Set @sqlstr = N'drop table [' + @tablename + ']'
        Exec sp_executesql @sqlstr
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomForm_GetAll
As
  Select *
  From   [Qianbo_CustomForm]
  Order  By CustomFormId Desc
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomForm_GetModel @CustomFormId Int
As
  Select *
  From   [Qianbo_CustomForm]
  Where  CustomFormId = @CustomFormId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomForm_Update @CustomFormId Int,
                                        @ShowForm     Int,
                                        @FormName     Nvarchar(100),
                                        @TableName    Nvarchar(100),
                                        @UploadPath   Nvarchar(100),
                                        @FormDesc     Nvarchar(400),
                                        @IsUnlockTime Bit,
                                        @StartTime    Datetime,
                                        @EndTime      Datetime,
                                        @UserGroup    Nvarchar(200),
                                        @IsSubmitNum  Bit,
                                        @Money        Int,
                                        @IsValidate   Bit,
                                        @AddTime      Datetime
As
  Update [Qianbo_CustomForm]
  Set    [ShowForm] = @ShowForm,
         [FormName] = @FormName,
         [TableName] = @TableName,
         [UploadPath] = @UploadPath,
         [FormDesc] = @FormDesc,
         [IsUnlockTime] = @IsUnlockTime,
         [StartTime] = @StartTime,
         [EndTime] = @EndTime,
         [UserGroup] = @UserGroup,
         [IsSubmitNum] = @IsSubmitNum,
         [Money] = @Money,
         [IsValidate] = @IsValidate,
         [AddTime] = @AddTime
  Where  [CustomFormId] = @CustomFormId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_CustomTable_GetList @TableName Nvarchar(50),
                                          @CurrPage  Int,
                                          @PageSize  Int,
                                          @strWhere  Nvarchar(2000)
As
  Declare @SqlStr Nvarchar(3000);
  If( @CurrPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [' + @TableName + '] ' + @strWhere + ' order by Id desc';
  Else
    If( @strWhere = '' )
      Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [' + @TableName + '] where Id < (select min(Id) from (select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' Id from [' + @TableName + '] ' + @strWhere + ' order by Id desc)o) order by Id desc';
    Else
      Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [' + @TableName + '] ' + @strWhere + ' and Id < (select min(Id) from (select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' Id from [' + @TableName + '] ' + @strWhere + ' order by Id desc)o) order by Id desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(Id) from [' + @TableName + ']' + @strWhere;
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Dictionary_Get @Type      Int,
                                     @PageSize  Int=20,
                                     @PageIndex Int=1,
                                     @WhereStr  Nvarchar(2000),
                                     @Id        Int
As
  Declare @SqlStr Nvarchar(2000)
  Declare @Filter Nvarchar(2000)
  If( @WhereStr = '' )
    Begin
        Set @WhereStr=' where '
        Set @Filter=''
    End
  Else
    Begin
        Set @Filter=' where ' + @WhereStr
        Set @WhereStr=' where ' + @WhereStr + ' and '
    End
  If( @Type = 1 )
    Begin
        Select *
        From   Qianbo_Dictionary
        Where  [ID] = @Id
    End
  If( @Type = 2 )
    Begin
        If( @PageIndex = 1 )
          Begin
              Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_Dictionary ' + @Filter + ' order by Sort,[ID] desc'
          End
        Else
          Begin
              Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_Dictionary ' + @WhereStr + ' [ID] < (select min([ID]) from(select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' * from Qianbo_Dictionary  ' + @Filter + ' order by Sort,[ID] desc)O) order by Sort,[ID] desc'
          End
        Execute Sp_ExecuteSql @SqlStr
        Set @SqlStr = 'select Count(*) from Qianbo_Dictionary ' + @Filter
        Execute Sp_ExecuteSql @SqlStr
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Dictionary_Set @Type     Int,
                                     @Id       Int,
                                     @ParentId Int,
                                     @DicName  Nvarchar(50),
                                     @Sort     Int,
                                     @Identity Int=0 output
As
  If @Type = 1
    Begin
        Insert Into Qianbo_Dictionary
        Values      (@ParentId,
                     @DicName,
                     @Sort)
        Select @Identity = Scope_Identity()
    End
  If @Type = 2
    Begin
        Update Qianbo_Dictionary
        Set    ParentId = @ParentId,
               DicName = @DicName,
               Sort = @Sort
        Where  ID = @Id
    End
  If @Type = 3
    Begin
        Delete From Qianbo_Dictionary
        Where  ID = @Id
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_DownLoadAddress_GetGroupAddresList @addresnum        Int,
                                                         @downloadserverid Int
As
  Select *
  From   Qianbo_DownLoadAddress a
         Left Join Qianbo_DownLoadServerType b
           On downloadserverid = b.typeid
         Left Join Qianbo_DownLoadServerData c
           On b.typeid = c.typeid
  Where  a.downloaddataid = @addresnum
         And a.downloadserverid = @downloadserverid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoadAddress_GetInfoBySoftId @SoftId Int
As
  Select *
  From   Qianbo_DownLoadAddress
  Where  DownLoadDataId = @SoftId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_DownLoadAddress_Set @AddressId        Int output,
                                          @DownLoadDataId   Int,
                                          @AddressNum       Int,
                                          @DownLoadServerID Int,
                                          @AddressName      Nvarchar(100),
                                          @AddressPath      Nvarchar(100)
As
  If( @AddressId = 0 )
    Begin
        Insert Into Qianbo_DownLoadAddress
                    ([DownLoadDataId],
                     [AddressNum],
                     [DownLoadServerID],
                     [AddressName],
                     [AddressPath])
        Values      ( @DownLoadDataId,
                      @AddressNum,
                      @DownLoadServerID,
                      @AddressName,
                      @AddressPath )
        Set @AddressId=Scope_identity()
    End
  Else
    Begin
        Update Qianbo_DownLoadAddress
        Set    [DownLoadDataId] = @DownLoadDataId,
               [AddressNum] = @AddressNum,
               [DownLoadServerID] = @DownLoadServerID,
               [AddressName] = @AddressName,
               [AddressPath] = @AddressPath
        Where  [AddressId] = @AddressId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoadData_ClearDownCount
As
  Update [Qianbo_DownLoadData]
  Set    downloaddownmonthnum = 0,
         monthcounttime = getdate()
  Where  DateDiff(month, monthcounttime, getdate()) != 0
  Update [Qianbo_DownLoadData]
  Set    downloaddownweeknum = 0,
         weekcounttime = getdate()
  Where  DateDiff(week, weekcounttime, getdate()) != 0
  Update [Qianbo_DownLoadData]
  Set    downloaddowndaynum = 0,
         daycounttime = getdate()
  Where  DateDiff(day, daycounttime, getdate()) != 0
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoadData_Delete @IDstr  Nvarchar(2000),
                                     @Option Varchar(50)
As
  Declare @SqlStr Nvarchar(2000)
  If( @Option = 'Delete' )
    Begin
        Set @SqlStr = 'delete from Qianbo_DownLoadData where Id in(' + @IDstr + ')'
    End
  If( @Option = 'Recycle' )
    Begin
        Set @SqlStr = 'update Qianbo_DownLoadData set SoftIsDel = 0 where Id in(' + @IDstr + ')'
    End
  If( @Option = 'DeletedToRecycle' )
    Begin
        Set @SqlStr = 'update Qianbo_DownLoadData set SoftIsDel = 1 where Id in(' + @IDstr + ')'
    End
  Exec sp_executesql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_DownLoadData_GetDataById @Id Int
As
  Select *
  From   Qianbo_DownLoadData
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_DownLoadData_Set @Id                   Int output,
                                       @ChId                 Int,
                                       @ColId                Int,
                                       @Title                Nvarchar(200),
                                       @TitleColor           Nvarchar(6)='',
                                       @TitleFontType        Int,
                                       @TitleType            Int,
                                       @TitleImgPath         Varchar(255) ='',
                                       @UId                  Int,
                                       @UName                Nvarchar(20) ='',
                                       @UserType             Int,
                                       @AdminUId             Int,
                                       @AdminUName           Nvarchar(20) ='',
                                       @Status               Int,
                                       @HitCount             Int,
                                       @AddTime              Datetime,
                                       @UpdateTime           Datetime,
                                       @TemplatePath         Varchar(255)='',
                                       @PageType             Int,
                                       @IsCreated            Bit,
                                       @UserCateId           Int,
                                       @PointCount           Int,
                                       @ChargeType           Int,
                                       @ChargeHourCount      Int,
                                       @ChargeViewCount      Int,
                                       @IsOpened             Int,
                                       @GroupIdStr           Varchar(200) ='',
                                       @IsDeleted            Bit,
                                       @IsRecommend          Bit,
                                       @IsTop                Bit,
                                       @IsFocus              Bit,
                                       @IsSideShow           Bit,
                                       @TagIdStr             Varchar(300) ='',
                                       @TagNameStr           Nvarchar(300) ='',
                                       @SpecialIdStr         Varchar(200) ='',
                                       @Content              Nvarchar(500),
                                       @Edition              Nvarchar(50),
                                       @PlayAddress          Nvarchar(100) ='',
                                       @DownLoadDownNum      Int,
                                       @DownLoadDownMonthNum Int,
                                       @DownLoadDownWeekNum  Int,
                                       @DownLoadDownDayNum   Int,
                                       @DownLoadOS           Nvarchar(100) ='',
                                       @DownLoadServerDataId Int,
                                       @Language             Nvarchar(50) ='',
                                       @WarrantType          Nvarchar(50) ='',
                                       @DownLoadSize         Nvarchar(50) ='',
                                       @RegAddress           Nvarchar(100) ='',
                                       @Plugin               Nvarchar(20) ='',
                                       @DownLoadStarLevel    Nvarchar(50) ='',
                                       @DownLoadDisplePwd    Nvarchar(50) ='',
                                       @DownLoadType         Nvarchar(50) ='',
                                       @IsAllowComment       Bit
As
  If( @Id = 0 )
    Begin
        Insert Into Qianbo_DownLoadData
                    ([ChId],
                     [ColId],
                     [Title],
                     [TitleColor],
                     [TitleFontType],
                     [TitleType],
                     [TitleImgPath],
                     [UId],
                     [UName],
                     [UserType],
                     [AdminUId],
                     [AdminUName],
                     [Status],
                     [HitCount],
                     [AddTime],
                     [UpdateTime],
                     [TemplatePath],
                     [PageType],
                     [IsCreated],
                     [UserCateId],
                     [PointCount],
                     [ChargeType],
                     [ChargeHourCount],
                     [ChargeViewCount],
                     [IsOpened],
                     [GroupIdStr],
                     [IsDeleted],
                     [IsRecommend],
                     [IsTop],
                     [IsFocus],
                     [IsSideShow],
                     [TagIdStr],
                     [TagNameStr],
                     [SpecialIdStr],
                     [Content],
                     [Edition],
                     [PlayAddress],
                     [DownLoadDownNum],
                     [DownLoadDownMonthNum],
                     [DownLoadDownWeekNum],
                     [DownLoadDownDayNum],
                     [DownLoadOS],
                     [DownLoadServerDataId],
                     [Language],
                     [WarrantType],
                     [DownLoadSize],
                     [RegAddress],
                     [Plugin],
                     [DownLoadStarLevel],
                     [DownLoadDisplePwd],
                     [DownLoadType],
                     [IsAllowComment])
        Values      (@ChId,
                     @ColId,
                     @Title,
                     @TitleColor,
                     @TitleFontType,
                     @TitleType,
                     @TitleImgPath,
                     @UId,
                     @UName,
                     @UserType,
                     @AdminUId,
                     @AdminUName,
                     @Status,
                     @HitCount,
                     @AddTime,
                     @UpdateTime,
                     @TemplatePath,
                     @PageType,
                     @IsCreated,
                     @UserCateId,
                     @PointCount,
                     @ChargeType,
                     @ChargeHourCount,
                     @ChargeViewCount,
                     @IsOpened,
                     @GroupIdStr,
                     @IsDeleted,
                     @IsRecommend,
                     @IsTop,
                     @IsFocus,
                     @IsSideShow,
                     @TagIdStr,
                     @TagNameStr,
                     @SpecialIdStr,
                     @Content,
                     @Edition,
                     @PlayAddress,
                     @DownLoadDownNum,
                     @DownLoadDownMonthNum,
                     @DownLoadDownWeekNum,
                     @DownLoadDownDayNum,
                     @DownLoadOS,
                     @DownLoadServerDataId,
                     @Language,
                     @WarrantType,
                     @DownLoadSize,
                     @RegAddress,
                     @Plugin,
                     @DownLoadStarLevel,
                     @DownLoadDisplePwd,
                     @DownLoadType,
                     @IsAllowComment )
        Set @ID = scope_identity()
    End
  Else
    Begin
        Update Qianbo_DownLoadData
        Set    [ChId] = @ChId,
               [ColId] = @ColId,
               [Title] = @Title,
               [TitleColor] = @TitleColor,
               [TitleFontType] = @TitleFontType,
               [TitleType] = @TitleType,
               [TitleImgPath] = @TitleImgPath,
               [HitCount] = @HitCount,
               [UpdateTime] = @UpdateTime,
               [TemplatePath] = @TemplatePath,
               [PageType] = @PageType,
               [PointCount] = @PointCount,
               [ChargeType] = @ChargeType,
               [ChargeHourCount] = @ChargeHourCount,
               [ChargeViewCount] = @ChargeViewCount,
               [IsOpened] = @IsOpened,
               [GroupIdStr] = @GroupIdStr,
               [IsRecommend] = @IsRecommend,
               [IsTop] = @IsTop,
               [IsFocus] = @IsFocus,
               [IsSideShow] = @IsSideShow,
               [TagIdStr] = @TagIdStr,
               [TagNameStr] = @TagNameStr,
               [SpecialIdStr] = @SpecialIdStr,
               [Content] = @Content,
               [Edition] = @Edition,
               [PlayAddress] = @PlayAddress,
               [DownLoadDownNum] = @DownLoadDownNum,
               [DownLoadDownMonthNum] = @DownLoadDownMonthNum,
               [DownLoadDownWeekNum] = @DownLoadDownWeekNum,
               [DownLoadDownDayNum] = @DownLoadDownDayNum,
               [DownLoadOS] = @DownLoadOS,
               [DownLoadServerDataId] = @DownLoadServerDataId,
               [Language] = @Language,
               [WarrantType] = @WarrantType,
               [DownLoadSize] = @DownLoadSize,
               [RegAddress] = @RegAddress,
               [Plugin] = @Plugin,
               [DownLoadStarLevel] = @DownLoadStarLevel,
               [DownLoadDisplePwd] = @DownLoadDisplePwd,
               [DownLoadType] = @DownLoadType,
               [IsAllowComment] = @IsAllowComment
        Where  [Id] = @Id
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoadServerData_Delete @DownLoadServerDataId Int
As
  Delete Qianbo_DownLoadServerData
  Where  [DownLoadServerDataId] = @DownLoadServerDataId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoadServerData_GetInfo @DownLoadServerDataId Int
As
  Select [DownLoadServerDataId],
         [TypeId],
         [DownLoadServerName],
         [DownLoadServerDir],
         [IsOpened],
         [IsOuter],
         [UnionId],
         [DayDownNum],
         [AllDownNum],
         [AddTime]
  From   Qianbo_DownLoadServerData
  Where  [DownLoadServerDataId] = @DownLoadServerDataId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_DownLoadServerData_GetList @TypeId Int
As
  Select [DownLoadServerDataId],
         D.[TypeId],
         [DownLoadServerName],
         [DownLoadServerDir],
         [IsOpened],
         [IsOuter],
         [UnionId],
         [DayDownNum],
         [AllDownNum],
         [AddTime],
         T.[TypeName],
         T.[TypeId]
  From   Qianbo_DownLoadServerData D
         Join Qianbo_DownLoadServerType T
           On D.TypeId = T.[TypeId]
  Where  D.TypeId = @TypeId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_DownLoadServerData_Set @DownLoadServerDataId Int=0,
                                             @TypeId               Int,
                                             @DownLoadServerName   Nvarchar(100),
                                             @DownLoadServerDir    Nvarchar(100),
                                             @IsOpened             Bit,
                                             @IsOuter              Int,
                                             @UnionId              Text='',
                                             @DayDownNum           Int=0,
                                             @AllDownNum           Int=0,
                                             @AddTime              Datetime
As
  If( @DownLoadServerDataId = 0 )
    Begin
        Insert Into Qianbo_DownLoadServerData
                    ([TypeId],
                     [DownLoadServerName],
                     [DownLoadServerDir],
                     [IsOpened],
                     [IsOuter],
                     [UnionId],
                     [DayDownNum],
                     [AllDownNum],
                     [AddTime])
        Values      ( @TypeId,
                      @DownLoadServerName,
                      @DownLoadServerDir,
                      @IsOpened,
                      @IsOuter,
                      @UnionId,
                      @DayDownNum,
                      @AllDownNum,
                      @AddTime )
        Set @DownLoadServerDataId=Scope_identity()
    End
  Else
    Begin
        Update Qianbo_DownLoadServerData
        Set    [TypeId] = @TypeId,
               [DownLoadServerName] = @DownLoadServerName,
               [DownLoadServerDir] = @DownLoadServerDir,
               [IsOpened] = @IsOpened,
               [IsOuter] = @IsOuter,
               [UnionId] = @UnionId,
               [DayDownNum] = @DayDownNum,
               [AllDownNum] = @AllDownNum,
               [AddTime] = @AddTime
        Where  [DownLoadServerDataId] = @DownLoadServerDataId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoadServerData_SetIsOpened @DownServerId Int,
                                                @IsOpened     Bit
As
  Update Qianbo_DownLoadServerData
  Set    IsOpened = @IsOpened
  Where  DownLoadServerDataId = @DownServerId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoadServerType_Delete @TypeId Int
As
  Delete From Qianbo_DownLoadServerType
  Where  TypeId = @TypeId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoadServerType_GetInfo @TypeId Int
As
  Select *
  From   Qianbo_DownLoadServerType
  Where  typeid = @TypeId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_DownLoadServerType_GetList
As
  Select *
  From   Qianbo_DownLoadServerType
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_DownLoadServerType_Set @TypeId   Int output,
                                             @TypeName Nvarchar(100)
As
  If( @TypeId = 0 )
    Begin
        Insert Into Qianbo_DownLoadServerType
                    ([TypeName])
        Values      ( @TypeName )
    End
  Else
    Begin
        Update Qianbo_DownLoadServerType
        Set    [TypeName] = @TypeName
        Where  [TypeId] = @TypeId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoad_GetAddressPath @serverid  Int,
                                         @addressid Int
As
  Select c.downloadserverdir,
         a.addressPath,
         a.downloaddataid,
         c.isopened
  From   Qianbo_DownLoadAddress a
         Left Join Qianbo_DownLoadServerType b
           On a.downloadserverid = b.typeid
         Left Join Qianbo_DownLoadServerData c
           On b.typeid = c.typeid
  Where  isnull(downloadserverdataid, -1) = @serverid
         And addressid = @addressid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoad_GetDownCount @id   Int,
                                       @type Int
As
  If( @type = 1 )
    Select downloaddownnum
    From   Qianbo_DownLoadData
    Where  [id] = @id
  Else
    If( @type = 2 )
      Select downloaddownmonthnum
      From   Qianbo_DownLoadData
      Where  [id] = @id
    Else
      If( @type = 3 )
        Select downloaddownweeknum
        From   Qianbo_DownLoadData
        Where  [id] = @id
      Else
        Select downloaddowndaynum
        From   Qianbo_DownLoadData
        Where  [id] = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_DownLoad_GetList @SortName    Nvarchar(20)='',
                                       @Keyword     Nvarchar(50)='',
                                       @ChannelId   Int=-1,
                                       @ColumnId    Nvarchar(500)='-1',
                                       @SoftStatus  Varchar(50)='-10',
                                       @IsRecommend Int=-1,
                                       @IsTop       Int=-1,
                                       @UserCateId  Int=-1,
                                       @CurrPage    Int=1,
                                       @PageSize    Int=20,
                                       @UserType    Int=-1,
                                       @RecordCount Int=0 output
As
  Declare @WhereStr Nvarchar(2000);
  Set @WhereStr = '';
  If( @SortName != '' )
    Begin
        Set @WhereStr = @WhereStr + @SortName + ' like ''%' + @Keyword + '%''' + ' and';
    End
  If( @ChannelId !=- 1 )
    Begin
        Set @WhereStr = @WhereStr + ' a.ChId = ' + Convert(Nvarchar(15), @ChannelId) + ' and';
    End
  If( @ColumnId != '-1' )
    Begin
        Set @WhereStr = @WhereStr + ' a.ColId in(' + @ColumnId + ') and';
    End
  If( @SoftStatus != '-10' )
    Begin
        Set @WhereStr = @WhereStr + ' SoftStatus in(' + @SoftStatus + ') and';
    End
  If( @IsRecommend !=- 1 )
    Begin
        Set @WhereStr = @WhereStr + ' SoftIsCommand = ' + Convert(Nvarchar(15), @IsRecommend) + ' and';
    End
  If( @IsTop != -1 )
    Begin
        Set @WhereStr = @WhereStr + ' SoftIsTop = ' + Convert(Nvarchar(15), @IsTop) + ' and';
    End
  If( @UserCateId !=- 1 )
    Begin
        Set @WhereStr = @WhereStr + ' a.UserCateId = ' + Convert(Nvarchar(15), @UserCateId) + ' and ';
    End
  If( @UserType = 0 )
    Begin
        Set @WhereStr = @WhereStr + ' UserType = 0 and '
    End
  Else
    If( @UserType = -1 )
      Begin
          Set @whereStr = @WhereStr + ' SoftStatus != -1 and '
      End
  Set @WhereStr = @WhereStr + ' a.SoftIsDel = 0';
  Declare @SqlStr Nvarchar(2000)
  If( @CurrPage = 1 )
    Set @SqlStr = 'select top ' + Convert(Nvarchar(15), @PageSize) + ' a.*,b.colname from Qianbo_DownLoadData a inner join Qianbo_Column b on a.colid = b.colid where ' + @WhereStr + ' order by a.ID desc'
  Else
    Set @SqlStr = 'select top ' + Convert(Nvarchar(15), @PageSize) + ' a.*,b.colname from Qianbo_DownLoadData a inner join Qianbo_Column b on a.colid = b.colid where ' + @WhereStr + ' and a.ID <(select min(ID) from(select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' ID from Qianbo_DownLoadData a where ' + @WhereStr + ' order by ID desc)O) order by a.ID desc'
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr ='select @TRecord = Count(a.ID) from Qianbo_DownLoadData a inner join Qianbo_Column b on a.colid = b.colid where ' + @WhereStr
  Declare @Parm Nvarchar(50)
  Set @Parm = '@TRecord int output';
  Exec Sp_ExecuteSql
    @SqlStr,
    @Parm,
    @TRecord = @RecordCount output;
  Print @RecordCount
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoad_IsAllowDeleteType @TypeId Int
As
  Select a.[TypeId]
  From   Qianbo_DownLoadServerType a
         Inner Join Qianbo_DownLoadServerData b
           On a.[TypeId] = b.TypeId
  Where  a.[TypeId] = @TypeId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_DownLoad_SetDownCount @id Int
As
  Update Qianbo_DownLoadData
  Set    downloaddownnum = downloaddownnum + 1,
         downloaddownmonthnum = downloaddownmonthnum + 1,
         downloaddownweeknum = downloaddownweeknum + 1,
         downloaddowndaynum = downloaddowndaynum + 1
  Where  [id] = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_EnterPrise_Set @Id       Int output,
                                     @UserId   Int,
                                     @Title    Nvarchar(200),
                                     @Conetent Text,
                                     @AddTime  Nvarchar(50),
                                     @TypeId   Int
As
  If( @Id = 0 )
    Begin
        Insert Into Qianbo_Enterprise
                    ([UserId],
                     [Title],
                     [Conetent],
                     [AddTime],
                     [TypeId])
        Values      ( @UserId,
                      @Title,
                      @Conetent,
                      @AddTime,
                      @TypeId )
        Set @Id = scope_identity()
    End
  Else
    Begin
        Update Qianbo_Enterprise
        Set    [Title] = @Title,
               [Conetent] = @Conetent,
               [TypeId] = @TypeId
        Where  Id = @Id
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Enterprise_Delete @IdStr  Nvarchar(1000),
                                        @UserId Int
As
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'delete Qianbo_Enterprise where [id] in(' + @idstr + ') and userid = @temp_userid'
  Declare @param Nvarchar(400)
  Set @param='@temp_userid int '
  Execute sp_executesql
    @sqlstr,
    @param,
    @temp_userid = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Enterprise_GetById @Id     Int,
                                         @UserId Int
As
  Select *
  From   Qianbo_Enterprise
  Where  [Id] = @Id
         And UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Enterprise_GetByUserId @UserId      Int,
                                        @PageIndex   Int=1,
                                        @PageSize    Int=10,
                                        @RecordCount Int=0 output
As
  Declare @sqlstr Nvarchar(4000)
  If( @PageIndex = 1 )
    Set @sqlstr =N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_Enterprise where UserId = ' + Convert(Nvarchar(15), @UserId) + ' order by Id desc'
  Else
    Set @sqlstr =N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_Enterprise where UserId = ' + Convert(Nvarchar(15), @UserId) + ' and id < (select min(o.id) from(select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' id from Qianbo_Enterprise where UserId = ' + Convert(Nvarchar(15), @UserId) + ' order by Id desc)o) order by Id desc'
  Execute sp_executesql @sqlstr
  Set @sqlstr='select Count(Id) from Qianbo_Enterprise where UserId = ' + Convert(Nvarchar(15), @UserId)
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_ExtendContent_Del @TableName Nvarchar(100),
                                            @FieldId   Int,
                                            @InfoId    Int,
                                            @ChId      Int,
                                            @ColId     Int
As
  Declare @SqlStr Nvarchar(500)
  If( @FieldId = 0 )
    Set @SqlStr=N'delete from [' + @TableName + '] where FieldId = ' + @FieldId + '';
  Else
    Set @SqlStr=N'delete from [' + @TableName + '] where ChId = ' + Convert(Nvarchar(15), @ChId) + ' and ColId = ' + Convert(Nvarchar(15), @ColId) + ' and InfoId = ' + Convert(Nvarchar(15), @InfoId) + '';
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_ExtendContent_List @TableName Nvarchar(50),
                                             @ChId      Int,
                                             @ColId     Int,
                                             @InfoId    Int
As
  Declare @SqlStr Nvarchar(2000);
  Set @SqlStr=N'select * from [' + @TableName + '] where [ChId] = ' + Convert(Nvarchar(15), @ChId) + ' and [ColId] = ' + Convert(Nvarchar(15), @ColId) + ' and [InfoId] = ' + Convert(Nvarchar(15), @InfoId) + '';
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_FeedBack_Add @ParentId   Int,
                                       @title      Nvarchar(100),
                                       @author     Nvarchar(20),
                                       @reward     Int,
                                       @scoring    Int,
                                       @categoryId Int,
                                       @content    Ntext,
                                       @state      Int,
                                       @replyDate  Datetime,
                                       @EndDate    Datetime,
                                       @IP         Nvarchar(15)
As
  Set Xact_Abort On
  Begin Tran
  If @ParentId = 0
    Begin
        Insert Into Qianbo_FeedBack
                    ([ParentId],
                     [title],
                     [author],
                     [reward],
                     [scoring],
                     [categoryId],
                     [content],
                     [state],
                     [replyDate],
                     [EndDate],
                     [IP])
        Values      ( @ParentId,
                      @title,
                      @author,
                      @reward,
                      @scoring,
                      @categoryId,
                      @content,
                      @state,
                      @replyDate,
                      @EndDate,
                      @IP )
    End
  Else
    Begin
        Insert Into Qianbo_FeedBack
                    ([ParentId],
                     [author],
                     [scoring],
                     [content],
                     [replyDate],
                     [IP])
        Values      ( @ParentId,
                      @author,
                      @scoring,
                      @content,
                      @replyDate,
                      @IP )
    End
  Commit Tran
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_FeedBack_Count
As
  Select Count(id) As total
  From   Qianbo_FeedBack
  Where  ParentId = 0
  Select Count(id) As finished
  From   Qianbo_FeedBack
  Where  parentId = 0
         And state = 1
          Or state = 2
  Select Count(id) As answing
  From   Qianbo_FeedBack
  Where  parentId = 0
         And state = 0
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_FeedBack_Delete @FeedBackId Int
As
  Set Xact_Abort On
  Begin Tran
  Delete From Qianbo_FeedBack
  Where  [ID] = @FeedBackId
  If Exists(Select Id
            From   Qianbo_FeedBack
            Where  parentId = @FeedBackId)
    Delete From Qianbo_FeedBack
    Where  parentId = @FeedBackId
  Commit Tran
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_FeedBack_GetFeedBack @FeedBackID Int,
                                               @Type       Int,
                                               @author     Nvarchar(20)
As
  If @Type = 1
    Begin
        Select *
        From   Qianbo_FeedBack
        Where  Id = @FeedBackID
        Select *
        From   Qianbo_FeedBack
        Where  parentId = @FeedBackID
    End
  If @Type = 2
    Begin
        Select author,
               Id
        From   Qianbo_FeedBack
        Where  parentId = @FeedBackID
               And author != @author
    End
  If @Type = 3
    Begin
        Select Top 10 author,
                      scoring,
                      sum(scoring) As [Sum]
        From   Qianbo_FeedBack
        Where  scoring > 0
        Group  By author,
                  scoring
        Order  By scoring Desc
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_FeedBack_GetList @PageSize  Int=20,
                                           @PageIndex Int=1,
                                           @WhereStr  Nvarchar(200)
As
  Declare @SqlStr Nvarchar(2000)
  Declare @fff Nvarchar(200)
  If( @WhereStr = '' )
    Begin
        Set @WhereStr=' where '
        Set @fff=''
    End
  Else
    Begin
        Set @fff=' where ' + @WhereStr
        Set @WhereStr=' where ' + @WhereStr + ' and '
    End
  If( @PageIndex = 1 )
    Set @SqlStr='select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_FeedBack ' + @fff + ' order by [ID] desc'
  Else
    Set @SqlStr='select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_FeedBack  ' + @WhereStr + ' [ID] < (select min(ID) from (select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' * from Qianbo_FeedBack' + @fff + ' order by [ID] desc)F) order by [ID] desc'
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr ='select Count([ID]) from Qianbo_FeedBack ' + @fff
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_FeedBack_UpdateState @Id    Int,
                                               @Type  Int,
                                               @Value Nvarchar(20)
As
  If @Type = 0
    Begin
        Update Qianbo_FeedBack
        Set    State = @Value
        Where  [Id] = @Id
    End
  If @Type = 1
    Begin
        Update Qianbo_FeedBack
        Set    categoryId = @Value
        Where  [Id] = @Id
    End
  If @Type = 2
    Begin
        Update Qianbo_FeedBack
        Set    scoring = @Value
        Where  [Id] = @Id
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Group_Delete @GroupId Int
As
  Declare @IsSystem Int
  Set @IsSystem = (Select IsSystem
                   From   Qianbo_PowerGroup
                   Where  PowerId = @GroupId)
  If( @IsSystem = 1 )
    Begin
        Select 0;
        Return;
    End
  Delete Qianbo_PowerGroup
  Where  PowerId = @GroupId
  Select 1;
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Group_GetAdminGroupUserCount @GroupId Int
As
  Select Count(UserId)
  From   Qianbo_Admin a
         Join Qianbo_PowerGroup b
           On a.GroupId = b.PowerId
  Where  a.GroupId = @GroupId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_HireInfo_Get @Type      Int,
                                   @PageSize  Int=20,
                                   @PageIndex Int=1,
                                   @WhereStr  Nvarchar(2000)
As
  Declare @SqlStr Nvarchar(2000)
  Declare @Filter Nvarchar(2000)
  If( @WhereStr = '' )
    Begin
        Set @WhereStr=' where '
        Set @Filter=''
    End
  Else
    Begin
        Set @Filter=' where ' + @WhereStr
        Set @WhereStr=' where ' + @WhereStr + ' and '
    End
  If( @Type = 1 )
    Begin
        Set @SqlStr = N'select Qianbo_User_Personal.[Sex],[Address],[Phone],[TrueName],[Geographical],[qq],[Email],[Picture],Qianbo_U_Job.[Drection],[Type],Qianbo_U_Job.[Industry],[work],[Posts],[city],Qianbo_U_Job.[Area],[Times],[more],[Money],[Types],Birthday,Height,Degree,experience from Qianbo_User_Personal join Qianbo_U_Job on Qianbo_User_Personal.UId = Qianbo_U_Job.Uid ' + @Filter
        Execute Sp_ExecuteSql @SqlStr
    End
  If( @Type = 2 )
    Begin
        If( @PageIndex = 1 )
          Begin
              Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_HireInfo ' + @Filter + ' order by [Id] desc'
          End
        Else
          Begin
              Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_HireInfo ' + @WhereStr + ' [Id] < (select min(Id) from(select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' * from Qianbo_HireInfo  ' + @Filter + ' order by [Id] desc)O) order by [Id] desc'
          End
        Execute Sp_ExecuteSql @SqlStr
        Set @SqlStr = 'select Count(*) from Qianbo_HireInfo ' + @Filter
        Execute Sp_ExecuteSql @SqlStr
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_HireInfo_Set @Type     Int=1,
                                   @Id       Int=0,
                                   @UserId   Int,
                                   @UserName Nvarchar(20),
                                   @UnitId   Int,
                                   @UnitName Nvarchar(100),
                                   @UserType Int,
                                   @Status   Int,
                                   @AddTime  Datetime,
                                   @JobId    Int
As
  If @Type = 1
    Begin
        If Exists(Select *
                  From   Qianbo_HireInfo
                  Where  UId = @UserId
                         And JobId = @JobId
                         And UserType = @UserType)
          Return
        Else
          Insert Into Qianbo_HireInfo
          Values      (@UserId,
                       @UserName,
                       @UnitId,
                       @UnitName,
                       @UserType,
                       @Status,
                       @AddTime,
                       @JobId)
    End
  Else
    If @Type = 2
      Begin
          Update Qianbo_HireInfo
          Set    Status = @Status
          Where  [Id] = @Id
      End
    Else
      If @Type = 3
        Begin
            Delete From Qianbo_HireInfo
            Where  [Id] = @Id
        End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Image_Add @ChId            Int,
                                @ColId           Int,
                                @Title           Nvarchar(200),
                                @TitleColor      Nvarchar(12),
                                @TitleFontType   Int,
                                @TitleType       Int,
                                @TitleImgPath    Varchar(255),
                                @UId             Int,
                                @UName           Nvarchar(40),
                                @UserType        Int,
                                @AdminUId        Int,
                                @AdminUName      Char(10),
                                @Status          Int,
                                @HitCount        Int,
                                @AddTime         Datetime,
                                @UpdateTime      Datetime,
                                @TemplatePath    Varchar(255),
                                @PageType        Int,
                                @IsCreated       Bit,
                                @UserCateId      Int,
                                @PointCount      Int,
                                @ChargeType      Int,
                                @ChargeHourCount Int,
                                @ChargeViewCount Int,
                                @IsOpened        Int,
                                @GroupIdStr      Varchar(200),
                                @IsDeleted       Bit,
                                @IsRecommend     Bit,
                                @IsTop           Bit,
                                @IsFocus         Bit,
                                @IsSideShow      Bit,
                                @TagIdStr        Varchar(300),
                                @IsAllowComment  Bit,
                                @TagNameStr      Nvarchar(600),
                                @SpecialIdStr    Varchar(200),
                                @Content         Ntext,
                                @ImgPath         Ntext,
                                @Identity        Int=0 output
As
  Insert Into Qianbo_Image
              ([ChId],
               [ColId],
               [Title],
               [TitleColor],
               [TitleFontType],
               [TitleType],
               [TitleImgPath],
               [UId],
               [UName],
               [UserType],
               [AdminUId],
               [AdminUName],
               [Status],
               [HitCount],
               [AddTime],
               [UpdateTime],
               [TemplatePath],
               [PageType],
               [IsCreated],
               [UserCateId],
               [PointCount],
               [ChargeType],
               [ChargeHourCount],
               [ChargeViewCount],
               [IsOpened],
               [GroupIdStr],
               [IsDeleted],
               [IsRecommend],
               [IsTop],
               [IsFocus],
               [IsSideShow],
               [TagIdStr],
               [IsAllowComment],
               [TagNameStr],
               [SpecialIdStr],
               [Content],
               [ImgPath])
  Values      (@ChId,
               @ColId,
               @Title,
               @TitleColor,
               @TitleFontType,
               @TitleType,
               @TitleImgPath,
               @UId,
               @UName,
               @UserType,
               @AdminUId,
               @AdminUName,
               @Status,
               @HitCount,
               @AddTime,
               @UpdateTime,
               @TemplatePath,
               @PageType,
               @IsCreated,
               @UserCateId,
               @PointCount,
               @ChargeType,
               @ChargeHourCount,
               @ChargeViewCount,
               @IsOpened,
               @GroupIdStr,
               @IsDeleted,
               @IsRecommend,
               @IsTop,
               @IsFocus,
               @IsSideShow,
               @TagIdStr,
               @IsAllowComment,
               @TagNameStr,
               @SpecialIdStr,
               @Content,
               @ImgPath )
  Select @Identity = scope_identity()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Image_Update @ChId            Int,
                                   @Id              Int,
                                   @ColId           Int,
                                   @Title           Nvarchar(200),
                                   @TitleColor      Nvarchar(12),
                                   @TitleFontType   Int,
                                   @TitleType       Int,
                                   @TitleImgPath    Varchar(255),
                                   @UId             Int,
                                   @UName           Nvarchar(40),
                                   @UserType        Int,
                                   @AdminUId        Int,
                                   @AdminUName      Char(10),
                                   @Status          Int,
                                   @HitCount        Int,
                                   @AddTime         Datetime,
                                   @UpdateTime      Datetime,
                                   @TemplatePath    Varchar(255),
                                   @PageType        Int,
                                   @IsCreated       Bit,
                                   @UserCateId      Int,
                                   @PointCount      Int,
                                   @ChargeType      Int,
                                   @ChargeHourCount Int,
                                   @ChargeViewCount Int,
                                   @IsOpened        Int,
                                   @GroupIdStr      Varchar(200),
                                   @IsDeleted       Bit,
                                   @IsRecommend     Bit,
                                   @IsTop           Bit,
                                   @IsFocus         Bit,
                                   @IsSideShow      Bit,
                                   @TagIdStr        Varchar(300),
                                   @IsAllowComment  Bit,
                                   @TagNameStr      Nvarchar(600),
                                   @SpecialIdStr    Varchar(200),
                                   @Content         Ntext,
                                   @ImgPath         Ntext
As
  Update Qianbo_Image
  Set    [ChId] = @ChId,
         [ColId] = @ColId,
         [Title] = @Title,
         [TitleColor] = @TitleColor,
         [TitleFontType] = @TitleFontType,
         [TitleType] = @TitleType,
         [TitleImgPath] = @TitleImgPath,
         [UId] = @UId,
         [UName] = @UName,
         [UserType] = @UserType,
         [AdminUId] = @AdminUId,
         [AdminUName] = @AdminUName,
         [Status] = @Status,
         [HitCount] = @HitCount,
         [AddTime] = @AddTime,
         [UpdateTime] = @UpdateTime,
         [TemplatePath] = @TemplatePath,
         [PageType] = @PageType,
         [IsCreated] = @IsCreated,
         [UserCateId] = @UserCateId,
         [PointCount] = @PointCount,
         [ChargeType] = @ChargeType,
         [ChargeHourCount] = @ChargeHourCount,
         [ChargeViewCount] = @ChargeViewCount,
         [IsOpened] = @IsOpened,
         [GroupIdStr] = @GroupIdStr,
         [IsDeleted] = @IsDeleted,
         [IsRecommend] = @IsRecommend,
         [IsTop] = @IsTop,
         [IsFocus] = @IsFocus,
         [IsSideShow] = @IsSideShow,
         [TagIdStr] = @TagIdStr,
         [IsAllowComment] = @IsAllowComment,
         [TagNameStr] = @TagNameStr,
         [SpecialIdStr] = @SpecialIdStr,
         [Content] = @Content,
         [ImgPath] = @ImgPath
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_InfoModel_GetTextType @ModelId Int
As
  Select ModelId,
         [Name],
         Type
  From   [Qianbo_ModelField]
  Where  [ModelId] = @ModelId
         And [Type] = 'MultipleHtmlType'
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_AddHitCount @tablename Nvarchar(50),
                                       @id        Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'update [' + @tablename + '] set hitcount = hitcount + 1 where id = ' + Convert(Nvarchar(15), @id)
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_Auditing @tablename Nvarchar(50),
                                    @id        Int,
                                    @status    Int,
                                    @adminid   Int,
                                    @adminname Nvarchar(20)
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'update [' + @tablename + '] set [status] = @tstatus,[adminuname] = @tadminname,[adminuid] = @tadminid where id = @tid and status in(0,1,2)'
  Declare @param Nvarchar(1000)
  Set @param ='@tid int,@tstatus int,@tadminid int,@tadminname nvarchar(20)'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tid = @id,
    @tstatus = @status,
    @tadminid = @adminid,
    @tadminname = @adminname
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_Cancel @tablename Nvarchar(50),
                                  @id        Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'update [' + @tablename + '] set [status] = -2 where id = @tid';
  Declare @param Nvarchar(50)
  Set @param = '@tid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tid = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Info_CompleteDeleteInfo @tablename Nvarchar(50),
                                         @id        Int
As
  Declare @sqlstr Nvarchar(2000)
  Declare @param Nvarchar(200)
  Set @param='@tid int'
  Set @sqlstr = 'delete from [' + @tablename + '] where [id] = @tid'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tid = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_DeleteToRecycle @idstr     Nvarchar(2000),
                                           @tablename Nvarchar(50)
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = N'update [' + @tablename + '] set isdeleted = 1 where [id] in (' + @idstr + ')';
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_GetHitCount @tablename Nvarchar(50),
                                       @id        Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'select hitcount from [' + @tablename + '] where id = ' + Convert(Nvarchar(15), @id)
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_GetInfo @tablename Nvarchar(50),
                                   @id        Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr='select t.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname from [' + @tablename + '] t inner join Qianbo_Column co on t.ColId = co.ColId inner join Qianbo_Channel ch on t.ChId = ch.ChId inner join Qianbo_Model m on ch.ModelType = m.ModelId where t.Id = @tid';
  Declare @param Nvarchar(200)
  Set @param='@tid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tid = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_GetInfoCount @tablename Nvarchar(50),
                                        @wherestr  Nvarchar(2000)
As
  Declare @sqlstr Nvarchar(4000)
  If( @wherestr = '' )
    Begin
        Set @sqlstr = 'select Count([id]) from [' + @tablename + ']'
    End
  Else
    Begin
        Set @sqlstr = 'select Count([id]) from [' + @tablename + '] where ' + @wherestr
    End
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_GetInfoList @tableName     Nvarchar(50)='',
                                       @fieldName     Nvarchar(20)='',
                                       @keyword       Nvarchar(50)='',
                                       @chid          Int,
                                       @colidstr      Nvarchar(3000)='',
                                       @status        Varchar(50)='-99',
                                       @property      Varchar(50)='',
                                       @propertytype  Varchar(10)='=',
                                       @propertyvalue Varchar(50)='',
                                       @usertype      Int=-1,
                                       @pageindex     Int=1,
                                       @pagesize      Int=20,
                                       @recordcount   Int=0 output
As
  Declare @wherestr Nvarchar(4000)
  Set @wherestr = '';
  If( @tablename = '' )
    Return;
  If( @fieldname != '' )
    Set @wherestr = @wherestr + ' i.' + @fieldname + ' like ''%' + @keyword + '%'' and ';
  If( @chid != 0 )
    Set @wherestr = @wherestr + ' co.chid = ' + Convert(Nvarchar(15), @chid) + ' and ';
  If( @colidstr != '0' )
    Set @wherestr = @wherestr + ' i.colId in(' + @colidstr + ') and ';
  If( @status != '-99' )
    Set @wherestr = @wherestr + ' i.status in(' + @status + ') and ';
  If( @property != ''
      And @propertytype != ''
      And @propertyvalue != '' )
    Set @wherestr = @wherestr + ' i.' + @property + @propertytype + @propertyvalue + ' and ';
  If( @usertype !=- 1 )
    Set @wherestr = @wherestr + ' i.usertype=' + Convert(Nvarchar(15), @usertype) + ' and '
  Set @wherestr = @wherestr + ' i.status != -1 and i.isdeleted = 0'
  Declare @selectfield Nvarchar(500)
  Set @selectfield = ' co.colname,i.[id],i.title,i.titletype,i.colid,i.uname,i.usertype,i.hitcount,i.issideshow,i.istop,i.isrecommend,i.isfocus,i.status,i.iscreated '
  Declare @selecttable Nvarchar(500)
  Set @selecttable = @tablename + ' i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on ch.chid = co.chid '
  Declare @sqlstr Nvarchar(4000)
  If( @pageindex = 1 )
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @selectfield + ' from ' + @selecttable + ' where ' + @wherestr + ' order by i.[id] desc';
  Else
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @PageSize) + @selectfield + ' from ' + @selecttable + ' where ' + @wherestr + ' and i.[id] < (select min(O.[id]) from(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from ' + @selecttable + ' where ' + @wherestr + ' order by i.[id] desc)O) order by i.[id] desc'
  Execute sp_executesql @sqlstr
  Set @sqlstr ='select Count(i.[id]) from ' + @selecttable + ' where ' + @wherestr
  Execute sp_executesql @sqlstr;
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Info_GetInfo_CustomForm @tablename Nvarchar(50),
                                              @id        Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr='select * from [' + @tablename + '] where [id] = @tid';
  Declare @param Nvarchar(200)
  Set @param='@tid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tid = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_GetRecycleInfoList @tablename Nvarchar(50),
                                              @type      Int,
                                              @pageindex Int=1,
                                              @pagesize  Int=20
As
  Declare @sqlstr Nvarchar(2000)
  Declare @countstr Nvarchar(2000)
  If( @type = 1 )
    Begin
        Set @sqlstr = 'select chid as id,chname,description,addtime from Qianbo_Channel where isdeleted = 1'
        Set @countstr = 'select Count(*) from Qianbo_Channel where isdeleted = 1'
    End
  Else
    If( @type = 2 )
      Begin
          Set @sqlstr = 'select colid as id,colname,co.description,co.chid,colparentid,chname from Qianbo_Column co join Qianbo_Channel ch on co.chid = ch.chid where co.isdeleted = 1'
          Set @countstr = 'select Count(*) from Qianbo_Column co join Qianbo_Channel ch on co.chid = ch.chid where co.isdeleted = 1'
      End
    Else
      If( @type = 3 )
        Begin
            If( @pageindex = 1 )
              Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + ' id,specialcname,specialdomain,specialremark,specialaddtime,parentid from Qianbo_Special where isdeleted = 1 order by id desc'
            Else
              Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + ' id,specialcname,specialdomain,specialremark,specialaddtime,parentid from Qianbo_Special where isdeleted = 1 and id < (select min(id) from(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' id from Qianbo_Special where isdeleted = 1 order by id desc)o) order by id desc'
            Set @countstr = 'select Count(*) from Qianbo_Special where isdeleted = 1'
        End
      Else
        If( @type = 4 )
          Begin
              If( @tablename = '' )
                Return;
              If( @pageindex = 1 )
                Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + ' co.colname,i.[id],i.colid,i.title,i.addtime from [' + @tablename + '] i join Qianbo_Column co on i.colid = co.colid where i.[isdeleted] = 1 order by id desc'
              Else
                Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + ' co.colname,i.[id],i.colid,i.title,i.addtime from [' + @tablename + '] i join Qianbo_Column co on i.colid = co.colid where i.[isdeleted] = 1 and i.[id] < (select min(id) from(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' id from [' + @tablename + '] i join Qianbo_Column co on i.colid = co.colid  where i.isdeleted = 1 order by id desc)o) order by id desc'
              Set @countstr = 'select Count(*) from [' + @tablename + '] i join Qianbo_Column co on i.colid = co.colid where i.isdeleted = 1'
          End
  Execute sp_executesql @sqlstr
  Execute sp_executesql @countstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_GetUserInfo @tablename Nvarchar(50),
                                       @UserId    Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr='select * from [' + @tablename + '] where [UId] = @tid';
  Declare @param Nvarchar(200)
  Set @param='@tid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tid = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_MassMoveInfo @tablename   Nvarchar(20),
                                        @idstr       Varchar(2000),
                                        @colid       Int,
                                        @targetcolid Int
As
  If( @tablename = '' )
    Return;
  Declare @sqlstr Nvarchar(4000)
  Declare @wherestr Nvarchar(400)
  If( @idstr = '' )
    Set @wherestr = ' where colid = @tcolid'
  Else
    Set @wherestr = ' where [id] in(' + @idstr + ')'
  Set @sqlstr = 'update [' + @tablename + '] set colid = @ttargetcolid ' + @wherestr
  Declare @param Nvarchar(400)
  Set @param = '@ttargetcolid int,@tcolid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @ttargetcolid = @targetcolid,
    @tcolid = @colid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_MassSetInfo @tablename           Nvarchar(50),
                                       @idstr               Varchar(2000),
                                       @colid               Int,
                                       @tagflag             Bit,
                                       @tagidstr            Nvarchar(300),
                                       @tagnamestr          Nvarchar(300),
                                       @topflag             Bit,
                                       @istop               Bit,
                                       @recommendflag       Bit,
                                       @isrecommend         Bit,
                                       @focusflag           Bit,
                                       @isfocus             Bit,
                                       @templatepathflag    Bit,
                                       @templatepath        Varchar(255),
                                       @hitcountflag        Bit,
                                       @hitcount            Int,
                                       @isopenedflag        Bit,
                                       @isopened            Int,
                                       @groupidstrflag      Bit,
                                       @groupidstr          Varchar(1000),
                                       @pointcountflag      Bit,
                                       @pointcount          Int,
                                       @chargetypeflag      Bit,
                                       @chargetype          Int,
                                       @chargehourcountflag Bit,
                                       @chargehourcount     Int,
                                       @chargeviewcountflag Bit,
                                       @chargeviewcount     Int,
                                       @pagetypeflag        Bit,
                                       @pagetype            Int
As
  If( @tablename = '' )
    Return;
  Declare @sqlstr Nvarchar(4000)
  Declare @param Nvarchar(4000)
  Declare @wherestr Nvarchar(2000)
  Set @wherestr=''
  Declare @setstr Nvarchar(4000)
  Set @setstr = ''
  Declare @char Varchar(1)
  Set @char=''
  If( @idstr = '' )
    Set @wherestr = ' where i.colid = @tcolid ';
  Else
    Set @wherestr = ' where i.[id] in(' + @idstr + ')'
  If( @tagflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.tagidstr = @ttagidstr,i.tagnamestr = @ttagnamestr'
        Set @char = ','
    End
  If( @topflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.istop = @tistop'
        Set @char=','
    End
  If( @recommendflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.isrecommend = @tisrecommend'
        Set @char=','
    End
  If( @focusflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.isfocus = @tisfocus'
        Set @char=','
    End
  If( @templatepathflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.templatepath = @ttemplatepath'
        Set @char=','
    End
  If( @hitcountflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.hitcount = @thitcount'
        Set @char=','
    End
  If( @isopenedflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.isopened = @tisopened'
        Set @char=','
    End
  If( @groupidstrflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.groupidstr = @tgroupidstr'
        Set @char=','
    End
  If( @pointcountflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.pointcount = @tpointcount'
        Set @char=','
    End
  If( @chargetypeflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.chargetype = @tchargetype'
        Set @char=','
    End
  If( @chargehourcountflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.chargehourcount = @tchargehourcount'
        Set @char=','
    End
  If( @chargeviewcountflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.chargeviewcount = @tchargeviewcount'
        Set @char=','
    End
  If( @pagetypeflag = 1 )
    Begin
        Set @setstr = @setstr + @char + 'i.pagetype = @tpagetype'
    End
  If( @setstr = '' )
    Return;
  Set @sqlstr='update i set ' + @setstr + ' from [' + @tablename + ' ] i ' + @wherestr
  Set @param = '@ttagidstr nvarchar(300),@ttagnamestr nvarchar(300),@tistop bit,@tisrecommend bit,@tisfocus bit,@ttemplatepath varchar(255),@thitcount int,@tisopened int,@tgroupidstr varchar(1000),@tpointcount int,@tchargetype int,@tchargehourcount int,@tchargeviewcount int,@tpagetype int,@tcolid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @ttagidstr = @tagidstr,
    @ttagnamestr = @tagnamestr,
    @tistop = @istop,
    @tisrecommend = @isrecommend,
    @tisfocus = @isfocus,
    @ttemplatepath = @templatepath,
    @thitcount = @hitcount,
    @tisopened = @isopened,
    @tgroupidstr = @groupidstr,
    @tpointcount = @pointcount,
    @tchargetype = @chargetype,
    @tchargehourcount = @chargehourcount,
    @tchargeviewcount = @chargeviewcount,
    @tpagetype = @pagetype,
    @tcolid = @colid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_SetInfoSpecial @tablename    Nvarchar(50),
                                          @id           Int,
                                          @specialidstr Varchar(500)
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'update [' + @tablename + '] set [specialidstr] = @tspecialidstr where [id] = @tid'
  Declare @param Nvarchar(2000)
  Set @param = '@tspecialidstr varchar(5000),@tid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tspecialidstr = @specialidstr,
    @tid = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_SetProperty @tablename     Nvarchar(50),
                                       @property      Nvarchar(50),
                                       @propertyvalue Nvarchar(50),
                                       @id            Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'update ' + @tablename + ' set [' + @property + '] = ' + @propertyvalue + ' where [id] = ' + Convert(Nvarchar(15), @id);
  Exec sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_UpdateIsCreated @tablename Nvarchar(50),
                                           @id        Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'update [' + @tablename + '] set iscreated=1 where [id] = ' + Convert(Nvarchar(15), @id)
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_User_DeleteInfo @idstr     Nvarchar(2000),
                                           @tablename Nvarchar(50),
                                           @uid       Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'delete from [' + @tablename + '] where [id] in (' + @idstr + ') and [uId] = @tuid and usertype = 0 and status = -1';
  Declare @param Nvarchar(200)
  Set @param = '@tuid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tuid = @uid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_User_GetInfoList @tableName     Nvarchar(50)='',
                                            @uid           Int,
                                            @fieldName     Nvarchar(20)='',
                                            @keyword       Nvarchar(50)='',
                                            @chid          Int,
                                            @colidstr      Nvarchar(500)='',
                                            @status        Varchar(50)='-99',
                                            @property      Varchar(50)='',
                                            @propertytype  Varchar(10)='=',
                                            @propertyvalue Varchar(50)='',
                                            @usercateid    Int=-1,
                                            @pageindex     Int=1,
                                            @pagesize      Int=20,
                                            @recordcount   Int=0 output
As
  If( @tablename = '' )
    Return;
  Declare @wherestr Nvarchar(2000)
  Set @wherestr = ' i.uid = ' + Convert(Nvarchar(15), @uid) + ' and usertype = 0 and ';
  If( @fieldname != '' )
    Set @wherestr = @wherestr + ' i.' + @fieldname + ' like ''%' + @keyword + '%'' and ';
  If( @chid != 0 )
    Set @wherestr = @wherestr + ' co.chid = ' + Convert(Nvarchar(15), @chid) + ' and ';
  If( @colidstr != '0' )
    Set @wherestr = @wherestr + ' i.colId in(' + @colidstr + ') and ';
  If( @status != '-99' )
    Set @wherestr = @wherestr + ' i.status in(' + @status + ') and ';
  If( @property != ''
      And @propertyType != ''
      And @propertyvalue != '' )
    Set @wherestr = @wherestr + ' i.' + @property + @propertyType + @propertyvalue + ' and ';
  If( @usercateid !=- 1 )
    Set @wherestr = @wherestr + ' i.usercateid=' + Convert(Nvarchar(15), @usercateid) + ' and '
  Set @wherestr = @wherestr + ' i.isdeleted = 0 '
  Declare @selectfield Nvarchar(500)
  Set @selectfield = ' ch.chid,ch.modeltype,ch.minihitcount,co.colname,i.[id],i.title,i.titletype,i.colid,i.uname,i.usertype,i.hitcount,i.issideshow,i.istop,i.isrecommend,i.isfocus,i.status,i.addtime '
  Declare @selecttable Nvarchar(500)
  Set @selecttable = @tablename + ' i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on ch.chid = co.chid '
  Declare @sqlstr Nvarchar(4000)
  If( @pageindex = 1 )
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @selectfield + ' from ' + @selecttable + ' where ' + @wherestr + ' order by i.[id] desc';
  Else
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @PageSize) + @selectfield + ' from ' + @selecttable + ' where ' + @wherestr + ' and i.[id] < (select min(O.[id]) from(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from ' + @selecttable + ' where ' + @wherestr + ' order by i.[id] desc)O) order by i.[id] desc'
  Execute sp_executesql @sqlstr
  Set @sqlstr ='select Count(i.[id]) from ' + @selecttable + ' where ' + @wherestr
  Execute sp_executesql @sqlstr;
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Info_User_IsExistsInfo @tableName Nvarchar(50),
                                             @UId       Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr='if exists(select 1 from ' + @tableName + ' where status = 3 and isdeleted = 0 and UId = ' + Convert(Nvarchar(15), @UId) + ') select 1 else select 0'
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Info_User_Publish @tablename Nvarchar(50),
                                   @id        Int,
                                   @uId       Int
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr = 'update [' + @tablename + '] set status = 0 where [id] = @tid and [uid] = @tuid and usertype = 0 and status = -1'
  Declare @param Nvarchar(200)
  Set @param = '@tid int,@tuid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tid = @id,
    @tuid = @uid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LabelContent_ConByName @Name Nvarchar(50)
As
  Select Content
  From   Qianbo_LabelContent
  Where  Name = @Name
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LabelContent_Delete @LabelCategoryID Nvarchar(500)
As
  Declare @SqlStr Nvarchar(2000)
  Set @SqlStr = N'delete Qianbo_LabelContent where [LabelCategoryID] in (' + @LabelCategoryID + ')'
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LabelContent_GetContent @LabelCategoryID Int
As
  Select Content
  From   Qianbo_LabelContent
  Where  LabelCategoryID = @LabelCategoryID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LabelContent_GetInfo @LabelCategoryID Int
As
  Select [LabelCategoryID],
         [Name],
         [Content],
         [LbCategoryId],
         [ModeType],
         [AnomalyStyle]
  From   Qianbo_LabelContent
  Where  [LabelCategoryID] = @LabelCategoryID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LabelContent_GetLabelByModelId @modelId Int
As
  Select *
  From   Qianbo_LabelContent
  Where  ModeType = @modelId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_LabelContent_GetLbCategoryIdList @LbCategoryId Int,
                                                  @CursorPage   Int,
                                                  @PageSize     Int,
                                                  @RecordCount  Int output
As
  Declare @SqlStr Nvarchar(2000);
  If( @CursorPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_LabelContent where LbCategoryId = ' + Convert(Nvarchar(50), @LbCategoryId) + ' order by LabelCategoryID desc'
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_LabelContent where LbCategoryId = ' + Convert(Nvarchar(50), @LbCategoryId) + 'and LabelCategoryID < (select min(LabelCategoryID) from(select top ' + Convert(Nvarchar(15), (@CursorPage - 1) * @PageSize) + ' LabelCategoryID from Qianbo_LabelContent where LbCategoryId = ' + Convert(Nvarchar(50), @LbCategoryId) + ' order by LabelCategoryID desc)O)order by LabelCategoryID desc'
  Execute SP_ExecuteSql @SqlStr
  Set @SqlStr = N'select @TRecordCount = Count(LabelCategoryID) from Qianbo_LabelContent where LbCategoryId = ' + Convert(Nvarchar(50), @LbCategoryId);
  Declare @Param Nvarchar(50)
  Set @Param = N'@TRecordCount int output'
  Execute SP_ExecuteSql
    @SqlStr,
    @Param,
    @TRecordCount = @RecordCount output
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Proc Proc_LabelContent_GetLbCategoryNameList @labelName   Nvarchar(200),
                                                    @CursorPage  Int,
                                                    @PageSize    Int,
                                                    @RecordCount Int output
As
  Declare @SqlStr Nvarchar(2000);
  If( @CursorPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_LabelContent where [Name] like @tlabelName order by LabelCategoryID desc'
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_LabelContent where [Name] like @tlabelName and LabelCategoryID < (select min(LabelCategoryID) from(select top ' + Convert(Nvarchar(15), (@CursorPage - 1) * @PageSize) + ' LabelCategoryID from Qianbo_LabelContent where [Name] like @tlabelName order by LabelCategoryID desc)O)order by LabelCategoryID desc'
  Declare @paramlb Nvarchar(500)
  Set @paramlb=N'@tlabelName Nvarchar(200)'
  Execute Sp_executeSql
    @SqlStr,
    @paramlb,
    @tlabelName = @labelName
  Set @RecordCount=(Select Count(LabelCategoryID)
                    From   Qianbo_LabelContent
                    Where  [Name] Like @labelName)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LabelContent_GetList
As
  Select *
  From   [Qianbo_LabelContent]
  Order  By LabelCategoryID Desc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LabelContent_Set @LabelCategoryID Int,
                                       @Name            Nvarchar(100),
                                       @Content         Text,
                                       @LbCategoryId    Int,
                                       @ModeType        Int,
                                       @AnomalyStyle    Text
As
  If( @LabelCategoryID <= 0 )
    Begin
        Insert Into Qianbo_LabelContent
                    ([Name],
                     [Content],
                     [LbCategoryId],
                     [ModeType],
                     [AnomalyStyle])
        Values      (@Name,
                     @Content,
                     @LbCategoryId,
                     @ModeType,
                     @AnomalyStyle)
    End
  Else
    Begin
        Update Qianbo_LabelContent
        Set    [Name] = @Name,
               [Content] = @Content,
               [LbCategoryId] = @LbCategoryId,
               [ModeType] = @ModeType,
               [AnomalyStyle] = @AnomalyStyle
        Where  [LabelCategoryID] = @LabelCategoryID
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LabelContent_UpdateModelId @oldmodelid Int,
                                                 @newmodelid Int
As
  Update Qianbo_LabelContent
  Set    ModeType = @newmodelid
  Where  ModeType = @oldmodelid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LbCategory_Add @LbCategoryID Int output,
                                     @Name         Nvarchar(100),
                                     @ParentID     Int,
                                     @Desc         Nvarchar(200)
As
  Insert Into Qianbo_LbCategory
              ([Name],
               [ParentID],
               [Desc])
  Values      ( @Name,
                @ParentID,
                @Desc )
  Set @LbCategoryID = @@identity
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LbCategory_Delete @LbCategoryID Int
As
  Delete Qianbo_LbCategory
  Where  [LbCategoryID] = @LbCategoryID
          Or ParentID = @LbCategoryID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LbCategory_GetIdData @LbCategoryID Int
As
  Select [Name],
         [ParentID],
         [Desc]
  From   Qianbo_LbCategory
  Where  [LbCategoryID] = @LbCategoryID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LbCategory_GetParentIDList @ParentID Int
As
  Select [LbCategoryID],
         [Name],
         [ParentID],
         [Desc]
  From   Qianbo_LbCategory
  Where  [ParentID] = @ParentID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LbCategory_ID
As
  Select *
  From   Qianbo_LbCategory
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LbCategory_Update @LbCategoryID Int,
                                        @Name         Nvarchar(100),
                                        @ParentID     Int,
                                        @Desc         Nvarchar(200)
As
  Update Qianbo_LbCategory
  Set    [Name] = @Name,
         [ParentID] = @ParentID,
         [Desc] = @Desc
  Where  [LbCategoryID] = @LbCategoryID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_LbContent_DeleteLbCategoryId @lbCategoryID Int
As
  Delete From Qianbo_LabelContent
  Where  LbCategoryId = @lbCategoryID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Link_Add @LinkType     Int,
                               @LinkCategory Nvarchar(40),
                               @SiteName     Nvarchar(100),
                               @SiteUrl      Varchar(255),
                               @SiteLogo     Varchar(255),
                               @OwnerName    Nvarchar(100),
                               @Email        Nvarchar(100),
                               @Description  Nvarchar(400),
                               @AddTime      Datetime,
                               @Status       Int,
                               @IsDisable    Bit
As
  Insert Into Qianbo_Link
              ([LinkType],
               [LinkCategory],
               [SiteName],
               [SiteUrl],
               [SiteLogo],
               [OwnerName],
               [Email],
               [Description],
               [AddTime],
               [Status],
               [IsDisable])
  Values      ( @LinkType,
                @LinkCategory,
                @SiteName,
                @SiteUrl,
                @SiteLogo,
                @OwnerName,
                @Email,
                @Description,
                @AddTime,
                @Status,
                @IsDisable )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Link_GetList (@PageSize    Int=20,
                                    @PageIndex   Int=1,
                                    @WhereString Nvarchar(200))
As
  Begin
      Declare @SqlStr Nvarchar(2000)
      Declare @Filter Nvarchar(200)
      If( @WhereString = '' )
        Begin
            Set @WhereString=' where '
            Set @Filter=''
        End
      Else
        Begin
            Set @Filter=' where ' + @WhereString
            Set @WhereString=' where ' + @WhereString + ' and '
        End
      If( @PageIndex = 1 )
        Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_Link ' + @Filter + ' order by LinkId desc'
      Else
        Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_Link ' + @WhereString + ' LinkId < (select min(LinkId) from(select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' * from Qianbo_Link  ' + @Filter + ' order by LinkId desc)L) order by LinkId desc'
  End
Print @SqlStr
Execute Sp_ExecuteSql @SqlStr
Set @SqlStr ='select Count(LinkId) as Total from Qianbo_Link ' + @Filter
Exec Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Link_GetModel @LinkId Int
As
  Select [LinkId],
         [LinkType],
         [LinkCategory],
         [SiteName],
         [SiteUrl],
         [SiteLogo],
         [OwnerName],
         [Email],
         [Description],
         [AddTime],
         [Status],
         [IsDisable]
  From   Qianbo_Link
  Where  [LinkId] = @LinkId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Link_Set @LinkId Int,
                               @Type   Int
As
  If( @Type = 1 )
    Begin
        Delete Qianbo_Link
        Where  [LinkId] = @LinkId
    End
  If( @Type = 2 )
    Begin
        Update Qianbo_Link
        Set    Status = 2
        Where  LinkId = @LinkId
    End
  If( @Type = 3 )
    Begin
        Update Qianbo_Link
        Set    IsDisable = 1
        Where  LinkId = @LinkId
    End
  If( @Type = 4 )
    Begin
        Update Qianbo_Link
        Set    IsDisable = 0
        Where  LinkId = @LinkId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Link_Update @LinkId       Int,
                                  @LinkType     Int,
                                  @LinkCategory Nvarchar(40),
                                  @SiteName     Nvarchar(100),
                                  @SiteUrl      Varchar(255),
                                  @SiteLogo     Varchar(255),
                                  @OwnerName    Nvarchar(100),
                                  @Email        Nvarchar(100),
                                  @Description  Nvarchar(400),
                                  @AddTime      Datetime,
                                  @Status       Int,
                                  @IsDisable    Bit
As
  Update Qianbo_Link
  Set    [LinkType] = @LinkType,
         [LinkCategory] = @LinkCategory,
         [SiteName] = @SiteName,
         [SiteUrl] = @SiteUrl,
         [SiteLogo] = @SiteLogo,
         [OwnerName] = @OwnerName,
         [Email] = @Email,
         [Description] = @Description,
         [AddTime] = @AddTime,
         [Status] = @Status,
         [IsDisable] = @IsDisable
  Where  [LinkId] = @LinkId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Log_Add @LogType     Int,
                              @UserName    Nvarchar(20),
                              @UserId      Int,
                              @Description Nvarchar(100),
                              @IpAddress   Varchar(15),
                              @LogTime     Datetime
As
  Insert Into Qianbo_Log
              (LogType,
               UserName,
               UserId,
               Description,
               IpAddress,
               LogTime)
  Values      (@LogType,
               @UserName,
               @UserId,
               @Description,
               @IpAddress,
               @LogTime)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Log_Delete @LogTime Datetime
As
  Delete From Qianbo_Log
  Where  LogTime < @LogTime
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Log_GetList @LogType     Int,
                                  @UserName    Nvarchar(20),
                                  @StartTime   Varchar(10),
                                  @EndTime     Varchar(10),
                                  @CurrPage    Int,
                                  @PageSize    Int,
                                  @RecordCount Int Output
As
  Declare @SqlStr Nvarchar(2000);
  Declare @WhereStr Nvarchar(500);
  Set @WhereStr = '';
  If( @LogType != 0 )
    Set @WhereStr = @WhereStr + N' LogType = ' + Convert(Nvarchar(5), @LogType) + ' and ';
  If( @UserName != '' )
    Set @WhereStr = @WhereStr + N' UserName = ''' + @UserName + ''' and ';
  If( @StartTime != ' '
      And @EndTime != '' )
    Set @WhereStr = @WhereStr + N' LogTime >= ''' + @StartTime + ''' and LogTime <  ''' + @EndTime + ''' and '
  If( @StartTime != ''
      And @EndTime = '' )
    Set @WhereStr = @WhereStr + N' LogTime >= ''' + @StartTime + ''' and '
  If( @StartTime = ''
      And @EndTime != '' )
    Set @WhereStr = @WhereStr + N' LogTime < ''' + @EndTime + ''' and '
  Set @WhereStr = @WhereStr + N' 1=1 '
  If( @CurrPage = 1 )
    Set @SqlStr = N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_Log where ' + @WhereStr + ' order by LogId desc ';
  Else
    Set @SqlStr = N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_Log where LogId < (select min(LogId) from(select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' LogId from Qianbo_Log where ' + @WhereStr + ' order by LogId desc)O) and ' + @WhereStr + ' order by LogId desc'
  Execute SP_ExecuteSql @SqlStr
  Set @SqlStr = N'select @TRecordCount = Count(LogId) from Qianbo_Log where ' + @WhereStr;
  Declare @Param Nvarchar(50)
  Set @Param = N'@TRecordCount int output'
  Execute SP_ExecuteSql
    @SqlStr,
    @Param,
    @TRecordCount = @RecordCount output
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_Add @ModelId      Int,
                                     @Name         Nvarchar(100),
                                     @Alias        Nvarchar(300),
                                     @Description  Nvarchar(400),
                                     @IsNotNull    Bit,
                                     @IsSearchForm Bit,
                                     @Type         Nvarchar(100),
                                     @Content      Ntext,
                                     @AddDate      Datetime,
                                     @ColId        Int,
                                     @IsChild      Bit,
                                     @IsList       Bit,
                                     @IsUserInsert Bit
As
  Declare @OrderId Int;
  Set @OrderId=(Select max(OrderId)
                From   [Qianbo_ModelField]
                Where  ModelId = @ModelId)
  If @OrderId Is Null
    Set @OrderId=0
  Else
    Set @OrderId = @OrderId + 1
  Insert Into [Qianbo_ModelField]
              ([ModelId],
               [Name],
               [Alias],
               [Description],
               [IsNotNull],
               [IsSearchForm],
               [Type],
               [Content],
               [AddDate],
               [OrderId],
               [ColId],
               [IsList],
               [IsUserInsert],
               [IsChild])
  Values      (@ModelId,
               @Name,
               @Alias,
               @Description,
               @IsNotNull,
               @IsSearchForm,
               @Type,
               @Content,
               @AddDate,
               @OrderId,
               @ColId,
               @IsList,
               @IsUserInsert,
               @IsChild)
  Select scope_identity()
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_AddField @TableName    Nvarchar(50),
                                          @FieldName    Nvarchar(50),
                                          @FieldType    Nvarchar(50),
                                          @DefaultValue Nvarchar(150)
As
  Declare @sqlstr Nvarchar(1000)
  If( @FieldType = 'nvarchar' )
    Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] nvarchar(100) default (''' + @DefaultValue + ''')'
  Else
    If( @FieldType = 'varchar' )
      Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] varchar(100)'
    Else
      If( @FieldType = 'ntext' )
        Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] ntext'
      Else
        If( @FieldType = 'int' )
          Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] int'
        Else
          If( @FieldType = 'bit' )
            Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] bit'
          Else
            If( @FieldType = 'char' )
              Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] char(10)'
            Else
              If( @FieldType = 'datetime' )
                Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] datetime'
              Else
                If( @FieldType = 'decimal' )
                  Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] decimal(8)'
                Else
                  If( @FieldType = 'money' )
                    Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] money'
                  Else
                    If( @FieldType = 'nchar' )
                      Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] nchar(10)'
                    Else
                      If( @FieldType = 'text' )
                        Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] text'
                      Else
                        If( @FieldType = 'float' )
                          Set @sqlstr = 'alter table [' + @TableName + '] add [' + @FieldName + '] float(8)'
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_Del @FieldId Int
As
  Delete From [Qianbo_ModelField]
  Where  FieldId = @FieldId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_DelField @TableName Nvarchar(50),
                                          @FieldName Nvarchar(50)
As
  Declare @Name Nvarchar(50)
  Declare @sqlstr Nvarchar(500)
  Select @Name = b.name
  From   syscolumns a,
         sysobjects b
  Where  a.id = object_id(@TableName)
         And b.id = a.cdefault
         And a.name = @FieldName
         And b.name Like 'DF%'
  Set @sqlstr = 'alter table [' + @TableName + '] drop constraint [' + @Name + ']'
  Execute sp_executesql @sqlstr
  Set @sqlstr = 'alter table [' + @TableName + '] drop column [' + @FieldName + ']'
  Execute sp_executesql @sqlstr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_GetAllTable
As
  Select name
  From   [sysobjects]
  Where  xtype = 'U'
  Order  By name
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_ModelField_GetList @ModelId Int
As
  Select *
  From   [Qianbo_ModelField]
  Where  ModelId = @ModelId
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_ModelField_GetList_Col @ModelId  Int,
                                                 @ColIdStr Nvarchar(3500)
As
  Select *
  From   [Qianbo_ModelField]
  Where  ( ModelId = @ModelId
           And [ColId] = 0 )
          Or ( charindex(',' + Convert(Varchar, ColId) + ',', ',' + @ColIdStr + ',') > 0
               And IsChild = 1 )
  Order  By OrderId,
            FieldId;
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_ModelField_GetList_FieldOrder @FieldOrder Nvarchar(2000)
As
  Select *
  From   [Qianbo_ModelField]
  Where  charindex(',' + Convert(Varchar, FieldId) + ',', ',' + @FieldOrder + ',') > 0
  Order  By OrderId,
            FieldId;
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure dbo.Proc_ModelField_GetList_Model @ModelId Int
As
  Select *
  From   [Qianbo_ModelField]
  Where  ModelId = @ModelId
         And [ColId] = 0
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_GetModel @FieldId Int
As
  Select *
  From   [Qianbo_ModelField]
  Where  FieldId = @FieldId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_ModelField_GetSearchField @modelid Int
As
  Select *
  From   Qianbo_ModelField
  Where  modelid = @modelid
         And issearchform = 1
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_ModelField_GetTableAllField @TableName Nvarchar(50)
As
  Select a.name
  From   syscolumns a,
         sysobjects b
  Where  a.id = b.id
         And b.name = @TableName
  Order  By a.colid
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_GetTableAllFieldAndType @TableName Nvarchar(50)
As
  Select COLUMN_NAME,
         DATA_TYPE
  From   INFORMATION_SCHEMA.COLUMNS
  Where  TABLE_NAME = @TableName
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure dbo.Proc_ModelField_InField @FieldStr Nvarchar(3000)
As
  Declare @SqlStr Nvarchar(4000)
  Set @SqlStr=N'select * from [Qianbo_ModelField] where FieldId in(' + @FieldStr + ')'
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_InModelId @InModelId Nvarchar(2000)
As
  Declare @SqlStr Nvarchar(2000);
  Set @SqlStr=N'select * from [Qianbo_ModelField] where ModelId in(' + @InModelId + ')';
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_IsNotField @TableName Nvarchar(50),
                                            @FieldName Nvarchar(50)
As
  Select *
  From   syscolumns a,
         sysobjects b
  Where  a.id = b.id
         And a.name = @FieldName
         And b.name = @TableName
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_MoveField @ModelId  Int,
                                           @FieldId  Int,
                                           @MoveType Nvarchar(20)
As
  Declare @OrderId Int;
  Declare @NewFieldId Int;
  Declare @NewOrderId Int;
  If @MoveType = 'UpMove'
    Begin
        Declare @MinOrderId Int;
        Set @MinOrderId=(Select min(OrderId)
                         From   [Qianbo_ModelField]
                         Where  ModelId = @ModelId)
        Set @OrderId=(Select OrderId
                      From   [Qianbo_ModelField]
                      Where  ModelId = @ModelId
                             And FieldId = @FieldId)
        If @OrderId != @MinOrderId
          Begin
              Set @NewFieldId=(Select Top 1 FieldId
                               From   [Qianbo_ModelField]
                               Where  ModelId = @ModelId
                                      And OrderId < @OrderId
                               Order  By OrderId Desc)
              Set @NewOrderId=(Select OrderId
                               From   [Qianbo_ModelField]
                               Where  ModelId = @ModelId
                                      And FieldId = @NewFieldId)
              Update [Qianbo_ModelField]
              Set    OrderId = @OrderId
              Where  FieldId = @NewFieldId
                     And ModelId = @ModelId
              Update [Qianbo_ModelField]
              Set    OrderId = @NewOrderId
              Where  FieldId = @FieldId
                     And ModelId = @ModelId
          End
    End
  If @MoveType = 'DownMove'
    Begin
        Declare @MaxOrderId Int;
        Set @MaxOrderId=(Select max(OrderId)
                         From   [Qianbo_ModelField]
                         Where  ModelId = @ModelId)
        Set @OrderId=(Select OrderId
                      From   [Qianbo_ModelField]
                      Where  ModelId = @ModelId
                             And FieldId = @FieldId)
        If @OrderId != @MaxOrderId
          Begin
              Set @NewFieldId=(Select Top 1 FieldId
                               From   [Qianbo_ModelField]
                               Where  ModelId = @ModelId
                                      And OrderId > @OrderId
                               Order  By OrderId)
              Set @NewOrderId=(Select OrderId
                               From   [Qianbo_ModelField]
                               Where  ModelId = @ModelId
                                      And FieldId = @NewFieldId)
              Update [Qianbo_ModelField]
              Set    OrderId = @OrderId
              Where  FieldId = @NewFieldId
                     And ModelId = @ModelId
              Update [Qianbo_ModelField]
              Set    OrderId = @NewOrderId
              Where  FieldId = @FieldId
                     And ModelId = @ModelId
          End
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_SelectPropertyTrue @ModelId Nvarchar(50)
As
  Select *
  From   [Qianbo_ModelField]
  Where  ModelId = @ModelId
         And Content Like '%Property=2%'
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_Update @FieldId      Int,
                                        @ModelId      Int,
                                        @Alias        Nvarchar(300),
                                        @Description  Nvarchar(400),
                                        @IsNotNull    Bit,
                                        @IsSearchForm Bit,
                                        @Content      Ntext,
                                        @AddDate      Datetime,
                                        @ColId        Int,
                                        @IsChild      Int,
                                        @IsList       Int,
                                        @IsUserInsert Int
As
  Update Qianbo_ModelField
  Set    [Alias] = @Alias,
         [Description] = @Description,
         [IsNotNull] = @IsNotNull,
         [IsSearchForm] = @IsSearchForm,
         [Content] = @Content,
         [AddDate] = @AddDate,
         [ColId] = @ColId,
         [IsChild] = @IsChild,
         [IsList] = @IsList,
         [IsUserInsert] = @IsUserInsert
  Where  [FieldId] = @FieldId
         And ModelId = @ModelId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ModelField_UpdateFieldDefault @TableName    Nvarchar(50),
                                                    @FieldName    Nvarchar(50),
                                                    @DefaultValue Nvarchar(50)
As
  Declare @Name Nvarchar(50)
  Declare @sqlstr Nvarchar(1000)
  Select @Name = b.name
  From   syscolumns a,
         sysobjects b
  Where  a.id = object_id(@TableName)
         And b.id = a.cdefault
         And a.name = @FieldName
         And b.name Like 'DF%'
  Set @sqlstr = 'alter table [' + @TableName + '] drop constraint [' + @Name + ']'
  Execute sp_executesql @sqlstr
  Set @sqlstr='alter table [' + @TableName + '] add default (''' + @DefaultValue + ''') for [' + @FieldName + ']'
  Execute sp_executesql @sqlstr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [dbo].[Proc_Model_AddTable] @TableName Nvarchar(50)
As
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr=N'
CREATE TABLE [dbo].[' + @TableName + ']
(
[Id] [int] IDENTITY (1, 1) PRIMARY Key NOT NULL,
[ChId] [int] NOT NULL ,
[ColId] [int] NOT NULL ,
[Title] [nvarchar] (200)  COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''''),
[TitleColor] [nvarchar] (6) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''''),
[TitleFontType] [int]   NULL default (0),
[TitleType] [int]   NULL default (0),
[TitleImgPath] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL default (''''),
[UId] [int] NOT NULL ,
[UName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[UserType] [int] NOT NULL ,
[AdminUId] [int] NULL ,
[AdminUName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL default (''''),
[Status] [int]  NULL default (0),
[HitCount] [int]  NULL default (0),
[AddTime] [datetime] NOT NULL ,
[UpdateTime] [datetime] NOT NULL ,
[TemplatePath] [varchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL default ('''') ,
[PageType] [int] NULL default (1) ,
[IsCreated] [bit]  NULL default (0),
[UserCateId] [int]  NULL default (0),
[PointCount] [int]  NULL default (0),
[ChargeType] [int]  NULL default (1),
[ChargeHourCount] [int]  NULL default (0),
[ChargeViewCount] [int] NULL default (0) ,
[IsOpened] [int]  NULL default (2),
[OuterUrl] [nvarchar] (300)  COLLATE Chinese_PRC_CI_AS NULL default (''''),
[GroupIdStr] [varchar] (200)  COLLATE Chinese_PRC_CI_AS NULL default (''''),
[IsDeleted] [bit] NULL default (0) ,
[IsRecommend] [bit]  NULL default (0),
[IsTop] [bit]  NULL default (0),
[IsFocus] [bit]  NULL default (0),
[IsSideShow] [bit] NULL default (0) ,
[TagIdStr] [varchar] (300)  COLLATE Chinese_PRC_CI_AS NULL default (''''),
[TagNameStr] [nvarchar] (300)  COLLATE Chinese_PRC_CI_AS NULL default (''''),
[IsAllowComment] [bit]  NULL default (0),
[SpecialIdStr] [varchar] (200)  COLLATE Chinese_PRC_CI_AS NULL default (''''),
[ViewUName] [ntext]  NULL default (''),
[ViewUName2] [ntext]  NULL default (''),
[ExtendContentTable] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL default ('''') )
CREATE  INDEX [IX_' + @TableName + '_ChId] ON [' + @TableName + ']([ChId]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_ColId] ON [' + @TableName + ']([ColId]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_AddTime] ON [' + @TableName + ']([AddTime]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_SpecialIdStr] ON [' + @TableName + ']([SpecialIdStr]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_TagIdStr] ON [' + @TableName + ']([TagIdStr]) ON [PRIMARY]'
  Exec sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure [dbo].[Proc_Model_AddTableGIPS] @TableName Nvarchar(50)
As
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr=N'
CREATE TABLE [dbo].[' + @TableName + ']
(
[Id] [int] IDENTITY (1, 1) PRIMARY Key NOT NULL,
[ChId] [int] NOT NULL ,
[ColId] [int] NOT NULL ,
[Title] [nvarchar] (200)  COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''''),
[TitleColor] [nvarchar] (6) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''''),
[TitleFontType] [int]   NULL default (0),
[TitleType] [int]   NULL default (0),
[TitleImgPath] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL default (''''),
[IndexNum] [nvarchar] (200)  COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''''),
[UId] [int] NOT NULL ,
[UName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[UserType] [int] NOT NULL ,
[AdminUId] [int] NULL ,
[AdminUName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL default (''''),
[Status] [int]  NULL default (0),
[HitCount] [int]  NULL default (0),
[AddTime] [datetime] NOT NULL ,
[UpdateTime] [datetime] NOT NULL ,
[TemplatePath] [varchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL default ('''') ,
[PageType] [int] NULL default (1) ,
[IsCreated] [bit]  NULL default (0),
[UserCateId] [int]  NULL default (0),
[PointCount] [int]  NULL default (0),
[ChargeType] [int]  NULL default (1),
[ChargeHourCount] [int]  NULL default (0),
[ChargeViewCount] [int] NULL default (0) ,
[IsOpened] [int]  NULL default (2),
[GroupIdStr] [varchar] (200)  COLLATE Chinese_PRC_CI_AS NULL default (''''),
[IsDeleted] [bit] NULL default (0) ,
[IsRecommend] [bit]  NULL default (0),
[IsTop] [bit]  NULL default (0),
[IsFocus] [bit]  NULL default (0),
[IsSideShow] [bit] NULL default (0) ,
[TagIdStr] [varchar] (300)  COLLATE Chinese_PRC_CI_AS NULL default (''''),
[TagNameStr] [nvarchar] (300)  COLLATE Chinese_PRC_CI_AS NULL default (''''),
[IsAllowComment] [bit]  NULL default (0),
[SpecialIdStr] [varchar] (200)  COLLATE Chinese_PRC_CI_AS NULL default ('''') )
CREATE  INDEX [IX_' + @TableName + '_ColId] ON [' + @TableName + ']([ColId]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_AddTime] ON [' + @TableName + ']([AddTime]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_SpecialIdStr] ON [' + @TableName + ']([SpecialIdStr]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_TagIdStr] ON [' + @TableName + ']([TagIdStr]) ON [PRIMARY]'
  Exec sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [dbo].[Proc_Model_AddTableShop] @TableName Nvarchar(50)
As
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr=N'
CREATE TABLE [dbo].[' + @TableName + ']
(
        [Id] [int] IDENTITY (1, 1) NOT NULL ,
        [ChId] [int] NULL ,
        [ColId] [int] NULL ,
        [ProductNum] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
        [BarCode] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
        [Title] [nvarchar] (150) COLLATE Chinese_PRC_CI_AS NULL ,
        [TitleColor] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
        [TitleFontType] [int] NULL ,
        [TitleType] [int] NULL ,
        [TitleImgPath] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
        [UId] [int] NULL ,
        [UName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
        [UserType] [int] NULL ,
        [AdminUId] [int] NULL ,
        [AdminUName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
        [Status] [int] NULL ,
        [TagIdStr] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
        [TagNameStr] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
        [IsRecommend] [bit] NULL,
        [IsFocus] [bit] NULL,
        [IsTop] [bit] NULL,
        [IsSideShow] [bit] NULL ,
        [IsAllowComment] [bit] NULL ,
        [IsCreated] [bit] NULL ,
        [IsSale] [bit] NULL ,
        [IsDeleted] [bit] NULL ,
        [IsOpened] [int] NULL ,
        [SpecialIdStr] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
        [ProducerId] [int] NULL ,
        [ProducerName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
        [BrandId] [int] NULL ,
        [BrandName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
        [OutOfStockIsBuy] [bit] NULL ,
        [LimitNum] [int] NULL ,
        [StorageNum] [int] NULL ,
        [StorageCallNum] [int] NULL ,
        [StorageCountMode] [int] NULL ,
        [TaxRateSet] [int] NULL ,
        [TaxRate] [decimal](18, 6) NULL ,
        [StarLevel] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
        [MarketPrice] [decimal](18, 2) NULL ,
        [NowRetailPrice] [decimal](18, 2) NULL ,
        [RetailPriceSet] [int] NULL ,
        [RetailPrice] [decimal](18, 2) NULL ,
        [IsWholesale] [bit] NULL ,
        [Wholesale] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
        [SalesPromotionSet] [int] NULL ,
        [SalesPromotion] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
        [PresentId] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
        [PresentName] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
        [PresentPoint] [int] NULL ,
        [PresentExp] [int] NULL ,
        [PresentMoney] [int] NULL ,
        [Priority] [int] NULL ,
        [HitCount] [int] NULL ,
        [AddTime] [datetime] NULL ,
        [UpdateTime] [datetime] NULL ,
        [TemplatePath] [nvarchar] (150) COLLATE Chinese_PRC_CI_AS NULL ,
        [PageType] [int] Null,
        [PointCount] [int] Null)
CREATE  INDEX [IX_' + @TableName + '_ChId] ON [' + @TableName + ']([ChId]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_ColId] ON [' + @TableName + ']([ColId]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_AddTime] ON [' + @TableName + ']([AddTime]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_SpecialIdStr] ON [' + @TableName + ']([SpecialIdStr]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_TagIdStr] ON [' + @TableName + ']([TagIdStr]) ON [PRIMARY]'
  Exec sp_executesql @sqlstr
  Set @sqlstr=N'
ALTER TABLE [dbo].[' + @TableName + '] WITH NOCHECK ADD
        CONSTRAINT [PK_' + @TableName + '] PRIMARY KEY  CLUSTERED
        (
                [Id]
        )  ON [PRIMARY]'
  Exec sp_executesql @sqlstr
  Set @sqlstr=N'
ALTER TABLE [dbo].[' + @TableName + '] ADD
        CONSTRAINT [DF_' + @TableName + '_TitleColor] default ('''') FOR [TitleColor],
        CONSTRAINT [DF_' + @TableName + '_TitleFontType] default (0) FOR [TitleFontType],
        CONSTRAINT [DF_' + @TableName + '_TitleType] default (0) FOR [TitleType],
        CONSTRAINT [DF_' + @TableName + '_TitleImgPath] default ('''') FOR [TitleImgPath],
        CONSTRAINT [DF_' + @TableName + '_AdminUName] default ('''') FOR [AdminUName],
        CONSTRAINT [DF_' + @TableName + '_Status] default (0) FOR [Status],
        CONSTRAINT [DF_' + @TableName + '_TagIdStr] default ('''') FOR [TagIdStr],
        CONSTRAINT [DF_' + @TableName + '_TagNameStr] default ('''') FOR [TagNameStr],
        CONSTRAINT [DF_' + @TableName + '_IsRecommend] default (0) FOR [IsRecommend],
        CONSTRAINT [DF_' + @TableName + '_IsFocus] default (0) FOR [IsFocus],
        CONSTRAINT [DF_' + @TableName + '_IsTop] default (0) FOR [IsTop],
        CONSTRAINT [DF_' + @TableName + '_IsSideShow] default (0) FOR [IsSideShow],
        CONSTRAINT [DF_' + @TableName + '_IsAllowComment] default (0) FOR [IsAllowComment],
        CONSTRAINT [DF_' + @TableName + '_IsCreate] default (0) FOR [IsCreated],
        CONSTRAINT [DF_' + @TableName + '_IsSale] default (0) FOR [IsSale],
        CONSTRAINT [DF_' + @TableName + '_IsDeleted] default (0) FOR [IsDeleted],
        CONSTRAINT [DF_' + @TableName + '_SpecialIdStr] default ('''') FOR [SpecialIdStr],
        CONSTRAINT [DF_' + @TableName + '_ProducerId] default (0) FOR [ProducerId],
        CONSTRAINT [DF_' + @TableName + '_ProducerName] default ('''') FOR [ProducerName],
        CONSTRAINT [DF_' + @TableName + '_BrandId] default (0) FOR [BrandId],
        CONSTRAINT [DF_' + @TableName + '_OutOfStockIsBuy] default (0) FOR [OutOfStockIsBuy],
        CONSTRAINT [DF_' + @TableName + '_LimitNum] default (0) FOR [LimitNum],
        CONSTRAINT [DF_' + @TableName + '_StorageNum] default (0) FOR [StorageNum],
        CONSTRAINT [DF_' +
              @TableName +
                          '_StorageCallNum] default (0) FOR [StorageCallNum],
        CONSTRAINT [DF_' + @TableName + '_StorageCountMode] default (1) FOR [StorageCountMode],
        CONSTRAINT [DF_' + @TableName + '_TaxRate] default (1) FOR [TaxRateSet],
        CONSTRAINT [DF_' + @TableName + '_MarketPrice] default (0) FOR [MarketPrice],
        CONSTRAINT [DF_' + @TableName + '_RetailPrice] default (0) FOR [NowRetailPrice],
        CONSTRAINT [DF_' + @TableName + '_SalesPromotionSet] default (1) FOR [SalesPromotionSet],
        CONSTRAINT [DF_' + @TableName + '_PresentId] default (0) FOR [PresentId],
        CONSTRAINT [DF_' + @TableName + '_PresentPoint] default (0) FOR [PresentPoint],
        CONSTRAINT [DF_' + @TableName + '_PresentExp] default (0) FOR [PresentExp],
        CONSTRAINT [DF_' + @TableName + '_Priority] default (0) FOR [Priority],
        CONSTRAINT [DF_' + @TableName + '_HitCount] default (0) FOR [HitCount],
        CONSTRAINT [DF_' + @TableName + '_PageType] default (1) FOR [PageType]'
  Exec sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Model_CheckExistsChannel @modelid Int
As
  If Exists(Select *
            From   Qianbo_Channel
            Where  modeltype = @modelid)
    Select 1
  Else
    Select 0
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Model_CheckTableValidate @TableName Nvarchar(50)
As
  If Exists (Select *
             From   sysobjects
             Where  xtype = 'U'
                    And name = @TableName)
    Select 0
  Else
    Select 1
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Model_CheckUploadPathValidate @UploadPath Nvarchar(50)
As
  If Exists (Select *
             From   Qianbo_Model
             Where  UploadPath = @UploadPath)
    Select 0
  Else
    Select 1
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Model_Delete @modelid Int
As
  Declare @tablename Nvarchar(50)
  Set @tablename=''
  Set @tablename=(Select tablename
                  From   Qianbo_Model
                  Where  modelid = @modelid)
  Declare @sqlstr Nvarchar(1000)
  Declare @param Nvarchar(100);
  Set @param='@tmodelid int'
  If( @tablename != '' )
    Begin
        Set @sqlstr = N'delete from Qianbo_Model where modelid = @tmodelid'
        Exec sp_executesql
          @sqlstr,
          @param,
          @tmodelid = @modelid
        Set @sqlstr = N'drop table [' + @tablename + ']'
        Exec sp_executesql @sqlstr
        Set @sqlstr = N'delete from Qianbo_ModelField where modelId = @tmodelid'
        Exec sp_executesql
          @sqlstr,
          @param,
          @tmodelid = @modelid
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Model_ExtendTable @TableName Nvarchar(50)
As
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr=N'
CREATE TABLE [dbo].[' + @TableName + ']
(
[Id] [int] IDENTITY (1, 1) PRIMARY Key NOT NULL,
[ChId] [int]  NULL,
[ColId] [int]  NULL,
[ModelId] [int]  NULL,
[InfoId] [int]  NULL,
[FieldId] [int]  NULL,
[FieldName] [nvarchar] (100) NULL,
[Nvarchar] [nvarchar]  (200) NULL,
[DateTime] [datetime]  NULL default (getdate()),
[Ntext] [ntext]  NULL,
[Bit] [bit]  NULL default (0),
[Decimal] [decimal]  (18,2) NULL default (0),
[Int] [int]  NULL default (0),
[AddTime] [datetime]  NULL default (getdate())
)
CREATE  INDEX [IX_' + @TableName + '_ChId] ON [dbo].[' + @TableName + ']([ChId]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_ColId] ON [dbo].[' + @TableName + ']([ColId]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_ModelId] ON [dbo].[' + @TableName + ']([ModelId]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_InfoId] ON [dbo].[' + @TableName + ']([InfoId]) ON [PRIMARY]
CREATE  INDEX [IX_' + @TableName + '_FieldId] ON [dbo].[' + @TableName + ']([FieldId]) ON [PRIMARY]'
  Exec sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Model_GetInfo @modelid Int
As
  Select *
  From   Qianbo_Model
  Where  modelid = @modelid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Model_GetList
As
  Select *
  From   Qianbo_Model
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Model_InfoList @TableName Nvarchar(100),
                                         @CurrPage  Int,
                                         @PageSize  Int,
                                         @strWhere  Nvarchar(3000)
As
  Declare @SqlStr Nvarchar(4000);
  If( @CurrPage = 1 )
    Set @SqlStr=N'select m.*,ch.ChName,ch.DirName,co.ColName,co.ColDirName from [' + @TableName + '] m inner join Qianbo_Channel ch on m.ChId = ch.ChId inner join Qianbo_Column co on m.ColId = co.ColId ' + @strWhere + ' order by m.AddTime desc';
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' m.*,ch.ChName,ch.DirName,co.ColName,co.ColDirName from [' + @TableName + '] m inner join Qianbo_Channel ch on m.ChId = ch.ChId inner join Qianbo_Column co on m.ColId = co.ColId ' + @strWhere + ' and m.AddTime < (select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' m.AddTime from [' + @TableName + '] ' + @strWhere + ' order by m.AddTime desc) order by m.AddTime desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(Id) from [' + @TableName + '] m ' + @strWhere;
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Model_ModelHtml @ModelHtml Ntext,
                                      @ModelId   Int
As
  Update [Qianbo_Model]
  Set    ModelHtml = @ModelHtml
  Where  ModelId = @ModelId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Model_Out @InModelId Nvarchar(2000)
As
  Declare @SqlStr Nvarchar(2000);
  Set @SqlStr=N'select * from [Qianbo_Model] where ModelId in(' + @InModelId + ')';
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Model_Set @ModelId    Int,
                                    @ModelName  Nvarchar(20),
                                    @ModelDesc  Nvarchar(200),
                                    @TableName  Nvarchar(50),
                                    @UploadPath Varchar(50),
                                    @UploadSize Int,
                                    @ModelHtml  Ntext,
                                    @IsHtml     Bit,
                                    @ModelSort  Int
As
  If( @ModelId = 0 )
    Begin
        Insert Into Qianbo_Model
                    (modelname,
                     modeldesc,
                     tablename,
                     uploadpath,
                     uploadsize,
                     ModelHtml,
                     IsHtml,
                     ModelSort)
        Values      (@modelname,
                     @modeldesc,
                     @tablename,
                     @uploadpath,
                     @uploadsize,
                     @ModelHtml,
                     @IsHtml,
                     @ModelSort)
        Select scope_identity()
    End
  Else
    Begin
        Update Qianbo_Model
        Set    modelname = @modelname,
               modeldesc = @modeldesc,
               uploadpath = @uploadpath,
               uploadsize = @uploadsize,
               IsHtml = @IsHtml,
               ModelSort = @ModelSort
        Where  modelid = @modelid
        Select @modelid
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Notice @NoticeId    Int=0,
                                 @Title       Nvarchar(300)=" ",
                                 @Content     Ntext=" ",
                                 @UserId      Int=0,
                                 @UserName    Nvarchar(100)=" ",
                                 @OverdueDate Datetime=" ",
                                 @IsPriority  Int=0,
                                 @IsState     Nvarchar(20)=" ",
                                 @AddDate     Datetime=" ",
                                 @TypeId      Int=0
As
  If @TypeId = 1
    Begin
        Insert Into Qianbo_Notice
                    ([Title],
                     [Content],
                     [UserId],
                     [UserName],
                     [OverdueDate],
                     [IsPriority],
                     [IsState],
                     [AddDate])
        Values      (@Title,
                     @Content,
                     @UserId,
                     @UserName,
                     @OverdueDate,
                     @IsPriority,
                     @IsState,
                     @AddDate)
    End
  If @TypeId = 2
    Begin
        Update Qianbo_Notice
        Set    [Title] = @Title,
               [Content] = @Content,
               [UserId] = @UserId,
               [UserName] = @UserName,
               [OverdueDate] = @OverdueDate,
               [IsPriority] = @IsPriority,
               [IsState] = @IsState,
               [AddDate] = @AddDate
        Where  [NoticeId] = @NoticeId
    End
  If @TypeId = 3
    Begin
        Delete Qianbo_Notice
        Where  [NoticeId] = @NoticeId
    End
  If @TypeId = 4
    Begin
        Select [NoticeId],
               [Title],
               [Content],
               [UserId],
               [UserName],
               [OverdueDate],
               [IsPriority],
               [IsState],
               [AddDate]
        From   Qianbo_Notice
        Where  NoticeId = @NoticeId
    End
  If @TypeId = 5
    Begin
        Update Qianbo_Notice
        Set    [IsState] = @IsState
        Where  [NoticeId] = @NoticeId
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Notice_GetTop @Top Int
As
  Declare @SqlStr Nvarchar(2000);
  Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @Top) + ' * from [Qianbo_Notice]  where datediff(day,OverdueDate,getdate()) <= 0 and IsState = ''审核通过'' order by IsPriority desc,NoticeId desc'
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_PlanAssignMent_Add @Name       Nvarchar(300),
                                         @AssType    Int,
                                         @PlanAss    Nvarchar(50),
                                         @Content    Ntext,
                                         @AddDate    Datetime,
                                         @UpdateDate Datetime
As
  Insert Into Qianbo_PlanAssignMent
              ([Name],
               [AssType],
               [PlanAss],
               [Content],
               [AddDate],
               [UpdateDate])
  Values      (@Name,
               @AssType,
               @PlanAss,
               @Content,
               @AddDate,
               @UpdateDate)
  Select scope_identity()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_PlanAssignMent_Delete @id Int
As
  Delete [Qianbo_PlanAssignMent]
  Where  id = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_PlanAssignMent_GetModel @id Int
As
  Select *
  From   Qianbo_PlanAssignMent
  Where  id = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_PlanAssignMent_List @PageSize  Int,
                                              @PageIndex Int
As
  Declare @SqlStr Nvarchar(2000);
  If( @PageIndex = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_PlanAssignMent] order by Id desc';
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_PlanAssignMent] where Id not in(select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' Id from [Qianbo_PlanAssignMent] order by Id desc) order by Id desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(Id) from [Qianbo_PlanAssignMent]';
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_PlanAssignMent_Update @id         Int,
                                                @Name       Nvarchar(300),
                                                @AssType    Int,
                                                @PlanAss    Nvarchar(50),
                                                @Content    Ntext,
                                                @AddDate    Datetime,
                                                @UpdateDate Datetime
As
  Update Qianbo_PlanAssignMent
  Set    [Name] = @Name,
         [AssType] = @AssType,
         [PlanAss] = @PlanAss,
         [Content] = @Content,
         [AddDate] = @AddDate,
         [UpdateDate] = @UpdateDate
  Where  id = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_PowerColumn_Update @id Int
As
  Select *
  From   [Qianbo_PowerColumn]
  Where  PCId = @id
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_PowerGroup @PowerId       Int=0,
                                 @PowerName     Nvarchar(50)=" ",
                                 @PowerColumn   Ntext=" ",
                                 @PowerChannel  Ntext=" ",
                                 @PowerAuditing Ntext=" ",
                                 @PowerModel    Nvarchar(50)=" ",
                                 @PowerContent  Nvarchar(500)=" ",
                                 @AddDate       Datetime="2008-8-8",
                                 @TypeId        Int=0,
                                 @AllChannel    Ntext=" ",
                                 @AllColumn     Ntext=" ",
                                 @PowerFunction Ntext=" ",
                                 @SiteId        Int=0
As
  If @TypeId = 1
    Begin
        Select *
        From   [Qianbo_PowerGroup]
        Where  PowerModel = '否'
        Order  By PowerId Desc
    End
  If @TypeId = 2
    Begin
        Select *
        From   [Qianbo_PowerGroup]
        Where  PowerId = @PowerId
    End
  If @TypeId = 3
    Begin
        Update [Qianbo_PowerGroup]
        Set    PowerName = @PowerName,
               PowerColumn = @PowerColumn,
               PowerChannel = @PowerChannel,
               PowerAuditing = @PowerAuditing,
               PowerModel = @PowerModel,
               PowerContent = @PowerContent,
               AllChannel = @AllChannel,
               AllColumn = @AllColumn,
               PowerFunction = @PowerFunction,
               SiteId = @SiteId
        Where  PowerId = @PowerId
    End
  If @TypeId = 4
    Begin
        Delete [Qianbo_PowerGroup]
        Where  PowerId = @PowerId
    End
  If @TypeId = 5
    Begin
        Insert Into [Qianbo_PowerGroup]
                    (PowerName,
                     PowerColumn,
                     PowerChannel,
                     PowerAuditing,
                     PowerModel,
                     PowerContent,
                     AddDate,
                     AllChannel,
                     AllColumn,
                     PowerFunction,
                     SiteId)
        Values      (@PowerName,
                     @PowerColumn,
                     @PowerChannel,
                     @PowerAuditing,
                     @PowerModel,
                     @PowerContent,
                     @AddDate,
                     @AllChannel,
                     @AllColumn,
                     @PowerFunction,
                     @SiteId)
    End
  If @TypeId = 6
    Begin
        Select *
        From   [Qianbo_PowerColumn]
        Order  By PCId Asc
    End
  If @TypeId = 7
    Begin
        Select PowerId,
               PowerName
        From   [Qianbo_PowerGroup]
        Where  PowerModel = '是'
        Order  By PowerId
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_PowerGroup_BySiteId @PowerId       Int=0,
                                          @PowerName     Nvarchar(50)=" ",
                                          @PowerColumn   Ntext=" ",
                                          @PowerChannel  Ntext=" ",
                                          @PowerAuditing Ntext=" ",
                                          @PowerModel    Nvarchar(50)=" ",
                                          @PowerContent  Nvarchar(500)=" ",
                                          @AddDate       Datetime="2008-8-8",
                                          @TypeId        Int=0,
                                          @AllChannel    Ntext=" ",
                                          @AllColumn     Ntext=" ",
                                          @PowerFunction Ntext=" ",
                                          @SiteId        Int=0
As
  If @TypeId = 1
    Begin
        Select *
        From   [Qianbo_PowerGroup]
        Where  PowerModel = '否'
               And SiteId = @SiteId
        Order  By PowerId Desc
    End
  If @TypeId = 2
    Begin
        Select *
        From   [Qianbo_PowerGroup]
        Where  PowerId = @PowerId
    End
  If @TypeId = 3
    Begin
        Update [Qianbo_PowerGroup]
        Set    PowerName = @PowerName,
               PowerColumn = @PowerColumn,
               PowerChannel = @PowerChannel,
               PowerAuditing = @PowerAuditing,
               PowerModel = @PowerModel,
               PowerContent = @PowerContent,
               AllChannel = @AllChannel,
               AllColumn = @AllColumn,
               PowerFunction = @PowerFunction,
               SiteId = @SiteId
        Where  PowerId = @PowerId
    End
  If @TypeId = 4
    Begin
        Delete [Qianbo_PowerGroup]
        Where  PowerId = @PowerId
    End
  If @TypeId = 5
    Begin
        Insert Into [Qianbo_PowerGroup]
                    (PowerName,
                     PowerColumn,
                     PowerChannel,
                     PowerAuditing,
                     PowerModel,
                     PowerContent,
                     AddDate,
                     AllChannel,
                     AllColumn,
                     PowerFunction,
                     SiteId)
        Values      (@PowerName,
                     @PowerColumn,
                     @PowerChannel,
                     @PowerAuditing,
                     @PowerModel,
                     @PowerContent,
                     @AddDate,
                     @AllChannel,
                     @AllColumn,
                     @PowerFunction,
                     @SiteId)
    End
  If @TypeId = 6
    Begin
        Select *
        From   [Qianbo_PowerColumn]
        Order  By PCId Asc
    End
  If @TypeId = 7
    Begin
        Select PowerId,
               PowerName
        From   [Qianbo_PowerGroup]
        Where  PowerModel = '是'
        Order  By PowerId
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Property_Add @ParentId         Int,
                              @PropertyCName    Nvarchar(400),
                              @PropertyEName    Nvarchar(400),
                              @PropertyKeyword  Nvarchar(1000),
                              @PropertyContent  Text,
                              @PropertyExtName  Int,
                              @PropertyPic      Nvarchar(400),
                              @PropertyTemplate Nvarchar(400),
                              @PropertyDir      Int,
                              @PropertyOrder    Int
As
  Insert Into Qianbo_Property
              ([ParentId],
               [PropertyCName],
               [PropertyEName],
               [PropertyKeyword],
               [PropertyContent],
               [PropertyExtName],
               [PropertyPic],
               [PropertyTemplate],
               [PropertyDir],
               [PropertyOrder])
  Values      ( @ParentId,
                @PropertyCName,
                @PropertyEName,
                @PropertyKeyword,
                @PropertyContent,
                @PropertyExtName,
                @PropertyPic,
                @PropertyTemplate,
                @PropertyDir,
                @PropertyOrder )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Property_Delete @idStr Nvarchar(1000)
As
  Declare @sqlStr Nvarchar(2000)
  Set @sqlStr=N'delete from Qianbo_Property where id in(' + @idStr + ')'
  Execute Sp_ExecuteSql @sqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Property_GetAllList
As
  Select *
  From   Qianbo_Property
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Property_GetAllSubProperty @subidstr Nvarchar(1000)
As
  Declare @sqlstr Varchar(2000)
  Set @sqlstr=N'select * from Qianbo_Property where id in(' + @subidstr + ')'
  Exec (@sqlstr)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Property_GetIdStrList @idstr Nvarchar(1000)
As
  Declare @sqlstr Nvarchar(2000)
  Set @sqlstr=N'select [Id],[ParentId],[ModelId],[PropertyCName],[PropertyEName],[PropertyKeyword],[PropertyContent],[PropertyExtName],[PropertyPic],[PropertyTemplate],[PropertyDir],[PropertyOrder] from Qianbo_Property where [Id] in(' + @idstr + ')'
  Execute SP_EXECUTESQL @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Property_GetList @ParentId Int
As
  Select *
  From   Qianbo_Property
  Where  [ParentId] = @ParentId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Property_GetModel @Id Int
As
  Select *
  From   Qianbo_Property
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Property_Update @Id               Int,
                                 @ParentId         Int,
                                 @PropertyCName    Nvarchar(400),
                                 @PropertyEName    Nvarchar(400),
                                 @PropertyKeyword  Nvarchar(1000),
                                 @PropertyContent  Text,
                                 @PropertyExtName  Int,
                                 @PropertyPic      Nvarchar(400),
                                 @PropertyTemplate Nvarchar(400),
                                 @PropertyDir      Int,
                                 @PropertyOrder    Int
As
  Update Qianbo_Property
  Set    [ParentId] = @ParentId,
         [PropertyCName] = @PropertyCName,
         [PropertyEName] = @PropertyEName,
         [PropertyKeyword] = @PropertyKeyword,
         [PropertyContent] = @PropertyContent,
         [PropertyExtName] = @PropertyExtName,
         [PropertyPic] = @PropertyPic,
         [PropertyTemplate] = @PropertyTemplate,
         [PropertyDir] = @PropertyDir,
         [PropertyOrder] = @PropertyOrder
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Property_UpdatePropertyArea @id    Int,
                                                  @type  Int,
                                                  @value Nvarchar(1000)
As
  If( @type = 0 )
    Update Qianbo_Property
    Set    [ModelId] = @value
    Where  [id] = @id
  Else
    If( @type = 1 )
      Update Qianbo_Property
      Set    [FormId] = @value
      Where  [id] = @id
    Else
      If( @type = 2 )
        Update Qianbo_Property
        Set    [UserId] = @value
        Where  [id] = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure dbo.Proc_Recycle_Restore @TableName Varchar(50),
                                          @Type      Int,
                                          @Id        Int
As
  Declare @SqlStr Nvarchar(2000)
  Declare @Filed Nvarchar(200)
  If( @Type = 1 )
    Begin
        Set @SqlStr='update Qianbo_Channel set [IsDeleted] = 0 where ChId = ' + Convert(Nvarchar(10), @Id)
    End
  If ( @Type = 2 )
    Begin
        Set @SqlStr='update Qianbo_Column set [IsDeleted] = 0 where ColId = ' + Convert(Nvarchar(10), @Id)
    End
  If( @Type = 3 )
    Begin
        Set @SqlStr='update Qianbo_Special set [IsDeleted] = 0 where [Id] = ' + Convert(Nvarchar(10), @Id)
    End
  If( @Type = 4 )
    Begin
        If( @TableName = '' )
          Return;
        Set @SqlStr='update ' + @TableName + ' set [IsDeleted] = 0 where [Id] = ' + Convert(Nvarchar(10), @Id)
    End
  Execute sp_executesql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Report_Add @Content    Nvarchar(500),
                                 @Url        Varchar(255),
                                 @UserId     Int,
                                 @UserName   Nvarchar(20),
                                 @IsComplete Int,
                                 @AddTime    Datetime
As
  Insert Into Qianbo_Report
              ([Content],
               [Url],
               [UserId],
               [UserName],
               [IsComplete],
               [AddTime])
  Values      (@Content,
               @Url,
               @UserId,
               @UserName,
               @IsComplete,
               @AddTime)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Report_Delete @ReportId Int
As
  Delete From Qianbo_Report
  Where  ReportId = @ReportId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Report_GetList @PageIndex Int,
                                     @PageSize  Int,
                                     @WhereStr  Nvarchar(1000)
As
  Declare @SqlStr Nvarchar(2000)
  If( @PageIndex = 1 )
    Set @SqlStr = N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_Report where ' + @WhereStr + ' order by ReportId desc';
  Else
    Set @SqlStr = N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_Report where ReportId not in(select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' ReportId from Qianbo_Report where ' + @WhereStr + ') and ' + @WhereStr + ' order by ReportId desc'
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(ReportId) from Qianbo_Report where ' + @WhereStr
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Report_SetStatus @ReportId Int,
                                       @Status   Int
As
  Update Qianbo_Report
  Set    IsComplete = @Status
  Where  ReportId = @ReportId
         And IsComplete = 0
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Review_Add @ModelType     Int,
                                 @InfoId        Int,
                                 @ReviewTitle   Nvarchar(200),
                                 @IsArgue       Bit,
                                 @IsSquare      Tinyint,
                                 @BrarNum       Int,
                                 @FightNum      Int,
                                 @IsElite       Bit,
                                 @ReviewContent Ntext,
                                 @ReviewTime    Datetime,
                                 @UserNum       Nvarchar(36),
                                 @ReviewIP      Nvarchar(40),
                                 @IsCheck       Bit
As
  Insert Into Qianbo_Review
              ([ModelType],
               [InfoId],
               [ReviewTitle],
               [IsArgue],
               [IsSquare],
               [BrarNum],
               [FightNum],
               [IsElite],
               [ReviewContent],
               [ReviewTime],
               [UserNum],
               [ReviewIP],
               [IsCheck])
  Values      (@ModelType,
               @InfoId,
               @ReviewTitle,
               @IsArgue,
               @IsSquare,
               @BrarNum,
               @FightNum,
               @IsElite,
               @ReviewContent,
               @ReviewTime,
               @UserNum,
               @ReviewIP,
               @IsCheck )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Review_GetManageList @tablename Nvarchar(100),
                                           @modeltype Int,
                                           @ischeck   Bit,
                                           @pageindex Int,
                                           @pagesize  Int
As
  If( @tablename = '' )
    Return;
  Declare @sqlstr Nvarchar(2000)
  Declare @param Nvarchar(200)
  Declare @selecttable Nvarchar(500)
  Set @selecttable = ' [' + @tablename + '] i join Qianbo_Review re on re.modeltype = @tmodeltype and i.[id] = re.infoid '
  Set @param = '@tischeck bit,@tmodeltype int'
  If( @pageindex = 1 )
    Set @sqlstr = 'select distinct top ' + Convert(Nvarchar(15), @pagesize) + ' i.[id],i.title from ' + @selecttable + ' where re.ischeck = @tischeck order by i.[id] desc'
  Else
    Set @sqlstr = 'select distinct top ' + Convert(Nvarchar(15), @pagesize) + ' i.[id],i.title from ' + @selecttable + ' where i.[id] < (select min(o.[id]) from(select distinct top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' i.[id] from ' + @selecttable + ' where re.ischeck = @tischeck order by i.[id] desc )o) and re.ischeck = @tischeck order by i.[id] desc'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tischeck = @ischeck,
    @tmodeltype = @modeltype
  Set @sqlstr = 'select Count(*) as tatal from (select distinct i.[id] from ' + @selecttable + ' where re.ischeck = @tischeck)c'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tischeck = @ischeck,
    @tmodeltype = @modeltype
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Review_GetMoreList @pageindex Int,
                                         @pagesize  Int,
                                         @wherestr  Nvarchar(500)
As
  Declare @sqlstr Nvarchar(2000);
  If( @pageindex = 1 )
    Set @sqlStr='select top ' + Convert(Nvarchar(15), @pagesize) + ' a.* from Qianbo_Review a  ' + @wherestr + ' order by [id] desc';
  Else
    Set @sqlstr='select top ' + Convert(Nvarchar(15), @pagesize) + ' a.* from Qianbo_Review a  ' + @whereStr + ' and id not in(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' id from Qianbo_Review a ' + @wherestr + ' order by [id] desc) order by [id] desc';
  Execute sp_executesql @sqlstr
  Set @sqlstr = 'select Count(id) from Qianbo_Review ' + @wherestr;
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Review_GetTop5List @ModelType Int,
                                         @InfoId    Int,
                                         @IsCheck   Bit
As
  Select Top 5 [Id],
               UserNum,
               InfoId,
               ReviewContent,
               ReviewTime
  From   Qianbo_Review a
  Where  ModelType = @ModelType
         And InfoId = @InfoId
         And IsCheck = @IsCheck
  Order  By [Id] Desc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Review_Oper @id        Int=0,
                             @infoid    Int=0,
                             @modeltype Int=1,
                             @typeid    Int,
                             @ischeck   Bit=1
As
  If( @typeid = 1 )
    Begin
        Delete From Qianbo_Review
        Where  [id] = @id
    End
  Else
    If( @typeid = 2 )
      Begin
          Delete From Qianbo_Review
          Where  infoid = @infoid
                 And modeltype = @modeltype
      End
    Else
      If( @typeid = 3 )
        Begin
            Update Qianbo_Review
            Set    ischeck = @ischeck
            Where  [id] = @id
        End
      Else
        If( @typeid = 4 )
          Begin
              Select *
              From   Qianbo_Review
              Where  [id] = @id
          End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Rss_GetInfoList @tablename Nvarchar(50),
                                      @chid      Int,
                                      @colid     Nvarchar(3000)
As
  Declare @fieldstr Nvarchar(1000)
  Set @fieldstr = ' i.*,m.modelid,m.tablename,m.uploadpath,ch.chid,ch.typename,ch.chname,ch.dirName,ch.infosorttype,ch.filenametype,ch.isstatictype,colisopened = co.isopened,co.colName,co.coldirname '
  Declare @tablestr Nvarchar(400)
  Set @tablestr = ' [' + @tableName + '] as i join Qianbo_Column co on i.colid = co.colid join Qianbo_Channel ch on co.chid = ch.chid join Qianbo_Model m on ch.modeltype = m.modelid '
  Declare @wherestr Nvarchar(3000)
  Set @wherestr = ''
  If( @chid != 0 )
    Set @wherestr = @wherestr + ' co.chid = @tchid and '
  If( @colid != '0' )
    Set @wherestr = @wherestr + ' i.colid in(' + @colid + ') and '
  Set @wherestr = @wherestr + '  i.status = 3 and i.isdeleted = 0 '
  Declare @sqlstr Nvarchar(1000)
  Set @sqlstr = 'select top 100 ' + @fieldstr + 'from' + @tablestr + 'where' + @wherestr + ' order by i.[id] desc'
  Declare @param Nvarchar(500)
  Set @param = '@tchid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @tchid = @chid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SelectAll
As
  Select *
  From   Qianbo_Users
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SinglePage_Add @Name         Nvarchar(200),
                                     @FolderPath   Nvarchar(100),
                                     @FileName     Nvarchar(200),
                                     @FileExtend   Nvarchar(100),
                                     @TemplatePath Nvarchar(300),
                                     @Content      Nvarchar(400),
                                     @AddTime      Datetime
As
  Insert Into [Qianbo_SinglePage]
              ([Name],
               [FolderPath],
               [FileName],
               [FileExtend],
               [TemplatePath],
               [Content],
               [AddTime])
  Values      (@Name,
               @FolderPath,
               @FileName,
               @FileExtend,
               @TemplatePath,
               @Content,
               @AddTime)
  Select scope_identity()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SinglePage_Del @SingleId Int
As
  Delete Qianbo_SinglePage
  Where  [SingleId] = @SingleId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SinglePage_GetList @CurrPage Int,
                                         @PageSize Int
As
  Declare @SqlStr Nvarchar(2000);
  If( @CurrPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_SinglePage] order by SingleId desc';
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_SinglePage] where SingleId not in(select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' SingleId from [Qianbo_SinglePage] order by SingleId desc) order by SingleId desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(SingleId) from [Qianbo_SinglePage]';
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SinglePage_GetModel @SingleId Int
As
  Select [SingleId],
         [Name],
         [FolderPath],
         [FileName],
         [FileExtend],
         [TemplatePath],
         [Content],
         [AddTime]
  From   [Qianbo_SinglePage]
  Where  [SingleId] = @SingleId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SinglePage_Update @SingleId     Int,
                                        @Name         Nvarchar(200),
                                        @FolderPath   Nvarchar(100),
                                        @FileName     Nvarchar(200),
                                        @FileExtend   Nvarchar(100),
                                        @TemplatePath Nvarchar(300),
                                        @Content      Nvarchar(400),
                                        @AddTime      Datetime
As
  Update Qianbo_SinglePage
  Set    [Name] = @Name,
         [FolderPath] = @FolderPath,
         [FileName] = @FileName,
         [FileExtend] = @FileExtend,
         [TemplatePath] = @TemplatePath,
         [Content] = @Content,
         [AddTime] = @AddTime
  Where  [SingleId] = @SingleId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Site_Count @Type   Varchar(10),
                                     @Filter Varchar(15)
As
  If @Type = 'Year'
    Begin
        Select *
        From   Qianbo_CountYear
        Where  Flag = @Filter
    End
  If @Type = 'Month'
    Begin
        Select *
        From   Qianbo_CountMonth
        Where  Flag = @Filter
    End
  If @Type = 'Week'
    Begin
        Select *
        From   Qianbo_CountWeek
        Where  Flag = @Filter
    End
  If @Type = 'Day'
    Begin
        Select *
        From   Qianbo_CountDay
        Where  Flag = @Filter
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Special_Add @ParentID       Int,
                                      @SiteID         Int,
                                      @SpecialCName   Nvarchar(30),
                                      @SpecialEName   Nvarchar(20),
                                      @SpecialDomain  Nvarchar(100),
                                      @SpecialRemark  Nvarchar(200),
                                      @IsLock         Bit,
                                      @IsCommand      Bit,
                                      @SpecialAddTime Datetime,
                                      @MetaKeyWord    Nvarchar(200),
                                      @MetaRemark     Nvarchar(200),
                                      @SpecialTemplet Nvarchar(200),
                                      @SpecialItemNum Int,
                                      @SpecialContent Ntext,
                                      @SaveDirType    Nvarchar(200),
                                      @Extension      Varchar(50),
                                      @PicSavePath    Nvarchar(200),
                                      @IsDeleted      Bit
As
  Insert Into Qianbo_Special
              ([ParentID],
               [SiteID],
               [SpecialCName],
               [SpecialEName],
               [SpecialDomain],
               [SpecialRemark],
               [IsLock],
               [IsCommand],
               [SpecialAddTime],
               [MetaKeyWord],
               [MetaRemark],
               [SpecialTemplet],
               [SpecialItemNum],
               [SpecialContent],
               [SaveDirType],
               IsDeleted,
               Extension,
               PicSavePath)
  Values      ( @ParentID,
                @SiteID,
                @SpecialCName,
                @SpecialEName,
                @SpecialDomain,
                @SpecialRemark,
                @IsLock,
                @IsCommand,
                @SpecialAddTime,
                @MetaKeyWord,
                @MetaRemark,
                @SpecialTemplet,
                @SpecialItemNum,
                @SpecialContent,
                @SaveDirType,
                @IsDeleted,
                @Extension,
                @PicSavePath )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Special_CompleteDelete @specialid Int
As
  Delete From Qianbo_Special
  Where  id = @specialid
  Delete From Qianbo_Special
  Where  parentid = @specialid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Special_Delete @ID Int
As
  Set Xact_Abort On
  Begin
      Update Qianbo_Special
      Set    [IsDeleted] = 1
      Where  [ID] = @ID
      If Exists(Select [ID]
                From   Qianbo_Special
                Where  ParentId = @ID)
        Update Qianbo_Special
        Set    [IsDeleted] = 1
        Where  ParentId = @ID
  End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Special_GetAll
As
  Select *
  From   Qianbo_Special
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Special_GetChSpecialList @chid Int
As
  Select *
  From   Qianbo_Special
  Where  ( siteid = @chid
            Or siteid = 0 )
         And isdeleted = 0
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Special_GetSpecial (@ID Int)
As
  Select *
  From   Qianbo_Special
  Where  [ID] = @ID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Special_GetSpecials (@SelectType Int,
                                               @ParentId   Int)
As
  If @SelectType = 0
    Begin
        Select Qianbo_Special.*,
               Qianbo_Channel.ChName
        From   Qianbo_Special
               Left Join Qianbo_Channel
                 On Qianbo_Special.SiteID = Qianbo_Channel.ChId
        Where  Qianbo_Special.parentId = 0
               And Qianbo_Special.IsDeleted = 0
        Order  By Qianbo_Special.SiteID
    End
  If @SelectType = 1
    Begin
        Select Qianbo_Special.*,
               Qianbo_Channel.ChName
        From   Qianbo_Special
               Left Join Qianbo_Channel
                 On Qianbo_Special.SiteID = Qianbo_Channel.ChId
        Where  parentId = @ParentId
               And Qianbo_Special.IsDeleted = 0
        Order  By Qianbo_Special.SiteID
    End
  If @SelectType = 2
    Begin
        Select Qianbo_Special.*
        From   Qianbo_Special
               Left Join Qianbo_Channel
                 On Qianbo_Special.SiteID = Qianbo_Channel.ChId
        Where  Qianbo_Special.IsLock = 0
               And Qianbo_Special.IsDeleted = 0
        Order  By ID
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Special_Update @ID             Int,
                                         @ParentID       Int,
                                         @SiteID         Int,
                                         @SpecialCName   Nvarchar(30),
                                         @SpecialDomain  Nvarchar(100),
                                         @SpecialRemark  Nvarchar(200),
                                         @IsLock         Bit,
                                         @IsCommand      Bit,
                                         @SpecialAddTime Datetime,
                                         @MetaKeyWord    Nvarchar(200),
                                         @MetaRemark     Nvarchar(200),
                                         @SpecialTemplet Nvarchar(200),
                                         @SpecialItemNum Int,
                                         @SpecialContent Ntext,
                                         @SaveDirType    Nvarchar(200),
                                         @Extension      Varchar(50),
                                         @PicSavePath    Nvarchar(200)
As
  Update Qianbo_Special
  Set    [ParentID] = @ParentID,
         [SiteID] = @SiteID,
         [SpecialCName] = @SpecialCName,
         [SpecialDomain] = @SpecialDomain,
         [SpecialRemark] = @SpecialRemark,
         [IsLock] = @IsLock,
         [IsCommand] = @IsCommand,
         [SpecialAddTime] = @SpecialAddTime,
         [MetaKeyWord] = @MetaKeyWord,
         [MetaRemark] = @MetaRemark,
         [SpecialTemplet] = @SpecialTemplet,
         [SpecialItemNum] = @SpecialItemNum,
         [SpecialContent] = @SpecialContent,
         [SaveDirType] = @SaveDirType,
         Extension = @Extension,
         PicSavePath = @PicSavePath
  Where  [ID] = @ID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_StyleCategoryId
As
  Select StyleCategoryID,
         [Name],
         ParentID
  From   Qianbo_StyleCategory
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_StyleCategory_Add @Name     Nvarchar(100),
                                        @ParentID Int,
                                        @Desc     Nvarchar(200)
As
  Insert Into Qianbo_StyleCategory
              ([Name],
               [ParentID],
               [Desc])
  Values      ( @Name,
                @ParentID,
                @Desc )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_StyleCategory_Delete @StyleCategoryID Int
As
  Delete From Qianbo_StyleCategory
  Where  StyleCategoryID = @StyleCategoryID
          Or ParentID = @StyleCategoryID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_StyleCategory_GetIdData @StyleCategoryId Int
As
  Select ParentId,
         [NAME],
         [DESC]
  From   Qianbo_StyleCategory
  Where  StyleCategoryId = @StyleCategoryId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_StyleCategory_GetList @ParentID Int
As
  Select [StyleCategoryID],
         [Name],
         [ParentID],
         [Desc]
  From   Qianbo_StyleCategory
  Where  ParentID = @ParentID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_StyleCategory_Update @StyleCategoryId Int,
                                           @ParentId        Int,
                                           @Name            Nvarchar(50),
                                           @Desc            Nvarchar(100)
As
  Update Qianbo_StyleCategory
  Set    ParentId = @ParentId,
         [Name] = @Name,
         [Desc] = @Desc
  Where  StyleCategoryId = @StyleCategoryId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Proc Proc_StyleContent_GetLbCategoryNameList @labelName   Nvarchar(200),
                                                    @CursorPage  Int,
                                                    @PageSize    Int,
                                                    @RecordCount Int output
As
  Declare @SqlStr Nvarchar(2000);
  If( @CursorPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_Style where [Name] like @tlabelName order by StyleID desc'
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_Style where [Name] like @tlabelName and StyleID < (select min(StyleID) from(select top ' + Convert(Nvarchar(15), (@CursorPage - 1) * @PageSize) + ' StyleID from Qianbo_Style where [Name] like @tlabelName order by StyleID desc)O)order by StyleID desc'
  Declare @paramlb Nvarchar(500)
  Set @paramlb=N'@tlabelName Nvarchar(200)'
  Execute Sp_executeSql
    @SqlStr,
    @paramlb,
    @tlabelName = @labelName
  Set @RecordCount=(Select Count(StyleID)
                    From   Qianbo_Style
                    Where  [Name] Like @labelName)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_Add @StyleCategoryId Int,
                                @Name            Nvarchar(100),
                                @Content         Text,
                                @Type            Int,
                                @Id              Int output
As
  Insert Into Qianbo_Style
              ([StyleCategoryId],
               [Name],
               [Content],
               [Type])
  Values      ( @StyleCategoryId,
                @Name,
                @Content,
                @Type )
  Set @Id = @@identity
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [dbo].[Proc_Style_AddSearchStyle] @modelId Int,
                                                   @content Ntext
As
  Insert Into Qianbo_ListStyleContent
              (ModelId,
               Content)
  Values      (@modelid,
               @content)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_ConById @StyleID Int
As
  Select Content
  From   Qianbo_Style
  Where  StyleID = @StyleID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_Delete @StyleId Int
As
  Delete From Qianbo_Style
  Where  StyleId = @StyleId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_DeleteAndStyleCategoryId @StyleCategoryID Int
As
  Delete From Qianbo_Style
  Where  StyleCategoryID = @StyleCategoryID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_GetAll
As
  Select *
  From   Qianbo_Style
  Order  By StyleID Desc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_GetByModelId @type Int
As
  Select StyleID,
         [Name]
  From   Qianbo_Style
  Where  [Type] = @type
  Order  By StyleID Desc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_GetHasRows @Name Nvarchar(200)
As
  Select [Name]
  From   Qianbo_Style
  Where  [Name] = @Name
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_GetId @StyleId Int
As
  Select [StyleCategoryId],
         [Name],
         [Content],
         [Type]
  From   Qianbo_Style
  Where  StyleId = @StyleId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_GetList @StyleCategoryId Int
As
  Select StyleID,
         [Name],
         Content,
         Type
  From   Qianbo_Style
  Where  StyleCategoryId = @StyleCategoryId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Style_GetSearchStyle @modelid Int
As
  Select *
  From   Qianbo_ListStyleContent
  Where  modelid = @modelid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_StyleIDGetStylegoryId @StyleID Int
As
  Select [StyleID],
         [StyleCategoryId]
  From   Qianbo_Style
  Where  [StyleID] = @StyleID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_Update @StyleID         Int,
                                   @StyleCategoryId Int,
                                   @Name            Nvarchar(100),
                                   @Content         Text,
                                   @Type            Int
As
  Update Qianbo_Style
  Set    [StyleCategoryId] = @StyleCategoryId,
         [Name] = @Name,
         [Content] = @Content,
         [Type] = @Type
  Where  [StyleID] = @StyleID
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Style_UpdateModelId @oldmodelid Int,
                                          @newmodelid Int
As
  Update Qianbo_Style
  Set    Type = @newmodelid
  Where  Type = @oldmodelid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [dbo].[Proc_Style_UpdateSearchStyle] @modelId Int,
                                                      @content Ntext
As
  Update Qianbo_ListStyleContent
  Set    Content = @content
  Where  ModelId = @modelId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SubSite_Add @Name          Nvarchar(100),
                                  @FirstChar     Nvarchar(20),
                                  @EnName        Varchar(200),
                                  @LOGO          Nvarchar(400),
                                  @Sort          Int,
                                  @Status        Int,
                                  @AddTime       Datetime,
                                  @Remark        Nvarchar(1000),
                                  @OpenTime      Varchar(50),
                                  @DbServer      Varchar(50),
                                  @DbName        Varchar(50),
                                  @DbUid         Varchar(50),
                                  @DbPwd         Varchar(50),
                                  @Permision     Varchar(500),
                                  @CallName      Nvarchar(50),
                                  @CallPass      Nvarchar(50),
                                  @IsCreateModel Bit,
                                  @Domain        Nvarchar(100)
As
  Insert Into Qianbo_SubSite
              ([Name],
               [FirstChar],
               [EnName],
               [LOGO],
               [Sort],
               [Status],
               [AddTime],
               [Remark],
               [OpenTime],
               [DbServer],
               [DbName],
               [DbUid],
               [DbPwd],
               [Permision],
               [CallName],
               [CallPass],
               [IsCreateModel],
               [Domain])
  Values      ( @Name,
                @FirstChar,
                @EnName,
                @LOGO,
                @Sort,
                @Status,
                @AddTime,
                @Remark,
                @OpenTime,
                @DbServer,
                @DbName,
                @DbUid,
                @DbPwd,
                @Permision,
                @CallName,
                @CallPass,
                @IsCreateModel,
                @Domain )
  Select SCOPE_IDENTITY()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure dbo.Proc_SubSite_DelAdmin @SiteId Int
As
  Delete From [Qianbo_Admin]
  Where  [SiteId] = @SiteId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SubSite_Delete @Id Int
As
  Delete From Qianbo_SubSite
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_SubSite_GetList @PageSize  Int=20,
                                      @PageIndex Int=1,
                                      @strWhere  Varchar(200)
As
  Declare @SqlStr Nvarchar(2000)
  Declare @Filter Nvarchar(2000)
  If( @strWhere = '' )
    Begin
        Set @strWhere=' where '
        Set @Filter=''
    End
  Else
    Begin
        Set @Filter=' where ' + @strWhere
        Set @strWhere=' where ' + @strWhere + ' and '
    End
  Begin
      If( @PageIndex = 1 )
        Begin
            Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_SubSite ' + @Filter + ' order by [Id] desc'
        End
      Else
        Begin
            Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_SubSite ' + @strWhere + ' Id not in(select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' Id from Qianbo_SubSite ' + @Filter + ' order by [Id] desc) order by [Id] desc'
        End
      Execute Sp_ExecuteSql @SqlStr
      Set @SqlStr = 'select Count(*) from Qianbo_SubSite ' + @Filter
      Execute Sp_ExecuteSql @SqlStr
  End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SubSite_GetModel @Id Int
As
  Select *
  From   Qianbo_SubSite
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SubSite_GetModel_EnName @EnName Varchar(200)
As
  Select *
  From   Qianbo_SubSite
  Where  [EnName] = @EnName
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SubSite_Update @Id            Int,
                                     @Name          Nvarchar(100),
                                     @FirstChar     Char(1),
                                     @EnName        Varchar(200),
                                     @LOGO          Nvarchar(400),
                                     @Sort          Int,
                                     @Status        Int,
                                     @AddTime       Datetime,
                                     @Remark        Nvarchar(1000),
                                     @OpenTime      Varchar(50),
                                     @DbServer      Varchar(50),
                                     @DbName        Varchar(50),
                                     @DbUid         Varchar(50),
                                     @DbPwd         Varchar(50),
                                     @Permision     Varchar(500),
                                     @CallName      Nvarchar(50),
                                     @CallPass      Nvarchar(50),
                                     @IsCreateModel Bit,
                                     @Domain        Nvarchar(100)
As
  Update Qianbo_SubSite
  Set    [Name] = @Name,
         [FirstChar] = @FirstChar,
         [EnName] = @EnName,
         [LOGO] = @LOGO,
         [Sort] = @Sort,
         [Status] = @Status,
         [AddTime] = @AddTime,
         [Remark] = @Remark,
         [OpenTime] = @OpenTime,
         [DbServer] = @DbServer,
         [DbName] = @DbName,
         [DbUid] = @DbUid,
         [DbPwd] = @DbPwd,
         [Permision] = @Permision,
         CallName = @CallName,
         CallPass = @CallPass,
         IsCreateModel = @IsCreateModel,
         Domain = @Domain
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_SuperLabel_Add @Name           Nvarchar(100),
                                     @LbCategoryName Nvarchar(100),
                                     @LbCategoryId   Int,
                                     @DataBaseType   Int,
                                     @SuperDes       Nvarchar(1000),
                                     @IsUnlockPage   Bit,
                                     @HostTable      Nvarchar(100),
                                     @GuestTable     Nvarchar(100),
                                     @SqlStr         Nvarchar(1000),
                                     @Content        Ntext,
                                     @AddTime        Datetime,
                                     @PageSize       Int,
                                     @NumColumns     Int,
                                     @IsHtml         Bit,
                                     @DataBaseConn   Nvarchar(300)=" "
As
  Insert Into [Qianbo_SuperLabel]
              ([Name],
               [LbCategoryName],
               [LbCategoryId],
               [DataBaseType],
               [SuperDes],
               [IsUnlockPage],
               [HostTable],
               [GuestTable],
               [SqlStr],
               [Content],
               [AddTime],
               [PageSize],
               [NumColumns],
               [IsHtml],
               [DataBaseConn])
  Values      (@Name,
               @LbCategoryName,
               @LbCategoryId,
               @DataBaseType,
               @SuperDes,
               @IsUnlockPage,
               @HostTable,
               @GuestTable,
               @SqlStr,
               @Content,
               @AddTime,
               @PageSize,
               @NumColumns,
               @IsHtml,
               @DataBaseConn)
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_SuperLabel_CheckName @Name Nvarchar(100)
As
  If Exists(Select *
            From   [Qianbo_SuperLabel]
            Where  Name = @Name)
    Select 1
  Else
    Select 0
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_SuperLabel_Delete @SuperId Int
As
  Delete [Qianbo_SuperLabel]
  Where  [SuperId] = @SuperId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_SuperLabel_GetList @CurrPage Int,
                                         @PageSize Int
As
  Declare @SqlStr Nvarchar(2000);
  If( @CurrPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_SuperLabel] order by SuperId desc';
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_SuperLabel] where SuperId not in(select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' SuperId from [Qianbo_SuperLabel] order by SuperId desc) order by SuperId desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(SuperId) from [Qianbo_SuperLabel]';
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_SuperLabel_GetModel @SuperId Int
As
  Select [SuperId],
         [Name],
         [LbCategoryName],
         [LbCategoryId],
         [DataBaseType],
         [SuperDes],
         [IsUnlockPage],
         [HostTable],
         [GuestTable],
         [SqlStr],
         [Content],
         [AddTime],
         [PageSize],
         [NumColumns],
         [IsHtml],
         [DataBaseConn]
  From   [Qianbo_SuperLabel]
  Where  [SuperId] = @SuperId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_SuperLabel_GetSuperId @Name Nvarchar(150)
As
  Declare @SuperId Int;
  Set @SuperId=(Select Top 1 SuperId
                From   [Qianbo_SuperLabel]
                Where  [Name] = @Name
                Order  By SuperId Desc)
  If @SuperId Is Null
    Select 0
  Else
    Select @SuperId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_SuperLabel_IsModelTable @TableName Nvarchar(100)
As
  If Exists(Select *
            From   [Qianbo_Model]
            Where  TableName = @TableName)
    Select 1
  Else
    Select 0
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_SuperLabel_Out @InSuperId Nvarchar(2000)
As
  Declare @SqlStr Nvarchar(2000);
  Set @SqlStr=N'select * from [Qianbo_SuperLabel] where SuperId in(' + @InSuperId + ')';
  Execute Sp_ExecuteSql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_SuperLabel_Update @SuperId        Int,
                                        @Name           Nvarchar(100),
                                        @LbCategoryName Nvarchar(100),
                                        @LbCategoryId   Int,
                                        @DataBaseType   Int,
                                        @SuperDes       Nvarchar(1000),
                                        @IsUnlockPage   Bit,
                                        @HostTable      Nvarchar(100),
                                        @GuestTable     Nvarchar(100),
                                        @SqlStr         Nvarchar(1000),
                                        @Content        Ntext,
                                        @AddTime        Datetime,
                                        @PageSize       Int,
                                        @NumColumns     Int,
                                        @IsHtml         Bit,
                                        @DataBaseConn   Nvarchar(300)=" "
As
  Update [Qianbo_SuperLabel]
  Set    [Name] = @Name,
         [LbCategoryName] = @LbCategoryName,
         [LbCategoryId] = @LbCategoryId,
         [DataBaseType] = @DataBaseType,
         [SuperDes] = @SuperDes,
         [IsUnlockPage] = @IsUnlockPage,
         [HostTable] = @HostTable,
         [GuestTable] = @GuestTable,
         [SqlStr] = @SqlStr,
         [Content] = @Content,
         [AddTime] = @AddTime,
         PageSize = @PageSize,
         NumColumns = @NumColumns,
         IsHtml = @IsHtml,
         DataBaseConn = @DataBaseConn
  Where  [SuperId] = @SuperId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Superior_Add @Name      Nvarchar(400),
                                   @StartCode Nvarchar(1000),
                                   @EndCode   Nvarchar(1000)
As
  Insert Into Qianbo_Superior
              ([Name],
               [StartCode],
               [EndCode])
  Values      ( @Name,
                @StartCode,
                @EndCode )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Superior_Delete @id Int
As
  Delete Qianbo_Superior
  Where  [id] = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Superior_GetIdBySuperiorl @id Int
As
  Select [id],
         [Name],
         [StartCode],
         [EndCode]
  From   Qianbo_Superior
  Where  [id] = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Superior_GetList
As
  Select [id],
         [Name],
         [StartCode],
         [EndCode]
  From   Qianbo_Superior
  Order  By [ID] Desc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Superior_Update @id        Int,
                                      @Name      Nvarchar(400),
                                      @StartCode Nvarchar(1000),
                                      @EndCode   Nvarchar(1000)
As
  Update Qianbo_Superior
  Set    [Name] = @Name,
         [StartCode] = @StartCode,
         [EndCode] = @EndCode
  Where  [id] = @id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_TagCategory_GetList
As
  Select *
  From   Qianbo_TagCategory
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_TagCategory_Set @TagCategoryId Int,
                                      @Name          Nvarchar(20),
                                      @Desc          Nvarchar(100)
As
  If ( @TagCategoryId <= 0 )
    Begin
        Insert Into Qianbo_TagCategory
                    ([Name],
                     [Desc])
        Values      (@Name,
                     @Desc);
    End
  Else
    Begin
        Update Qianbo_TagCategory
        Set    [Name] = @Name,
               [Desc] = @Desc
        Where  TagCategoryId = @TagCategoryId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_TagCateogry_Delete @TagCategoryId Int
As
  Set Xact_Abort On
  Begin Tran
  Update Qianbo_Tag
  Set    TagCategoryId = 0
  Where  TagCategoryId = @TagCategoryId
  Delete From Qianbo_TagCategory
  Where  TagCategoryId = @TagCategoryId
  Commit Tran
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_TagNotice_GetList @CurrPage Int,
                                            @PageSize Int,
                                            @WhereStr Nvarchar(1000)
As
  Declare @SqlStr Nvarchar(2000);
  If( @CurrPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_Notice] ' + Convert(Nvarchar(100), @WhereStr) + ' order by IsPriority desc,NoticeId desc';
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_Notice] ' + Convert(Nvarchar(100), @WhereStr) + ' and NoticeId not in(select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' NoticeId from [Qianbo_Notice] ' + Convert(Nvarchar(100), @WhereStr) + ' order by IsPriority desc,NoticeId desc) order by IsPriority desc,NoticeId desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(NoticeId) from [Qianbo_Notice] ' + @WhereStr;
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Tag_Add @Name          Nvarchar(20),
                              @TagCategoryId Int,
                              @ModelType     Int,
                              @UserId        Int,
                              @UserName      Nvarchar(20)
As
  If Exists(Select *
            From   Qianbo_Tag
            Where  Name = @Name)
    Return
  Insert Into Qianbo_Tag
              ([Name],
               TagCategoryId,
               ModelType,
               UserId,
               UserName)
  Values      (@Name,
               @TagCategoryId,
               @ModelType,
               @UserId,
               @UserName)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Tag_AddTagStr @tagstr    Nvarchar(300),
                                    @modeltype Int,
                                    @uid       Int,
                                    @uname     Nvarchar(20)
As
  If( @tagstr = '' )
    Select '',
           ''
  Else
    Set @tagstr = @tagstr + '|'
  Declare @tb Table(
    [name] Nvarchar(20))
  Declare @index Int
  Declare @name Nvarchar(20)
  While( @tagstr <> '' )
    Begin
        Set @index = charindex('|', @tagstr)
        Set @name = substring(@tagstr, 1, @index - 1)
        Set @tagstr = substring(@tagstr, @index + 1, len(@tagstr) - @index)
        Insert Into @tb
        Values      (@name)
    End
  Declare @returnidstr Nvarchar(300)
  Declare @char Nvarchar(1)
  Set @returnidstr = ''
  Set @char = '';
  Declare @returnid Nvarchar(15)
  Declare @returnnamestr Nvarchar(300)
  Set @returnnamestr = ''
  Declare cur Cursor fast_forward For
    (Select [name]
     From   @tb)
  Open cur
  Fetch next From cur Into @name
  While( @@fetch_status = 0 )
    Begin
        If Exists(Select *
                  From   Qianbo_Tag
                  Where  [name] = @name)
          Begin
              Set @returnid = (Select tagid
                               From   Qianbo_Tag
                               Where  [name] = @name)
              Set @returnidstr= @returnidstr + @char + @returnid
              Set @returnnamestr = @returnnamestr + @char + @name
              Set @char = '|'
          End
        Else
          Begin
              If( @name != '' )
                Begin
                    Insert Into Qianbo_Tag
                                ([name],
                                 tagcategoryid,
                                 modeltype,
                                 userid,
                                 username)
                    Values      (@name,
                                 0,
                                 @modeltype,
                                 @uid,
                                 @uname)
                    Set @returnid = scope_identity()
                    Set @returnidstr= @returnidstr + @char + @returnid
                    Set @returnnamestr = @returnnamestr + @char + @name
                    Set @char = '|'
                End
          End
        Fetch next From cur Into @name
    End
  Close cur
  Deallocate cur
  Select @returnidstr,
         @returnnamestr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Tag_Clear
As
  Update [Qianbo_Tag]
  Set    daysearchcount = 0,
         yesterdaysearchcount = daysearchcount,
         counttime = getdate()
  Where  datediff(day, counttime, getdate()) != 0
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Tag_Delete @SearchCount Int
As
  Delete From Qianbo_Tag
  Where  TotalSearchCount < @SearchCount
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Tag_GetList @currpage    Int,
                                  @pagesize    Int,
                                  @recordcount Int output
As
  Declare @sqlstr Nvarchar(4000)
  Declare @selectfield Nvarchar(1000)
  Declare @selecttable Nvarchar(1000)
  Declare @order Nvarchar(500)
  Set @selectfield = ' a.tagid,tagname = a.name,tagcategoryname=isnull(b.name,''无类别''),a.modeltype,a.yesterdaysearchcount,a.daysearchcount,a.totalsearchcount,a.username,a.userid,c.modelname '
  Set @selecttable =' Qianbo_Tag a left join Qianbo_TagCategory b on a.tagcategoryid = b.tagcategoryid join Qianbo_Model c on a.modeltype = c.modelid '
  Set @order = ' order by totalsearchcount desc, tagid desc '
  If( @currpage = 1 )
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @selectfield + 'from' + @selecttable + @order
  Else
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + @selectfield + 'from' + @selecttable + 'where a.tagid not in(select top ' + Convert(Nvarchar(15), (@currpage - 1) * @pagesize) + ' a.tagid from ' + @selecttable + @order + ')' + @order
  Execute sp_executesql @sqlstr
  Set @recordcount = (Select Count(tagid)
                      From   Qianbo_Tag)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Tag_SetSearchCount @tagName   Nvarchar(20),
                                    @modeltype Int
As
  Update Qianbo_Tag
  Set    daysearchcount = daysearchcount + 1,
         totalsearchcount = totalsearchcount + 1
  Where  [name] = @tagname
         And modeltype = @modeltype
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Proc Proc_TempTablePage_GetList @pageIndex   Int,
                                       @pageSize    Int,
                                       @recordCount Int output
As
  Declare @sqlStr Nvarchar(2000)
  If( @pageIndex = 1 )
    Set @sqlStr=N'select top ' + Convert(Nvarchar(15), @pageSize) + ' * from Qianbo_TempTable where issend = 0 order by id desc'
  Else
    Set @sqlStr=N'select top ' + Convert(Nvarchar(15), @pageSize) + ' * from Qianbo_TempTable where id < (select min(id) from (select top ' + Convert(Nvarchar(15), (@pageIndex-1) * @pageSize) + ' id from Qianbo_TempTable order by id desc)o) and  issend = 0 order by id desc'
  Execute Sp_ExecuteSql @sqlStr
  Set @recordCount=(Select Count(id)
                    From   Qianbo_TempTable
                    Where  issend = 0)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_TempTableSimple_Delete @Id Int
As
  Delete Qianbo_TempTable
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_TempTable_Add @ChId               Int,
                                    @ColId              Int,
                                    @Title              Nvarchar(200),
                                    @TitleColor         Nvarchar(6),
                                    @TitleFontType      Int,
                                    @TitleType          Int,
                                    @TitleImgPath       Varchar(255),
                                    @UId                Int,
                                    @UName              Nvarchar(20),
                                    @UserType           Int,
                                    @AdminUId           Int,
                                    @AdminUName         Nvarchar(50),
                                    @Status             Int,
                                    @HitCount           Int,
                                    @AddTime            Datetime,
                                    @UpdateTime         Datetime,
                                    @TemplatePath       Varchar(255),
                                    @PageType           Int,
                                    @IsCreated          Bit,
                                    @UserCateId         Int,
                                    @PointCount         Int,
                                    @ChargeType         Int,
                                    @ChargeHourCount    Int,
                                    @ChargeViewCount    Int,
                                    @IsOpened           Int,
                                    @OuterUrl           Nvarchar(300),
                                    @GroupIdStr         Varchar(200),
                                    @IsDeleted          Bit,
                                    @IsRecommend        Bit,
                                    @IsTop              Bit,
                                    @IsFocus            Bit,
                                    @IsSideShow         Bit,
                                    @TagIdStr           Varchar(300),
                                    @TagNameStr         Nvarchar(300),
                                    @IsAllowComment     Bit,
                                    @SpecialIdStr       Varchar(200),
                                    @ViewUName          Ntext,
                                    @ViewUName2         Ntext,
                                    @ExtendContentTable Nvarchar(50),
                                    @InputDateOuthor    Int,
                                    @SubSiteId          Int,
                                    @IsSend             Bit,
                                    @SendTime           Datetime,
                                    @InfoId             Int
As
  Insert Into Qianbo_TempTable
              ([ChId],
               [ColId],
               [Title],
               [TitleColor],
               [TitleFontType],
               [TitleType],
               [TitleImgPath],
               [UId],
               [UName],
               [UserType],
               [AdminUId],
               [AdminUName],
               [Status],
               [HitCount],
               [AddTime],
               [UpdateTime],
               [TemplatePath],
               [PageType],
               [IsCreated],
               [UserCateId],
               [PointCount],
               [ChargeType],
               [ChargeHourCount],
               [ChargeViewCount],
               [IsOpened],
               [OuterUrl],
               [GroupIdStr],
               [IsDeleted],
               [IsRecommend],
               [IsTop],
               [IsFocus],
               [IsSideShow],
               [TagIdStr],
               [TagNameStr],
               [IsAllowComment],
               [SpecialIdStr],
               [ViewUName],
               [ViewUName2],
               [ExtendContentTable],
               [InputDateOuthor],
               [SubSiteId],
               [IsSend],
               [SendTime],
               [InfoId])
  Values      ( @ChId,
                @ColId,
                @Title,
                @TitleColor,
                @TitleFontType,
                @TitleType,
                @TitleImgPath,
                @UId,
                @UName,
                @UserType,
                @AdminUId,
                @AdminUName,
                @Status,
                @HitCount,
                @AddTime,
                @UpdateTime,
                @TemplatePath,
                @PageType,
                @IsCreated,
                @UserCateId,
                @PointCount,
                @ChargeType,
                @ChargeHourCount,
                @ChargeViewCount,
                @IsOpened,
                @OuterUrl,
                @GroupIdStr,
                @IsDeleted,
                @IsRecommend,
                @IsTop,
                @IsFocus,
                @IsSideShow,
                @TagIdStr,
                @TagNameStr,
                @IsAllowComment,
                @SpecialIdStr,
                @ViewUName,
                @ViewUName2,
                @ExtendContentTable,
                @InputDateOuthor,
                @SubSiteId,
                @IsSend,
                @SendTime,
                @InfoId )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_TempTable_Delete @idstr Nvarchar(2000)
As
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr='delete Qianbo_TempTable where id in(' + @idstr + ')'
  Execute (@sqlstr)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_TempTable_Exists @outUrl Nvarchar(500)
As
  Select [id]
  From   Qianbo_TempTable
  Where  [OuterUrl] = @outUrl
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_TempTable_GetList @idstr Nvarchar(2000)
As
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr='select Id,ChId,ColId,Title,TitleColor,TitleFontType,TitleType,TitleImgPath,UId,UName,UserType,AdminUId,AdminUName,Status,HitCount,AddTime,UpdateTime,TemplatePath,PageType,IsCreated,UserCateId,PointCount,ChargeType,ChargeHourCount,ChargeViewCount,IsOpened,OuterUrl,GroupIdStr,IsDeleted,IsRecommend,IsTop,IsFocus,IsSideShow,TagIdStr,TagNameStr,IsAllowComment,SpecialIdStr,ViewUName,ViewUName2,ExtendContentTable from Qianbo_TempTable where [id] in (' + Convert(Nvarchar(2000), @idstr) + ')'
  Execute (@sqlstr)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_TempTable_IsSend (@subsiteid Int,
                                        @colid     Int,
                                        @infoid    Int)
As
  Select id
  From   Qianbo_TempTable
  Where  infoid = @infoid
         And colid = @colid
         And subsiteid = @subsiteid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_TempTable_Update @ChId  Int,
                                       @ColId Int,
                                       @idstr Varchar(2000)
As
  Declare @sqlstr Varchar(4000)
  Set @sqlstr='update Qianbo_TempTable set [ChId] =' + Convert(Varchar(15), @ChId) + ',[ColId] = ' + Convert(Varchar(15), @ColId) + ' where [id] in (' + @idstr + ')'
  Execute (@sqlstr)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_TempTable_UpdateSate @idstr Nvarchar(2000)
As
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr='update Qianbo_TempTable set IsSend = 1 where id in(' + @idstr + ')'
  Execute (@sqlstr)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UpdateMoney @Value  Decimal,
                                  @UserID Int,
                                  @TypeId Int
As
  If @TypeId = 1
    Begin
        Update [Qianbo_Users]
        Set    YellowBoy = YellowBoy + @Value
        Where  UserID = @UserID
    End
  If @TypeId = 2
    Begin
        Update [Qianbo_Users]
        Set    Integral = Integral + @Value
        Where  UserID = @UserID
    End
  If @TypeId = 3
    Begin
        Update [Qianbo_Users]
        Set    ExpireTime = DATEADD([day], @Value, ExpireTime)
        Where  UserID = @UserID
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserAlbum_Delete @Id     Int,
                                  @UserId Int
As
  Delete Qianbo_UserAlbum
  Where  Id = @Id
         And userId = @UserId
  Delete Qianbo_UserPhoto
  Where  AlbumId = @Id
         And userId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserAlbum_GetById @Id     Int,
                                        @UserId Int
As
  Select [Id],
         [AlbumName],
         [AlbumCate],
         [AlbumDescription],
         [ImgCount],
         [Logo],
         [IsOpened],
         [AlbumPassword],
         [AddTime],
         [UserId],
         [UserName]
  From   Qianbo_UserAlbum
  Where  [Id] = @Id
         And UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserAlbum_GetByUserId @UserId      Int,
                                       @PageIndex   Int=1,
                                       @PageSize    Int=10,
                                       @RecordCount Int=0 output
As
  Declare @sqlstr Nvarchar(4000)
  If( @PageIndex = 1 )
    Set @sqlstr =N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_UserAlbum where UserId = ' + Convert(Nvarchar(15), @UserId) + ' order by Id desc'
  Else
    Set @sqlstr =N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_UserAlbum where UserId = ' + Convert(Nvarchar(15), @UserId) + ' and id < (select min(o.id) from(select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' id from Qianbo_UserAlbum where UserId = ' + Convert(Nvarchar(15), @UserId) + ' order by Id desc)o) order by Id desc'
  Execute sp_executesql @sqlstr
  Set @sqlstr='select Count(Id) from Qianbo_UserAlbum where UserId = ' + Convert(Nvarchar(15), @UserId)
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserAlbum_Set @Id               Int output,
                                    @AlbumName        Nvarchar(50),
                                    @AlbumCate        Nvarchar(50),
                                    @AlbumDescription Nvarchar(500),
                                    @ImgCount         Int,
                                    @Logo             Nvarchar(50),
                                    @IsOpened         Int,
                                    @AlbumPassword    Nvarchar(50),
                                    @AddTime          Nvarchar(50),
                                    @UserId           Int,
                                    @UserName         Nvarchar(50)
As
  If( @Id = 0 )
    Begin
        Insert Into Qianbo_UserAlbum
                    ([AlbumName],
                     [AlbumCate],
                     [AlbumDescription],
                     [ImgCount],
                     [Logo],
                     [IsOpened],
                     [AlbumPassword],
                     [AddTime],
                     [UserId],
                     [UserName])
        Values      ( @AlbumName,
                      @AlbumCate,
                      @AlbumDescription,
                      0,
                      @Logo,
                      @IsOpened,
                      @AlbumPassword,
                      @AddTime,
                      @UserId,
                      @UserName )
        Set @Id=scope_identity()
    End
  Else
    Begin
        Update Qianbo_UserAlbum
        Set    [AlbumName] = @AlbumName,
               [AlbumCate] = @AlbumCate,
               [AlbumDescription] = @AlbumDescription,
               [Logo] = @Logo,
               [IsOpened] = @IsOpened,
               [AlbumPassword] = @AlbumPassword,
               [UserId] = @UserId,
               [UserName] = @UserName
        Where  [Id] = @Id
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserCate_Delete @UserCateId Int
As
  Delete From Qianbo_UserCate
  Where  UserCateId = @UserCateId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserCate_GetById @UserCateId Int
As
  Select *
  From   Qianbo_UserCate
  Where  UserCateId = @UserCateId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserCate_GetByUser @UserId   Int,
                                    @CateType Int=-1,
                                    @KeyWord  Nvarchar(500)=''
As
  Declare @WhereStr Nvarchar(2000)
  Set @Wherestr='';
  If( @CateType !=- 1 )
    Begin
        Set @WhereStr = @WhereStr + 'a.CateType=' + Convert(Nvarchar(15), @CateType) + ' and ';
    End
  If( @KeyWord != '' )
    Begin
        Set @WhereStr = @WhereStr + 'a.CateName like ''%' + @KeyWord + '%''' + ' and ';
    End
  Set @WhereStr = @WhereStr + 'a.UserId = ' + Convert(Nvarchar(15), @UserId)
  Declare @SqlStr Nvarchar(2000)
  Set @SqlStr='select a.*,b.LogName from Qianbo_UserCate a inner join Qianbo_Users b on a.UserId = b.UserID where ' + @WhereStr
  Execute sp_executesql @SqlStr
  Print @sqlstr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserCate_GetCountByUserId @UserId Int
As
  Select Count(userCateId)
  From   Qianbo_UserCate
  Where  UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserCate_GetList @userid    Int,
                                  @modeltype Int
As
  If( @modeltype = 0 )
    Select a.*,
           c.modelname
    From   Qianbo_UserCate a
           Inner Join Qianbo_Users b
             On a.userid = b.userid
           Inner Join Qianbo_Model c
             On a.modeltype = c.modelid
    Where  a.userid = @userid
  Else
    Select a.*,
           c.modelname
    From   Qianbo_UserCate a
           Inner Join Qianbo_Users b
             On a.userid = b.userid
           Inner Join Qianbo_Model c
             On a.modeltype = c.modelid
    Where  a.userid = @userid
           And a.modeltype = @modeltype
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserCate_Set @UserCateId  Int output,
                                   @UserId      Int,
                                   @CateName    Varchar(50),
                                   @CateType    Int,
                                   @Discription Text
As
  If( @UserCateId = 0 )
    Begin
        Insert Into Qianbo_UserCate
                    ([UserId],
                     [CateName],
                     [ModelType],
                     [Discription])
        Values      ( @UserId,
                      @CateName,
                      @CateType,
                      @Discription )
        Set @UserCateId=Scope_identity()
    End
  Else
    Begin
        Update Qianbo_UserCate
        Set    [UserId] = @UserId,
               [CateName] = @CateName,
               [ModelType] = @CateType,
               [Discription] = @Discription
        Where  [UserCateId] = @UserCateId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserFavorite @id      Int=0,
                                   @UserId  Int=0,
                                   @Title   Nvarchar(100)=" ",
                                   @Url     Nvarchar(1000)=" ",
                                   @AddDate Datetime=" ",
                                   @TypeId  Int=0
As
  If @TypeId = 1
    Begin
        Insert Into Qianbo_UserFavorite
                    ([UserId],
                     [Title],
                     [Url],
                     [AddDate])
        Values      (@UserId,
                     @Title,
                     @Url,
                     @AddDate)
    End
  If @TypeId = 2
    Begin
        Delete Qianbo_UserFavorite
        Where  [id] = @id
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserFavorite_GetList @CurrPage Int,
                                           @PageSize Int,
                                           @WhereStr Nvarchar(100)
As
  Declare @SqlStr Nvarchar(2000);
  If( @CurrPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_UserFavorite] ' + Convert(Nvarchar(100), @WhereStr) + ' order by Id desc';
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_UserFavorite] ' + Convert(Nvarchar(100), @WhereStr) + ' and Id not in(select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' Id from [Qianbo_UserFavorite] ' + Convert(Nvarchar(100), @WhereStr) + ' order by Id desc) order by Id desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(Id) from [Qianbo_UserFavorite] ' + @WhereStr;
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserGroup @UserGroupId      Int=0,
                                @UserGroupName    Nvarchar(100)=" ",
                                @UserGroupContent Nvarchar(1000)=" ",
                                @TypeId           Int=0,
                                @GroupPower       Ntext=" ",
                                @ColumnPower      Ntext=" ",
                                @IsSystem         Int=0,
                                @AddDate          Datetime=" ",
                                @Up_Id            Int=0,
                                @ChannelPower     Ntext=" ",
                                @AllChannel       Ntext=" ",
                                @AllColumn        Ntext=" "
As
  If( @Up_Id = 1 )
    Begin
        Insert Into Qianbo_UserGroup
                    ([UserGroupName],
                     [UserGroupContent],
                     [TypeId],
                     [GroupPower],
                     [ColumnPower],
                     [IsSystem],
                     [AddDate],
                     [ChannelPower],
                     [AllChannel],
                     [AllColumn])
        Values      (@UserGroupName,
                     @UserGroupContent,
                     @TypeId,
                     @GroupPower,
                     @ColumnPower,
                     @IsSystem,
                     @AddDate,
                     @ChannelPower,
                     @AllChannel,
                     @AllColumn)
    End
  If( @Up_Id = 2 )
    Begin
        Update Qianbo_UserGroup
        Set    [UserGroupName] = @UserGroupName,
               [UserGroupContent] = @UserGroupContent,
               [GroupPower] = @GroupPower,
               [ColumnPower] = @ColumnPower,
               [AddDate] = @AddDate,
               [ChannelPower] = @ChannelPower,
               [AllChannel] = @AllChannel,
               [AllColumn] = @AllColumn
        Where  [UserGroupId] = @UserGroupId
    End
  If( @Up_Id = 3 )
    Begin
        Delete Qianbo_UserGroup
        Where  [UserGroupId] = @UserGroupId
    End
  If( @Up_Id = 4 )
    Begin
        Select *
        From   Qianbo_UserGroup
        Where  [UserGroupId] = @UserGroupId
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModelField_Add @ModelId      Int,
                                              @Name         Nvarchar(100),
                                              @Alias        Nvarchar(300),
                                              @Description  Nvarchar(400),
                                              @IsNotNull    Bit,
                                              @IsSearchForm Bit,
                                              @Type         Nvarchar(100),
                                              @Content      Ntext,
                                              @IsList       Bit,
                                              @IsUserInsert Bit,
                                              @AddDate      Datetime
As
  Declare @OrderId Int;
  Set @OrderId=(Select max(OrderId)
                From   [Qianbo_UserGroupModelField]
                Where  ModelId = @ModelId)
  If @OrderId Is Null
    Set @OrderId=0
  Else
    Set @OrderId = @OrderId + 1
  Insert Into [Qianbo_UserGroupModelField]
              ([ModelId],
               [Name],
               [Alias],
               [Description],
               [IsNotNull],
               [IsSearchForm],
               [Type],
               [Content],
               [AddDate],
               [OrderId],
               [IsList],
               [IsUserInsert])
  Values      (@ModelId,
               @Name,
               @Alias,
               @Description,
               @IsNotNull,
               @IsSearchForm,
               @Type,
               @Content,
               @AddDate,
               @OrderId,
               @IsList,
               @IsUserInsert)
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModelField_Del @FieldId Int
As
  Delete From [Qianbo_UserGroupModelField]
  Where  FieldId = @FieldId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModelField_GetIsUserList @ModelId Int
As
  Select *
  From   [Qianbo_UserGroupModelField]
  Where  ModelId = @ModelId
         And IsUserInsert = 1
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModelField_GetList @ModelId Int
As
  Select *
  From   [Qianbo_UserGroupModelField]
  Where  ModelId = @ModelId
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModelField_GetModel @FieldId Int=0,
                                                   @ModelId Int=0,
                                                   @Name    Nvarchar(50)=" ",
                                                   @TypeId  Int
As
  If @TypeId = 1
    Select *
    From   [Qianbo_UserGroupModelField]
    Where  FieldId = @FieldId
  Else
    Select *
    From   [Qianbo_UserGroupModelField]
    Where  ModelId = @ModelId
           And [Name] = @Name
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModelField_GetTitleList @ModelId Int
As
  Select *
  From   [Qianbo_UserGroupModelField]
  Where  IsList = 1
         And ModelId = @ModelId
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModelField_MoveField @ModelId  Int,
                                                    @FieldId  Int,
                                                    @MoveType Nvarchar(20)
As
  Declare @OrderId Int;
  Declare @NewFieldId Int;
  Declare @NewOrderId Int;
  If @MoveType = 'UpMove'
    Begin
        Declare @MinOrderId Int;
        Set @MinOrderId=(Select min(OrderId)
                         From   [Qianbo_UserGroupModelField]
                         Where  ModelId = @ModelId)
        Set @OrderId=(Select OrderId
                      From   [Qianbo_UserGroupModelField]
                      Where  ModelId = @ModelId
                             And FieldId = @FieldId)
        If @OrderId != @MinOrderId
          Begin
              Set @NewFieldId=(Select Top 1 FieldId
                               From   [Qianbo_UserGroupModelField]
                               Where  ModelId = @ModelId
                                      And OrderId < @OrderId
                               Order  By OrderId Desc)
              Set @NewOrderId=(Select OrderId
                               From   [Qianbo_UserGroupModelField]
                               Where  ModelId = @ModelId
                                      And FieldId = @NewFieldId)
              Update [Qianbo_UserGroupModelField]
              Set    OrderId = @OrderId
              Where  FieldId = @NewFieldId
                     And ModelId = @ModelId
              Update [Qianbo_UserGroupModelField]
              Set    OrderId = @NewOrderId
              Where  FieldId = @FieldId
                     And ModelId = @ModelId
          End
    End
  If @MoveType = 'DownMove'
    Begin
        Declare @MaxOrderId Int;
        Set @MaxOrderId=(Select max(OrderId)
                         From   [Qianbo_UserGroupModelField]
                         Where  ModelId = @ModelId)
        Set @OrderId=(Select OrderId
                      From   [Qianbo_UserGroupModelField]
                      Where  ModelId = @ModelId
                             And FieldId = @FieldId)
        If @OrderId != @MaxOrderId
          Begin
              Set @NewFieldId=(Select Top 1 FieldId
                               From   [Qianbo_UserGroupModelField]
                               Where  ModelId = @ModelId
                                      And OrderId > @OrderId
                               Order  By OrderId)
              Set @NewOrderId=(Select OrderId
                               From   [Qianbo_UserGroupModelField]
                               Where  ModelId = @ModelId
                                      And FieldId = @NewFieldId)
              Update [Qianbo_UserGroupModelField]
              Set    OrderId = @OrderId
              Where  FieldId = @NewFieldId
                     And ModelId = @ModelId
              Update [Qianbo_UserGroupModelField]
              Set    OrderId = @NewOrderId
              Where  FieldId = @FieldId
                     And ModelId = @ModelId
          End
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModelField_SelectPropertyTrue @ModelId Nvarchar(50)
As
  Select *
  From   [Qianbo_UserGroupModelField]
  Where  ModelId = @ModelId
         And Type = 'RadioType'
         And Content Like '%Property=True%'
  Order  By OrderId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModelField_Update @FieldId      Int,
                                                 @ModelId      Int,
                                                 @Alias        Nvarchar(300),
                                                 @Description  Nvarchar(400),
                                                 @IsNotNull    Bit,
                                                 @IsSearchForm Bit,
                                                 @Content      Ntext,
                                                 @IsList       Bit,
                                                 @IsUserInsert Bit,
                                                 @AddDate      Datetime
As
  Update [Qianbo_UserGroupModelField]
  Set    [Alias] = @Alias,
         [Description] = @Description,
         [IsNotNull] = @IsNotNull,
         [IsSearchForm] = @IsSearchForm,
         [Content] = @Content,
         [IsList] = @IsList,
         [IsUserInsert] = @IsUserInsert,
         [AddDate] = @AddDate
  Where  [FieldId] = @FieldId
         And ModelId = @ModelId
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModel_Add @Name        Nvarchar(100),
                                         @TableName   Nvarchar(200),
                                         @Content     Nvarchar(1000),
                                         @ModelHtml   Ntext,
                                         @AddTime     Datetime,
                                         @IsValidate  Bit,
                                         @UserGroupId Int,
                                         @IsHtml      Bit,
                                         @SpaceTypeId Int
As
  Insert Into Qianbo_UserGroupModel
              ([Name],
               [TableName],
               [Content],
               [ModelHtml],
               [AddTime],
               [IsValidate],
               [UserGroupId],
               [IsHtml],
               [SpaceTypeId])
  Values      (@Name,
               @TableName,
               @Content,
               @ModelHtml,
               @AddTime,
               @IsValidate,
               @UserGroupId,
               @IsHtml,
               @SpaceTypeId)
  Select scope_identity()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [dbo].[Proc_UserGroupModel_AddTable] @TableName Nvarchar(50)
As
  Declare @sqlstr Nvarchar(500)
  Set @sqlstr=N'
CREATE TABLE [dbo].[' + @TableName + ']
(
[Id] [int] IDENTITY (1, 1) PRIMARY Key NOT NULL,
[UId] [int] NULL ,
[AddTime] [datetime] NULL,
[UpdateTime] [datetime] NULL)
CREATE  INDEX [IX_' + @TableName + '_UId] ON [' + @TableName + ']([UId]) ON [PRIMARY]'
  Exec sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModel_Delete @Id Int
As
  Declare @tablename Nvarchar(50)
  Set @tablename=''
  Set @tablename=(Select TableName
                  From   [Qianbo_UserGroupModel]
                  Where  [Id] = @Id)
  Declare @sqlstr Nvarchar(500)
  If( @tablename != '' )
    Begin
        Set @sqlstr = N'delete from [Qianbo_UserGroupModel] where [Id] = ' + Convert(Nvarchar(15), @Id)
        Exec sp_executesql @sqlstr
        Set @sqlstr = N'drop table [' + @tablename + ']'
        Exec sp_executesql @sqlstr
    End
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModel_GetAll
As
  Select [Id],
         [Name],
         [TableName],
         [Content],
         [ModelHtml],
         [AddTime],
         [IsValidate],
         [UserGroupId],
         [IsHtml],
         [SpaceTypeId]
  From   [Qianbo_UserGroupModel]
  Order  By Id Desc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModel_GetModel @Id Int
As
  Select [Id],
         [Name],
         [TableName],
         [Content],
         [ModelHtml],
         [AddTime],
         [IsValidate],
         [UserGroupId],
         [IsHtml],
         [SpaceTypeId]
  From   Qianbo_UserGroupModel
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModel_GetTextType @ModelId Int
As
  Select ModelId,
         [Name],
         Type
  From   [Qianbo_UserGroupModelField]
  Where  [ModelId] = @ModelId
         And [Type] = 'MultipleHtmlType'
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModel_ModelHtml @ModelHtml Ntext,
                                               @Id        Int
As
  Update [Qianbo_UserGroupModel]
  Set    ModelHtml = @ModelHtml
  Where  [Id] = @Id
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModel_Update @Id          Int,
                                            @Name        Nvarchar(100),
                                            @TableName   Nvarchar(200),
                                            @Content     Nvarchar(1000),
                                            @AddTime     Datetime,
                                            @IsValidate  Bit,
                                            @IsHtml      Bit,
                                            @SpaceTypeId Int
As
  Update [Qianbo_UserGroupModel]
  Set    [Name] = @Name,
         [TableName] = @TableName,
         [Content] = @Content,
         [AddTime] = @AddTime,
         [IsValidate] = @IsValidate,
         [IsHtml] = @IsHtml,
         [SpaceTypeId] = @SpaceTypeId
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_UserGroupModel_UpdateUserGroupId @Id          Int,
                                                       @UserGroupId Int
As
  Update [Qianbo_UserGroupModel]
  Set    UserGroupId = @UserGroupId
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserGroup_GetList @CurrPage Int,
                                        @PageSize Int,
                                        @WhereStr Nvarchar(100)
As
  Declare @SqlStr Nvarchar(2000);
  If( @CurrPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_UserGroup] ' + Convert(Nvarchar(100), @WhereStr) + ' order by UserGroupId desc';
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_UserGroup] ' + Convert(Nvarchar(100), @WhereStr) + ' and UserGroupId not in(select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' UserGroupId from [Qianbo_UserGroup] ' + Convert(Nvarchar(100), @WhereStr) + ' order by UserGroupId desc) order by UserGroupId desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(UserGroupId) from [Qianbo_UserGroup] ' + @WhereStr;
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserGroup_GetNameAndId @TypeId Int
As
  Select UserGroupId,
         UserGroupName
  From   Qianbo_UserGroup
  Where  TypeId = @TypeId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserGroup_ManageList @StrWhere Nvarchar(1000)
As
  Declare @SqlStr Nvarchar(2000);
  Set @SqlStr = N'select * from [Qianbo_UserGroup] ' + @StrWhere;
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserLog_Add @UserId      Int,
                                  @UserName    Nvarchar(20),
                                  @Description Nvarchar(1000),
                                  @InfoId      Int,
                                  @ModelType   Int,
                                  @Point       Int,
                                  @AddTime     Datetime
As
  Insert Into Qianbo_UserLog
              ([UserId],
               [UserName],
               [Description],
               [InfoId],
               [ModelType],
               [Point],
               [AddTime])
  Values      (@UserId,
               @UserName,
               @Description,
               @InfoId,
               @ModelType,
               @Point,
               @AddTime)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserLog_CheckIsPay @CheckPayType Int,
                                         @ModelType    Int,
                                         @InfoId       Int,
                                         @UserId       Int,
                                         @HourCount    Int,
                                         @ViewCount    Int
As
  If( @CheckPayType = 6 )
    Begin
        Select 0;
        Return;
    End
  Declare @PrePayTime Datetime;
  Declare @PreViewCount Int
  If Not Exists(Select Id
                From   Qianbo_UserLog
                Where  UserId = @UserId
                       And ModelType = @ModelType
                       And InfoId = @InfoId)
    Begin
        Select 0;
        Return;
    End
  If( @CheckPayType = 1 )
    Begin
        Select 1;
        Return;
    End
  If( @CheckPayType = 2 )
    Begin
        If( @HourCount <= 0 )
          Begin
              Select 1;
              Return;
          End
        Else
          Begin
              Set @PrePayTime = (Select Top 1 AddTime
                                 From   Qianbo_UserLog
                                 Where  UserId = @UserId
                                        And ModelType = @ModelType
                                        And InfoId = @InfoId
                                 Order  By Id Desc)
              If( DateDiff(hour, @PrePayTime, GetDate()) < @HourCount )
                Begin
                    Select 1;
                    Return;
                End
              Else
                Begin
                    Select 0;
                    Return;
                End
          End
    End
  If( @CheckPayType = 3 )
    Begin
        If( @ViewCount <= 0 )
          Begin
              Select 1;
              Return;
          End
        Else
          Begin
              Set @PrePayTime = (Select Top 1 AddTime
                                 From   Qianbo_UserLog
                                 Where  UserId = @UserId
                                        And ModelType = @ModelType
                                        And InfoId = @InfoId
                                 Order  By Id Desc)
              Set @PreViewCount = (Select Count(Id)
                                   From   Qianbo_ViewLog
                                   Where  UserId = @UserId
                                          And ModelType = @ModelType
                                          And InfoId = @InfoId
                                          And AddTime >= @PrePayTime)
              If( @PreViewCount < @ViewCount )
                Begin
                    Select 1;
                    Return;
                End
              Else
                Begin
                    Select 0;
                    Return;
                End
          End
    End
  If( @CheckPayType = 4 )
    Begin
        If( @ViewCount <= 0
             Or @HourCount <= 0 )
          Begin
              Select 1;
              Return;
          End
        Else
          Begin
              Set @PrePayTime = (Select Top 1 AddTime
                                 From   Qianbo_UserLog
                                 Where  UserId = @UserId
                                        And ModelType = @ModelType
                                        And InfoId = @InfoId
                                 Order  By Id Desc)
              Set @PreViewCount = (Select Count(Id)
                                   From   Qianbo_ViewLog
                                   Where  UserId = @UserId
                                          And ModelType = @ModelType
                                          And InfoId = @InfoId
                                          And AddTime >= @PrePayTime)
              If( DateDiff(hour, @PrePayTime, GetDate()) < @HourCount
                   Or @PreViewCount < @ViewCount )
                Begin
                    Select 1;
                    Return;
                End
              Else
                Begin
                    Select 0;
                    Return;
                End
          End
    End
  If( @CheckPayType = 5 )
    Begin
        If( @ViewCount <= 0
            And @HourCount <= 0 )
          Begin
              Select 1;
              Return;
          End
        Else
          Begin
              Set @PrePayTime = (Select Top 1 AddTime
                                 From   Qianbo_UserLog
                                 Where  UserId = @UserId
                                        And ModelType = @ModelType
                                        And InfoId = @InfoId
                                 Order  By Id Desc)
              Set @PreViewCount = (Select Count(Id)
                                   From   Qianbo_ViewLog
                                   Where  UserId = @UserId
                                          And ModelType = @ModelType
                                          And InfoId = @InfoId
                                          And AddTime >= @PrePayTime)
              If( ( DateDiff(hour, @PrePayTime, GetDate()) < @HourCount
                     Or @HourCount <= 0 )
                  And ( @PreViewCount < @ViewCount
                         Or @ViewCount <= 0 ) )
                Begin
                    Select 1;
                    Return;
                End
              Else
                Begin
                    Select 0;
                    Return;
                End
          End
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_UserLog_ListLog @WhereStr  Nvarchar(200),
                                          @PageSize  Int=20,
                                          @PageIndex Int=1,
                                          @Total     Int=0 output
As
  Declare @SqlStr Nvarchar(2000)
  If @PageIndex = 1
    Set @SqlStr='select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_UserLog where ' + @WhereStr
  Else
    Set @SqlStr='select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_UserLog where ' + @WhereStr + ' and [ID] < (select min([ID]) from (select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' * from Qianbo_UserLog where ' + @WhereStr + ' order by [ID] desc)L) order by [ID] desc'
  Print @SqlStr
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr ='select @TRecord = Count([ID]) from Qianbo_UserLog where ' + @WhereStr
  Declare @Parm Nvarchar(50)
  Set @Parm = '@TRecord int output';
  Exec Sp_ExecuteSql
    @SqlStr,
    @Parm,
    @TRecord = @Total output;
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserLog_ReducePoint @UserId Int,
                                          @Point  Int
As
  Declare @CurrPoint Int
  Set @CurrPoint=(Select YellowBoy
                  From   Qianbo_Users
                  Where  UserId = @UserId)
  If( @CurrPoint < @Point )
    Select 0;
  Else
    Begin
        Update Qianbo_Users
        Set    YellowBoy = YellowBoy - @Point
        Where  UserId = @UserId
        Select 1
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserMessage_Delete @IdStr  Nvarchar(1000),
                                         @UserId Int
As
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'delete Qianbo_UserMessage where [id] in(' + @idstr + ') and userid = @temp_userid'
  Declare @param Nvarchar(400)
  Set @param='@temp_userid int '
  Execute sp_executesql
    @sqlstr,
    @param,
    @temp_userid = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserMessage_GetById @Id     Int,
                                     @UserId Int
As
  Select *
  From   Qianbo_UserMessage
  Where  [id] = @Id
         And UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserMessage_GetByUserId @UserId      Int,
                                         @PageIndex   Int=1,
                                         @PageSize    Int=10,
                                         @RecordCount Int=0 output
As
  Declare @sqlstr Nvarchar(4000)
  If( @PageIndex = 1 )
    Set @sqlstr =N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_UserMessage where UserId = ' + Convert(Nvarchar(15), @UserId) + ' order by Id desc'
  Else
    Set @sqlstr =N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from Qianbo_UserMessage where UserId = ' + Convert(Nvarchar(15), @UserId) + ' and id < (select min(o.id) from(select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' id from Qianbo_UserMessage where UserId = ' + Convert(Nvarchar(15), @UserId) + ' order by Id desc)o) order by Id desc'
  Execute sp_executesql @sqlstr
  Set @sqlstr='select Count(Id) from Qianbo_UserMessage where UserId = ' + Convert(Nvarchar(15), @UserId)
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserMessage_Resume @Id            Int,
                                         @UserId        Int,
                                         @ResumeContent Text,
                                         @ResumeTime    Nvarchar(100)
As
  Update Qianbo_UserMessage
  Set    IsResume = 1,
         [ResumeContent] = @ResumeContent,
         [ResumeTime] = @ResumeTime
  Where  [Id] = @Id
         And UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserMessage_Set @Id            Int,
                                      @Title         Nvarchar(100),
                                      @Content       Text,
                                      @UserId        Int,
                                      @AnounName     Nvarchar(50),
                                      @HomePage      Nvarchar(100),
                                      @IsPrivacy     Bit,
                                      @IsResume      Bit,
                                      @ResumeContent Text,
                                      @PostTime      Nvarchar(100)
As
  If( @Id = 0 )
    Begin
        Insert Into Qianbo_UserMessage
                    ([Title],
                     [Content],
                     [UserId],
                     [AnounName],
                     [HomePage],
                     [IsPrivacy],
                     [IsResume],
                     [ResumeContent],
                     [PostTime])
        Values      ( @Title,
                      @Content,
                      @UserId,
                      @AnounName,
                      @HomePage,
                      @IsPrivacy,
                      @IsResume,
                      @ResumeContent,
                      @PostTime )
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserPhoto_Delete @PhotoIdStr Nvarchar(1000),
                                  @UserId     Int,
                                  @Count      Int
As
  Declare @SqlStr Nvarchar(4000)
  Set @SqlStr=N'update Qianbo_UserAlbum set Qianbo_UserAlbum.imgcount = imgcount-' + Convert(Nvarchar(15), @Count) + ' from Qianbo_UserPhoto inner join Qianbo_UserAlbum on Qianbo_UserAlbum.Id = Qianbo_UserPhoto.AlbumId where Qianbo_UserAlbum.UserId = ' + Convert(Nvarchar(15), @UserId) + ' and photoid in(' + @PhotoIdStr + ')'
  Execute sp_executesql @SqlStr
  Set @SqlStr=N'delete Qianbo_UserPhoto where PhotoId in (' + @PhotoIdStr + ') and UserId = ' + Convert(Nvarchar(15), @UserId) + ''
  Execute sp_executesql @SqlStr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserPhoto_GetById @AlbumId     Int,
                                   @UserId      Int,
                                   @PageIndex   Int=1,
                                   @PageSize    Int=10,
                                   @RecordCount Int=0 output
As
  Declare @sqlstr Nvarchar(4000)
  If( @PageIndex = 1 )
    Set @sqlstr =N'select top ' + Convert(Nvarchar(15), @PageSize) + ' p.*,a.AlbumName from Qianbo_UserPhoto as p join Qianbo_UserAlbum as a on p.AlbumId = a.Id where p.UserId = ' + Convert(Nvarchar(15), @UserId) + ' and P.Albumid = ' + Convert(Nvarchar(15), @AlbumId) + ' order by PhotoId desc'
  Else
    Set @sqlstr =N'select top ' + Convert(Nvarchar(15), @PageSize) + ' p.*,a.AlbumName from Qianbo_UserPhoto as p join Qianbo_UserAlbum as a on p.AlbumId = a.Id where p.UserId = ' + Convert(Nvarchar(15), @UserId) + ' and P.Albumid = ' + Convert(Nvarchar(15), @AlbumId) + ' and PhotoId < (select min(o.PhotoId) from(select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' PhotoId from Qianbo_UserPhoto as p where p.UserId = ' + Convert(Nvarchar(15), @UserId) + ' and P.Albumid = ' + Convert(Nvarchar(15), @AlbumId) + ' order by PhotoId desc)o) order by PhotoId desc'
  Execute sp_executesql @sqlstr
  Set @sqlstr='select Count(Photoid) from Qianbo_UserPhoto where UserId = ' + Convert(Nvarchar(15), @UserId) + ' and AlbumId = ' + Convert(Nvarchar(15), @AlbumId)
  Execute sp_executesql @sqlstr
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserPhoto_GetByPhotoId @PhotoId Int
As
  Select *
  From   Qianbo_UserPhoto
  Where  PhotoId = @PhotoId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserPhoto_Set @PhotoId     Int output,
                                    @AlbumId     Int,
                                    @FileName    Nvarchar(50),
                                    @FilePath    Nvarchar(100),
                                    @Description Nvarchar(500),
                                    @PostTime    Nvarchar(50),
                                    @UserId      Int,
                                    @UserName    Nvarchar(50),
                                    @VisitNum    Int,
                                    @FileSize    Int
As
  If( @PhotoId = 0 )
    Begin
        Insert Into Qianbo_UserPhoto
                    ([AlbumId],
                     [FileName],
                     [FilePath],
                     [Description],
                     [PostTime],
                     [UserId],
                     [UserName],
                     [VisitNum],
                     [FileSize])
        Values      ( @AlbumId,
                      @FileName,
                      @FilePath,
                      @Description,
                      @PostTime,
                      @UserId,
                      @UserName,
                      @VisitNum,
                      @FileSize )
        Set @PhotoId =SCOPE_Identity()
        Update Qianbo_UserAlbum
        Set    imgcount = imgcount + 1
        From   Qianbo_UserAlbum a
               Join Qianbo_UserPhoto b
                 On a.id = b.albumid
        Where  photoid = @PhotoId
    End
  Else
    Begin
        Update Qianbo_UserPhoto
        Set    [FileName] = @FileName,
               [FilePath] = @FilePath,
               [Description] = @Description,
               [PostTime] = @PostTime,
               [UserName] = @UserName,
               [FileSize] = @FileSize,
               [VisitNum] = @VisitNum
        Where  [PhotoId] = @PhotoId
               And [UserId] = @UserId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserSpace_GetById @Id Int
As
  Select *
  From   Qianbo_UserSpace
  Where  [UserId] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_UserSpace_GetPrevPower @userId Int
As
  Select PrevPower
  From   Qianbo_UserSpace
  Where  UserId = @userId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_UserSpace_Set @Id               Int output,
                                    @SpaceName        Nvarchar(50),
                                    @SpaceDescription Nvarchar(500),
                                    @PrevPower        Int,
                                    @Password         Nvarchar(50),
                                    @AddTime          Nvarchar(50),
                                    @UserId           Int,
                                    @UserName         Nvarchar(50),
                                    @TemplateId       Int,
                                    @UserType         Int
As
  If( @Id = 0 )
    Begin
        Insert Into Qianbo_UserSpace
                    ([SpaceName],
                     [SpaceDescription],
                     [PrevPower],
                     [Password],
                     [AddTime],
                     [UserId],
                     [UserName],
                     [TemplateId],
                     [UserType])
        Values      ( @SpaceName,
                      @SpaceDescription,
                      @PrevPower,
                      @Password,
                      @AddTime,
                      @UserId,
                      @UserName,
                      @TemplateId,
                      @UserType )
        Set @Id=Scope_identity()
    End
  Else
    Begin
        Update Qianbo_UserSpace
        Set    [SpaceName] = @SpaceName,
               [SpaceDescription] = @SpaceDescription,
               [PrevPower] = @PrevPower,
               [Password] = @Password,
               [UserId] = @UserId,
               [UserName] = @UserName,
               [TemplateId] = @TemplateId,
               [UserType] = @UserType
        Where  [Id] = @Id
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc dbo.Proc_User_AddFriend @UserId        Int,
                                    @FriendName    Nvarchar(20),
                                    @FriendGroupId Int,
                                    @Flag          Int=0 output
As
  Declare @FriendId Int
  If Exists(Select [UserID]
            From   Qianbo_Users
            Where  LogName = @FriendName)
    Begin
        Select @FriendId = UserId
        From   Qianbo_Users
        Where  LogName = @FriendName
        If Exists(Select *
                  From   Qianbo_UserFriend
                  Where  UserId = @UserId
                         And FriendId = @FriendId)
          Begin
              Set @Flag=1
          End
        Else
          Begin
              Insert Into Qianbo_UserFriend
              Values      (@UserId,
                           @FriendId,
                           @FriendGroupId)
              Set @Flag=3
          End
    End
  Else
    Set @Flag=2
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_User_Changepwd (@LogName Nvarchar(20),
                                          @newPwd  Nvarchar(200))
As
  Update Qianbo_Users
  Set    UserPwd = @newPwd
  Where  LogName = @LogName
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_User_CheckMultiIdentity @input     Nvarchar(500),
                                                  @tableName Nvarchar(100),
                                                  @filedName Nvarchar(100),
                                                  @output    Int=0 output
As
  Declare @SqlStr Nvarchar(2000)
  Set @SqlStr ='select @TRecord = Count(*) from ' + @tableName + ' where ' + @filedName + '=''' + @input + ''''
  Declare @Parm Nvarchar(50)
  Set @Parm = '@TRecord int output';
  Exec Sp_ExecuteSql
    @SqlStr,
    @Parm,
    @TRecord = @output output;
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_User_DeleteFriend @Id Int
As
  Delete From Qianbo_UserFriend
  Where  [ID] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [dbo].[Proc_User_GetAllInfo] @userId Int
As
  Declare @tableName Nvarchar(30)
  Declare @spaceTypeId Int
  Select @tableName = [tablename],
         @spacetypeid = [spacetypeid]
  From   [Qianbo_Users] u
         Join [Qianbo_UserGroupModel] m
           On u.[typeid] = m.[id]
  Where  [userid] = @userid
  Declare @sqlstr Nvarchar(4000)
  Set @sqlstr = 'select u.*,e.*,g.[usergroupname],' + Convert(Nvarchar(15), @spacetypeid) + ' as spacetypeid from [Qianbo_Users] u join [' + @tablename + '] e on u.[userid] = e.[uid] join [Qianbo_UserGroup] g on u.[groupid] = g.[usergroupid] where u.[userid] = @t_userid'
  Declare @param Nvarchar(200)
  Set @param='@t_userid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @t_userid = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_User_GetUserCount @typeid  Int,
                                   @groupid Int
As
  Declare @wherestr Nvarchar(2000)
  Declare @wherestr2 Nvarchar(10)
  Set @wherestr2 = ' where '
  Declare @char Nvarchar(10)
  Set @char = ''
  Set @wherestr = '';
  Declare @sqlstr Nvarchar(4000)
  If( @typeid != 0 )
    Begin
        Set @wherestr = @wherestr + @wherestr2 + @char + ' [typeid] = @t_typeid '
        Set @char = ' and '
        Set @wherestr2 = '';
    End
  If( @groupid != 0 )
    Begin
        Set @wherestr = @wherestr + @wherestr2 + @char + ' [groupid] = @t_groupid '
    End
  Set @sqlstr = 'select Count([userid]) from [Qianbo_Users] ' + @wherestr
  Declare @param Nvarchar(400)
  Set @param = '@t_typeid int,@t_groupid int'
  Execute sp_executesql
    @sqlstr,
    @param,
    @t_typeid = @typeid,
    @t_groupid = @groupid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_User_ListGroupMember @WhereStr  Nvarchar(2000),
                                               @PageSize  Int=20,
                                               @PageIndex Int=0,
                                               @Total     Int=0 output
As
  Declare @SqlStr Nvarchar(2000)
  Declare @fff Nvarchar(100)
  If( @WhereStr = '' )
    Begin
        Set @WhereStr=' where '
        Set @fff=''
    End
  Else
    Begin
        Set @fff=' where ' + @WhereStr
        Set @WhereStr=' where ' + @WhereStr + ' and '
    End
  If @PageIndex = 1
    Set @SqlStr=N'select top ' + Convert(Nvarchar(10), @PageSize) + ' FriendId,[ID],LogName from Qianbo_UserFriend inner join Qianbo_Users on Qianbo_UserFriend.FriendId = Qianbo_Users.UserId' + @fff + ' order by [ID] desc'
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(10), @PageSize) + ' FriendId,[ID],LogName from Qianbo_UserFriend inner join Qianbo_Users on Qianbo_UserFriend.FriendId = Qianbo_Users.UserId' + @WhereStr + ' ID < (select min(ID) from (select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' * from Qianbo_UserFriend ' + @fff + ' order by [ID] desc)F) order by [ID] desc'
  Print @SqlStr
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr ='select @Count = Count([ID]) from Qianbo_UserFriend' + @fff
  Declare @Parm Nvarchar(50)
  Set @Parm = '@Count int output';
  Exec Sp_ExecuteSql
    @SqlStr,
    @Parm,
    @Count = @Total output
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_User_Login (@LogName Nvarchar(20),
                                      @Pwd     Nvarchar(200))
As
  Select UserID
  From   Qianbo_Users
  Where  LogName = @LogName
         And UserPwd = @Pwd
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_User_Recharge (@UserId      Int,
                                     @CardAccount Varchar(15),
                                     @CardPwd     Varchar(200),
                                     @Flag        Int output)
As
  Set Xact_Abort On
  Begin Tran
  If Exists(Select [ID]
            From   Qianbo_Card
            Where  CardAccount = @CardAccount
                   And Password = @CardPwd)
    Begin
        Declare @Type Int
        Declare @Point Int
        Declare @date Datetime
        Declare @day Int
        Declare @IsUsed Bit
        Declare @expireTime Datetime
        Select @Type = Type
        From   Qianbo_Card
        Where  CardAccount = @CardAccount
        Select @Point = CardPoint
        From   Qianbo_Card
        Where  CardAccount = @CardAccount
        Select @date = OverdueDate
        From   Qianbo_Card
        Where  CardAccount = @CardAccount
        Select @day = CardDay
        From   Qianbo_Card
        Where  CardAccount = @CardAccount
        Select @IsUsed = IsUsed
        From   Qianbo_Card
        Where  CardAccount = @CardAccount
        Select @expireTime = ExpireTime
        From   Qianbo_Users
        Where  UserId = @UserId
        If( @IsUsed = 0 )
          Begin
              If( @date > getDate() )
                Begin
                    If( @Type = 1 )
                      Begin
                          Update Qianbo_Card
                          Set    OverdueDate = DateAdd(dd, @day, OverdueDate),
                                 IsUsed = 1,
                                 UserId = @UserId
                          Where  CardAccount = @CardAccount
                          If( @expireTime >= getDate() )
                            Update Qianbo_Users
                            Set    ExpireTime = DateAdd(dd, @day, @expireTime)
                            Where  UserId = @UserId
                          Else
                            Update Qianbo_Users
                            Set    ExpireTime = DateAdd(dd, @day, getDate())
                            Where  UserId = @UserId
                          Insert Into Qianbo_RechargeRecord
                          Values      (@UserId,
                                       @CardAccount,
                                       @Point,
                                       @day,
                                       getDate())
                          Set @Flag=1
                      End
                    If( @Type = 0 )
                      Begin
                          Update Qianbo_Users
                          Set    YellowBoy = YellowBoy + @Point
                          Where  UserId = @UserId
                          Update Qianbo_Card
                          Set    IsUsed = 1,
                                 UserId = @UserId
                          Where  CardAccount = @CardAccount
                          Insert Into Qianbo_RechargeRecord
                          Values      (@UserId,
                                       @CardAccount,
                                       @Point,
                                       @day,
                                       getDate())
                          Set @Flag=1
                      End
                End
              Else
                Set @Flag=3
          End
        Else
          Set @Flag=2
    End
  Else
    Set @Flag=4
  Commit Tran
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_User_RechargeRecord @UserId    Int,
                                              @PageSize  Int=20,
                                              @PageIndex Int=1,
                                              @PageCount Int=0 output
As
  Declare @SqlStr Nvarchar(2000)
  If( @PageIndex = 1 )
    Set @SqlStr='select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_RechargeRecord where [UserId] = ' + Convert(Nvarchar(20), @UserId) + ' order by [ID] desc'
  Else
    Set @SqlStr='select top ' + Convert(Nvarchar(10), @PageSize) + ' * from Qianbo_RechargeRecord where [ID] < (select min([ID]) from (select top ' + Convert(Nvarchar(10), (@PageSize * (@PageIndex-1))) + ' * from Qianbo_RechargeRecord where [UserId] = ' + Convert(Nvarchar(20), @UserId) + ' order by [ID] desc)R) order by [ID] desc'
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr ='select @Total = Count([ID]) from Qianbo_RechargeRecord where UserId = ' + Convert(Nvarchar(20), @UserId)
  Declare @Parm Nvarchar(50)
  Set @Parm = '@Total int output';
  Exec Sp_ExecuteSql
    @SqlStr,
    @Parm,
    @Total = @PageCount output
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_User_SetFriend (@Id        Int,
                                          @IsDisable Int)
As
  Update Qianbo_UserFriend
  Set    FriendGroupId = @IsDisable
  Where  [ID] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_User_SetFriendGroup @GroupName Nvarchar(50),
                                              @IsUserId  Int,
                                              @GroupId   Int,
                                              @Type      Varchar(20)
As
  If @Type = 'Add'
    Begin
        Insert Into Qianbo_UserFriendGroup
        Values      (@GroupName,
                     @IsUserId)
    End
  If @Type = 'ListGroup'
    Begin
        Select *
        From   Qianbo_UserFriendGroup
        Where  IsUserId = @IsUserId
                Or IsUserId = 0
    End
  If @Type = 'Delete'
    Begin
        Delete From Qianbo_UserFriendGroup
        Where  FriendGroupId = @GroupId
        Delete From Qianbo_UserFriend
        Where  FriendGroupId = @GroupId
    End
  If @Type = 'Update'
    Begin
        Update Qianbo_UserFriendGroup
        Set    FriendGroupName = @GroupName
        Where  FriendGroupId = @GroupId
    End
  If @Type = 'CountMember'
    Begin
        Select Count(FriendId)
        From   Qianbo_UserFriend
        Where  FriendGroupId = @GroupId
               And UserId = @IsUserId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_User_UpdateRegCode @UserId  Int,
                                         @NewCode Varchar(50)
As
  Update Qianbo_Users
  Set    ConfirmRegCode = @NewCode
  Where  UserId = @UserId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure [dbo].[Proc_Users_Add] @logname     Nvarchar(100),
                                        @userpwd     Nvarchar(200),
                                        @typeid      Int,
                                        @email       Varchar(100),
                                        @islock      Bit,
                                        @groupid     Int,
                                        @question    Nvarchar(50),
                                        @answer      Nvarchar(50),
                                        @integral    Int,
                                        @secret      Tinyint,
                                        @confirmCode Nvarchar(50),
                                        @status      Int,
                                        @SiteId      Int
As
  Insert Into Qianbo_Users
              ([logname],
               [userpwd],
               [typeid],
               [email],
               [islock],
               [groupid],
               [question],
               [answer],
               [integral],
               [secret],
               [confirmregcode],
               [status],
               [SiteId])
  Values      (@logname,
               @userpwd,
               @typeid,
               @email,
               @islock,
               @groupid,
               @question,
               @answer,
               @integral,
               @secret,
               @confirmcode,
               @status,
               @SiteId)
  Select scope_identity()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Users_Delete @UserID Int
As
  Set Xact_Abort On
  Begin Tran
  Delete From Qianbo_Users
  Where  UserID = @UserId
  Delete From Qianbo_UserFavorite
  Where  UserId = @UserId
  Delete From Qianbo_UserCate
  Where  UserId = @UserId
  Delete From Qianbo_UserFriend
  Where  FriendId = @UserId
  Commit Tran
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Users_GetUser @Identity Nvarchar(20),
                                    @Type     Int
As
  If( @Type = 1 )
    Select *
    From   Qianbo_Users
    Where  UserId = @Identity
  If( @Type = 0 )
    Select *
    From   Qianbo_Users
    Where  LogName = @Identity
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Users_GetUserList @groupid     Int,
                                        @nologintype Int,
                                        @logname     Nvarchar(20),
                                        @typeid      Int,
                                        @islock      Int,
                                        @order       Nvarchar(50),
                                        @pageindex   Int,
                                        @pagesize    Int,
                                        @siteid      Int
As
  Declare @wherestr Nvarchar(4000)
  Set @wherestr = '';
  If( @groupid > 0 )
    Begin
        Set @wherestr = @wherestr + ' a.[groupid] = @t_groupid and ';
    End
  If( @nologintype > 0 )
    Begin
        Declare @nologintime Datetime
        If( @nologintype = 1 )
          Begin
              Set @nologintime = dateadd(month, -3, getdate());
          End
        Else
          If( @nologintype = 2 )
            Begin
                Set @nologintime = dateadd(month, -6, getdate())
            End
          Else
            Begin
                Set @nologintime = dateadd(month, -12, getdate())
            End
        Set @wherestr = @wherestr + ' a.[lastlogintime]<@t_nologintime and '
    End
  If( @logname != '' )
    Begin
        Set @wherestr = @wherestr + ' a.[logname] like @t_logname and '
    End
  If( @islock !=- 1 )
    Begin
        Set @wherestr = @wherestr + ' a.[islock] = @t_islock and '
    End
  If( @siteid != '' )
    Begin
        Set @wherestr = @wherestr + ' a.[siteid] = @t_siteid and '
    End
  If( @typeid > 0 )
    Begin
        Set @wherestr = @wherestr + ' a.typeid = @t_typeid '
    End
  Else
    Begin
        Set @wherestr = @wherestr + ' 1=1 '
    End
  Declare @sqlstr Nvarchar(4000)
  Declare @param Nvarchar(2000)
  Set @param='@t_groupid int,@t_nologintime datetime,@t_logname nvarchar(50),@t_islock bit,@t_typeid int,@t_siteid int'
  If( @pageindex = 1 )
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + ' * from [Qianbo_Users] a join [Qianbo_UserGroup] b on a.groupid = b.usergroupid where ' + @wherestr + ' order by a.[' + @order + '] desc'
  Else
    Set @sqlstr = 'select top ' + Convert(Nvarchar(15), @pagesize) + ' * from [Qianbo_Users] a join [Qianbo_UserGroup] b on a.groupid = b.usergroupid where ' + @wherestr + ' and a.[userid] not in(select top ' + Convert(Nvarchar(15), (@pageindex - 1) * @pagesize) + ' a.[userid] from [Qianbo_Users] a join [Qianbo_UserGroup] b on a.groupid = b.usergroupid where ' + @wherestr + ' order by a.[' + @order + '] desc) order by a.[' + @order + '] desc'
  Execute sp_executesql
    @sqlstr,
    @param,
    @t_groupid = @groupid,
    @t_nologintime = @nologintime,
    @t_logname = @logname,
    @t_islock = @islock,
    @t_typeid = @typeid,
    @t_siteid = @siteid
  Set @sqlstr = 'select Count(a.[userid]) from Qianbo_Users a join [Qianbo_UserGroup] b on a.groupid = b.usergroupid where ' + @wherestr
  Execute sp_executesql
    @sqlstr,
    @param,
    @t_groupid = @groupid,
    @t_nologintime = @nologintime,
    @t_logname = @logname,
    @t_islock = @islock,
    @t_typeid = @typeid,
    @t_siteid = @siteid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Users_Login_Error @userid Int
As
  Update [Qianbo_Users]
  Set    [errornum] = [errornum] + 1
  Where  [userid] = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Users_Login_OnErrorNum @userid    Int,
                                        @errortime Datetime
As
  Update [Qianbo_Users]
  Set    [errortime] = @errortime
  Where  [userid] = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Users_Login_Success @userid        Int,
                                     @lastloginip   Nvarchar(20),
                                     @lastlogintime Datetime
As
  Update [Qianbo_Users]
  Set    [loginnum] = [loginnum] + 1,
         [lastloginip] = @lastloginip,
         [lastlogintime] = @lastlogintime,
         [errornum] = 0
  Where  [userid] = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Users_ModifyOtherBasicInfo @userid  Int,
                                            @email   Varchar(100),
                                            @groupid Int,
                                            @secret  Int
As
  Update [Qianbo_Users]
  Set    [email] = @email,
         [groupid] = @groupid,
         [secret] = @secret
  Where  [userid] = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_Users_ModifyPwd @userid Int,
                                      @pwd    Nvarchar(200)
As
  Update [Qianbo_Users]
  Set    [userpwd] = @pwd
  Where  userid = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Users_ModifyQuestion @userid   Int,
                                      @question Nvarchar(50),
                                      @answer   Nvarchar(50)
As
  Update [Qianbo_Users]
  Set    [question] = @question,
         [answer] = @answer
  Where  userid = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc Proc_Users_SetLockStatus @userid     Int,
                                     @lockstatus Bit
As
  Update [Qianbo_Users]
  Set    [islock] = @lockstatus
  Where  [userid] = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Proc [dbo].[Proc_Users_SetStatus] @userid Int,
                                         @status Int
As
  Update [Qianbo_Users]
  Set    [status] = @status
  Where  [userid] = @userid
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ViewLog_Add @UserId    Int,
                                  @UserName  Nvarchar(20),
                                  @ModelType Int,
                                  @InfoId    Int,
                                  @AddTime   Datetime
As
  Insert Into Qianbo_ViewLog
              ([UserId],
               [UserName],
               [ModelType],
               [InfoId],
               [AddTime])
  Values      (@UserId,
               @UserName,
               @ModelType,
               @InfoId,
               @AddTime)
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_ViewLog_GetViewCount @UserId Int,
                                           @Date   Varchar(10)
As
  Select Count(Id)
  From   Qianbo_ViewLog
  Where  Convert(Varchar(10), AddTime, 120) = @Date
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_VoteCategory_Get @Id   Int=0,
                                           @Type Int
As
  If @Type = 1
    Begin
        Select *
        From   Qianbo_VoteCategory
        Where  CategoryId = @Id
    End
  If @Type = 2
    Begin
        Select *
        From   Qianbo_VoteCategory
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_VoteCategory_Set @CategoryId Int=0,
                                           @Name       Nvarchar(200)='NULL',
                                           @Type       Int
As
  If @Type = 1
    Begin
        Insert Into Qianbo_VoteCategory
        Values      (@Name)
    End
  If @Type = 2
    Begin
        Update Qianbo_VoteCategory
        Set    [Name] = @Name
        Where  CategoryId = @CategoryId
    End
  If @Type = 3
    Begin
        Delete Qianbo_VoteCategory
        Where  CategoryId = @CategoryId
    End
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_VoteSubject_Add @Subject      Nvarchar(200),
                                          @StartDate    Datetime,
                                          @EndDate      Datetime,
                                          @RequireLogin Bit,
                                          @CategoryId   Int,
                                          @Identity     Int output
As
  Insert Into Qianbo_VoteSubject
  Values      (@Subject,
               @StartDate,
               @EndDate,
               @RequireLogin,
               @CategoryId)
  Select @Identity = SCOPE_IDENTITY()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_VoteSubject_Delete @SubjectId Int
As
  Set XACT_ABORT On
  Begin Tran
  Delete From Qianbo_VoteSubject
  Where  VoteSubjectId = @SubjectId
  Delete From Qianbo_Vote
  Where  subjectId = @SubjectId
  Commit Tran
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_VoteSubject_Get @SubjectId Int=0,
                                          @Type      Int,
                                          @PageSize  Int=20,
                                          @PageIndex Int=1,
                                          @WhereStr  Varchar(100)='',
                                          @Total     Int=0 output
As
  Begin
      Declare @SqlStr Nvarchar(2000)
      Declare @fff Nvarchar(200)
      If @WhereStr != ''
        Begin
            Set @fff=' where ' + @WhereStr + ' and'
            Set @WhereStr=' where ' + @WhereStr
        End
      If @WhereStr = ''
        Set @fff=' where '
      If @Type = 1
        If @PageIndex = 1
          Begin
              Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' Qianbo_VoteSubject.* ,Qianbo_VoteCategory.Name as CategoryName from Qianbo_VoteSubject left join Qianbo_VoteCategory on Qianbo_VoteSubject.CategoryId = Qianbo_VoteCategory.CategoryId  ' + @WhereStr + ' order by VoteSubjectID desc'
          End
        Else
          Set @SqlStr = N'select top ' + Convert(Nvarchar(10), @PageSize) + ' Qianbo_VoteSubject.*,Qianbo_VoteCategory.Name as CategoryName from Qianbo_VoteSubject left join Qianbo_VoteCategory on Qianbo_VoteSubject.CategoryId = Qianbo_VoteCategory.CategoryId ' + @fff + ' VoteSubjectID < (select min(VoteSubjectID) from(select top ' + Convert(Nvarchar(10), (@PageIndex - 1) * @PageSize) + ' Qianbo_VoteSubject.* from Qianbo_VoteSubject order by VoteSubjectID desc)O) order by VoteSubjectID desc'
      If @Type = 2
        Select Qianbo_Vote.*,
               Qianbo_VoteSubject.*
        From   Qianbo_Vote
               Join Qianbo_VoteSubject
                 On Qianbo_Vote.SubjectId = Qianbo_VoteSubject.VoteSubjectId
        Where  VoteSubjectId = @SubjectId
  End
Execute Sp_ExecuteSql @SqlStr
Set @SqlStr ='select @TRecord = Count(VoteSubjectID) from Qianbo_VoteSubject ' + @WhereStr
Declare @Parm Nvarchar(50)
Set @Parm = '@TRecord int output';
Exec Sp_ExecuteSql
  @SqlStr,
  @Parm,
  @TRecord = @Total output;
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_VoteSubject_GetAll
As
  Select VoteSubjectId,
         Subject,
         EndDate,
         RequireLogin
  From   Qianbo_VoteSubject
  Order  By VoteSubjectId Desc
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_VoteSubject_Update @VoteSubjectId Int,
                                         @Subject       Nvarchar(200),
                                         @StartDate     Datetime,
                                         @EndDate       Datetime,
                                         @RequireLogin  Bit,
                                         @CategoryId    Int
As
  Update Qianbo_VoteSubject
  Set    [Subject] = @Subject,
         [StartDate] = @StartDate,
         [EndDate] = @EndDate,
         [RequireLogin] = @RequireLogin,
         [CategoryId] = @CategoryId
  Where  [VoteSubjectId] = @VoteSubjectId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Vote_Add @SubjectId   Int,
                                   @VoteTitle   Nvarchar(100),
                                   @DisplayType Int,
                                   @IsMore      Bit,
                                   @ModelType   Int,
                                   @ItemTitle1  Nvarchar(100),
                                   @ItemNum1    Int,
                                   @ItemTitle2  Nvarchar(100),
                                   @ItemNum2    Int,
                                   @ItemTitle3  Nvarchar(100),
                                   @ItemNum3    Int,
                                   @ItemTitle4  Nvarchar(100),
                                   @ItemNum4    Int,
                                   @ItemTitle5  Nvarchar(100),
                                   @ItemNum5    Int,
                                   @ItemTitle6  Nvarchar(100),
                                   @ItemNum6    Int
As
  Insert Into Qianbo_Vote
              ([SubjectId],
               [VoteTitle],
               [DisplayType],
               [IsMore],
               [ModelType],
               [ItemTitle1],
               [ItemNum1],
               [ItemTitle2],
               [ItemNum2],
               [ItemTitle3],
               [ItemNum3],
               [ItemTitle4],
               [ItemNum4],
               [ItemTitle5],
               [ItemNum5],
               [ItemTitle6],
               [ItemNum6])
  Values      ( @SubjectId,
                @VoteTitle,
                @DisplayType,
                @IsMore,
                @ModelType,
                @ItemTitle1,
                @ItemNum1,
                @ItemTitle2,
                @ItemNum2,
                @ItemTitle3,
                @ItemNum3,
                @ItemTitle4,
                @ItemNum4,
                @ItemTitle5,
                @ItemNum5,
                @ItemTitle6,
                @ItemNum6 )
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_Vote_GetVoteIdByInfo @voteId Int
As
  Select *
  From   Qianbo_Vote
  Where  voteId = @voteId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure dbo.Proc_Vote_Update @VoteId     Int,
                                      @VoteTitle  Nvarchar(100),
                                      @IsMore     Bit,
                                      @ItemTitle1 Nvarchar(100),
                                      @ItemNum1   Int,
                                      @ItemTitle2 Nvarchar(100),
                                      @ItemNum2   Int,
                                      @ItemTitle3 Nvarchar(100),
                                      @ItemNum3   Int,
                                      @ItemTitle4 Nvarchar(100),
                                      @ItemNum4   Int,
                                      @ItemTitle5 Nvarchar(100),
                                      @ItemNum5   Int,
                                      @ItemTitle6 Nvarchar(100),
                                      @ItemNum6   Int
As
  Update Qianbo_Vote
  Set    [VoteTitle] = @VoteTitle,
         [IsMore] = @IsMore,
         [ItemTitle1] = @ItemTitle1,
         [ItemNum1] = @ItemNum1,
         [ItemTitle2] = @ItemTitle2,
         [ItemNum2] = @ItemNum2,
         [ItemTitle3] = @ItemTitle3,
         [ItemNum3] = @ItemNum3,
         [ItemTitle4] = @ItemTitle4,
         [ItemNum4] = @ItemNum4,
         [ItemTitle5] = @ItemTitle5,
         [ItemNum5] = @ItemNum5,
         [ItemTitle6] = @ItemTitle6,
         [ItemNum6] = @ItemNum6
  Where  [VoteId] = @VoteId
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_WebMessage @WMId               Int=0,
                                 @ReceiverId         Int=0,
                                 @ReceiverName       Nvarchar(50)=" ",
                                 @SendId             Int=0,
                                 @SendName           Nvarchar(50)=" ",
                                 @Title              Nvarchar(150)=" ",
                                 @Content            Ntext=" ",
                                 @IsSend             Int=0,
                                 @IsRead             Int=0,
                                 @ReceiverDel        Int=0,
                                 @SendDel            Int=0,
                                 @ReceiverRecycleDel Int=0,
                                 @SendRecycleDel     Int=0,
                                 @AllUser            Int=0,
                                 @UserGroupId        Int=0,
                                 @AddDate            Datetime=" ",
                                 @OverdueDate        Datetime=" ",
                                 @WhereStr           Nvarchar(100)=" "
As
  Insert Into [Qianbo_WebMessage]
              (ReceiverId,
               ReceiverName,
               SendId,
               SendName,
               Title,
               Content,
               IsSend,
               IsRead,
               ReceiverDel,
               SendDel,
               AllUser,
               UserGroupId,
               OverdueDate,
               AddDate)
  Values      (@ReceiverId,
               @ReceiverName,
               @SendId,
               @SendName,
               @Title,
               @Content,
               @IsSend,
               @IsRead,
               @ReceiverDel,
               @SendDel,
               @AllUser,
               @UserGroupId,
               @OverdueDate,
               @AddDate)
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS On
GO
Create Procedure Proc_WebMessage_GetList @CurrPage Int,
                                         @PageSize Int,
                                         @WhereStr Nvarchar(100)
As
  Declare @SqlStr Nvarchar(2000);
  If( @CurrPage = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_WebMessage] ' + Convert(Nvarchar(100), @WhereStr) + ' order by WMId desc';
  Else
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_WebMessage] ' + Convert(Nvarchar(100), @WhereStr) + ' and WMId not in(select top ' + Convert(Nvarchar(15), (@CurrPage - 1) * @PageSize) + ' WMId from [Qianbo_WebMessage] ' + Convert(Nvarchar(100), @WhereStr) + ' order by WMId desc) order by WMId desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(WMId) from [Qianbo_WebMessage] ' + @WhereStr;
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_WorkFlow_Add @Name       Nvarchar(150),
                                   @Auditing   Int,
                                   @AddDate    Datetime,
                                   @UpdateDate Datetime,
                                   @PowerIdStr Ntext
As
  Insert Into [Qianbo_WorkFlow]
              ([Name],
               [Auditing],
               [AddDate],
               [UpdateDate],
               [PowerIdStr])
  Values      (@Name,
               @Auditing,
               @AddDate,
               @UpdateDate,
               @PowerIdStr)
  Select scope_identity()
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_WorkFlow_Delete @Id Int
As
  Delete Qianbo_WorkFlow
  Where  Id = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_WorkFlow_GetList @PageIndex Int,
                                       @PageSize  Int,
                                       @strWhere  Nvarchar(1000)
As
  Declare @SqlStr Nvarchar(2000);
  If( @PageIndex = 1 )
    Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_WorkFlow] ' + Convert(Nvarchar(100), @strWhere) + ' order by Id desc';
  Else
    If( @strWhere = '' )
      Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_WorkFlow] where Id not in(select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' Id from [Qianbo_WorkFlow] ' + Convert(Nvarchar(1000), @strWhere) + ' order by Id desc) order by Id desc';
    Else
      Set @SqlStr=N'select top ' + Convert(Nvarchar(15), @PageSize) + ' * from [Qianbo_WorkFlow] ' + Convert(Nvarchar(100), @strWhere) + ' and Id not in(select top ' + Convert(Nvarchar(15), (@PageIndex - 1) * @PageSize) + ' Id from [Qianbo_WorkFlow] ' + Convert(Nvarchar(1000), @strWhere) + ' order by Id desc) order by Id desc';
  Execute Sp_ExecuteSql @SqlStr
  Set @SqlStr = N'select Count(Id) from [Qianbo_WorkFlow] ' + @strWhere;
  Execute Sp_ExecuteSql @SqlStr
  Return
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_WorkFlow_GetModel @Id Int
As
  Select *
  From   Qianbo_WorkFlow
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO
Set QUOTED_IDENTIFIER On
GO
Set ANSI_NULLS Off
GO
Create Procedure Proc_WorkFlow_Update @Id         Int,
                                      @Name       Nvarchar(150),
                                      @Auditing   Int,
                                      @UpdateDate Datetime,
                                      @PowerIdStr Ntext
As
  Update [Qianbo_WorkFlow]
  Set    [Name] = @Name,
         [Auditing] = @Auditing,
         [UpdateDate] = @UpdateDate,
         [PowerIdStr] = @PowerIdStr
  Where  [Id] = @Id
GO
Set QUOTED_IDENTIFIER Off
GO
Set ANSI_NULLS On
GO