

/****** 对象: 存储过程 dbo.GetTemplateType    脚本日期: 2006-7-12 8:59:33 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetTemplateType]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetTemplateType]
GO


/* 创建过程/函数 GetBigClass;1。                                                                     */
CREATE PROCEDURE dbo.GetTemplateType
AS
	SET NOCOUNT ON;
SELECT *       
FROM templateType



GO





/****** 对象: 存储过程 dbo.GetBigClass    脚本日期: 2006-7-12 8:59:33 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetBigClass]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetBigClass]
GO

/* 创建过程/函数 GetBigClass;1。                                                                     */
CREATE PROCEDURE [dbo].[GetBigClass]
AS
	SET NOCOUNT ON;
SELECT b.*,
       t.name 'template',t.code,t.previewTemplate,a.adminName, tp.type	--　添加分类
       
FROM bigClass b,template t,admin a, templateType tp
where 
   b.templateId=t.pkId
   and b.adminId=a.pkId and tp.pkId = t.typeId
  order by b.isSystemItem desc, tp.pkId, b.templateId asc, b.pkId

GO





/****** 对象: 存储过程 dbo.GetBigClassByAdminId    脚本日期: 2006-7-12 8:59:33 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetBigClassByAdminId]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetBigClassByAdminId]
GO


/* 创建过程/函数 GetBigClassByAdminId;1。                                                            */
CREATE PROCEDURE dbo.GetBigClassByAdminId
@adminId int
AS
	SET NOCOUNT ON;
	SELECT b.*, t.name 'template',t.code,t.previewTemplate,a.adminName, tp.type, tp.pkId	--添加分类
       
FROM bigClass b,template t,admin a, templateType tp
where 
   b.templateId=t.pkId
   and b.isSystemItem=1
   and b.adminId=a.pkId
   and t.typeId=tp.pkId
   
UNION
SELECT b.*, t.name 'template',t.code,t.previewTemplate,a.adminName, tp.type, tp.pkId
       
FROM bigClass b,template t,admin a, templateType tp
where 
   b.templateId=t.pkId
   and b.isSystemItem=0
   and b.adminId=@adminId
   and b.adminId=a.pkId
   and t.typeId=tp.pkId
   
  order by b.isSystemItem desc, tp.pkId, b.templateId asc, b.pkId


GO





/****** 对象: 存储过程 dbo.GetBigClassByPkId    脚本日期: 2006-7-12 8:59:33 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetBigClassByPkId]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetBigClassByPkId]
GO


/* 创建过程/函数 GetBigClassByPkId;1。                                                               */
CREATE PROCEDURE GetBigClassByPkId
@pkId int=null
/*
	(
		@parameter1 datatype = default value,
		@parameter2 datatype OUTPUT
	)
*/
AS
	/* SET NOCOUNT ON */
	SELECT b.*,
       t.name 'template',
       t.code 'code',t.previewTemplate,a.adminName, tp.pkId as typeId		--添加分类
       
FROM bigClass b,template t,admin a, templateType tp
where b.pkId=@pkId
  
  and b.templateId=t.pkId
  and a.pkId=b.adminId
  and t.typeId = tp.pkId
	RETURN 


GO





/****** 对象: 存储过程 dbo.InsertLayoutTemplate    脚本日期: 2006-7-12 8:59:33 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[InsertLayoutTemplate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[InsertLayoutTemplate]
GO


/* 创建过程/函数 InsertLayoutTemplate;1。                                                            */
CREATE PROCEDURE dbo.InsertLayoutTemplate
(
	@name varchar(100),
	@template text,
	@simple text,
	@itemNum int,
	@itemName varchar(4000),
	@isArtDesign int,
	@pkId int output,
	@layoutTemplateType int,
	@adminId int,
	@bgpic varchar(100)
)
AS
	SET NOCOUNT OFF;
INSERT INTO layoutTemplate(name, template, simple, itemNum, itemName, isArtDesign,layoutTemplateType,adminId,bgpic) VALUES (@name, @template, @simple, @itemNum, @itemName, @isArtDesign,@layoutTemplateType,@adminId,@bgpic)
SET @pkId = @@IDENTITY


GO





/****** 对象: 存储过程 dbo.GetImageNewsByRecommand    脚本日期: 2006-7-12 8:59:33 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetImageNewsByRecommand]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetImageNewsByRecommand]
GO



/* 创建过程/函数 GetNewsByRecommand;1。                                                              */
CREATE PROCEDURE [dbo].[GetImageNewsByRecommand]
@pageSize int=5,
@gradeid int=1,
@gateId int
/*
	(
		@parameter1 datatype = default value,
		@parameter2 datatype OUTPUT
	)
*/
AS
	 SET NOCOUNT ON 
	
	declare @vSQL varchar(1000)
select @vSQL ='select top 1 pkId,listTitle,intactTitle,updateTime,imageName,isImageNews,width,height,istop from news where passed=1   and isRecommand=1  and IsImageNews=1   and gate<>'+Convert(varchar,@gateId)+'  and gradeId<='+Convert(varchar,@gradeId)+' order by istop desc,pkId desc'
Execute (@vSQL)
RETURN



GO





/****** 对象: 存储过程 dbo.GetNewsByRecommand    脚本日期: 2006-7-12 8:59:33 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetNewsByRecommand]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetNewsByRecommand]
GO




/* 创建过程/函数 GetNewsByRecommand;1。                                                              */
CREATE PROCEDURE [dbo].[GetNewsByRecommand]
@pageSize int=5,
@gradeid int=1,
@gateId int
/*
	(
		@parameter1 datatype = default value,
		@parameter2 datatype OUTPUT
	)
*/
AS
	 SET NOCOUNT ON 
	
	declare @vSQL varchar(1000)
select @vSQL ='select top ' + convert(varchar, @pageSize) + ' pkId,listTitle,intactTitle,updateTime,imageName,isImageNews,width,height,istop from news where   gate<>'+Convert(varchar,@gateId)+' and  IsImageNews=0 and gradeId<='+convert(varchar,@gradeId)+' and passed=1  and isRecommand=1  order by istop desc,pkId desc'
Execute (@vSQL)
RETURN




GO





