-- ==============================
-- 长登科技 www.ppfor.com
-- 唐镇波   2010-04-19
-- ------------------------------
-- 上传下载文件配置表
-- ==============================

----创建数据库--------------
if not exists (select * from sysobjects where name='PPFOR_TZB_FileSetting')
	create table PPFOR_TZB_FileSetting
	(
	 [ID] int identity(1,1) not null primary key,
	 [BelongLanguage] int not null REFERENCES [PPFOR_TZB_Language]([ID]) ON DELETE CASCADE,
	 [IsUpload] bit not null,			--是否允许上传
	 [FileMaxSize] int not null,		--允许上传的最大值
	 [FileType] varchar(255) COLLATE Chinese_PRC_CI_AS not null,	--允许上传的文件格式		
     [ErrorUrl] varchar(255) null
	)
PPFOR_GO;

----插入与更新数据库记录---------
if exists (select * from sysobjects where name='PPFOR_TZB_FileSetting_Update')
drop procedure PPFOR_TZB_FileSetting_Update
PPFOR_GO;

create procedure PPFOR_TZB_FileSetting_Update(@BelongLanguage int, @IsUpload bit,@FileMaxSize int,
@FileType varchar(255), @ErrorUrl varchar(255))
as 
   begin
	 	if not exists (select [ID] from [PPFOR_TZB_FileSetting] where [BelongLanguage]=@BelongLanguage)
      		insert into [PPFOR_TZB_FileSetting] values(@BelongLanguage,@IsUpload,@FileMaxSize,@FileType,@ErrorUrl)
		else
			update [PPFOR_TZB_FileSetting] set [IsUpload]=@IsUpload,[FileMaxSize]=@FileMaxSize,
				[FileType]=@FileType,ErrorUrl=@ErrorUrl				
   end
PPFOR_GO;

----获取记录---------------------
if exists (select * from sysobjects where name='PPFOR_TZB_FileSetting_GetModel')
drop procedure PPFOR_TZB_FileSetting_GetModel
PPFOR_GO;

create procedure PPFOR_TZB_FileSetting_GetModel(@BelongLanguage int)
as
   select * from [PPFOR_TZB_FileSetting] where [BelongLanguage]=@BelongLanguage
PPFOR_GO;
 
----删除记录------------------------
if exists (select * from sysobjects where name='PPFOR_TZB_FileSetting_Delete')
drop procedure PPFOR_TZB_FileSetting_Delete
PPFOR_GO;
create procedure PPFOR_TZB_FileSetting_Delete(@BelongLanguage int)
as
   delete from [PPFOR_TZB_FileSetting] where [BelongLanguage]=@BelongLanguage
PPFOR_GO;
