-- ==============================
-- 长登科技 www.ppfor.com
-- 唐镇波   2010-04-20
-- ------------------------------
-- 水印配置表
-- ==============================

--创建水印配置表
if not exists(select name from sysobjects where name='PPFOR_TZB_WaterImage' and type='U')
create table PPFOR_TZB_WaterImage
(
	id int identity(1,1) not null primary key,	--ID，自动编号，从1开始递增
	waterType tinyint not null default(0),		--水印类型，0为无水印，1为水印文字，2为图片水印
	waterFontText nvarchar(255) null,			--水印文字
	waterFontFamily varchar(50) null,			--水印字体
	waterFontStyle varchar(10) null,			--水印字体样式
	waterFontSize tinyint null,					--水印字体大小
	waterFontColor varchar(6) null,				--水印字体颜色
	waterFontBorderSize tinyint null,			--水印文字边框大小
	waterFontBorderColor varchar(6) null,		--水印文字边框颜色
	waterFontBackColor varchar(6) null,			--水印文字背景颜色
	waterFontAlpha tinyint null,				--水印文字透明度
	waterFontPosition tinyint null,				--水印文字位置
	waterImageFile nvarchar(255) null,			--水印图片文件路径
	waterImageWidth varchar(8) null,			--水印图片宽度
 	waterImageHeight varchar(8) null,			--水印图片高度
    waterImageOpacity tinyint null,				--水印图片透明度
	waterImagePosition tinyint null				--水印图片位置
)
PPFOR_GO;  

--返回水印图片设置
if exists(select name from sysobjects where name='PPFOR_TZB_WaterImage_GetWaterSetting' and type='P')
	drop procedure PPFOR_TZB_WaterImage_GetWaterSetting
PPFOR_GO;
create procedure PPFOR_TZB_WaterImage_GetWaterSetting
as
	select top 1 * from PPFOR_TZB_WaterImage where [id]>0 order by [id] desc
PPFOR_GO;

--水印图片设置
if exists(select name from sysobjects where name='PPFOR_TZB_WaterImage_SetWaterSetting' and type='P')
	drop procedure PPFOR_TZB_WaterImage_SetWaterSetting
PPFOR_GO;
create procedure PPFOR_TZB_WaterImage_SetWaterSetting (@waterType tinyint,@waterFontText nvarchar(255),
	@waterFontFamily varchar(50),@waterFontStyle varchar(10),@waterFontSize tinyint,
	@waterFontColor varchar(6),@waterFontBorderSize tinyint,@waterFontBorderColor varchar(6),
	@waterFontBackColor varchar(6),@waterFontAlpha tinyint,@waterFontPosition tinyint,
	@waterImageFile nvarchar(255),@waterImageWidth varchar(8),@waterImageHeight varchar(8),
	@waterImageOpacity tinyint,@waterImagePosition tinyint)
as
	begin
		if not exists(select [id] from PPFOR_TZB_WaterImage)
			insert into PPFOR_TZB_WaterImage(waterType,waterFontText,waterFontFamily,waterFontStyle,
			waterFontSize,waterFontColor,waterFontBorderSize,waterFontBorderColor,waterFontBackColor,
			waterFontAlpha,waterFontPosition,waterImageFile,waterImageWidth,waterImageHeight,
			waterImageOpacity,waterImagePosition) values (@waterType,@waterFontText,@waterFontFamily,
			@waterFontStyle,@waterFontSize,@waterFontColor,@waterFontBorderSize,@waterFontBorderColor,
			@waterFontBackColor,@waterFontAlpha,@waterFontPosition,@waterImageFile,@waterImageWidth,
			@waterImageHeight,@waterImageOpacity,@waterImagePosition)
		else
			update PPFOR_TZB_WaterImage set waterType=@waterType,waterFontText=@waterFontText,
			waterFontFamily=@waterFontFamily,waterFontStyle=@waterFontStyle,
			waterFontSize=@waterFontSize,waterFontColor=@waterFontColor,
			waterFontBorderSize=@waterFontBorderSize,waterFontBorderColor=@waterFontBorderColor,
			waterFontBackColor=@waterFontBackColor,waterFontAlpha=@waterFontAlpha,
			waterFontPosition=@waterFontPosition,waterImageFile=@waterImageFile,
			waterImageWidth=@waterImageWidth,waterImageHeight=@waterImageHeight,
			waterImageOpacity=@waterImageOpacity,waterImagePosition=@waterImagePosition
	end
PPFOR_GO;