<!-- #include file="../conn.asp" -->
<!-- #include file="../cls_main.asp" -->
<!-- #include file="../cls_Mesky_showPage.asp" -->
<% MyDbPath = "../"
dim obj
set obj = New admin_cms_special
	obj.AspInit()
set obj = nothing

Class admin_cms_special

	Private isEdit, y, Mesky
	Private Sub Class_Initialize()
		Set Mesky = New Cls_Main
	End Sub
	Private Sub Class_Terminate()
		Set Mesky = Nothing
	End Sub
	Public Sub AspInit()
		Response.Write "<HTML>" & vbCrLf
		Response.Write "<HEAD>" & vbCrLf
		Response.Write "<TITLE>专题管理</TITLE>" & vbCrLf
		Response.Write "<META http-equiv=Content-Type content=""text/html; charset=gb2312"">" & vbCrLf
		Response.Write "<LINK href=""admin.css"" type=text/css rel=stylesheet>" & vbCrLf
		Response.Write "</HEAD>" & vbCrLf
		Response.Write "<BODY leftmargin=""1"" topmargin=""1"">" & vbCrLf
		isEdit = False
			If Mesky.adminName = "" Then
				Mesky.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统，<a href=""../admin_login.asp"" target=_top>点此进入管理员登录界面</a>。"
				Call Mesky.SystemMsg
			ElseIf Mesky.checkPermission(Mesky.adminName, "21") = False Then
				Mesky.strMsg = "<li>非法操作：你没有权限进行此项操作，请联系管理员！"
				Call Mesky.SystemMsg
			Else
				Call Main
			End If
		Response.Write "</BODY>" & vbCrLf
		Response.Write "</HTML>" & vbCrLf
	
	End Sub
	Private Sub Main()
		Select Case Request("action")
		Case "saveadd"
			Call SaveAdd
		Case "modify"
			Call SaveModify
		Case "edit"
			isEdit = True
			Call myform
		Case "add"
			isEdit = False
			Call myform
		Case "batch_isDel"
			Call batch_isDel
		Case Else
			Call showList
		End Select
	End Sub
	Private Sub SaveAdd()
		Dim sContent, i, Rs, sql
		If Not IsObject(Conn) Then ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select * from Mesky_Cms_Special where (SpecialID is null)"
		Rs.open sql, Conn, 1, 3
		Rs.AddNew
		Rs("SpecialName") = Trim(Request.Form("SpecialName"))
		Rs("SmallImg") = Trim(Request.Form("SmallImg"))
		Rs("RedirectUrl") = Trim(Request.Form("RedirectUrl"))
		For i = 1 To Request.Form("content1").Count
			sContent = sContent & Request.Form("content1")(i)
		Next
		Rs("Content") = sContent
		Rs("DateAndTime") = Now()
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		Mesky.strMsg = "<li>添加新专题操作成功！<li><a href=?action=add>继续添加新专题</a></li>"
		Call Mesky.SystemMsg
	End Sub
	Private Sub SaveModify()
		Dim sContent, i, Rs, sql
		If Not IsObject(Conn) Then ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select * from Mesky_Cms_Special where SpecialID=" & CLng(Request.Form("SpecialID"))
		Rs.open sql, Conn, 1, 3
		Rs("SpecialName") = Trim(Request.Form("SpecialName"))
		Rs("SmallImg") = Trim(Request.Form("SmallImg"))
		Rs("RedirectUrl") = Trim(Request.Form("RedirectUrl"))
		For i = 1 To Request.Form("content1").Count
			sContent = sContent & Request.Form("content1")(i)
		Next
		Rs("Content") = sContent
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		Mesky.strMsg = "<li>修改专题操作成功！<li><a href=?action=add>继续添加新专题</a></li>"
		Call Mesky.SystemMsg
	End Sub
	Private Sub batch_isDel()
		Dim selSpecialID
		selSpecialID = Trim(Request.Form("selSpecialID"))
		If selSpecialID <> "" Then
			Mesky.Execute ("delete from Mesky_Cms_Special where SpecialID in (" & selSpecialID & ")")
		End If
		Set Mesky.strMsg = "<li>批量删除专题操作成功！></li>"
		Call Mesky.SystemMsg
	End Sub
	Private Sub showList()
	
		Dim sColumn, showPageRs, strSQL, Rs, i, currentPage
		If Trim(Request.QueryString("Page")) = "" Then
			currentPage = 1
		Else
			currentPage = Trim(Request.QueryString("Page"))
		End If
		sColumn = "SpecialID,SpecialName,OrderID,Content,SmallImg,DateAndTime,RedirectUrl"
		Response.Write " <fieldset><legend>文章专题管理：[<a href=""?action=add"">添加专题</a>]</legend>" & vbCrLf
		Response.Write "      <table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"">" & vbCrLf
		Response.Write "        <COLGROUP>" & vbCrLf
		Response.Write "        <COL width=30>" & vbCrLf
		Response.Write "        <COL width=*>" & vbCrLf
		Response.Write "        <COL width=120>" & vbCrLf
		Response.Write "        <COL width=60>" & vbCrLf
		Response.Write "        <COL width=100>" & vbCrLf
		Response.Write "        <tr style=""font-weight: bold;"" class=""tdbg2""> " & vbCrLf
		Response.Write "          <td>选择</td>" & vbCrLf
		Response.Write "          <td>专题名称</td>" & vbCrLf
		Response.Write "          <td>建立时间</td>" & vbCrLf
		Response.Write "          <td>修改</td>" & vbCrLf
		Response.Write "          <td>备注</td>" & vbCrLf
		Response.Write "        </tr>" & vbCrLf
		Response.Write "        <SCRIPT language = ""JavaScript"">" & vbCrLf
		Response.Write "function SelectAll() {" & vbCrLf
		Response.Write "    for (var i=0;i<document.myform.selSpecialID.length;i++) {" & vbCrLf
		Response.Write "        var e=document.myform.selSpecialID[i];" & vbCrLf
		Response.Write "        e.checked=!e.checked;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "        <form name=""myform"" method=""post"" action="""">" & vbCrLf
	
		Set showPageRs = New cls_Mesky_showPage '创建对象
			If IsSqlDataBase = 1 Then
				showPageRs.DbType = "MSSQL_SP"
			Else
				showPageRs.DbType = "AC"
			End If
			'数据库类型,AC为access,MSSQL为sqlserver2000,MSSQL_SP为存储过程版,MYSQL为mysql,PGSQL为PostgreSql
			showPageRs.RecType = 0
			'取记录总数方法(0执行count,1自写sql语句取,2固定值)
			showPageRs.RecSql = 0
			'如果RecType＝1则=取记录sql语句，如果是2=数值，等于0=""
			showPageRs.RecTerm = 2
			'取从记录条件是否有变化(0无变化,1有变化,2不设置cookies也就是及时统计，适用于搜索时候)
			showPageRs.CookieName = "admin_cms_special" '如果RecTerm＝2,cookiesname="",否则写cookiesname
			showPageRs.Order = 0              '排序(0顺序1降序),注意要和下面sql里面主键ID的排序对应
			showPageRs.PageSize = 30          '每页记录条数
			showPageRs.currentPage = currentPage
			showPageRs.sql = sColumn & "$Mesky_Cms_Special$$SpecialID$SpecialID" '字段,表,条件(不需要where),排序(不需要需要ORDER BY),主键ID
		Dim iRecCount, sqlRs
		iRecCount = showPageRs.RecCount() '记录总数
	   
		If iRecCount < 1 Then
			Response.Write "<tr bgcolor=""#FCFCFC""><td colspan=""5"">Sorry！没有找到任何记录。</td></tr>"
		Else
			Set sqlRs = showPageRs.ResultSet()  '返回ResultSet
			Rs = sqlRs.GetRows(-1)
			For i = 0 To UBound(Rs, 2)
			' sColumn = "SpecialID,SpecialName,OrderID,Content,SmallImg,DateAndTime,RedirectUrl"
				Response.Write "          <tr> " & vbCrLf
				Response.Write "            <td class=""tdbg2""> "
				Response.Write "<input name=""selSpecialID"" type=""checkbox"" value=""" & Rs(0, i) & """>"
				Response.Write "            </td>" & vbCrLf
				Response.Write "            <td class=""tdbg2"">" & Rs(1, i) & "</td>" & vbCrLf
				Response.Write "            <td class=""tdbg2"">" & Rs(5, i) & "</td>" & vbCrLf
				Response.Write "            <td class=""tdbg2""><a href=""?action=edit&SpecialID=" & Rs(0, i) & """>修改</a></td>" & vbCrLf
				Response.Write "            <td class=""tdbg2""></td>" & vbCrLf
				Response.Write "          </tr>" & vbCrLf
			Next
			Rs = Null
			Set sqlRs = Nothing
		End If
		
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <td colspan=""5"" class=""tdbg2""><a href=""javascript:SelectAll()"">选择</a> " & vbCrLf
		Response.Write "              管理选项: " & vbCrLf
		Response.Write "              <input type=""radio"" name=""action"" value=""batch_isDel""> <font color=""#FF0000"">批量删除</font> " & vbCrLf
		Response.Write "              <input type=""submit"" name=""Submit3"" value=""执行操作"" onclick=""{if(confirm('您确定执行的操作吗?')){this.document.myform.submit();return true;}return false;}""> " & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "        </form>" & vbCrLf
		If iRecCount > 0 Then
			Response.Write "<tr bgcolor=""#FFFFFF""><td colspan=""9"">" & showPageRs.showPage("?Page={$pages}" & q) & "</td></tr>"
		End If
		Response.Write "      </table></fieldset>" & vbCrLf
		Set showPageRs = Nothing
		
	End Sub
	Sub myform()
		Response.Write "<script language=""Javascript""><!--" & vbCrLf
		Response.Write "function VF_form1(){ //v2.0" & vbCrLf
		Response.Write "<!--start_of_saved_settings-->" & vbCrLf
		Response.Write "<!--type,text,name,SpecialName,required,true,errMsg,专题名称不能为空！-->" & vbCrLf
		Response.Write "<!--end_of_saved_settings-->" & vbCrLf
		Response.Write "    var theForm = document.form1;" & vbCrLf
		Response.Write "    var errMsg = """";" & vbCrLf
		Response.Write "    var setfocus = """";" & vbCrLf
		Response.Write vbCrLf
		Response.Write "    if (theForm['SpecialName'].value == """"){" & vbCrLf
		Response.Write "        errMsg = ""专题名称不能为空！"";" & vbCrLf
		Response.Write "        setfocus = ""['SpecialName']"";" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    if (errMsg != """"){" & vbCrLf
		Response.Write "        alert(errMsg);" & vbCrLf
		Response.Write "        eval(""theForm"" + setfocus + "".focus()"");" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    if (eWebEditor1.getHTML()==""""){" & vbCrLf
		Response.Write "        alert(""专题描述不能为空！"");" & vbCrLf
		Response.Write "        return false;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    else theForm.submit();" & vbCrLf
		Response.Write "}//-->" & vbCrLf
		Response.Write "<!--" & vbCrLf
		Response.Write "function SetSmallImg(){" & vbCrLf
		Response.Write "    var arr = showModalDialog(""../eWebEditor/Upload_Images_Dialog.asp?style=s_meskycn"", """", ""dialogWidth:26em; dialogHeight:10em; status:0;help=no"");" & vbCrLf
		Response.Write "    if (arr ==null){" & vbCrLf
		Response.Write "        myform.SmallImg.value="""";" & vbCrLf
		Response.Write "        alert(""系统提示：当前没有上传图片，资源缩略图为空，用户可以重新上传图片！"");" & vbCrLf
		Response.Write "        //myform.SmallImg.focus();" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    if (arr !=null){" & vbCrLf
		Response.Write "        myform.SmallImg.value=arr;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "//-->" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<form action=""admin_cms_special.asp"" method=""post"" name=""form1""> " & vbCrLf
		Response.Write "<fieldset><legend>" & vbCrLf
		If isEdit Then
			Set Rs = Mesky.Execute("select * from Mesky_Cms_Special where SpecialID=" & CLng(Request.QueryString("SpecialID")))
			Response.Write ("修改专题")
			Response.Write ("<input type=""Hidden"" name=""action"" value=""modify"">")
			Response.Write ("<input type=""Hidden"" name=""SpecialID"" value=""" & Trim(Request.QueryString("SpecialID")) & """>")
		Else
			Response.Write ("添加专题")
			Response.Write ("<input type=""Hidden"" name=""action"" value=""saveadd"">")
		End If
		Response.Write "</legend>" & vbCrLf
		Response.Write " <table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""3"">" & vbCrLf
		Response.Write "          <tr class=""tdbg2""> " & vbCrLf
		Response.Write "            <td align=""right"">专题名称</td>" & vbCrLf
		Response.Write "            <td><input name=""SpecialName"" type=""text"" size=""50"" maxlength=""100"" value="""
		If isEdit Then Response.Write Trim(Rs("SpecialName"))
		Response.Write """>" & vbCrLf
		Response.Write "            <font color=red>！</font></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg3""> " & vbCrLf
		Response.Write "            <td align=""right"">转向链接</td>" & vbCrLf
		Response.Write "            <td><input name=""RedirectUrl"" type=""text"" size=""50"" maxlength=""100"" value="""
		If isEdit Then Response.Write Trim(Rs("RedirectUrl"))
		Response.Write """></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2""> " & vbCrLf
		Response.Write "            <td align=""right"">专题图片</td>" & vbCrLf
		Response.Write "            <td><input name=""SmallImg"" type=""text"" size=""50"" maxlength=""100"" value="""
		If isEdit Then Response.Write Trim(Rs("SmallImg"))
		Response.Write """>" & vbCrLf
		Response.Write "            <input type=""button"" value=""设置"" onclick=""SetSmallImg();""></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg3""> " & vbCrLf
		Response.Write "            <td align=""right"" valign=""top"">专题描述</td>" & vbCrLf
		Response.Write "            <td>"
		If isEdit Then
			Response.Write "<textarea name=""content1"" id=""content1"" style=""display:none"">" & Rs("Content") & "</textarea>" & vbCrLf
		Else
			Response.Write " <INPUT type=""hidden"" name=""content1"" value=""""> " & vbCrLf
		End If
		Response.Write "        <IFRAME ID=""eWebEditor1"" src=""../ewebeditor/ewebeditor.asp?id=content1&style=s_meskycn"" frameborder=""0"" scrolling=""no"" width=""600"" height=""300""></IFRAME> </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2""> " & vbCrLf
		Response.Write "            <td align=""right"">&nbsp;</td>" & vbCrLf
		Response.Write "            <td><input type=""button"" name=""btnSubmit"" value="" 提 交 "" onclick=""VF_form1()""></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "</table></fieldset></form>" & vbCrLf
		If isEdit Then Set Rs = Nothing
	End Sub
	Public Sub OnEndPage()
		Response.Write Mesky.CopyRight
	End Sub ' OnEndPage

End Class %>