<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" EnableEventValidation="false" AutoEventWireup="true" Inherits="Kesion.NET.WebSite.Admin_ZGCard" Title="准考证管理" Codebehind="KS.ZGCard.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server">
<div id="manage_top" class="menu_top_fixed">
   <ul class="titleTab">
      <li><a href="KS.SJConfig.aspx">频道参数设置</a></li>
      <li><a href="KS.SJCategory.aspx">分类管理</a></li>
      <li><a href="KS.SJType.aspx">自定义类别</a></li>
      <li><a href="KS.SJZDYType.aspx">自定义题型</a></li>
      <%if (MyCache.GetSJCacheConfig(2).ToString() == "1"){ %>
      <li><a href="KS.SJKnowledge.aspx">知识点管理</a></li>
      <%} %>
      <li><a href="KS.SjTypeClass.aspx">章节管理</a></li>
      <li><a href="KS.SJCJD.aspx">成绩等级管理</a></li>
      <li class="curr"><a href="KS.ZGCard.aspx">准考证生成管理</a></li>
      <li><a href="KS.SJKM.aspx">会计科目管理</a></li>
   </ul>
</div>  
<div class="menu_top_fixed_height"></div> 
<asp:Panel ID="ListPanel" runat="server" Width="100%">
<div class="content-area">
	<div class="myTitle">
        <asp:LinkButton ID="addclassbutton" runat="server" OnClick="addclassbutton_Click" CssClass="fr mr20 button button_on">添加准考证项目</asp:LinkButton>
        准考证生成管理
    </div>
    <KS:ksgv id="List" cssclass="CTable" runat="server" AutoGenerateColumns="False" EmptyDataText="没有添加任何准考证项目!" PagerType="CustomNumeric" Width="99%" HorizontalAlign="Center" GridLines="None" OnRowDataBound="List_RowDataBound" OnRowCommand="List_RowCommand" OnRowCreated="List_RowCreated">
        <Columns>
         	<asp:TemplateField HeaderText="选择">
                <itemstyle horizontalalign="Center" width="50px" />
                <itemtemplate>
                	<input type="checkbox"  name="ids" id="ids" value="<%#Eval("id") %>" />
                </itemtemplate>
            </asp:TemplateField>

            <asp:BoundField HeaderText="准考证项目名称" DataField="ItemName" HtmlEncode="False" >
                <itemstyle/>
            </asp:BoundField>
            <asp:BoundField HeaderText="准考证前缀" DataField="CardPre">
                <itemstyle HorizontalAlign="Center" width="250px" />
            </asp:BoundField>
            
            <asp:TemplateField HeaderText="数量">
                <itemstyle horizontalalign="Center" width="150px" />
                <itemtemplate>
                <a href="KS.ZGCardItem.aspx?itemid=<%# Eval("id") %>"><%# GetCardNum(Convert.ToInt16(Eval("id"))) %>张</a>
                </itemtemplate>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="状态">
                <itemstyle horizontalalign="Center" width="150px" />
                <itemtemplate>
                <%# Convert.ToString(Eval("status"))=="1"?"<span class='greenFont'>正常</span>":"关闭" %>
                </itemtemplate>
            </asp:TemplateField>
           
            <asp:TemplateField HeaderText="操作">
                <itemstyle horizontalalign="Center" Width="300px" />
                <itemtemplate>
                     <a class="greenFont" title="生成"  href="KS.ZGCardCreate.aspx?ItemId=<%#Eval("id") %>">生成</a>&nbsp;&nbsp;&nbsp;
                     <a class="greenFont" title="打印"  href="KS.ZGPrintCard.aspx?itemid=<%#Eval("id") %>" target="_blank">打印</a>&nbsp;&nbsp;&nbsp;
                     <a class="greenFont" title="修改" href="?action=modify&itemid=<%# Eval("id") %>">修改</a>&nbsp;&nbsp;&nbsp;
                     <asp:LinkButton runat="server" CssClass="greenFont" title="删除" id="delete" commandargument=<%#Eval("id") %> commandname="del">删除</asp:LinkButton>
                </itemtemplate>
            </asp:TemplateField>
        </Columns>
        <HeaderStyle CssClass="CTitle" />
        <EmptyDataRowStyle CssClass="emptycss" />
       
    </KS:ksgv>

    <div class="listedit">
        <ul>
            <input type='checkbox' name='chkall' id='chkall' onClick='CheckAll(this.form);'/><label for="chkall">全选</label>
            <asp:LinkButton ID="delclassbutton" runat="server" OnClick="delclassbutton_Click" CssClass="button">删除准考证项目</asp:LinkButton>
        </ul>
    </div>
    
     <KS:Page ID="Page1" runat="server" />
        <asp:Panel ID="Panel1" runat="server" Height="30px" Width="100%">
			<script type="text/javascript">
            showtips('<span class="state"><strong>操作说明：</strong><br /></span>准考证项目一旦建立，建议尽量少改动。删除准考证项目将同时删除该项目下的所有准考证。');
            </script>
        </asp:Panel>
