'update 1.0 to 1.1
CREATE TABLE zymenu (id int IDENTITY (1,1) NOT null,ParentNodeId integer,Text varchar(100),OrderID integer,Depth integer)
alter table workgroup add [order] integer
Select id From Menu where url='search.aspx'
*insert into Menu ([Text],ImageUrl,Url,Target,Show,OrderID,Sys,Depth) values ('全文检索','pics/my_space_s.gif','search.aspx','wdcontent','0',3,'0',0)
alter table config add textsearch varchar(1)
alter table config add issharesh1 varchar(1),iszysh1 varchar(1),issharesh2 varchar(1),iszysh2 varchar(1),issharesh3 varchar(1),iszysh3 varchar(1)
alter table allpath add markzy varchar(1)
alter table allpath add zykind integer

'update 1.1 to 1.2
alter table allpath add safe integer
CREATE TABLE Company (id int IDENTITY (1,1) NOT null,company varchar(100))
alter table Dept add company integer
CREATE TABLE Relevance (id int IDENTITY (1,1) NOT null,SoureID integer,TargetID integer,Type integer,Remark varchar(255))
CREATE TABLE Safe (id int IDENTITY (1,1) NOT null,dj varchar(50),pic varchar(50),od integer)
Select count(id) as tcount From safe
*insert into safe (dj,pic,od) values ('秘密','pics/flag1.gif',1)
*insert into safe (dj,pic,od) values ('机密','pics/flag2.gif',2)
*insert into safe (dj,pic,od) values ('绝密','pics/flag3.gif',3)
*insert into safe (dj,pic,od) values ('普通','pics/flag0.gif',0)
CREATE TABLE Role (id int IDENTITY (1,1) NOT null,RoleNo varchar(20),RoleName varchar(50),limit1 varchar(1),limit2 varchar(1),limit3 varchar(1),limit4 varchar(1),limit5 varchar(1),limit6 varchar(1),limit7 varchar(1),limit8 varchar(1),limit9 varchar(1))
Select count(id) as tcount From Role
*insert into Role (RoleNo,RoleName) values ('001','教师')
*insert into Role (RoleNo,RoleName) values ('002','学生')
*insert into Role (RoleNo,RoleName) values ('003','管理')


alter table reg add safe integer
alter table reg add tempDept integer

'update 1.2 to 1.3
create  PROCEDURE [dbo].[udp_Pagination] @TableName varchar(8000), @Fieldlist varchar(8000),@TableField varchar(200),@Where varchar(8000),@OrderFld varchar(500)='',@FieldIndex int =1,@PageSize int = 15,@Sort varchar(8)='asc',@RecordCount int= -1 output AS BEGIN Declare @cmd nvarchar(4000)  Declare @uprecord int Declare @Op varchar(2)  Declare @max_min varchar(4) declare @TopPageSize nvarchar(300) Set @op = '<'  Set @max_min = 'MIN' If @Sort = 'asc' Begin set @Op = '>' set @max_min = 'MAX' End If @Where = '' Begin set @Where = '1=1' End If @OrderFld <> '' Begin set @OrderFld = ' Order by ' + @OrderFld + ' ' End set @cmd = 'SELECT @RecordCount = count(1) FROM '+@TableName+' where '+@Where Exec sp_executesql @cmd, N'@RecordCount int output', @RecordCount output  if(@PageSize = 0) set @TopPageSize = '' else set @TopPageSize = 'top ' + cast(@PageSize AS NVARCHAR); set @uprecord=@FieldIndex * @PageSize  set @cmd = '' set @cmd = 'select ' + @TopPageSize +' '+ @Fieldlist + ' from ' + @TableName + ' where ' + @TableField + ' not in( ' + 'select top '+ cast(@uprecord AS NVARCHAR)+' '+ @TableField + ' from ' + @TableName + ' where ' + @Where + @OrderFld + ') and ' +  @Where + @OrderFld EXEC(@cmd)  End

alter table config add AdvertiseLogo varchar(255)
alter table config add QuestionNeedToAudit char(1)

CREATE TABLE [FileOperation] ([ID] [int]  IDENTITY (1, 1)  NOT NULL,[AllPathID] [int]  NOT NULL,[ViewedTime] [datetime]  NULL,[ViewedUser] [varchar]  (50) NULL,[DownLoadTime] [datetime]  NULL,[DownLoadUser] [varchar]  (50) NULL,[ShareTime] [datetime]  NULL,[ShaerUser] [varchar]  (50) NULL,[ForwardTime] [datetime]  NULL,[ForwardUser] [varchar]  (50) NULL,[Remark] [varchar]  (200) NULL) ALTER TABLE [FileOperation] WITH NOCHECK ADD  CONSTRAINT [PK_FileOperation] PRIMARY KEY  NONCLUSTERED ( [ID] )

create table FileComments (ID int identity, FileID  int not null, Comment varchar(2) not null,CommentUser  varchar(20) not null,CommentDate  datetime not null,Remark varchar(200) null,constraint PK_FILECOMMENTS primary key (ID))

