<%Response.Expires = 0 
Response.Expiresabsolute = Now() - 1 
Response.AddHeader "pragma","no-cache" 
Response.AddHeader "cache-control","private" 
Response.CacheControl = "no-cache" 
ab=array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z")
LOGINID=request("LOGINID")
subaction = Request("subaction")
urlParam = "functions.asp?action="&action&LOGINPROPAGATEGET
id=request("id")
Uiratio=0
Uiexpdate=now()
if subaction="addnew" then
sql = "SELECT top 1 * FROM question ORDER BY expdate asc"
rs.open sql,conn,3,3
elseif subaction="edit" or subaction="editnew" or subaction="open" or subaction="opennew" THEN
sql = "SELECT * FROM question where id="&request("id")&""
rs.open sql,conn,3,3
end if

if subaction="Re" then 
conn.execute("exec Ye_guess_ck @questionid="&id &"")
errorMsg = errorMsg &"撤消开盘成功！<br>"
end if

if subaction="opennew" then
conn.execute("exec Ye_guess_kp @questionid="&id &",@rightkey="&trim(request("Uisyskey"))&",@mult=1.2")
errorMsg = errorMsg &"开盘成功！<br>"
end if

if subaction="edit" or subaction="open"then
		Uititle=rs("title")
		Uiid=rs("id")
		Uiexpdate=rs("expdate")
		Uiratio=rs("ratio")
		Uigroup=cint(rs("group"))
		Uikind=rs("kind")
		Uistatus=rs("status")
		Uichoose=rs("choose")
		Uisyskey=rs("syskey")
		if rs("rightkey")<>"" then
		Uirightkey=rs("rightkey")
		else
		Uirightkey=""
	    end if
		if rs("status")=3 then ttt="disabled"
		if subaction="open" then
		   Uisyskey=split(Uisyskey,":")
		   Uiratio=split(Uiratio,":")
		end if
end if

if request("subaction")="addnew" or request("subaction")="editnew" then
     if trim(request("Uisyskey"))="" then
        errorMsg = errorMsg &"备选答案不能为空!<br>"
     end if
     if trim(request("Uititle"))="" then
        errorMsg = errorMsg &"标题不能为空!<br>"
     end if
     if cint(request("Uikind"))=2 then
        h1=replace(trim(request("Uisyskey"))," ","")
        h2=replace(trim(request("Uiratio"))," ","")
        if ubound(split(h1,":"))<>ubound(split(h2,":")) then
        errorMsg = errorMsg &"赔率与备选答案数目不一致!<br>"
        end if
      end if
end if

if  subaction = "delSelect" then
	idList = split(trim(Request("SID")),",")
	for i=0 to UBound(idList)
		idList(i) = Trim(idList(i))
		sql = "delete from Question where id="& idList(i)
		conn.Execute(sql)
	next
	errorMsg = errorMsg &"批量删除成功！<br>"
elseif  subaction = "del" then
    id=request("id")
	sql = "delete from Question where id="&id
	conn.Execute(sql)
	errorMsg = errorMsg &"删除成功！<br>"
end if

if errorMsg="" then
   if subaction="editnew" or subaction="addnew" then
     if request("subaction")="addnew" then rs.addnew
     rs("syskey")=replace(trim(request("Uisyskey"))," ","")
     rs("title")=request("Uititle")
     rs("group")=request("Uigroup")
     rs("expdate")=request("Uiexpdate")
     rs("ratio")=request("Uiratio")
     rs("kind")=request("Uikind")
     rs("choose")=request("Uichoose")
     rs.update
     errorMsg = errorMsg &"操作成功！<br>"
     end if
end if
if errorMsg <> "" then
    subaction=""
	DisplayMessage errorMsg,True
end if
%>
<link href="../../css/main.css" rel="stylesheet" type="text/css">

<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF">
 <% if  request("subaction")="add" then subaction="addnew"
  if  request("subaction")="edit" then subaction="editnew"
    if  request("subaction")="open" then subaction="opennew"
 if request("subaction")="add" or request("subaction")="edit"  then
