<!--#include file="setup.asp"-->
<%
Dim skid, sName, act, mdbname, StyleConn, i
Set Rs = Server.CreateObject("ADODB.Recordset")
NC_Admin.AdminChk = "03"
NC_Admin.Check
DownsysClass.admin_header
Response.Write "<script language=""JavaScript"">" & vbCrLf
Response.Write "<!--" & vbCrLf
Response.Write "function CheckAll(form) {" & vbCrLf
Response.Write " for (var i=0;i<form.elements.length;i++) {" & vbCrLf
Response.Write " var e = form.elements[i];" & vbCrLf
Response.Write " if (e.name != 'chkall'){" & vbCrLf
Response.Write Chr(9) & "e.checked = form.chkall.checked;" & vbCrLf
Response.Write Chr(9) & "}" & vbCrLf
Response.Write " }" & vbCrLf
Response.Write " }" & vbCrLf
Response.Write " function MyConfirm()" & vbCrLf
Response.Write "{" & vbCrLf
Response.Write "if (confirm(""您确定要执行此操作吗！""))" & vbCrLf
Response.Write Chr(9) & "return true;" & vbCrLf
Response.Write "else" & vbCrLf
Response.Write Chr(9) & "return false;" & vbCrLf
Response.Write "}" & vbCrLf
Response.Write "//-->"
Response.Write "</script>" & vbCrLf
Response.Write "<table border=""0"" cellspacing=""1"" cellpadding=""5"" align=center width=""95%"" class=""tableBorder"">" & vbCrLf
Response.Write "<tr>" & vbCrLf
Response.Write "<th colspan=""3"" align=""center"" ID=""TableTitleLink""><a href=? class=TableTitleLink>模版导出功能</a> | <a href=?action=load class=TableTitleLink>模版导入功能</a></th>" & vbCrLf
Response.Write "</tr>" & vbCrLf
Response.Write "<tr>" & vbCrLf
Response.Write "<td class=""forumrow"">" & vbCrLf
Response.Write "注意<br>" & vbCrLf
Response.Write "１，确认模版数据库名正确；<br>" & vbCrLf
Response.Write "２，如模版数据库放在skin目录下，即填写："& DownsysClass.SetupDir &"skin/NC_Skin.mdb；<br>" & vbCrLf
Response.Write "３，模版数据库内备份的表名为NC_Template,请不要更改；<br>" & vbCrLf
Response.Write "４，模版数据包括ＣＳＳ设置，与及所有界面设置．" & vbCrLf
Response.Write "</td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
Response.Write "</table><br>" & vbCrLf

If Request("action") = "inputskin" Then
	Call inputskin
ElseIf Request("action") = "loadskin" Then
	Call loadskin
ElseIf Request("action") = "load" Then
	Call Load
ElseIf Request("action") = "rename" Then
	Call rename
ElseIf Request("action") = "savenm" Then
	Call savenm
ElseIf Request("action") = "CreatMdb" Then
	Call CreateStyleMdb
ElseIf Request("action") = "DelFields" Then
	Call DelFields
Else
	Call Main
End If
If ErrMsg <> "" Then NC_Admin.Error_Msg (ErrMsg)
If Founderr = True Then
	Call NC_Admin.Error_Msg(ErrMsg)
End If
DownsysClass.admin_footer
NothingObject
If IsObject(StyleConn) Then
	StyleConn.Close
	Set StyleConn = Nothing
End If

