<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="stuadd.aspx.cs" Inherits="jiaowu.student.stuadd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title></title>
    <link href="../css/table.css" rel="stylesheet" type="text/css" />
    <script src="../js/toolsFunction.js" type="text/javascript"></script>
    <script src="../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <style type="text/css">
        .style1
        {
            text-align: center;
            width: 22%;
        }
        .style2
        {
        }
        .style6
        {
            color: #FF0000;
        }
        .style7
        {
            width: 612px;
        }
       
        .style16
        {
            text-align: right;
            width: 107px;
        }
       
        #pho0
        {
            width: 292px;
        }
        #pho1
        {
            width: 292px;
        }
       
        #imgzheng
        {
            width: 551px;
        }
       
        #imgfan
        {
            width: 300px;
        }
       
        .style17
        {
            width: 715px;
        }
       
        #IdrControl1
        {
            width: 149px;
            height: 21px;
        }
           
        .style18
        {
            text-align: right;
            width: 107px;
            height: 24px;
        }
        .style19
        {
            width: 715px;
            height: 24px;
        }
        .style20
        {
            text-align: right;
            width: 107px;
            height: 22px;
        }
        .style21
        {
            width: 715px;
            height: 22px;
        }
           
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="place">
        <asp:SiteMapPath ID="SiteMapPath1" runat="server" Height="27px">
        </asp:SiteMapPath>
    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <table border="1" align="center" bordercolor="#D2ECFC"  
            style="border-collapse:collapse " width="100%" class="line_table">
        <tr >
          <td class="style16"> 所属分校</td>
          <td class="style17" align="left">
              <asp:DropDownList ID="ddlfenxiao" runat="server" AppendDataBoundItems="true">
                  <asp:ListItem Value="">请选择</asp:ListItem>
              </asp:DropDownList>
              <span class="style6">*</span><asp:RequiredFieldValidator 
                  ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddlfenxiao" 
                  ErrorMessage="校区必需选择！"></asp:RequiredFieldValidator></td>
            <td align="left" style="width:200" rowspan="10">
               <div align="center">
                <img ID="imgpho" runat="server" alt="照片" height="166"  name="imgpho" src="" 
                    width="116" /><br /><input name="Submit23" 
                    onclick="javascript:window.open('../upphoto.aspx?hidname=hidphoto&amp;imgname=imgpho','上传照片','width=500,height=300')" 
                    type="button" value="上传照片" /></div>
                <asp:HiddenField ID="hidphoto" runat="server" />
                <input id="textB64" type="hidden" value="" />
            </td>
        </tr>
        
        <tr>
            <td class="style16">
                报名时间</td>
            <td align="left" class="style17">
                <asp:TextBox ID="txtbaoming" runat="server" onfocus="WdatePicker()" 
                    Width="300px"></asp:TextBox>
                <span class="style6">*</span></input></td>
        </tr>
        
        <tr>
            <td class="style20">
                档案编号</td>
            <td align="left" class="style21">
                <asp:TextBox ID="txtdanganhao" runat="server"  Width="300px" Height="19px"></asp:TextBox>
                </td>
        </tr>
        <tr>
            <td class="style16">
                身份证件号</td>
            <td align="left" class="style17">
                <asp:TextBox ID="txtcard" runat="server" Width="300px" MaxLength="18"></asp:TextBox>
                <span class="style6">*<asp:RequiredFieldValidator ID="RequiredFieldValidator4" 
                    runat="server" ControlToValidate="txtcard" ErrorMessage="身份证号不能为空！"></asp:RequiredFieldValidator>
                <input onClick="Idcard();" type="button" value="读身份证">
                <object ID="IdrControl1" classid="clsid:5EB842AE-5C49-4FD8-8CE9-77D4AF9FD4FF">
                </object>
                </input></span> </td>
        </tr>
        <tr>
            <td class="style16">
                姓名</td>
            <td align="left" class="style17">
                <asp:TextBox ID="txtstuxm" runat="server"  Width="300px"></asp:TextBox>
                <span class="style6">*</span><asp:RequiredFieldValidator 
                    ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtstuxm" 
                    ErrorMessage="姓名必需填写！"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style16">
                性别</td>
            <td align="left" class="style17">
                <asp:RadioButtonList ID="rblxb" runat="server" RepeatDirection="Horizontal" 
                    RepeatLayout="Flow">
                    <asp:ListItem Selected="True">男</asp:ListItem>
                    <asp:ListItem>女</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td class="style16">
                出生日期</td>
            <td align="left" class="style17">
                <asp:TextBox ID="txtbirthdy" runat="server" 
                    onfocus="WdatePicker()" Width="300px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style16">
                身份证地址</td>
            <td align="left" class="style17">
                <asp:TextBox ID="txtdizhi" runat="server" Width="318px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style16">
                报考类型</td>
            <td align="left" class="style17">
                <asp:RadioButtonList ID="rblleixing" runat="server" RepeatDirection="Horizontal" 
                    RepeatLayout="Flow">
                    <asp:ListItem Selected="True">初次</asp:ListItem>
                    <asp:ListItem>增驾</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td class="style16">
                报考车型</td>
            <td align="left" class="style17">
                <asp:DropDownList ID="ddlchexing" runat="server" AppendDataBoundItems="true">
                <asp:ListItem Value="">请选择车型</asp:ListItem>
                   
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style16">
                电话</td>
            <td align="left" colspan="2">
                <asp:TextBox ID="txttel" runat="server" Width="300px" MaxLength="11"></asp:TextBox>
                <span class="style6">*</span><asp:RequiredFieldValidator 
                    ID="RequiredFieldValidator3" runat="server" ControlToValidate="txttel" 
                    ErrorMessage="电话号码不能为空"></asp:RequiredFieldValidator>
            </td>
        </tr>
            <tr>
                <td class="style16">
                    身份证正反面</td>
                <td align="left" class="style2" colspan="2">
                    <img ID="imgzheng" runat="server" alt="照片" height="166" width="300" name="imgzheng" 
                        src="" /><span class="style7">
                    &nbsp;
                    <input id="textc64" type="hidden" value="" /><br />
                    <input name="Submit24" 
                        onclick="javascript:window.open('../upphoto.aspx?hidname=hidzheng&amp;imgname=imgzheng','上传照片','width=500,height=300')" 
                        type="button" value="上传正面照片" />
                    &nbsp;
                    </span>&nbsp;<asp:HiddenField ID="hidzheng" 
                        runat="server" />
                </td>
        </tr>
            <tr>
                <td class="style16">
                    备注</td>
                <td align="left" class="style2" colspan="2">
                    <asp:TextBox ID="txtbeizhu" runat="server" Height="64px" TextMode="MultiLine" 
                        Width="638px"></asp:TextBox>
                </td>
        </tr>
            <tr>
          <td class="style1" colspan="3"> 
              <asp:Button ID="Button1" runat="server" 
                  onclick="Button1_Click" Text=" 保  存 "/>
              <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text=" 修  改 " 
                  Visible="false" />
              <input ID="Reset1" type="reset" value=" 重  置 " /><asp:Label ID="lblmsg" 
                  runat="server" Text=""></asp:Label></td>
        </tr>
        
      </table>
      </ContentTemplate>
    </asp:UpdatePanel>