</asp:Panel>

</div>
     
 <asp:Panel ID="AddPanel" runat="server"  Width="100%" Visible="false">
 <div class="content-area">   
     <div class="myTitle">
        <%=!string.IsNullOrEmpty(KSCMS.S("itemid"))?"修改":"添加" %>准考证项目</div>  
    <table width="99%" align="center" border="0" cellpadding="1" cellspacing="1" class="CTable no-borderTable"> 
        
          <tr>
            <td class="lefttd" height="30" align="right" style="width: 258px"><b>准考证项目名称：</b></td>
            <td class="righttd">
                <asp:TextBox CssClass="textbox" ID="TxtItemName" runat="server" Width="203px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtItemName"
                    ErrorMessage="请填写准考证项目名称!" Display="Dynamic"></asp:RequiredFieldValidator> <span class="tips">如中考准考证项目等</span></td>
        </tr>

        <tr>
            <td align="right" class="lefttd" height="30" style="width: 258px">
                <strong>准考证号前缀：</strong></td>
            <td class="righttd">
                <asp:TextBox CssClass="textbox" ID="TxtCardPre" runat="server" Width="200px"></asp:TextBox>
                 <span class="tips">如：20130101,也可以留空等</span> </td>
        </tr>
        <tr>
            <td align="right" class="lefttd" height="30" style="width: 258px">
                <strong>有效期限：</strong></td>
            <td class="righttd">
               从&nbsp;<asp:TextBox  CssClass="textbox" ID="TxtBeginTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" runat="server"></asp:TextBox>至&nbsp;&nbsp;<asp:TextBox CssClass="textbox" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" ID="TxtEndTime" runat="server"></asp:TextBox>
               <br /><span class='tips'>具体是以每份试卷限制的时间为准，这里说明的一个准考证可以同时参加多份试卷考试时的一个时间范围。</span>                  </td>
        </tr>
        <tr>
            <td align="right" class="lefttd" height="30" style="width: 258px">
                <strong>准许考试的科目：</strong></td>
            <td class="righttd">
                <asp:TextBox CssClass="textbox" ID="TxtKM" runat="server" Width="200px"></asp:TextBox>
             <span class="tips">如：语文、数学等</span>      </td>
        </tr>
 
        <tr>
            <td align="right" class="lefttd" height="30" style="padding-left:4px;width: 258px">
                <strong>备注说明：</strong></td>
            <td class="righttd">
                <asp:TextBox CssClass="textbox" ID="TxtIntro" TextMode="MultiLine" height="100px" runat="server" Width="300px"></asp:TextBox>
             <span class="tips">可以不填</span>      </td>
        </tr>
        <tr>
            <td align="right" class="lefttd" height="30" style="padding-left:4px;width: 258px">
                <strong>状态：</strong></td>
            <td class="righttd">
             <asp:RadioButtonList ID="RdbStatus" runat="server" RepeatLayout="Flow" 
                    RepeatDirection="Horizontal">
               <asp:ListItem Value="0">关闭</asp:ListItem>
               <asp:ListItem Value="1" Selected>正常</asp:ListItem>
             </asp:RadioButtonList>  
              
            </td>
        </tr>
       <tr>
          <td colspan="2" class="topbar">准许考试的试卷</td>
        </tr> 
       <tr>
          <td colspan="2">
          
          
          <table style="width:100%;margin:0 auto;" cellpadding="2" cellspacing="1" class="CTable">
           <tr>
			<td class="righttd" style="width: 320px;line-height:30px;" valign="top">
			 <script type="text/javascript">
			     function CheckForm() {
			        
			         if (jQuery("#<%=this.TxtItemName.ClientID %>").val() == '') {
			             KesionJS.Alert("准考证项目名称必须输入!", 'jQuery("#<%=this.TxtItemName.ClientID %>").focus()');
			             return false;
			         }
			         if (jQuery("#<%=this.TxtBeginTime.ClientID %>").val() == '') {
			             KesionJS.Alert("准考证有效期限开始日期必须输入!", 'jQuery("#<%=this.TxtBeginTime.ClientID %>").focus()');
			             return false;
			         }
			         if (jQuery("#<%=this.TxtEndTime.ClientID %>").val() == '') {
			             KesionJS.Alert("准考证有效期限结束日期必须输入!", 'jQuery("#<%=this.TxtEndTime.ClientID %>").focus()');
			             return false;
			         }
			         var idArr = new Array();
			         var dest = document.getElementById('SJIds');
			         for (var i = 0; i < dest.options.length; i++) {
			             dest.options[i].selected = "true";
			             idArr.push(dest.options[i].value);
			         }
			         if (idArr.length <= 0) {
			             KesionJS.Alert("必须绑定试卷！");
			             return false;
			         }
			         else {
			             return true;
			         }

			     }
		  function getSJ()
		  {	 jQuery('#ajaxmsg',window.parent.document).fadeIn("slow");		 
		  var key = jQuery('input[name=key]').val();
			 var classid = jQuery('#<%=this.DrpClassID.ClientID %> option:selected').val();
			 jQuery.get("KS.SJAjax.ashx", { action: "searchsj",realtest:1, key: key, classid: classid },
			 function(data){
					jQuery('#ajaxmsg',window.parent.document).fadeOut("slow");
					jQuery("#sjlist").empty();
					jQuery("#sjlist").append(data);
			  });
		  }

        function  addIn(){
            var src = document.getElementById('sjlist');
            var dest = document.getElementById('SJIds');

            for (var i = 0; i < src.options.length; i++) {
                if (src.options[i].selected) {
                    var exist = false;
                    for (var j = 0; j < dest.options.length; j++) {
                        if (dest.options[j].value == src.options[i].value) {
                            exist = true;
                            break;
                        }
                    }
                    if (!exist) {
                        var opt = document.createElement('OPTION');
                        opt.value = src.options[i].value;
                        opt.text = src.options[i].text;
                        dest.options.add(opt);
                    }
                }
            }
        }

        function del() {
            var dest = document.getElementById('SJIds');

            for (var i = dest.options.length - 1; i >= 0; i--) {
                if (dest.options[i].selected) {
                    dest.options[i] = null;
                }
            }
        }
		  
		  

		</script>
                 <div class="l_height36"><b>试卷名称: </b></div>
                 <input type="text" class='textbox' name="key" /><br/>
                 <div class="l_height36"><b>试卷分类: </b></div>
                 <asp:DropDownList ID="DrpClassID" runat="server" Width="200" style="margin-right:8px;">
                        <asp:ListItem Value="0">--选择试卷分类--</asp:ListItem>
                 </asp:DropDownList>
                 <input type="button" onclick="getSJ()" value="开始搜索" class="button" name="s1" />
                 <div class="l_height36"><b>查询到的试卷:</b></div>	
                 <select name="sjlist" size="5" multiple="true" style="width:312px;height:200px" id="sjlist"></select>
			</td>
			
			<td  class='righttd' style="text-align:center">
                <p><input type="button" value=" > " onclick="addIn()" class="button" /></p>
                <br />
                <p><input type="button" value=" < " onclick="del()" class="button" /></p>
            </td>
			
			<td class="righttd">
                <div class="l_height36"><b>已绑定的试卷:</b></div>
                <select size="4" name="SJIds" multiple="multiple" id="SJIds" style="height:340px;width:360px;">
                <%=SJOptions%></select>
			</td>
		  </tr>
             
            </table>
          
          
          
          
          </td>
        </tr> 
        
      </table>
      <br />
        <KS:Foot ID="Foot1" runat="server" OnSubmit="Foot1_Submit" />
       <br />
    </asp:Panel>
</div>
</asp:Content>
