<%if session("admin")="" then
response.write"你没有登录或是非法用户!<meta http-equiv=refresh content='1;url=../index.asp'>"
response.End()
end if%>
<!--#include file=conn.asp-->
<!--#include file="../config.asp"-->
<head>
<link href=../iknow.css rel=stylesheet type=text/css>
</head>

<table width="95%" align="center" cellpadding="0" cellspacing="0" border="1" bgcolor="#AAAAAA" bordercolorlight="#000000" bordercolordark="#FFFFFF">
  <tr bgcolor="#eeeeee">
    <td height=30 colspan="7" align="center"><font style="font-size:14px">修改、删除问题</font></td>
  </tr>
  <%
  if request("tui")="推荐" then
  rs.open"select * from question where id="&cint(request("id")),conn,1,3
  rs("tui")=1
  rs.update
  rs3.open"select * from person where name='"&rs("sender")&"'",conn,1,3
  rs3("jifen")=rs3("jifen")+tjwendf
  temp=rs3("jifen")+tjwendf
          if temp<fen2 then
		  rs3("touxian")=""&ji1&" 一级"
	      elseif temp>=fen2 and temp<fen3 then
		  rs3("touxian")=""&ji2&" 二级"
		  elseif temp>=fen3 and temp<fen4 then
		  rs3("touxian")=""&ji3&" 三级"
		  elseif temp>=fen4 and temp<fen5 then
		  rs3("touxian")=""&ji4&" 四级"
		  elseif temp>=fen5 and temp<fen6 then
		  rs3("touxian")=""&ji5&" 五级"
		  elseif temp>=fen6 and temp<fen7 then
		  rs3("touxian")=""&ji6&" 六级"
		  elseif temp>=fen7 and temp<fen8 then
		  rs3("touxian")=""&ji7&" 七级"
		  elseif temp>=fen8 and temp<fen9 then
		  rs3("touxian")=""&ji8&" 八级"
		  elseif temp>=fen9 and temp<fen10 then
		  rs3("touxian")=""&ji9&" 九级"
		  elseif temp>=fen10 then
		  rs3("touxian")=""&ji10&" 十级"
		  end if
  rs3.update
  rs3.close
  rs3.open"select * from reply where replyid="&cint(request("id"))&" and isdeal=1",conn,1,3
  ren=rs3("replyer")
  rs3.close
  rs3.open"select * from person where name='"&ren&"'",conn,1,3
  rs3("jifen")=rs3("jifen")+tjdadf
  temp=rs3("jifen")+tjdadf
          if temp<fen2 then
		  rs3("touxian")=""&ji1&" 一级"
	      elseif temp>=fen2 and temp<fen3 then
		  rs3("touxian")=""&ji2&" 二级"
		  elseif temp>=fen3 and temp<fen4 then
		  rs3("touxian")=""&ji3&" 三级"
		  elseif temp>=fen4 and temp<fen5 then
		  rs3("touxian")=""&ji4&" 四级"
		  elseif temp>=fen5 and temp<fen6 then
		  rs3("touxian")=""&ji5&" 五级"
		  elseif temp>=fen6 and temp<fen7 then
		  rs3("touxian")=""&ji6&" 六级"
		  elseif temp>=fen7 and temp<fen8 then
		  rs3("touxian")=""&ji7&" 七级"
		  elseif temp>=fen8 and temp<fen9 then
		  rs3("touxian")=""&ji8&" 八级"
		  elseif temp>=fen9 and temp<fen10 then
		  rs3("touxian")=""&ji9&" 九级"
		  elseif temp>=fen10 then
		  rs3("touxian")=""&ji10&" 十级"
		  end if
  rs3.update
  rs3.close
  rs.close
  response.write"<tr><td bgcolor=ffffff colspan=7>问题推荐成功!</td></tr><meta http-equiv=refresh content='1;url=adminquestion.asp'>"
  response.End()  
  end if
  if request("che")="撤消" then
  rs.open"select * from question where id="&cint(request("id")),conn,1,3
  rs("tui")=0
  rs.update
  rs.close
  response.write"<tr><td bgcolor=ffffff colspan=7>撤消推荐成功!</td></tr><meta http-equiv=refresh content='1;url=adminquestion.asp'>"
  response.End() 
  end if
  if request("guan")="关闭" then
  rs.open"select * from question where id="&cint(request("id")),conn,1,3
  if rs("jie")=1 then
  response.write"<tr><td bgcolor=ffffff colspan=7>已经解决的问题不能关闭!<a href=javascript:history.back()>返回</a></td></tr>"
  response.End()
  else
  rs("jie")=2
  rs.update
  rs.close
  response.write"<tr><td bgcolor=ffffff colspan=7>关闭问题成功!</td></tr><meta http-equiv=refresh content='1;url=adminquestion.asp'>"
  response.End() 
  end if
  end if
  if request("hui")="恢复" then
  rs.open"select * from question where id="&cint(request("id")),conn,1,3
  if rs("jie")<>2 then
  response.write"<tr><td bgcolor=ffffff colspan=7>问题没有关闭不需要恢复!<a href=javascript:history.back()>返回</a></td></tr>"
  response.End()
  else
  rs("jie")=0
  rs.update
  rs.close
  response.write"<tr><td bgcolor=ffffff colspan=7>撤消推荐成功!</td></tr><meta http-equiv=refresh content='1;url=adminquestion.asp'>"
  response.End() 
  end if
  end if
  %>
  <%if request("del")="删除" then
  rs.open"select * from question where id="&cint(request("id")),conn,1,3
  rs2.open"select * from reply where replyid="&cint(request("id")),conn,1,3
  while not rs2.eof 
  '修改解决数和回复数、积分
  rs3.open"select * from person where name='"&rs2("replyer")&"'",conn,1,3
  if rs2("isdeal")=1 then
  rs3("helpnum")=rs3("helpnum")-1
  rs3("replynum")=rs3("replynum")-1
  else
  rs3("replynum")=rs3("replynum")-1
  end if
  rs3.update
  rs3.close
  rs3.open"select * from ping where replyid="&rs2("id")&"",conn,1,3
  while not rs3.eof
  rs3.delete
  rs3.movenext
  wend
  rs3.close
  rs3.open"select * from pj where jiaid="&rs2("id")&"",conn,1,3
  while not rs3.eof
  rs3.delete
  rs3.movenext
  wend
  rs3.close
  rs2.delete
  rs2.movenext
  wend
  rs2.close
  '修改发表问题数、积分
  rs3.open"select * from person where name='"&rs("sender")&"'",conn,1,3
  rs3("asknum")=rs3("asknum")-1
  rs3("jifen")=rs3("jifen")-wenkf
  rs3("del")=rs3("del")+1
  temp=rs3("jifen")-wenkf
  if temp<fen2 then
		  rs3("touxian")=""&ji1&" 一级"
	      elseif temp>=fen2 and temp<fen3 then
		  rs3("touxian")=""&ji2&" 二级"
		  elseif temp>=fen3 and temp<fen4 then
		  rs3("touxian")=""&ji3&" 三级"
		  elseif temp>=fen4 and temp<fen5 then
		  rs3("touxian")=""&ji4&" 四级"
		  elseif temp>=fen5 and temp<fen6 then
		  rs3("touxian")=""&ji5&" 五级"
		  elseif temp>=fen6 and temp<fen7 then
		  rs3("touxian")=""&ji6&" 六级"
		  elseif temp>=fen7 and temp<fen8 then
		  rs3("touxian")=""&ji7&" 七级"
		  elseif temp>=fen8 and temp<fen9 then
		  rs3("touxian")=""&ji8&" 八级"
		  elseif temp>=fen9 and temp<fen10 then
		  rs3("touxian")=""&ji9&" 九级"
		  elseif temp>=fen10 then
		  rs3("touxian")=""&ji10&" 十级"
		  end if
  rs3.update
  rs3.close
  rs3.open"select * from toupiao where wenid="&cint(request("id"))&"",conn,1,3
  while not rs3.eof
  rs3.delete
  rs3.movenext
  wend
  rs3.close
  rs3.open"select * from touuser where wenid="&cint(request("id"))&"",conn,1,3
  while not rs3.eof
  rs3.delete
  rs3.movenext
  wend
  rs3.close
  rs.delete
  rs.close
  response.write"<tr><td bgcolor=ffffff colspn=7>问题删除成功!</td></tr><meta http-equiv=refresh content='1;url=adminquestion.asp'>"
  response.End()
  end if%>
  <%if request("up2")="修改" then
  if request("title")="" then
  response.write"<tr><td bgcolor=ffffff colspan=7>问题标题不能为空!<a href=javascript:history.back()>返回</a></td></tr>"
  response.End()
  elseif request("content")="" then
  response.write"<tr><td bgcolor=ffffff colspan=7>问题内容不能为空!<a href=javascript:history.back()>返回</a></td></tr>"
  response.End()
  else
  rs.open"select * from question where id="&cint(request("id")),conn,1,3
  rs("title")=request("title")
  rs("content")=request("content")
  rs.update
  rs.close
  response.write"<tr><td bgcolor=ffffff colspan=7>问题修改成功!</td></tr><meta http-equiv=refresh content='1;url=adminquestion.asp'>"
  response.End()
  end if
  end if%>
  <%if request("up")="修改" then
  rs.open"select * from question where id="&cint(request("id")),conn,1,1%>
  <form method=post action=adminquestion.asp?id=<%=cint(request("id"))%>><tr><td bgcolor=ffffff colspan="7">标题:                                   
    <input name="title" type="text" id="title" size="37" value=<%=rs("title")%>><br>内容:<br>
    <textarea name="content" cols="66" rows="10" id="content"><%=rs("content")%></textarea><br>
    <input name="up2" type="submit" id="up2" value="修改">
    <input name="reset" type="reset" id="reset" value="重写">                                   
	</td></tr></form>
	<%rs.close
	response.End()
	end if%>
  <tr bgcolor="#FFFFFF">
    <td>标题</td>
    <td>主题</td>
    <td>浏览数</td>
    <td>回复数</td>
    <td>发布者</td>
    <td>发布时间</td>
    <td>操作</td>
  </tr>
  <%rs.open"select * from question order by id desc",conn,1,1
  if rs.eof then%>
  <tr bgcolor="#FFFFFF">
    <td colspan="7">暂时没有问题!</td>
  </tr>
  <%else
  maxnum=rs.recordcount
  rs.pagesize=15
  maxpage=rs.pagecount
  if request("p")="" then
  p=1
  else
  p=cint(request("p"))
  end if
  if p>maxpage then
  p=maxpage
  end if
  if p=0 then
  p=1
  end if
  if p<>1 then
  rs.move (p-1)*rs.pagesize
  end if
  for i=1 to rs.pagesize%>
  <tr bgcolor="#FFFFFF">
    <form method=post action=adminquestion.asp?id=<%=rs("id")%>>
    <td><%if rs("jie")=0 then %><img src=../img/icn_time.gif  alt=待解决问题><%elseif rs("jie")=1 or rs("jie")=3 then%><img src=../img/icn_ok.gif  alt =已解决问题><%elseif rs("jie")=2 then%><img src=../img/icn_cancel.gif  alt =问题已关闭><%elseif rs("jie")=4 then%><img src=../img/icn_vote.gif  alt =投票中问题><%end if%><a href=../showquestion.asp?id=<%=rs("id")%> target=_blank><%=rs("title")%></a></td><td><%=rs("topic")%></td><td><%=rs("views")%></td><td><%=rs("replys")%></td><td><a href=../showperson.asp?name=<%=rs("sender")%> target=_blank><%=rs("sender")%></a></td><td><%=rs("sendtime")%></td><td><input name="up" type="submit" id="up" value="修改">
	<input name="del" type="submit" id="del" value="删除"> <%if rs("jie")<>1 then%><%if rs("jie")<>2 then%><input name="guan" type="submit" id="guan" value="关闭"><%else%><input name="hui" type="submit" id="hui" value="恢复"><%end if%><%end if%> <%if rs("jie")=1 then%><%if rs("tui")<>1 then%><input name="tui" type="submit" id="tui" value="推荐"> <%else%><input name="che" type="submit" id="che" value="撤消"><%end if%><%end if%></td>
	</form>
  </tr>
  <%rs.movenext
  if rs.eof then exit for
  next%>
  <tr><td bgcolor=eeeeee colspan=7 height=30>问题数<font color=red><%=maxnum%></font> 15个每页 页次:<font color=red><%=p%></font>/<%=maxpage%>  
  <a href=adminquestion.asp?p=1>首页</a>  
  <a href=adminquestion.asp?p=<%=p-1%>>上页</a>  
  <a href=adminquestion.asp?p=<%=p+1%>>下页</a>  
  <a href=adminquestion.asp?p=<%=maxpage%>>尾页</a></td></tr>  
  <%end if
  rs.close%>
