<%@language=vbscript codepage=936 %>
<%
Response.Buffer = True
Server.ScriptTimeOut = 9999999
%>
<!--#include file="../Conn.asp"-->
<%
ComeUrl = Trim(Request.ServerVariables("HTTP_REFERER"))
Action = Trim(Request("Action"))
strFileName = "Admin_Survey.asp"
                                                    
Response.Write "<html><head><title>问卷调查</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><link href='Admin_Style.css' rel='stylesheet' type='text/css'><base target='_self'></head>"
Response.Write "<body leftmargin='2' topmargin='0' marginwidth='0' marginheight='0' >" & vbCrLf
If Action <> "ShowReportForm" Then
    Response.Write "<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' Class='border'>" & vbCrLf
    Call ShowPageTitle("问卷调查管理", 10401)

    Response.Write "  <tr class='tdbg'> "
    Response.Write "    <td width='80' height='30'><strong>管理导航：</strong></td>"
    Response.Write "    <td height='30'>"
    Response.Write "  <a href='" & strFileName & "?Action=AddSurvey'>创建问卷</a>&nbsp;|&nbsp;<a href='" & strFileName & "'>问卷管理</a>&nbsp;|&nbsp;<a href='" & strFileName & "?Action=ListQuestion'>题目列表</a></td></tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
End If

Select Case Action
Case "AddSurveyKey"
    Call Main
Case "SaveSurveyKey"
    Call SaveSurveyKey    
Case Else
    Call Main
End Select


Private Sub Main()
    Dim SurveyKey
    'If AdminPurview <> 1 And arrPurview(1) = False Then
        'Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>"
        'Response.Write "<tr><td align='center'>您无设置问卷调查序列号的权限！</td></tr></table>"
        'Exit Sub
    'End If
    SurveyKey = conn.execute("Select SurveyKey from PE_Config")(0)
    Response.Write "<form method='Post' name='myform' action='Admin_SurveyKey.asp'>"
    Response.Write "<br><table width='100%'><tr><td align='left'>您现在的位置：问卷调查管理&nbsp;&gt;&gt;&nbsp;设置问卷调查序列号"
    Response.Write "</td></tr></table>"

    Response.Write "<table width='100%' class='border' align='center' border='0' cellspacing='1' cellpadding='1'>"
    Response.Write "      <tr class='title'>" & vbCrLf
    Response.Write "        <td width='100%' colspan='2'><b><div align='center'>问卷调查序列号 </div></td>"
    Response.Write "   </tr>"
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='40%' class='tdbg5'><strong>序列号：</strong><br>每个使用本问卷调查系统的网站都有一个我们授权的唯一序列号，如果你还没有此序列号，请联系我们获取。</td>" & vbCrLf
    Response.Write "      <td>"
    Response.Write "<textarea name='SurveyKey' cols='60' rows='6' id='SurrveyKey'>" & SurveyKey & "</textarea>" & vbCrLf
    Response.Write "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>"
    Response.Write "      <td height='50'  align='center' colspan='2'>"
    Response.Write "       <input name='Action' type='hidden' id='Action' value='SaveSurveyKey'><input type='Submit' name='Submit' value=' 保 存 '>"
    Response.Write "     </td>"
    Response.Write "    </tr>"
    
    Response.Write "</table>"
    Response.Write "</form>"
    Response.Write "<br>"
End Sub

Private Sub SaveSurveyKey()
    Dim SurveyKey
    SurveyKey = Trim(request.form("SurveyKey"))
    Conn.execute("Update PE_Config set SurveyKey='" & SurveyKey & "'")
    Response.Write WriteSuccessMsg("<li>保存成功！</li>", ComeUrl)
End Sub

Private Function WriteSuccessMsg(sSuccessMsg, sComeUrl)
    Dim strMsg, QuestionType
    strMsg = strMsg & "<html><head><title>成功信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrLf
    strMsg = strMsg & "<link href='images/Style.css' rel='stylesheet' type='text/css'></head><body><br><br>" & vbCrLf
    strMsg = strMsg & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbCrLf
    strMsg = strMsg & "  <tr align='center' class='title'><td height='22'><strong>恭喜你！</strong></td></tr>" & vbCrLf
    strMsg = strMsg & "  <tr class='tdbg'><td height='100' valign='top'><br>" & sSuccessMsg & "</td></tr>" & vbCrLf
    strMsg = strMsg & "  <tr align='center' class='tdbg'><td>"
    If sComeUrl <> "" Then
        strMsg = strMsg & "<a href='" & sComeUrl & "'>&lt;&lt; 返回上一页</a>"
    Else
        strMsg = strMsg & "<a href='javascript:window.close();'>【关闭】</a>"
    End If
    strMsg = strMsg & "</td></tr>" & vbCrLf
    strMsg = strMsg & "</table>" & vbCrLf
    strMsg = strMsg & "</body></html>" & vbCrLf
    WriteSuccessMsg = strMsg
End Function

Private Sub ShowPageTitle(strTitle, UrlID)
    Response.Write "  <tr class='topbg'> " & vbCrLf
    Response.Write "    <td height='22' colspan='10'><table width='100%'><tr class='topbg'><td align='center'><b>" & strTitle & "</b></td><td width='60' align='right'><a href='http://go.powereasy.net/go.aspx?UrlID=" & UrlID & "' target='_blank'><img src='images/help.gif' border='0'></a></td></tr></table></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
End Sub
%>