<%Response.Buffer=True
Response.CacheControl="no-cache"   
Response.Expires=0%>
<!--#include file="../../config.asp"-->
<!--#include file="../../manage/checkuserflag.asp"-->
<%call CheckUserFlag("")
dim ObjDCW
dim dbconn

Dim PageNo	
Dim mpage
Dim startime
Dim endtime
PageNo = 3
Dim PageNum		
Dim RCount		
Dim i
dim page_str_SZ
dim page_xb
			
Dim sql	
Dim rs

Set ObjDCW = Server.CreateObject("dc_data100_v1_0.C_A_Config")
survey_id=request("S_id")
dc_sort=request("dc_sort")

Sub OpenDB(DataPathFile_c)
	'Set ObjReference = Server.CreateObject("dc_data100_v1_0.C_A_Config") 
	Set DbConn = Server.CreateObject("ADODB.Connection")	
	DbConn.Open ObjDCW.dbPath(DataPathFile_c)
End Sub
Sub CloseDB()
	DbConn.Close
	Set DbConn = Nothing
End Sub
%>
<html>
<head>
<title>盛维在线调查系统v9.0免费版-&gt问卷调查系统后台管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content="盛维在线调查系统v9.0免费版" name=description>
<link rel="stylesheet" href="../../inc/manage.css" type="text/css">
</head>
<script language="javascript">
function save_set(s) {                        
	  document.form1.action="survey_addSy.asp?S_id=<%=survey_id%>&dc_sort=<%=dc_sort%>&p=<%=Request("p")%>&add_sort="+ s;
	  document.form1.submit();       
  } 