%>
<form name="frmCommunityInfo" method="post" action="functions.asp?action=guess&subaction=<%=subaction%>&loginid=<%=loginid%>"" onSubmit="javascript:return check_form()">
  <tr align="left" bgcolor="#EFF5F0" class="InputTableRow"  >
    <td align="left"><table width="700"  border="0" align="center" cellpadding="0" cellspacing="0">
      <tr align="left" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td width="15%" height="22" align="left" valign="top">标&nbsp;&nbsp;&nbsp;&nbsp;题: </td>
        <td width="85%" align="left" valign="top"><input name="Uititle" type="text" class="ButtonEdit" id="Uititle" value="<%=Uititle%>" size="50" /></td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td height="22" align="left" valign="top">题目分组:</td>
        <td align="left" valign="top"><select name="Uigroup" id="Uigroup">
            <%For m=0 To Ubound(zb)%>
            <option value="<%=m%>" class="ButtonEdit"<%if Uigroup=m then response.write " selected"%>><%=zb(m)%></option>
            <%next%>
        </select></td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td height="22" align="left" valign="top">到期时间: </td>
        <td align="left" valign="top"><input name="UiexpDate" type="text" class="ButtonEdit" id="UiexpDate" value="<%=Uiexpdate%>" />
            <img src="tools/images/clock.gif" width="16" height="15" style="CURSOR: hand" onclick="getDate(UiexpDate);" /></td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td height="22" align="left" valign="top">竞猜类型: </td>
        <td align="left" valign="top"><select name="Uikind" id="Uikind" class="ButtonEdit">
            <%if Uikind=2 then%>
            <option value="1">分享</option>
            <option value="2" selected="selected">赔率</option>
            <%else%>
            <option value="1"  selected="selected">分享</option>
            <option value="2">赔率</option>
            <%end if%>
          </select>
            <%if Uichoose=1 or Uikind=2 or Uikind="" then%>
            <input name="Uichoose" type="radio" value="1"  checked="checked" />
          单选
          <input type="radio" name="Uichoose" value="2">
          多选
          <%else%>
          <input name="Uichoose" type="radio" value="1">
          单选
          <input type="radio" name="Uichoose" value="2" checked="checked" />
          多选
          <%end if%>
          <font color="#ff0000">赔率只能单项选择</font></td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td height="22" align="left" valign="top">赔&nbsp;&nbsp;&nbsp;&nbsp;率: </td>
        <td align="left" valign="top"><input name="Uiratio" type="text" class="ButtonEdit" id="Uiratio" value="<%=Uiratio%>" />
          如果为赔率类，请按球队顺序设定陪率，用：隔开,如<font color="#ff0000">1:2 </font>分享类设为<font color="#ff0000">0</font></td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td height="22" align="left" valign="top"><% 
		 response.write "备选答案:"
		 %></td>
        <td align="left" valign="top"><table width="100%"  border="0" align="left" cellpadding="0" cellspacing="0">
            <tr>
              <td><textarea name="Uisyskey" cols="50" rows="3" id="Uisyskey"><%=Uisyskey%></textarea>
              </td>
            </tr>
            <tr>
              <td>请将备选答案用 <font color="#ff0000">: </font>分开!</td>
            </tr>
            <tr>
              <td height="22" colspan="2" align="left"><input type="submit" name="Submit" value="<%if subaction="open" then response.write "确定公布竞猜结果吗？..."%>确认操作" onclick="javascipt:return xfInfo()" class="ButtonEdit" />
                  <input name="id" type="hidden" id="id" value="<%=Uiid%>" /></td>
            </tr>
        </table></td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  > </tr>
    </table></td>
  </tr>
</form>
  <%end if%>
   <% if  request("subaction")="add" then subaction="addnew"
  if  request("subaction")="edit" then subaction="editnew"
    if  request("subaction")="open" then subaction="opennew"
 if request("subaction")="open"  then
%>
<form name="frmCommunityInfo" method="post" action="functions.asp?action=guess&subaction=<%=subaction%>&loginid=<%=loginid%>"">
  <tr align="left" bgcolor="#EFF5F0" class="InputTableRow"  >
    <td align="left"><table width="700"  border="0" align="center" cellpadding="0" cellspacing="0">
      <tr align="left" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td width="15%" height="22" align="left" valign="top">标&nbsp;&nbsp;&nbsp;&nbsp;题: </td>
        <td width="85%" align="left" valign="top"><%=Uititle%></td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td height="22" align="left" valign="top">题目分组:</td>
        <td align="left" valign="top"><%=zb(m)%> </td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td height="22" align="left" valign="top">到期时间: </td>
        <td align="left" valign="top"><%=Uiexpdate%></td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td height="22" align="left" valign="top">竞猜类型: </td>
        <td align="left" valign="top"><%if Uikind=2 then%>
          赔率
          <%else%>
          分享
          <%end if%>
          <%if Uichoose=1 or Uikind=2 or Uikind="" then%>
          单选
          <%else%>
          多选
          <%end if%>
        </td>
      </tr>
      <tr align="center" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" bgcolor="#EFF5F0" class="InputTableRow"  >
        <td align="left" valign="top"><% if Uistatus<3 then 
		response.write "<font color=#ff0000><strong>公布答案:</strong></font>"
		else
		 response.write "<font color=#ff0000><strong>正确答案:</strong></font>"
		end if%></td>
        <td align="left" valign="top"><table width="100%"  border="0" align="left" cellpadding="0" cellspacing="0">
            <tr>
              <td><% if Uistatus<3 then 
   For mm=0 To Ubound(Uisyskey)
   if Uikind=2 then