create table Question (ID  int identity,QuestionType char(2) null,QuestionUser varchar(50) not null,Question varchar(800) not null, QuestionDateTime  datetime  null,AnswerCount int null,IsAudit char(1)  null default '0',Remark  varchar(200) null,constraint PK_QUESTION primary key (ID))

create table Anser (ID int  identity,QuestionID  int  not null,AnswerUser  varchar(200)  not null,AnswerDateTime  datetime  null default getdate(),Answer text  not null,Remark  varchar(800) null,constraint PK_ANSER primary key (ID))

update template set para='LastTime|Desc,0,3,3,14,,0,,0,,0,0,0,0,1,' where label='Default_ShowZY3'
update template set para='LastTime|ASC,0,0,10,14,,0,,0,,0,0,1,0,0,' where label='Default_ShowZY2'
update template set para='LastTime|Desc,0,0,8,14,,0,,0,,0,0,0,0,1,and a.zykind=(select id from zy where kind="课件"),' where label='hotestKJZY'
update template set para='LastTime|Desc,0,0,8,14,,0,,0,,0,0,0,0,1,' where label='recommendSourceList'

alter table anser add IsAudit char(1) default '0'
alter table config add AllowGG1 char(1) default '0'
alter table config add AllowGG2 char(1) default '0'
alter table config add AllowGG3 char(1) default '0'


delete from Menu where Text='公共空间'
delete from Menu where Text='风格选择'

alter table AllPath add IsRecommendZY char(1) default '0'

Select id From Menu where url='MyResourceMng.aspx'
*insert into Menu (ParentNodeId,Text,ImageUrl,Url,Target,Show,OrderID,Sys,Depth)  values(2,'已发布资源','pics/folder_sharing_s.gif','MyResourceMng.aspx','wdcontent','1',7,'0','1')
update template set para='LastTime|DESC,0,0,10,15,,0,,0,,0,0,1,0,0,' where label='Default_ShowZY2'
update template set para='Downcount|DESC,0,0,6,15,,0,,0,,0,0,1,0,0,' where label='hotestZY'

alter table config add editsoft char(1) default '0'
alter table reg add tempDept int 

delete from template
Select count(id) as tcount From template
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('searchlist','搜索文件列表','LastTime|Desc,1,0,20,50,,0,,1,,0,-1,,1,0,','<tr><td width="13%" class="gray">[{$kind}]</td><td width="59%" align="left">{$ico} <a href="{$down}" class="gray" target=_blank>{$filename}</a></td><td width="16%" class="gray" align="left">{$time}</td><td width="12%" class="gray" align="left">{$size}</td></tr><tr><td colspan="4" class="gray">{$note}</td></tr><tr><td colspan="4" height=3px></td></tr>','1')
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('userRankList','用户排行','regdate|ASC,0,6,6,0,,0,,0,1,','<li class="num{$num}"><a href="ResourceMng.aspx?username={$username}" target="_blank">{$username}</a><span><strong>{$fn}</strong>份文档</span></li>','2')
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('Default_GG','首页显示的公告','0,10,10,','<li>● <a href="#" target="_blank">{$title}</a></li>','4')
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('hotestKJZY','热门课件资源','LastTime|Desc,0,0,8,14,,0,,0,,0,0,0,0,1,and a.zykind=(select id from zy where kind="课件"),','<li><a href="resourceDetail.aspx?fileid={$fileId}" target="_blank"><img src="{$path}" /><br>{$filename}</a></li>','1')
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('recommendSourceList','推荐资源','LastTime|Desc,0,0,8,14,,0,,0,,0,0,0,0,1,','<li><a href="resourceDetail.aspx?fileid={$fileId}" target="_blank"><img src="{$path}" /><br>{$filename}</a></li>','1')
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('Default_NewFile2','首页最新关联文件','LastTime|DESC,0,0,7,15,,0,,0,,0,0,1,0,','<li>● <a href="resourceDetail.aspx?fileid={$fileId}" target="_blank">{$filename}</a></li>','1')
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('Default_NewFile3','首页最新关联文件图片','LastTime|Desc,0,0,8,4,,0,,0,,0,0,0,0,1,','<li class="img{$orderCount}"><img src="{$path}" /><p><a href="resourceDetail.aspx?fileid={$fileId}" target="_blank">{$filename}</a></p></li>','1')
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('Default_ShowZY3','首页最新关联资源文件图片','LastTime|Desc,0,3,2,14,,0,,0,,0,0,0,0,1,','<li class="img{$orderCount}"><a href="resourceDetail.aspx?fileid={$fileId}" target="_blank"><img src="{$path}" /><p>{$filename}</p></a></li>','1')
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('hotestZY','热门资源','Downcount|DESC,0,0,6,15,,0,,0,,0,0,1,0,0,','<li>● <a href="resourceDetail.aspx?fileid={$fileId}" target="_blank">{$filename}</a></li>','1')
*INSERT [template] ([label],[note],[para],[content],[type]) VALUES ('Default_ShowZY2','首页最新关联资源文件','LastTime|DESC,0,0,10,15,,0,,0,,0,0,1,0,0,','<li>● <a href="resourceDetail.aspx?fileid={$fileId}" target="_blank">{$filename}</a></li>','1')