</script>
<script language="javascript">
function iframeAutoFit()//自适应其加载的网页(多浏览器兼容)
{
 try
 {
	 if(window!=parent)
	 {
		 var a = parent.document.getElementsByTagName("IFRAME");
		 for(var i=0; i<a.length; i++) //author:meizz
		 {
			 if(a[i].contentWindow==window)
			 {
				 var h1=0, h2=0;
				 a[i].parentNode.style.height = a[i].offsetHeight +"px";
				 a[i].style.height = "10px";
				 if(document.documentElement&&document.documentElement.scrollHeight)
				 {
					 h1=document.documentElement.scrollHeight;
				 }
				 if(document.body) h2=document.body.scrollHeight;

				 var h=Math.max(h1, h2);
				 if(document.all) {h += 4;}
				 if(window.opera) {h += 1;}
				 a[i].style.height = a[i].parentNode.style.height = h +"px";
			 }
		 }
	 }
 }
 catch (ex){}
}
if(window.attachEvent)
{
 window.attachEvent("onload",   iframeAutoFit);
 //window.attachEvent("onresize",   iframeAutoFit);
}
else if(window.addEventListener)
{
 window.addEventListener('load',   iframeAutoFit,   false);
 //window.addEventListener('resize',   iframeAutoFit,   false);
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<%
OpenDB DataPathFile

add_sort=request("add_sort")
'response.write "<br>add_sort=" & add_sort & "<br>"
if add_sort=1 then'设置成筛选条件
	'response.write "<br>QID=" & request("QID") & "<br>"
	'response.end
	'ObjDCW.setSy(DataPathFile)
	setSy(DataPathFile)
end if
Function setSy(DataPathFile) '设置成筛选条件
    OpenDB DataPathFile
    QID = Request.Form("QID")
	Q_ID_string = Request.Form("Q_ID_string")
    Q_ID_string = mid(Q_ID_string,2,len(Q_ID_string)-1)
    DbConn.Execute ("UPDATE Question SET Q_konzhima=0 Where Q_ID in (" & Q_ID_string & ")")
    if QID<>"" then
		DbConn.Execute ("UPDATE Question SET Q_konzhima=1 Where Q_ID in (" & QID & ")")
	end if
    'CloseDB
End Function
%>
<form action="" method="post" name="form1">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#5C99DC">
  <tr>
    <td width="5%" height="25" align="center" background="../../images/s3wcn_bt.gif">页次</td>
    <td width="6%" height="25" align="center" background="../../images/s3wcn_bt.gif">次序</td>
    <td width="79%" height="25" background="../../images/s3wcn_bt.gif">问题标题</td>
    <td width="10%" align="center" background="../../images/s3wcn_bt.gif">参与筛选</td>
  </tr>
<%
sqlstr_page = "SELECT Q_Page FROM Question where D_T_S_ID=" & survey_id & " and Q_Sort<>12 order by Q_Page asc"
Set prs = Server.CreateObject("Adodb.recordset")
prs.open sqlstr_page, DbConn, 1, 1
prs_count = prs.recordcount
page_str = ""
mpage=0'最大页码
For I = 1 To prs_count Step 1
	Q_Page = prs("Q_Page")
	Q_page_s = "-" & Q_Page & "-"
	If UBound(Split(page_str_s, Q_page_s)) <= 0 Then
		page_str_s = page_str_s & Q_page_s
		page_str = page_str & "," & Q_Page
		if mpage<Q_Page then
			mpage=Q_Page'最大页码
		end if
	End If
	prs.movenext
Next
If page_str <> "" Then
	page_str = Mid(page_str, 2, Len(page_str) - 1)
Else
	Response.Write "尚未添加试题！"
	Response.End
End If
	
call CheckPage()'读出当前页码
sql = "Select * From Question where D_T_S_ID=" & survey_id
all=request("all")
if all<>1 and PageNum>0 then
	sql =sql & " and Q_Page=" & PageNum
end if
sql =sql & " and Q_Sort<>12 Order By Q_Page asc,Q_Order asc,Q_ID asc"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, DBConn, 1,1
Q_ID_string=""
If Not rs.EOF Then
	'rs.AbsolutePage = PageNum
	rscound=rs.recordcount
	For RCount = 1 To rscound step 1
	Q_ID=rs("Q_ID")
	Q_ID_string=Q_ID_string & "," & Q_ID
	S=rs("Q_Sort")
	startime=rs("Q_StartDate")
	endtime=rs("Q_EndDate")
	Q_Order=rs("Q_Order")
	Q_Page=rs("Q_Page")
	Q_konzhima=rs("Q_konzhima")
%>
  <tr bgcolor="#FFFFFF">
    <td width="5%" align="center" height="20"><%=Q_Page%></td>
    <td width="6%" align="center"><%=Q_Order%></td>
    <td><%response.write rs("Q_Title")%></td>
    <td align="center"><input name="QID" type="checkbox" value="<%=Q_ID%>" <%if Q_konzhima=1 then response.write "checked" end if%>></td>
  </tr>
  <%
	rs.MoveNext
	'If rs.EOF Then Exit For
	Next
	if mpage>1 then
%>  
  <tr bgcolor="#FFFFFF"> 
    <td colspan="4"> 
      <%call DisplayPage()%>    </td>
  </tr>
  <%
	end if
	no_record=0'表示有记录
Else
	response.write "<tr bgcolor=""#FFFFFF""> <td colspan=""6"">您还没有添加调查！</td></tr>"	
	no_record=1'表示没有记录
End IF
rs.Close
Set rs = Nothing
call CloseDB()
%>
  <tr bgcolor="#FFFFFF">
    <td colspan="4" align="center"><input name="Q_ID_string" type="hidden" id="Q_ID_string" value="<%=Q_ID_string%>">
    <input name="dc_sort" type="hidden" id="dc_sort" value="<%=dc_sort%>">
    <%if no_record=0 then%>
    <input type="submit" name="Submit" value="设置成筛选" class=p9 style="WIDTH: 95px; HEIGHT: 24px;" onClick="javascript:save_set(1);">
    <%end if%>    </td>
  </tr>
</table>
</form>
<%
Function RequestText(text)
	if text<>"" and not IsNull(text) then
		RequestText=Trim(Replace(text,"'",""))
	else
		RequestText=""
	end if
End Function

sub out(text)
	response.write "<br><br><center><font size=2>" & text & "<a href="""&_
	"javascript:history.back();"">[返回]</a></font></center>"
	response.end
end sub

Sub CheckPage()
	page_str_SZ=split(page_str,",")
	'rs.PageSize = PageNo
	'mpage=rs.pagecount'最大页码
	page_xb=Request("p")
	if IsNumeric(page_xb) then
		page=page_str_SZ(page_xb)'当前页码
	end if
	if not IsNumeric(page) then
		PageNum = 1
	elseIf page <> "" and int(mpage) >= int(page) Then
		PageNum = CINT(page)
	Else
		PageNum = 1
	End If
End Sub 

Sub DisplayPage()
	Response.Write "页次："
	Response.Write "<a href=""" _
	& Request.ServerVariables("SCRIPT_NAME") _
	& "?S_id=" & survey_id & "&dc_sort=" & dc_sort & "&all=" & 1 _
	& """>[显示全部]</a>"
	If PageNum > 1 Then
		Response.Write "<a href=""" _
		& Request.ServerVariables("SCRIPT_NAME") _
		& "?S_id=" & survey_id & "&dc_sort=" & dc_sort & "&p=" & page_xb-1 _
		& """>[&lt;&lt;]</a>"
	End If

	For i = 0 To ubound(page_str_SZ) step 1
		'response.write "||PageNum=" & PageNum & "||page_str_SZ(i)=" & page_str_SZ(i) & "||"
		If int(page_str_SZ(i)) = int(PageNum) Then
			Response.Write "<font color=""red"">[" & page_str_SZ(i) & "]</font>"
		else
			Response.Write "<a href=""" _
			& Request.ServerVariables("SCRIPT_NAME") _
			& "?S_id=" & survey_id & "&dc_sort=" & dc_sort & "&p=" & i _
			& """>[" & page_str_SZ(i) & "]</a>"
		End If
	Next
	If PageNum < mpage Then
		if isempty(page_xb) or not IsNumeric(page_xb) then
			page_xb=0
		end if
		Response.Write "<a href=""" _
		& Request.ServerVariables("SCRIPT_NAME") _
		& "?S_id=" & survey_id & "&dc_sort=" & dc_sort & "&p=" & page_xb+1 _
		& """>[&gt;&gt;]</a>"
	End If
End Sub
%>