response.write ""&ab(mm)&"<input type=radio name=Uisyskey value="&ab(mm)&" "&ttt&">"&Uisyskey(mm)&"&nbsp;<br>"
  else
  if Uichoose=2 then
  response.write ""&ab(mm)&"<input type=checkbox name=Uisyskey value="&ab(mm)&" "&ttt&">"&Uisyskey(mm)&"&nbsp;<br>"
  else
  response.write ""&ab(mm)&"<input type=radio name=Uisyskey value="&ab(mm)&" "&ttt&">"&Uisyskey(mm)&"<br>"
end if
end if
next
%>
<br><input type="submit" name="Submit3" value="<%if subaction="opennew" then response.write "确定公布竞猜结果吗？..."%>确认操作" onclick="javascipt:return xfInfo()" class="ButtonEdit" <%=ttt%>/>
                  <input name="id" type="hidden" id="id" value="<%=Uiid%>" />
				  <%else
 response.write "<font color=#ff0000><strong>"&Uirightkey&"</strong></font>"
end if%></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</form>
  <%end if%>
<%
if subaction="" then%>
<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF">
  <form name="listForm" action="functions.asp" method="post">
    <input type="hidden" name="action" value="<%=action%>">
    <input type="hidden" name="subaction" value="delselect">
  <input type="hidden" name="LOGINID" value="<%=LOGINID%>">
  <input type="hidden" name="iPage" value="<%=iCurrentPage%>">
  <tr class="ListTableHeader">
    <td width="233" height="27" align="left"  background="images/TableHeaderBg.gif"><strong>
      <input type="checkBox" name="checkAll" value="on" onClick="OnCheckAll(this.form)">
    标题

    </strong></td>
    <td  background="images/TableHeaderBg.gif" width="140" align="center"><strong>到期时间</strong></td>
    
    <td  background="images/TableHeaderBg.gif" width="51" align="center"><strong>类型</strong></td>
    <td width="66" align="center"  background="images/TableHeaderBg.gif"><strong>累积分</strong></td>
    <td width="58" align="center"  background="images/TableHeaderBg.gif"><strong>回答数</strong></td>
    <td  background="images/TableHeaderBg.gif" width="61" align="center"><strong>当前状态</strong></td>
    <td  background="images/TableHeaderBg.gif" width="119" align="center"><strong>操作</strong></td>
  </tr>
  <%
  
  if trim(Request("page")) <> "" then
	iCurrentPage = clng(request("page"))
else
	iCurrentPage = 1
end if
Set cmd=Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection=conn
cmd.CommandType = 4
cmd.CommandText="pagelist"
cmd.Parameters.Append cmd.CreateParameter("@a_TableList",200,1,300)
cmd.Parameters("@a_TableList").Value ="*"
cmd.Parameters.Append cmd.CreateParameter("@a_TableName",200,1,100)
cmd.Parameters("@a_TableName").Value ="Question"
cmd.Parameters.Append cmd.CreateParameter("@a_SelectWhere",200,1,100)
cmd.Parameters("@a_SelectWhere").Value ="where 1=1"
cmd.Parameters.Append cmd.CreateParameter("@a_SelectOrderId",200,1,100)
cmd.Parameters("@a_SelectOrderId").Value ="id"
cmd.Parameters.Append cmd.CreateParameter("@a_SelectOrder",200,1,100)
cmd.Parameters("@a_SelectOrder").Value ="order by id desc"
cmd.Parameters.Append cmd.CreateParameter("@a_intPageNo",3,1)
cmd.Parameters("@a_intPageNo").Value =iCurrentPage
cmd.Parameters.Append cmd.CreateParameter("@a_intPageSize",3,1)
cmd.Parameters("@a_intPageSize").Value =iRowsPerPage
cmd.Parameters.Append cmd.CreateParameter("@RecordCount",200,2,100)
cmd.execute
iMaxRowCount=cmd.Parameters("@RecordCount").Value
set rs=cmd.execute
	if iMaxRowCount mod iRowsPerPage = 0 then
		iMaxPage = iMaxRowCount \ iRowsPerPage
	else
		iMaxPage = iMaxRowCount \ iRowsPerPage+1
	end if
