<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="True" Inherits="Kesion.NET.WebSite.Admin.Course.KS_CosPropGame1" Codebehind="KS.CosPropGame.aspx.cs" %>

<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.BLL" %>

 <asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server"> 
     <link href="/admin/images/popup.css" rel="stylesheet" />
     <link href="/admin/images/Main.css" rel="stylesheet" />
     <style>
     #upframe{vertical-align: middle;height: 34px !important; margin-left:15px;}
     .button, .button_on{vertical-align: middle;}
     </style>
            <div id="manage_top" class="menu_top_fixed">
              <ul class="titleTab clearfix">      
                  <%if (Kesion.Cache.CommonJsonCache.CheckYunAPPHasAllow("plus.wenjuan"))
                { %>
	            <li id="p22"><a href="/Plus/Plus.wenjuan/KS.WJList.aspx">问卷题库</a></li>
                <%} %>
                <li id="p23"><a href="/<%=MyCache.GetCacheConfig(4) %>/exam/KS.SJ.aspx">试卷题库</a></li>
               <%if (Kesion.Cache.CommonJsonCache.CheckYunAPPHasAllow("plus.announce"))
                 { %>
	            <li id="p24"><a href="/Plus/Plus.Announce/KS.Announce.aspx">公告库</a></li>
                <%} %>
	            <li id="p25" class="curr"><a href="/<%=MyCache.GetCacheConfig(4) %>/Course/KS.CosPropgame.aspx">游戏库</a></li>  
             </ul>
            </div>
            <div class="menu_top_fixed_height"></div>
 
        <asp:Panel ID="listPanel" runat="server">
    <div class="content-area pageBlank">
            <div>
	      <!--<div class="myTitle">
              游戏库管理</div>-->
            <div class="tabs_header">
                <div class="fr addBtnBox"><a href="?action=add" id="addBtnA" class="button button_on mr15">添加游戏包</a></div>
                <ul class="tabs">
                    <li <%=KSCMS.S("Type")==""?"class='active'":"" %> ><a href="?"><span>所有</span></a></li>
                    <li <%=KSCMS.S("Type")=="0"?"class='active'":"" %>><a href="?Type=0"><span>大转盘</span></a></li>
                    <li <%=KSCMS.S("Type")=="1"?"class='active'":"" %>><a href="?Type=1"><span>红包</span></a></li>
                    <li <%=KSCMS.S("Type")=="2"?"class='active'":"" %>><a href="?Type=2"><span>抢答题</span></a></li>
                </ul>
            </div>

	      <table width="99%" cellpadding="0" cellspacing="0" class="CTable">
		     <tr class="CTitle">
		       <th scope="col" width="30"></th>
		       <th scope="col">游戏库名称</th>
		       <th scope="col">添加时间</th>
		       <th scope="col">游戏类型</th>
		       <th scope="col">参与记录</th>
		       <th scope="col" style="width:60px;">管理</th>
		       <th scope="col" style="width:60px;">删除</th>
		     </tr>
              <asp:Repeater ID="Repeater2" runat="server">
                  <ItemTemplate>
                    <tr>
		                <td class="Ctd" width="30"><input type="checkbox" name="ids" value="<%#Eval("ID") %>"></td>
		                <td class="Ctd"><%# Eval("acname") %></td>
		                <td class="Ctd" align="center"><%# Eval("adddate") %></td>
		                <td class="Ctd" align="center"><%#getgametype(Utils.StrToInt(Eval("gametype"))) %></td>
		                <td class="Ctd" align="center"><a href="javascript:;" onclick="parent.openWin('添加道具信息','course/KS.cosprop.aspx?action=look&gameid=<%#Eval("ID") %>&gametype=<%#Eval("gametype") %>',true,960,550)" >查看</a></td>
		                <td class="Ctd" align="center" ><a title="修改" href="KS.Cospropgame.aspx?action=edit&id=<%#Eval("ID") %>" class="edit">修改</a></td>
		                <td class="Ctd" align="center"><a title="删除" href="KS.Cospropgame.aspx?action=delete&ids=<%#Eval("ID") %>" class="delete" onclick="return (confirm('确定要删除么？此操作不可逆！请谨慎操作！'))"></a></td>
		            </tr>
                  </ItemTemplate>

              </asp:Repeater>
	      </table>
         <KS:Page ID="Page1" runat="server" /> 
                </div>
      </div>
    </asp:Panel>

    <asp:Panel ID="addpanel" runat="server">
    <div class="content-area pageBlank">
        <div class="examManage">
            <div class="myTitle">
                添加游戏
            </div>
            <div class="quickSearch clearfix">
              游戏类型：
              <select name="gametype" style="width:259px" onchange="return(gettype(this))" >
                <option selected="selected" value="0">大转盘</option>
                <option value="1">红包</option>
                <option value="2">抢答题</option>
              </select>
              游戏名称：<input type="text" class="textbox" name="gamename" placeholder="请输入游戏名称！">
            </div>
            <table width="99%" cellpadding="0" cellspacing="0" class="CTable" id="turngame">
                <tr class="noneBorder">
                  <td class="p-l-td" colspan="3" style="text-align:left"><input type="hidden" name="quyu" id="quyunum"  class="textbox" style="width:60px;" value="6">
                      <input type="button" value="增加区域" class="button"  style="display:none" onclick="addquyu()" />
                  </td>
                </tr>
             <tr class="CTitle">
               <th scope="col">奖励</th>
               <th scope="col">概率</th>
               <th scope="col">奖励小图标</th>
               <th scope="col">积分</th>
               <th scope="col">现金</th>
               <th scope="col">数量</th>
             </tr>
             <tr>
               <td class="Ctd" width="30" style="white-space: nowrap;"><input type="text" name="quyuname1" class="textbox" /><span class="jiang">(一等奖)</span></td>
               <td class="Ctd" align="center"><input type="text" name="jilv1" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="quyugl1" id="quyugl1" class="textbox" /><input type="button" class="button" onclick="SelectFiles('quyugl1', 0);" value="选择图片" /><%=Kesion.APPCode.UploadAPI.EchoUpload("classpic", "quyugl1", 150) %></td>
               <td class="Ctd" align="center"><input type="text" name="num1" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="shu1" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="money1" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
             </tr>
             <tr>
               <td class="Ctd" width="30" style="white-space: nowrap;"><input type="text" name="quyuname2" class="textbox"><span class="jiang">(二等奖)</span></td>
               <td class="Ctd" align="center"><input type="text" name="jilv2" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="quyugl2" id="quyugl2" class="textbox"><input type="button" class="button" onclick="SelectFiles('quyugl2', 0);" value="选择图片" /><%=Kesion.APPCode.UploadAPI.EchoUpload("classpic", "quyugl2", 150) %></td>
               <td class="Ctd" align="center"><input type="text" name="num2" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="shu2" value="0"  class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="money2" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
             </tr>
             <tr>
               <td class="Ctd" width="30" style="white-space: nowrap;"><input type="text" name="quyuname3" class="textbox"><span class="jiang">(三等奖)</span></td>
               <td class="Ctd" align="center"><input type="text" name="jilv3" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="quyugl3" id="quyugl3" class="textbox"><input type="button" class="button" onclick="SelectFiles('quyugl3', 0);" value="选择图片" /><%=Kesion.APPCode.UploadAPI.EchoUpload("classpic", "quyugl3", 150) %></td>
               <td class="Ctd" align="center"><input type="text" name="num3" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="shu3" value="0"  class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="money3" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
             </tr>
             <tr>
               <td class="Ctd" width="30" style="white-space: nowrap;"><input type="text" name="quyuname4" class="textbox"><span class="jiang">(幸运奖)</span></td>
               <td class="Ctd" align="center"><input type="text" name="jilv4" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="quyugl4" id="quyugl4" class="textbox"><input type="button" class="button" onclick="SelectFiles('quyugl4', 0);" value="选择图片" /><%=Kesion.APPCode.UploadAPI.EchoUpload("classpic", "quyugl4", 150) %></td>
               <td class="Ctd" align="center"><input type="text" name="num4" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="shu4" value="0"  class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="money4" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
             </tr>
             <tr>
               <td class="Ctd" width="30" style="white-space: nowrap;"><input type="text" name="quyuname5" class="textbox"><span class="jiang">(鼓励奖)</span></td>
               <td class="Ctd" align="center"><input type="text" name="jilv5" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="quyugl5" id="quyugl5" class="textbox"><input type="button" class="button" onclick="SelectFiles('quyugl5', 0);" value="选择图片" /><%=Kesion.APPCode.UploadAPI.EchoUpload("classpic", "quyugl5", 150) %></td>
               <td class="Ctd" align="center"><input type="text" name="num5" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="shu5" value="0"  class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="money5" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
             </tr>
             <tr>
               <td class="Ctd" width="30" style="white-space: nowrap;"><input type="text" name="quyuname6" class="textbox"><span class="jiang">(未中奖)</span></td>
               <td class="Ctd" align="center"><input type="text" name="jilv6" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="quyugl6" id="quyugl6" class="textbox"><input type="button" class="button" onclick="SelectFiles('quyugl6', 0);" value="选择图片" /><%=Kesion.APPCode.UploadAPI.EchoUpload("classpic", "quyugl6", 150) %></td>
               <td class="Ctd" align="center"><input type="text" name="num6" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="shu6" value="0"  class="textbox" style="width:60px; text-align:center;" /></td>
               <td class="Ctd" align="center"><input type="text" name="money6" value="0" class="textbox" style="width:60px; text-align:center;" /></td>
             </tr>
               <tbody id="quyu">
    
               </tbody>
            </table>
           
             <table id="qiangda" class="p-commonTable no-borderTable mt20" width="100%" border="0" cellpadding="0" cellspacing="0" style="display:none">
                 <tr class="noneBorder" style="display:none">
                  <td class="p-l-td">题目类型：</td>
                  <td class="p-r-td">
                      <select name="tmtype" style="width:259px">
                        <option value="0" selected="selected">单选题</option>
                      </select>
                  </td>
                </tr>
                <tr class="noneBorder" style="display:none">
                  <td class="p-l-td">抢答题数：</td>
                  <td class="p-r-td">
                      <input type="text" class="textbox" name="qiangdanum" style="width:60px;" value="1"><span>题</span>
                  </td>
                </tr>
                <tr class="Bdashed" style="display:none">
                  <td class="p-l-td">倒计时：</td>
                  <td class="p-r-td">
                      <input type="text" class="textbox" name="qiangdatime" style="width:60px;" value="5"><span>秒</span>
                  </td>
                </tr>
                <tr class="noneBorder">
                  <td class="p-l-td">题目内容：</td>
                  <td class="p-r-td">
                      <textarea class=" fl" name="Intro" id="Intro" style="width:70%;height:80px"></textarea> 
                     <% Kesion.APPCode.EditorAPI.EchoEditor("editor", "Intro", "Basic",0,false,true,false,false);%> 
                  </td>
                </tr>
                <tr class="noneBorder">
                  <td class="p-l-td">答案选项：<input type="hidden" name="answernum" id="answernum" value="3"/></td>
                  <td class="p-r-td">
                      <input type="button" value="增加选项" class="button"  onclick="adddaan()" /> 
                  </td>
                </tr>
                <tr class="noneBorder" style="text-align:left"> 
                    <td class="p-l-td" colspan="2" style="text-align:left">
                     <table id="answer" class="CTable no-borderTable" width="100%" border="0" cellpadding="0" cellspacing="0">
                         <tr>
                          <td class="p-l-td"><input type="radio" name="right" value="A"   /><span class="v-o-n">(A)</span></td>
                          <td class="p-r-td" align="left"><input type="text" name="answer1" class="textbox" style="width:67%;" /></td>
                        </tr>
                         <tr>
                          <td class="p-l-td"><input type="radio" name="right" value="B" /><span class="v-o-n">(B)</span> </td>
                          <td class="p-r-td" align="left"><input type="text" name="answer2" class="textbox" style="width:67%;" /></td>
                        </tr>
                         <tr>
                          <td class="p-l-td"><input type="radio" name="right" value="C" /><span class="v-o-n">(C)</span> </td>
                          <td class="p-r-td" align="left"><input type="text" name="answer3" class="textbox" style="width:67%;"></td>
                        </tr> 
                     </table>
                  </td>
                </tr>
                <tr class="noneBorder">
                  <td class="p-l-td" style="width:60px !important;">答对奖励：</td>
                  <td class="p-r-td">
                      <select name="gltype" style="width:100px;">
                        <option value="0">赠送积分</option>
                        <option value="1">赠送人民币</option>
                      </select>
                      <input type="text" name="glcontent" class="textbox" style="width:60px;">
                     
                  </td>
                </tr>
            </table>
    
            <table id="hongbao" style="display:none" class="p-commonTable no-borderTable mt20" width="100%" border="0" cellpadding="0" cellspacing="0">
             <tbody>
                <tr class="Bdashed">
                  <td class="p-l-td">红包个数：</td>
                  <td class="p-r-td">
                      <input type="text" name="hongbaonum" class="textbox" value="2" style="width:60px;"><span>个</span>
                  </td>
                </tr>
                <tr class="Bdashed">
                  <td class="p-l-td">金额：</td>
                  <td class="p-r-td">
                      <input type="text" name="hongbaomoney" class="textbox" value="1" style="width:60px;">  
                      类型：<select name="moneytype" style="width:100px;">
                        <option value="0">赠送积分</option>
                        <option value="1">赠送人民币</option>
                      </select>
                  </td>
                </tr>
                <tr class="noneBorder" style="display:none">
                  <td class="p-l-td">倒计时设置：</td>
                  <td class="p-r-td">
                      <input type="text" name="hongbaotime" class="textbox" value="2" style="width:60px;"><span>秒</span>
                  </td>
                </tr>
             </tbody>
           </table>
    
           <div class="main-button p-btnBox">
               <asp:Button ID="Button1" runat="server" Text="确定保存(O)" class="button"  OnClick="Button1_Click"   OnClientClick="return(check())"    />
              <input type="button" value="取消返回(C)" class="button" onclick="location.href='KS.CosPropgame.aspx'">
           </div>
     </div>
    </div>
     </asp:Panel>

     <asp:Panel ID="updatePanel" runat="server" Visible="false">
    <div class="content-area pageBlank">
         <div class="examManage">
            <div class="myTitle">
                修改游戏
                <input type="hidden" name="id" value="<%=KSCMS.S("id") %>" />
            </div>
            <div class="quickSearch clearfix">
                游戏类型：
                <input type="hidden" name="gametype" value="<%=gametype %>" />
                <select name="" style="width:259px" disabled onchange="return(gettype(this))" >
                    <option value="0" <%=gametype==0?"selected='selected'":"" %> >大转盘</option>
                    <option value="1" <%=gametype==1?"selected='selected'":"" %> >红包</option>
                    <option value="2" <%=gametype==2?"selected='selected'":"" %> >抢答题</option>
                </select>
                游戏名称：<input type="text" class="textbox" name="gamename" value="<%=gamename %>" placeholder="请输入新游戏名称！">  
            </div>
            <%if(gametype!=2){ %>
             <%=gameinfo %>
             <%}else{ %>
                <table id="Table1"  class="p-commonTable no-borderTable mt20" width="100%" border="0" cellpadding="0" cellspacing="0" >
                    <tbody>
                     <tr class="noneBorder" style="display:none">
                      <td class="p-l-td">题目类型：</td>
                      <td class="p-r-td">
                          <select name="tmtype" style="width:259px">
                            <option value="0" <%=qiangdatype=="0"?"selected='selected'":"" %>>单选题</option>
                            <option value="1" <%=qiangdatype=="1"?"selected='selected'":"" %>>多选题</option>
                            <option value="2" <%=qiangdatype=="2"?"selected='selected'":"" %>>填空题</option>
                            <option value="3" <%=qiangdatype=="3"?"selected='selected'":"" %>>简答题</option>
                            <option value="4" <%=qiangdatype=="4"?"selected='selected'":"" %>>阅读题</option>
                          </select>
                      </td>
                    </tr>
                    <tr class="noneBorder" style="display:none">
                      <td class="p-l-td">抢答题数：</td>
                      <td class="p-r-td">
                          <input type="text" class="textbox" name="qiangdanum" style="width:60px;" value="<%=qiangdatmnum %>"><span>题</span>
                      </td>
                    </tr>
                    <tr class="Bdashed">
                      <td class="p-l-td">倒计时设置：</td>
                      <td class="p-r-td">
                          <input type="text" class="textbox" name="qiangdatime" style="width:60px;" value="<%=qiangdatime %>"><span>秒</span>
                      </td>
                    </tr>
                    <tr class="noneBorder">
                      <td class="p-l-td">题目内容：</td>
                      <td class="p-r-td">
                          <textarea class="  fl" name="Intro" id="Intro" style="width:70%;height:80px"><%=qiangdacontent %></textarea> 
                         <% Kesion.APPCode.EditorAPI.EchoEditor("editor", "Intro", "Basic",0,false,true,false,false);%> 
                      </td>
                    </tr>
                    <tr class="noneBorder">
                      <td class="p-l-td">答案选项：<input type="hidden" name="answernum" id="answernum" value="<%=answernum %>"/></td>
                      <td class="p-r-td">
                          <input type="button" value="增加选项" class="button"  onclick="adddaan()" />
                      </td>
                    </tr>
                    <tr class="noneBorder">
                      <td class="p-l-td" colspan="2" style="text-align:left">
                         <table id="answer" class="p-commonTable" width="100%" border="0" cellpadding="0" cellspacing="0">
                            <%=answerinfo %>
                         </table>
                      </td>
                    </tr>
                    <tr class="noneBorder">
                      <td class="p-l-td">答对奖励：</td>
                      <td class="p-r-td">
                          <select name="gltype" style="width:100px;">
                            <option value="0"  <%=jltype=="0"?"selected='selected'":"" %>>赠送积分</option>
                            <option value="1" <%=jltype=="1"?"selected='selected'":"" %>>赠送人民币</option>
                          </select>
                          <input type="text" name="glcontent" value="<%=jlcontent %>" class="textbox" style="width:60px;">
                        
                      </td>
                    </tr>
                    </tbody>
                </table>
            
             <%} %>
            <div class="main-button p-btnBox">
                <asp:Button ID="Button2" runat="server" Text="确定修改(O)" class="button"  OnClick="Button1_Click"/>
                <input type="button" value="取消返回(C)" class="button" onclick="location.href = 'KS.CosPropgame.aspx'">
            </div>
         </div>
     </div>
     </asp:Panel>

     <script>

         var yingwen = new 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");
        
         function gettype(obj) {
             var $this = $(obj);
             var KS = $this.children('option:selected').val(); //document.getElementsByName("gametype").children('option:selected').val();
             if (KS == 0)//大转盘
             {
                 $("#turngame").show();
                 $("#qiangda").hide();
                 $("#hongbao").hide();
             } else if (KS == 1) {//红包
                 $("#turngame").hide();
                 $("#qiangda").hide();
                 $("#hongbao").show();
             } else {
                 $("#turngame").hide();
                 $("#qiangda").show();
                 $("#hongbao").hide();
             }
         }
         //增加区域
         function addquyu() {
             var num = document.getElementsByName("quyu")[0].value;
             var id = parseInt(num) + 1;
             var str = "<tr id=quyu" + (id) + " >";
             str += "<td class='Ctd' width='30'><input type='text' name=quyuname" + (id) + " class='textbox' ></td>";
             str += "<td class='Ctd' align='center'><input type='text' name=quyugl" + (id) + " id=quyugl" + (id) + " class='textbox'><input type='button' class=button onclick=SelectFiles('quyugl" + (id) + "',0); value=选择图片  /></td>";
             str += "<td class='Ctd' align='center'><input type='text' name='shu" + (id) + "' value='0' class='textbox' style='width:60px;' /></td>";
             str += "<td class='Ctd' align='center'><input type='text' name='money" + (id) + "' value='0' class='textbox' style='width:60px;' /></td>";
             str += "<td class='Ctd' align='center'><a title='删除' href='javascript:;'  onclick=delquyu(" + (id) + ")>删除</a></td>";
             str += "</tr>";
             jQuery("#quyu").append(str);
             jQuery("#quyunum").val(parseInt(jQuery('#quyunum').val()) + parseInt(1));//区域加一
         }
         //移除区域
         function delquyu(id)//删除选项小题
         {
             if (id == jQuery("#quyunum").val()) {
                 jQuery('#quyu' + id).remove();//移除小题
                 jQuery("#quyunum").val(parseInt(jQuery('#quyunum').val()) - parseInt(1));//区域减一
             }
         }
         //增加答案选项
         function adddaan() {
             var num = document.getElementsByName("answernum")[0].value;
             var id = parseInt(num) + 1;
             var str = "<tr id=answer" + (id) + " >";
             str += "<td class='p-l-td'><input type='radio' name='right' value=" + yingwen[num] + " /><span class='v-o-n'>(" + yingwen[num] + ")</span></td>";
             str += "<td class='p-r-td' align='left'><input type='text' name='answer" + (id) + "' class='textbox' style='width:67%;' /></td>";
             str += "</tr>";
             jQuery("#answer").append(str);
             jQuery("#answernum").val(parseInt(jQuery('#answernum').val()) + parseInt(1));//区域加一
         }
         //删除答案信息
         function deledaan(id) {
             if (id == jQuery("#answernum").val()) {
                 jQuery('#answer' + id).remove();//移除小题
                 jQuery("#answernum").val(parseInt(jQuery('#answernum').val()) - parseInt(1));//区域减一
             }
         }
         //提交的校验
         function check() {
           
             var name = document.getElementsByName("gamename")[0].value;
             if (name == "") {
                 alert("请请输入正确的游戏包名！");
                 return false;
             }
         }
     </script>
</asp:Content>
