<%@ Page Language="C#"  MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="True" Inherits="Kesion.NET.WebSite.Course.Admin_Course_KS_CsAddExam" Codebehind="KS.CsAddExam.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.BLL" %>

<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server">

<script>
    function searchSJ() {
        var key = jQuery("#<%=this.TxtSJKey.ClientID %>").val();
        if (key == '') {
            KesionJS.Alert("请输入试卷关键字！", "jQuery('#<%=this.TxtSJKey.ClientID %>').focus()");
            return false;
        } else {
            jQuery.ajax({ url: "KS.CSAddExam.aspx?action=GetSJ&Key=" + escape(key), success: function (d) {
                jQuery("#<%=this.LstB2.ClientID %>").append(d);
            }
            });
        }
    }
    function addUser() {
        var src = document.getElementById('<%=this.LstB2.ClientID %>');
        var dest = document.getElementById('<%=this.LstB1.ClientID %>');

        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 delUser() {
        var dest = document.getElementById('<%=this.LstB1.ClientID %>');

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

  function CheckForm() {
             if (jQuery('#<%=this.TxtSJKey.ClientID %>').val() == '') {
                 KesionJS.Alert('请输入试卷关键字!', "jQuery('#<%=this.TxtSJKey.ClientID %>').focus()");
                 return false;
             }
             if (jQuery('#<%=this.LstB2.ClientID %>').val() == '') {
                 KesionJS.Alert('查无试卷!', "jQuery('#<%=this.LstB2.ClientID %>').focus()");
                 return false;
             }
             if (jQuery('#<%=this.LstB1.ClientID %>').val() == '') {
                 KesionJS.Alert('请加入试卷!', "jQuery('#<%=this.LstB1.ClientID %>').focus()");
                 return false;
             }
         var idArr = new Array();
         var dest = document.getElementById('<%=this.LstB1.ClientID %>');
         for (var i = 0; i < dest.options.length; i++) {
             dest.options[i].selected = "true";
             idArr.push(dest.options[i].value);
         }
         if (idArr.length <= 0) {
             alert("请加入试卷!");
             return false;
         }
         else {
             return true;
         }
     }
   </script>

<asp:Panel ID="AddPanel" runat="server" Width="100%"> 
  <KS:TopNav ID="TopNav1" runat="server" Text="添加试卷" /> 
  <table border=0 width="100%">
             <tr>
	            <td style="width:200px">
                搜索试卷：<asp:TextBox ID="TxtSJKey" runat="server" Width="160px" CssClass="textbox" />
                <input type="button" value="搜索" class="button" onclick="searchSJ();" CssClass="button"/>
                <br />

                <asp:ListBox ID="LstB2" runat="server" Width="300px" Height="200px" SelectionMode="Multiple"></asp:ListBox>
                </td>
                  <td align="center"><p><input type="button" value=" > " onclick="addUser()" class="button" /></p>
					<br />
			 		<p><input type="button" value=" < " onclick="delUser()" class="button" /></p>
                  </td>
	            <td>
                 当前所添加的试卷如下:
                <asp:ListBox ID="LstB1" runat="server" Width="300px" Height="200px" SelectionMode="Multiple"></asp:ListBox>
                </td>
             </tr>
            
            </table>
 

   <%-- <KS:Foot ID="Foot1" runat="server" OnSubmit="Foot1_Submit" />--%>

   <div style="margin:8px;text-align:center">
       <asp:Button ID="Button1" runat="server" Text="确定添加"   CssClass="button" OnClientClick="return(CheckForm())" OnClick="Foot1_Submit"/>
&nbsp;
   &nbsp;<input type="button" value="关闭窗口(C)" onclick="parent.box.close();" class="button" accesskey="C" />

   </div>

</asp:Panel>
</asp:Content>