if rs.State<>AdStateClosed then
while not rs.eof
%>


  <tr align="center" bgcolor="#EFF5F0" class="InputTableRow" id="Row<%=rs("id")%>" onclick="javascript:setRowFocus(this,false,<%=rs("id")%>)">
    <td align="left" bgcolor="#EFF5F0"><input type="checkBox" name="SID" value="<%=rs("id")%>">      <%
For m=0 To Ubound(zb)
  if cint(rs("group"))=m then response.write "<font color=#ff0000>["&zb(m)&"]</font>"
next
	response.write "<font color=000066>"&rs("title")&"</font>"%></td>
    <td align="center" bgcolor="#EFF5F0"><%=rs("expdate")%></td>
    <td bgcolor="#EFF5F0"><%if rs("kind")=1 then
	 response.write "分享"
	 else
	 response.write "赔率"
	 end if
%>
</td>    <td bgcolor="#EFF5F0"><%=rs("totalscore")%></td>
  	
    <td bgcolor="#EFF5F0"><%=rs("totalans")%></td>
    <td bgcolor="#EFF5F0"><%
	
	if rs("status")=3 then
	response.write "已公布"
	elseif rs("status")<3 and rs("expdate")<=now() then
	response.write "已过期"
	else
	 response.write "进行中"
	 end if%></td>
    <td bgcolor="#EFF5F0">
	  <%response.write "<a href=functions.asp?Id="&rs("Id")&"&action="&action&"&subaction=Re&loginid="&loginid&" onclick='javascipt:return ck()'><img src=images/IconUnAuditing.gif border=0 width=16 height=16 alt=撤消></a>&nbsp;&nbsp;"%>
	  <%response.write "<a href=functions.asp?Id="&rs("Id")&"&action="&action&"&subaction=del&loginid="&loginid&" onclick='javascipt:return deleteInfo()'><img src=images/IconDelete.gif border=0 width=16 height=16 alt=删除></a>&nbsp;&nbsp;"%>
  	<%response.write "<a href=functions.asp?Id="&rs("Id")&"&action="&action&"&subaction=edit&loginid="&loginid&"><img src=images/IconEdit.gif border=0 width=16 height=16 alt=编辑></a>&nbsp;&nbsp;"%>
  	<%response.write "<a href=functions.asp?Id="&rs("Id")&"&action="&action&"&subaction=open&loginid="&loginid&"><img src=images/IconZero.gif border=0 width=16 height=16 alt=公布></a>"%></td>
  </tr>
  <tr align="center" bgcolor="#EFF5F0" class="InputTableRow" id="editPic<% =rs("id") %>details" style="display:None">
    <td colspan="9" align="right"><table width="39%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#F9F2E6">
      <tr bgcolor="#EEEEEE">
        <td colspan="6" align="center"></td>
        </tr>
    </table>
      </td>
    </tr>

  <%if bFirst = false then%>
  <script LANGUAGE="javascript">
  <!--
	setRowFocus(Row<%=rs("id")%>,true,<%=rs("id")%>);
  //-->
  </script>
<%bFirst = true
end if
i = i + 1
rs.MoveNext
wend
end if
rs.Close

%>

<script language="javascript">
<!--//
function deleteInfo(form){
	if(confirm('确认删除吗？')){
		return true;
		//eval("document."+form+".operation.value = 'del';")
		//eval("document."+form+".submit();")
	}
	else return false;
}
//-->
</script>
<script language="javascript">
<!--//
function ck(form){
	if(confirm('你要撤消开盘吗？')){
		return true;
		//eval("document."+form+".operation.value = 'del';")
		//eval("document."+form+".submit();")
	}
	else return false;
}
//-->
</script>
<script language="javascript">
<!--//
function ktInfo(form){
	if(confirm('确认开通吗？')){
		return true;
		//eval("document."+form+".operation.value = 'del';")
		//eval("document."+form+".submit();")
	}
	else return false;
}
//-->
</script>
<script language="javascript">
<!--//
function xfInfo(form){
	if(confirm('确认续费吗？')){
		return true;
		//eval("document."+form+".operation.value = 'del';")
		//eval("document."+form+".submit();")
	}
	else return false;
}
//-->
</script>  </form>
</table>