Private Sub Main()
	If Request("action") = "loadthis" Then
		sName = "导入"
		act = "loadskin"
		mdbname = DownsysClass.checkStr(Trim(Request.Form("skinmdb")))
		If mdbname = "" Then
			ErrMsg = ErrMsg + "<li>请填写导出模版保存的表名"
			Exit Sub
		End If
	Else
		sName = "导出"
		act = "inputskin"
	End If
	Response.Write "<table border=""0"" cellspacing=""1"" cellpadding=""5"" align=center width=""95%"" class=""tableBorder"">" & vbCrLf
	Response.Write "<tr><th width=""100%"" colspan=""4"">"
	Response.Write sName
	Response.Write "模版列表</th></tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td width=""10%"" align=""center"" class=""forumrow"">序号</td>" & vbCrLf
	Response.Write "<td width=""60%"" align=""center"" class=""forumrow"">模版名称</td>" & vbCrLf
	Response.Write "<td width=""20%"" align=""center"" class=""forumrow"">操作</td>" & vbCrLf
	Response.Write "<td width=""10%"" align=""center"" class=""forumrow"">选择</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<form method=post action=""admin_loadskin.asp?action="
	Response.Write act
	Response.Write """ name=even>" & vbCrLf
	If act = "loadskin" Then
		SkinConnection (mdbname)
		Set Rs = StyleConn.Execute("select id,TempName from NC_Template order by id ")
	Else
		Set Rs = DownsysClass.Execute("select id,TempName from NC_Template order by id ")
	End If
	Do While Not Rs.EOF
		Response.Write "<tr>" & vbCrLf
		Response.Write Chr(9) & "<td class=""forumrow"">"
		Response.Write Rs("id")
		Response.Write "</td>" & vbCrLf
		Response.Write Chr(9) & "<td class=""forumrow"">"
		Response.Write Rs("TempName")
		Response.Write "</td>" & vbCrLf
		Response.Write Chr(9) & "<td class=""forumrow"" align=center>" & vbCrLf
		Response.Write Chr(9) & "<a href=""?action=rename&act="
		Response.Write act
		Response.Write "&skid="
		Response.Write Rs("id")
		Response.Write "&mdbname="
		Response.Write mdbname
		Response.Write """ >改名</a>" & vbCrLf
		Response.Write Chr(9)
		If act <> "loadskin" Then
			Response.Write " | <a href=""admin_template.asp?action=manage&mostyle=编 辑&StyleID=" & Rs("id") & """ >编辑</a>"
		End If
		Response.Write Chr(9) & "</td>" & vbCrLf
		Response.Write Chr(9) & "<td class=""forumrow"" align=center><input type=""checkbox"" name=""skid"" value="""
		Response.Write Rs("id")
		Response.Write """></td>" & vbCrLf
		Response.Write "</tr>" & vbCrLf
		Rs.movenext
	Loop
	Rs.Close
	Set Rs = Nothing
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td colspan=""4"" align=center class=""forumRowHighlight"">" & vbCrLf
	Response.Write "<input type=""radio"" name=""type"" value=""删除"" >删除 " & vbCrLf
	Response.Write "<input type=""radio"" name=""type"" value="""
	Response.Write sName
	Response.Write """ checked> " & vbCrLf
	Response.Write sName
	Response.Write "的数据库：<input type=""text"" name=""skinmdb"" size=""30"" value="""& DownsysClass.SetupDir &"skin/NC_Skin.mdb"">" & vbCrLf
	Response.Write "<input type=""submit"" name=""submit"" class=button value=""操 作"" onclick=MyConfirm()>" & vbCrLf
	Response.Write "<input type=checkbox name=chkall value=on onclick=""CheckAll(this.form)"">全选</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "</form>" & vbCrLf
	Response.Write "</table>" & vbCrLf
End Sub

Private Sub SkinConnection(mdbname)
	On Error Resume Next
	Set StyleConn = CreateObject("ADODB.Connection")
	StyleConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(mdbname)
	If Err.Number = "-2147467259" Then
		ErrMsg = ErrMsg + "<li>" & mdbname & "数据库不存在。"
		Founderr = True
		Response.End
	End If
End Sub