</table>
<!--'添加问题
<br><form method=post action=adminquestion.asp>
<table width="80%"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#EEEEEE">
  <tr>
    <td align="center"><font style="font-size:14px">添加问题</font></td>
  </tr>
  <tr>
    <td><%if request("add")="添加" then
	if request("topic")="" then
	response.write"分类不能为空!<meta http-equiv=refresh content='1;url=adminquestion.asp'>"
	response.End()
	elseif request("title")="" then
	response.write"标题不能为空!<meta http-equiv=refresh content='1;url=adminquestion.asp'>"
	response.End()
	elseif request("content")="" then
	response.write"内容不能为空!<meta http-equiv=refresh content='1;url=adminquestion.asp'>"
	response.End()
	else
	rs.open"select * from question",conn,1,3
	rs.addnew
	rs("topic")=request("topic")
	rs("title")=request("title")
	rs("content")=request("content")
	rs("sendtime")=now
	rs.update
	rs.close
	response.write"问题添加成功!<meta http-equiv=refresh content='1;url=adminquestion.asp'>"
	response.End()
	end if
	end if%>
	<p>问题分类: 
	  <select name="topic">
	  <%rs.open"select * from assort",conn,1,1
	  while not rs.eof%><option value=<%=rs("topic")%>><%=rs("topic")%></option>
	  <%rs.movenext
	  wend
	  rs.close%>
	    </select>
	  <br>
	  <br>
	  问题标题: 
          <input name="title" type="text" id="title" size="12">
          <br>
          <br>
          问题内容: 
          <textarea cols="40" rows="10" name="content"></textarea>
          <br>
          <input name="add" type="submit" id="add" value="添加">
          <input name="reset" type="submit" id="reset" value="重写"> 
    </p>
	</td>
  </tr>
</table></form>-->