<script language="javascript">
<!--//
function getDate(target)
{
  myDate = window.showModalDialog("tools/calendar.htm",null,"dialogwidth:155pt;dialogheight:190pt,toolbar=no,status=no,resizable=no");
  target.value = myDate;
  if (target.value == "undefined")
  {
    target.value = "";
  }
  return;
}

function clickHandler()
{
  var targetId;
  var srcElement = window.event.srcElement;
  var targetElement;
  if (srcElement.className == "Outline")
  {
    targetId = srcElement.id + "details";
    targetElement = document.all(targetId);

    if (targetElement.style.display == "none")
    {
      targetElement.style.display = "";
    }
    else
    {
      targetElement.style.display = "none";
    }
 }
}
//-->
</script>

<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="25" align="left" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" background="images/TableHeaderBg.gif" class="InputTableRow"><!-- #include file="pageRobot.inc.asp" //--></td>
  </tr>
</table>	<%end if%>
<script language="javascript">
<!--//
function xfInfo(form){
	if(confirm('确认无误并提交吗？')){
		return true;
		//eval("document."+form+".operation.value = 'del';")
		//eval("document."+form+".submit();")
	}
	else return false;
}
//-->
</script>


<script language="javascript">
<!--//
function getDate(target)
{
  myDate = window.showModalDialog("tools/calendar.htm",null,"dialogwidth:155pt;dialogheight:190pt,toolbar=no,status=no,resizable=no");
  target.value = myDate;
  if (target.value == "undefined")
  {
    target.value = "";
  }
  return;
}

function clickHandler()
{
  var targetId;
  var srcElement = window.event.srcElement;
  var targetElement;
  if (srcElement.className == "Outline")
  {
    targetId = srcElement.id + "details";
    targetElement = document.all(targetId);

    if (targetElement.style.display == "none")
    {
      targetElement.style.display = "";
    }
    else
    {
      targetElement.style.display = "none";
    }
 }
}
//-->
</script>
<script language="javascript">
<!--//
function doEditWords(id)
{
  window.showModalDialog("frame.asp?action=presentUsers&subaction=preEdit&LOGINID=<%=LOGINID%>&id="+ id,null,"dialogwidth=680pt;dialogheight=450pt;toolbar=no;status=no;resizable=no");
  return;
}
function isDate (year, month, day){
	// month argument must be in the range 1 - 12
	month = month - 1;  // javascript month range : 0- 11
	var tempDate = new Date(year,month,day);

	if ( (year2k(tempDate.getYear()) == year) && (month == tempDate.getMonth()) && (day == tempDate.getDate()) ){ 	  
		return true;
	}
	else{
		return false;
	}
}
function jtrim(s){
	var i,b=0,e=s.length;
	for(i=0;i<s.length;i++) if(s.charAt(i)!=' '){b=i;break;}
	if(i==s.length) return "";
	for(i=s.length-1;i>b;i--) if(s.charAt(i)!=' '){e=i;break;}
	return s.substring(b,e+1);
}
function getDate(target)
{
  myDate = window.showModalDialog("tools/calendar.htm",null,"dialogwidth:155pt;dialogheight:190pt,toolbar=no,status=no,resizable=no");
  target.value = myDate;
  if (target.value == "undefined")
  {
    target.value = "";
  }
  return;
}
//-->
</script>
<script language="javascript">
<!--//
var submitted = false;

function check_form() {
	var er = 0;
	var error = 0;
	var error_message = "在提交表单时出错!\n请修改下面内容后再提交:\n\n";
	var title=document.frmCommunityInfo.Uititle.value;
	var expDate=document.frmCommunityInfo.UiexpDate.value;
	var ratio=document.frmCommunityInfo.Uiratio.value;
	var syskey=document.frmCommunityInfo.Uisyskey.value;
						if (title=="") {
		error_message = error_message + "* “标题”不能为空。\n";
		error=1;
	}
							if (syskey=="") {
		error_message = error_message + "* “备选答案”不能为空。\n";
		error=1;
	}
	
if (ratio=="") {
		error_message = error_message + "* “陪率”不能为空。\n";
		error=1;
	}
if (expDate=="") {
		error_message = error_message + "* “到期时间”必须为数字。\n";
		error=1;
	}


	if (error==1) { 
		alert(error_message); 
		return false; 
	}
	else { 
		submitted = true; 
		return true; 
	}
}
//-->
</script>