Private Sub inputskin()
	Dim TempRs
	Dim InsertName
	Dim InsertValue
	skid = DownsysClass.checkStr(Request("skid"))
	mdbname = DownsysClass.checkStr(Trim(Request.Form("skinmdb")))
	If skid = "" Or IsNull(skid) Or Not IsNumeric(Replace(Replace(skid, ",", ""), " ", "")) Then
		ErrMsg = ErrMsg + "<li>您还未选取要导出的模版，或参数有错误！"
		Exit Sub
	End If
	If mdbname = "" Then
		ErrMsg = ErrMsg + "<li>请请填写导出模版数据库名"
		Exit Sub
	End If
	If Request("type") = "删除" Then
		If InStr("," & skid & ",", "," & DownsysClass.tempid & ",") Then
			ErrMsg = ErrMsg + "<BR><li>本模板是默认模版，不允许删除。"
			Exit Sub
		End If
		DownsysClass.Execute ("Delete From [NC_Template] Where ID in (" & skid & ")")
		NC_Admin.Succeed_Msg ("成功删除模板。")
		DownsysClass.DelCahe ("Templateslist")
		'删除该模板所有页面缓存
		Set Rs = DownsysClass.Execute("Select Top 1 * From [NC_Template]")
		For i = 2 To Rs.Fields.Count - 1
			DownsysClass.DelCahe (Rs(i).Name & skid)
		Next
		Set Rs = Nothing
		Response.End
	ElseIf Request("type") = "导出" Then
		SkinConnection (mdbname)
		ChkSkinMDB
		If ErrMsg <> "" Then Exit Sub
		Set Rs = DownsysClass.Execute("select * from NC_Template where id in (" & skid & ") order by id ")
		If Rs.EOF Or Rs.bof Then
			ErrMsg = ErrMsg + "<BR><li>无法取出源模版数据"
			Founderr = True
			Exit Sub
		End If
		Do While Not Rs.EOF
			InsertName = ""
			InsertValue = ""
			For i = 1 To Rs.Fields.Count - 1
				InsertName = InsertName & Rs(i).Name
				InsertValue = InsertValue & "'" & DownsysClass.checkStr(Rs(i)) & "'"
				If i <> Rs.Fields.Count - 1 Then
					InsertName = InsertName & ","
					InsertValue = InsertValue & ","
				End If
			Next
			StyleConn.Execute ("insert into [NC_Template] (" & InsertName & ") values (" & InsertValue & ") ")
			Rs.movenext
		Loop
		Rs.Close
		Set Rs = Nothing
		NC_Admin.Succeed_Msg (SucMsg & "<li>数据导出成功！")
	Else
		ErrMsg = ErrMsg + "<li>错误参数!</li>"
		Founderr = True
	End If
End Sub

Private Sub Load()
	Response.Write "<form action=""?action=loadthis"" method=post>" & vbCrLf
	Response.Write "<table border=""0"" cellspacing=""1"" cellpadding=""5"" height=""1"" align=center width=""95%"" class=""tableBorder"">" & vbCrLf
	Response.Write "<tr><th colspan=""2"">导入模版数据</th></tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td width=""25%"" class=""forumrow"">导入模版数据库名：</td>" & vbCrLf
	Response.Write "<td width=""75%"" class=""forumrow""><input type=""text"" name=""skinmdb"" size=""30"" value="""& DownsysClass.SetupDir &"skin/NC_Skin.mdb""></td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr><td class=forumRowHighlight align=center colspan=""2""><input class=button type=""submit"" name=""submit"" value=""下一步""></td></tr>" & vbCrLf
	Response.Write "</table></form>" & vbCrLf
End Sub

Private Sub loadskin()
	Dim trs
	Dim InsertName
	Dim InsertValue
	skid = DownsysClass.checkStr(Request("skid"))
	mdbname = DownsysClass.checkStr(Trim(Request.Form("skinmdb")))
	If skid = "" Or IsNull(skid) Or Not IsNumeric(Replace(Replace(skid, ",", ""), " ", "")) Then
		ErrMsg = ErrMsg + "<BR><li>您还未选取要导入的模版"
		Exit Sub
	End If
	If mdbname = "" Then
		ErrMsg = ErrMsg + "<BR><li>请填写导入模版数据库名"
		Exit Sub
	End If
	SkinConnection (mdbname)
	If Request("type") = "删除" Then
		StyleConn.Execute ("Delete from NC_Template where id in (" & skid & ")")
		NC_Admin.Succeed_Msg ("删除成功。")
		Response.End
	ElseIf Request("type") = "导入" Then
		ChkSkinMDB
		If ErrMsg <> "" Then Exit Sub
		Set trs = StyleConn.Execute(" select * from NC_Template where id in (" & skid & ")  order by id ")
		Do While Not trs.EOF
			InsertName = ""
			InsertValue = ""
			For i = 1 To trs.Fields.Count - 1
				InsertName = InsertName & trs(i).Name
				InsertValue = InsertValue & "'" & DownsysClass.checkStr(trs(i)) & "'"
				If i <> trs.Fields.Count - 1 Then
					InsertName = InsertName & ","
					InsertValue = InsertValue & ","
				End If
			Next
			DownsysClass.Execute ("insert into [NC_Template] (" & InsertName & ") values (" & InsertValue & ") ")
			trs.movenext
		Loop
		trs.Close
		Set Rs = Nothing
		Set trs = Nothing
		NC_Admin.Succeed_Msg ("数据导入成功！")
		DownsysClass.DelCahe ("Templateslist")
	Else
		ErrMsg = ErrMsg + "<li>错误参数!</li>"
		Founderr = True
	End If
