<!--#include file="conn.asp"-->
<!--#include file="inc/function.asp"-->
<%
dim askid,tpmax,selectTP,str
askid=Trim(Request.Form("askid"))
tpmax=Trim(Request.Form("tpmax"))
selectTP=Trim(Request.Form("selectTP"))

opendb

Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	set AskD.myConn =conn
	AskD.myPredb =predb
	AskD.Getsetting()
	setting=AskD.setting
	set AskD.myConn =Nothing
Set AskD = Nothing

    IF setting(34)=0 Then
	str="ask.asp?id="&askid
	Else
	str="ask-"&askid&".html"
	End IF
	
dim rs,sql,askuser
set rs= Server.CreateObject("adodb.recordset")
sql="select askuser,tpmax,state from "&predb&"ask where askid="&askid
rs.open sql,conn,1,3

if rs(2)=4 then
  Response.Write("<script>var a = new parent.xWin(""1"",240,100,""快问知道"",""已经做过设置！"");</script>")
	rs.close
	set rs=nothing
	closedb
	Response.End()
end if

if Request.Cookies("Muser")<>cstr(rs(0)) then
  Response.Write("<script>var a = new parent.xWin(""1"",240,100,""快问知道"",""您没有操作权限！"");</script>")
else
  rs(1)=tpmax
  rs(2)=4
  rs.update
  
  conn.execute("update "&predb&"ans set istp=0,TpNum=0,zcTP=0,fdTP=0 where askid="&askid)
  conn.execute("update "&predb&"ans set istp=1,TpNum=0,zcTP=0,fdTP=0 where ansid in("&selectTP&")")
  Response.Write("<script>var a = new parent.xWin(""1"",240,100,""快问知道"",""恭喜，投票设置成功！"");setTimeout(""parent.location.href='"&str&"'"",1000);</script>")
end if
rs.close
set rs=nothing

closedb
%>