<script type="text/javascript">
    var PortOpened = 0;
    var CpuCardFound = 0;
    function Idcard() {
        var result;
        var photoname;
        var cardname;
        var cardsn;
        try {
            var ax = new ActiveXObject("IDRCONTROL.IdrControlCtrl.1");
        } catch (e) {
            alert("控件未安装");
        }
        result = ax.ReadCard("1001", "");
        if (result == 1) {
            document.getElementById("txtstuxm").value = ax.GetName();
            //document.getElementById("txtminzu").value = ax.GetFolk();
            document.getElementById("txtxb").value = ax.GetSex();
            document.getElementById("txtbirthdy").value = ax.GetBirthYear() + "-" + ax.GetBirthMonth() + "-" + ax.GetBirthDay();
            cardsn = ax.GetCode();
            document.getElementById("txtcard").value = cardsn;
            document.getElementById("txtzhuzhi").value = ax.GetAddress();
            document.getElementById("textB64").value = ax.GetJPGPhotobuf(); //个人照片base64编码
            document.getElementById("textc64").value = ax.GetCardPhotobuf(); //证件照片base64编码
            uploadPhoto();
            uploadcard();

        } else {
            if (result == -1)
                alert("端口初始化失败！");
            if (result == -2)
                alert("请重新将卡片放到读卡器上！");
            if (result == -3)
                alert("读取数据失败！");
            if (result == -4)
                alert("生成照片文件失败，请检查设定路径和磁盘空间！");

        }
    }
    function uploadPhoto()//上传拍照的图片
    {
        request = createRequest();
        if (request == null) {
            alert("Unable to create request");
        }
        else {
            var base64Data = document.getElementById('textB64').value.replace(/\+/g, "%2B"); //对参数中的+号编码，防止丢失
            var card = document.getElementById('txtcard').value;
            if (base64Data == "") {
                alert("未获取到base64数据！");
            }
            var url = "../uploadpicCode.ashx";
            request.open("POST", url, true);
            request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            request.onreadystatechange = responses;
            request.send("&card=" + card + "&img=" + base64Data);
        }
    }
    function responses() {
        if (request.readyState == 4)//服务器处理结束
        {
            if (request.status == 200)//一切正常
            {
                window.document.form1.pho.src = request.responseText; window.document.form1.hidpic.value = request.responseText;
            }
        }
    }
    function uploadcard()//上传拍照的图片
    {
        request = createRequest();
        if (request == null) {
            alert("Unable to create request");
        }
        else {
            var base64Data = document.getElementById('textB64').value.replace(/\+/g, "%2B"); //对参数中的+号编码，防止丢失
            var card = document.getElementById('txtcard').value;
            if (base64Data == "") {
                alert("未获取到base64数据！");
            }
            var url = "../uploadcardCode.ashx";
            request.open("POST", url, true);
            request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            request.onreadystatechange = responsesc;
            request.send("&card=" + card + "&img=" + base64Data);
        }
    }
    function responsesc() {
        if (request.readyState == 4)//服务器处理结束
        {
            if (request.status == 200)//一切正常
            {
                window.document.form1.imgzheng.src = request.responseText; window.document.form1.hidzheng.value = request.responseText;
            }
        }
    }
    </script>
    </form>
</body>
</html>