End Sub

Private Sub rename()
	Dim sRs
	'模板改名
	skid = DownsysClass.checkStr(Request("skid"))
	mdbname = DownsysClass.checkStr(Trim(Request("mdbname")))
	If skid <> "" And IsNumeric(skid) Then skid = CLng(skid) Else skid = 1
	If Request("act") = "loadskin" And mdbname <> "" Then
		SkinConnection (mdbname)
		Set sRs = StyleConn.Execute("select id,TempName from NC_Template where id=" & skid)
	Else
		Set sRs = DownsysClass.Execute("select id,TempName from NC_Template where id=" & skid)
	End If
	Response.Write "<form action=""?action=savenm"" method=post >" & vbCrLf
	Response.Write "<table border=""0"" cellspacing=""1"" cellpadding=""5"" align=center width=""95%"" class=""tableBorder"">" & vbCrLf
	Response.Write "<tr><th colspan=""2"">更改模版名称 ID="
	Response.Write sRs(0)
	Response.Write "</td></tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write Chr(9) & "<td width=""20%"" class=""forumrow"">模版原名：</td>" & vbCrLf
	Response.Write Chr(9) & "<td width=""80%"" class=""forumrow"">"
	Response.Write sRs(1)
	Response.Write "</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write Chr(9) & "<td class=""forumrow"">模版新名：</td>" & vbCrLf
	Response.Write Chr(9) & "<td class=""forumrow""><input type=""text"" name=""skinNAME"" size=""30"" value=""""></td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr><td align=center class=forumRowHighlight colspan=""2""><input class=button type=""submit"" name=""submit"" value=""更 新""></td></tr>" & vbCrLf
	If Request("act") = "loadskin" Then
		Response.Write "<input TYPE=""hidden"" NAME=""mdbname"" VALUE="""
		Response.Write mdbname
		Response.Write """>" & vbCrLf
	End If
	Response.Write "<input TYPE=""hidden"" NAME=""skid"" VALUE="""
	Response.Write sRs(0)
	Response.Write """>" & vbCrLf
	Response.Write "<input TYPE=""hidden"" NAME=""act"" VALUE="""
	Response.Write Request("act")
	Response.Write """>" & vbCrLf
	Response.Write "</table></form>" & vbCrLf
	sRs.Close
	Set sRs = Nothing
End Sub

Private Sub savenm()
	Dim skinNAME
	'模板改名保存
	skid = DownsysClass.checkStr(Request.Form("skid"))
	mdbname = DownsysClass.checkStr(Trim(Request.Form("mdbname")))
	skinNAME = DownsysClass.checkStr(Trim(Request.Form("skinname")))
	If skid = "" Or Not IsNumeric(skid) Then
		ErrMsg = ErrMsg + "<BR><li>请选择正确的参数"
		Exit Sub
	End If
	If skinNAME = "" Then
		ErrMsg = ErrMsg + "<li>新模板名称不能为空！"
		Exit Sub
	End If
	If Request("act") = "loadskin" And mdbname <> "" Then
		SkinConnection (mdbname)
		StyleConn.Execute ("UPDATE NC_Template set TempName='" & skinNAME & "'  where id=" & skid)
	Else
		DownsysClass.Execute ("UPDATE NC_Template set TempName='" & skinNAME & "'  where id=" & skid)
		DownsysClass.DelCahe ("Templateslist")
	End If
	NC_Admin.Succeed_Msg ("<li>数据更新成功！")
End Sub

Private Sub ChkSkinMDB()
	Dim TempField
	Dim TempRs
	Dim TempSql
	Dim FalseName
	Dim LostName
	If IsFoundTable("NC_Template", 1) = False Then
		ErrMsg = ErrMsg + "<li>" & mdbname & "数据库中找不到指定的数据表，请新建风格数据表；"
		ErrMsg = ErrMsg + "<li><a href=?action=CreatMdb&mdbname=" & mdbname & " >现在就新建风格数据表</a>。"
		Exit Sub
	End If
	'两个表字段比较
	TempField = ""
	FalseName = ""
	TempSql = "Select top 1 * From [NC_Template]"
	If Request("action") = "loadskin" Then
		Set TempRs = DownsysClass.Execute(TempSql)
	Else
		Set TempRs = StyleConn.Execute(TempSql)
	End If
	For i = 0 To TempRs.Fields.Count - 1
		TempField = TempField & TempRs(i).Name & ","
	Next
	TempRs.Close
	TempField = LCase(TempField)
	If Request("action") = "loadskin" Then
		Set TempRs = StyleConn.Execute(TempSql)
	Else
		Set TempRs = DownsysClass.Execute(TempSql)
	End If
	For i = 0 To TempRs.Fields.Count - 1
		If InStr(TempField, LCase(TempRs(i).Name)) = 0 Then
			FalseName = FalseName & TempRs(i).Name & ","
		Else
			TempField = Replace(TempField, LCase(TempRs(i).Name), "")
			TempField = Replace(TempField, ",,", ",")
		End If
	Next
	TempRs.Close
	Set TempRs = Nothing
	If Right(FalseName, 1) = "," Then FalseName = Left(FalseName, Len(FalseName) - 1)
	If Right(TempField, 1) = "," Then TempField = Left(TempField, Len(TempField) - 1)
	If Left(TempField, 1) = "," Then TempField = Replace(TempField, ",", "", 1, 1)
	If FalseName <> "" Then
		If Request("action") = "loadskin" Then
			ErrMsg = ErrMsg + "<li>备份表中多出以下字段： " & FalseName & " ，请更新数据库结构后再执行刚才的操作！"
		Else
			Call AddFields(FalseName)
		End If
	End If
	If TempField <> "" And Request("action") <> "loadskin" Then
		SucMsg = SucMsg + "<li>备份表中多出以下字段： " & TempField & " ，你可以点击下面链接删除多余的字段！"
		SucMsg = SucMsg + "<li><a href=?action=DelFields&fields=" & TempField & "&mdbname=" & mdbname & "><font color=red>执行清理删除该字段！</font></a>"
	End If
End Sub

Private Sub DelFields()
	Dim Fields
	Dim TempFields
	Fields = Request.Querystring("fields")
	If Request("mdbname") = "" Then
		ErrMsg = ErrMsg + "<BR><li>请指定备份模版数据库。"
		Exit Sub
	Else
		mdbname = DownsysClass.checkStr(Trim(Request("mdbname")))
	End If
	If Replace(Fields, ",", "") = "" Then Exit Sub
	If Not IsObject(StyleConn) Then SkinConnection (mdbname)
	TempFields = Split(Fields, ",")
	For i = 0 To UBound(TempFields)
		If TempFields(i) <> "" Then
			StyleConn.Execute ("alter table [NC_Template] drop COLUMN " & TempFields(i))
		End If
	Next
	NC_Admin.Succeed_Msg ("<li>" & Fields & "删除成功！<li><a href=admin_loadskin.asp>返回模板管理首页</a>")
End Sub

Private Sub AddFields(Fields)
	Dim TempFields
	Dim FieldName
	Dim FieldSql
	Dim FieldValue
	If Replace(Fields, ",", "") = "" Then Exit Sub
	TempFields = Split(Fields, ",")
	If IsObject(StyleConn) Then
		For i = 0 To UBound(TempFields)
			Select Case LCase(TempFields(i))
				Case "TempName"
					FieldValue = TempFields(i) & "=''"
					FieldSql = TempFields(i) & " varchar(50) NOT NULL"
				Case "forum_css"
					FieldValue = TempFields(i) & "='|||@@@|||'"
					FieldSql = TempFields(i) & " text not Null default '|||@@@|||'"
				Case Else
					FieldValue = TempFields(i) & "='|||@@@|||@@@|||@@@|||'"
					FieldSql = TempFields(i) & " text not Null default '|||@@@|||@@@|||@@@|||'"
			End Select
			If Request("action") = "loadskin" Then
				DownsysClass.Execute ("alter table [NC_Template] add " & FieldSql)
				DownsysClass.Execute ("Update [NC_Template] Set " & FieldValue)
			Else
				StyleConn.Execute ("alter table [NC_Template] add " & FieldSql)
				StyleConn.Execute ("Update [NC_Template] Set " & FieldValue)
			End If
		Next
	Else
		ErrMsg = ErrMsg + "<li>备份表链接未曾建立！"
	End If
End Sub

Private Sub CreateStyleMdb()
	Dim CreatStr
	If Request("mdbname") = "" Then
		ErrMsg = ErrMsg + "<BR><li>请指定备份模版数据库。"
		Exit Sub
	Else
		mdbname = DownsysClass.checkStr(Trim(Request("mdbname")))
	End If
	CreatStr = "CREATE TABLE NC_Template (ID int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_NC_Template PRIMARY KEY," & _
		   "TempName varchar(50) NOT NULL," & _
		   "Forum_CSS text not Null default '|||@@@|||',"
	Set Rs = DownsysClass.Execute("select top 1 * From [NC_Template] ")
	If Rs.EOF Then
		ErrMsg = ErrMsg + "<li>无法取出源模版数据"
		Founderr = True
		Exit Sub
	End If
	For i = 3 To Rs.Fields.Count - 1
		CreatStr = CreatStr & Rs(i).Name & " text not Null default '|||@@@|||@@@|||@@@|||'"
		If i <> Rs.Fields.Count - 1 Then
			CreatStr = CreatStr & ","
		End If
	Next
	CreatStr = CreatStr & ")"
	Rs.Close
	Set Rs = Nothing
	SkinConnection (mdbname)
	StyleConn.Execute (CreatStr)
	NC_Admin.Succeed_Msg ("<li>NC_Template数据表结构创建成功！<li><a href=admin_loadskin.asp>返回模板管理首页</a>")
End Sub

Private Function IsTruePage(page)
	Dim MyRs
	'校验字段是否存在
	IsTruePage = False
	If page <> "" Then
		page = LCase(Trim(page))
		Set MyRs = DownsysClass.Execute("Select top 1 * From [NC_Template]")
		For i = 2 To MyRs.Fields.Count - 1
			If LCase(MyRs(i).Name) = page Then
				IsTruePage = True
				Exit Function
			End If
		Next
		Set MyRs = Nothing
	End If
End Function

Private Sub ChkFields()
	Dim TempField
	Dim TempRs
	Dim TempSql
	Dim FalseName
	Dim LostName
	'两个表字段比较
	TempField = ""
	TempSql = "Select top 1 * From [NC_Template]"
	Set TempRs = StyleConn.Execute(TempSql)
	For i = 0 To TempRs.Fields.Count - 1
		TempField = TempField & TempRs(i).Name & ","
	Next
	TempRs.Close
	TempField = LCase(TempField)
	Set TempRs = DownsysClass.Execute(TempSql)
	For i = 0 To TempRs.Fields.Count - 1
		If InStr(TempField, LCase(TempRs(i).Name)) = 0 Then
			FalseName = FalseName & TempRs(i).Name & ","
		Else
			TempField = Replace(TempField, LCase(TempRs(i).Name), "")
			TempField = Replace(TempField, ",,", ",")
		End If
	Next
	TempRs.Close
	Set TempRs = Nothing
End Sub

Private Function IsFoundTable(TableName, Str)
	Dim ChkRs
	IsFoundTable = False
	If TableName <> "" Then
		TableName = LCase(Trim(TableName))
		If Str = 0 Then
			Set ChkRs = Conn.openSchema(20)
		Else
			Set ChkRs = StyleConn.openSchema(20)
		End If
		Do Until ChkRs.EOF
			If ChkRs("TABLE_TYPE") = "TABLE" Then
				If LCase(ChkRs("TABLE_NAME")) = TableName Then
					IsFoundTable = True
					Exit Function
				End If
			End If
			ChkRs.movenext
		Loop
		ChkRs.Close
		Set ChkRs = Nothing
	End If
End Function
%>
