<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="IDSignIn.aspx.cs" Inherits="MTCUN.Tools.IDSignIn"
    Title="ID卡签到器" %>

<%@ Register Src="../UserCol/Progress.ascx" TagName="Progress" TagPrefix="uc1" %>
<%@ Import Namespace="MTCUN" %>
<!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 runat="server">
    <link id="linkStyle" runat="server" href="Themes/blue/css.css" rel="stylesheet"
        type="text/css" />
    <link id="mobileCss" runat="server" href="../mobile/themes/mobile.css" rel="stylesheet"
        type="text/css" />
    <style type="text/css">
        .gridview1 {
            width: 100%;
            border: 1px solid Gray;
            text-align: left;
        }

            .gridview1 td {
                border-top: 1px solid Gray;
                border-right-color: Gray;
                border-bottom-color: Gray;
                border-left-color: Gray;
                background-color: #F1F0EE;
                line-height: 24px;
                text-align: left;
            }

            .gridview1 th {
                background-color: #F1F0EE;
                text-align: left;
                border-top-style: none;
                border-right-style: none;
                border-bottom-style: none;
                border-left-style: none;
                border-top-width: 1px;
                border-right-width: 1px;
                border-bottom-width: 1px;
                border-left-width: 1px;
                padding: 0px;
                line-height: 27px;
                vertical-align: middle;
                background-repeat: repeat-x;
            }

        .gridview1 {
            width: 100%;
            border: 1px solid Gray;
            text-align: left;
        }

        .input {
            border: 1px solid #c0c0c0 !important;
        }
    </style>
    <script type="text/javascript"> 
<!--
    var FocusState = true;

    function Focus() {
        if (FocusState) {
            if (!document.getElementById("tbxSignInID").disabled) {
                document.getElementById("tbxSignInID").focus();
            }
        }
    }

    function hotkey() {
        var a = window.event.keyCode;
        if (a == 13) {
            document.getElementById("btnPost").click();
        }
    }

    document.onkeydown = hotkey;
    document.onclick = Focus;
    window.onfocus = Focus;
    //--> 
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <script type="text/javascript">
            var IsPrint = false;
        </script>

        <div class="printWeb">
            <iframe id="PrintWeb" width="0" height="0"></iframe>
        </div>

        <bgsound id="bgsound" src="" loop="1" />
        <audio id="html5_bgsound" src="" autoplay="true" playcount="1"></audio>

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        <script type="text/javascript">
            var prm = Sys.WebForms.PageRequestManager.getInstance();

            function CancelAsyncPostBack() {

                if (prm.get_isInAsyncPostBack()) {

                    prm.abortPostBack();

                }

            }


            prm.add_initializeRequest(InitializeRequest);

            prm.add_endRequest(EndRequest);

            var postBackElement;

            function InitializeRequest(sender, args) {

                if (prm.get_isInAsyncPostBack()) {

                    args.set_cancel(true);
                }

                postBackElement = args.get_postBackElement();

                document.getElementById("tbxSignInID").disabled = "disabled";
                document.getElementById("labMsg").innerHTML = "<b>Load</b>" + "<img src='../images/Load.gif'>";

            }


            function EndRequest(sender, args) {

                document.getElementById("tbxSignInID").disabled = "";
                document.onclick = Focus;
                window.onfocus = Focus;
            }
        </script>

        <div id="IdWebSign">

            <div style="position: fixed; z-index: 10000">
                <div id="header">
                    <div id="header_menu" style="color: #c0c0c0">
                        <table>
                            <tr>
                                <td style="color:#c0c0c0">班级类型：
                                </td>
                                <td>
                                    <asp:RadioButtonList ID="rblClassType" runat="server" RepeatDirection="Horizontal" ForeColor="#c0c0c0">
                                        <asp:ListItem Value="-1" Selected="True">全部</asp:ListItem>
                                        <asp:ListItem Value="0">一对多</asp:ListItem>
                                        <asp:ListItem Value="1">一对一</asp:ListItem>
                                    </asp:RadioButtonList>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>

            <div id="web_page_contents">
                <div class="search biao_zhun_suo_jin">
                    <div class="kuai_show">
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <table style="width: 98%; margin-left: auto; margin-right: auto; margin-top: 10px; height: 200px"
                                    border="0" cellspacing="0">
                                    <tr>
                                        <td style="height: 100%; width: 180px">
                                            <div style="height: 200px; margin: 18px">
                                                <asp:Image ID="imgFace" runat="server" ImageUrl='<%#accTheme("pic.gif") %>' />
                                            </div>
                                        </td>
                                        <td style="height: 100%">
                                            <div style="height: 136px">
                                                <div style="width: auto; height: 100%; border: 1px solid #F1F0EE">
                                                    <table cellspacing="0" style="text-align: left; width: 100%">
                                                        <tr>
                                                            <td style="text-align: right">ID卡号：
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="tbxSignInID" runat="server" Font-Size="Large" AutoCompleteType="Disabled"
                                                                    CssClass="input"></asp:TextBox>
                                                            </td>
                                                            <td>
                                                                <asp:CheckBox ID="cbxPhoto" runat="server" Checked="True" Text="相片" />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td></td>
                                                            <td>
                                                                <input id="btnPost" runat="server" onserverclick="btnPost_Click" type="button" value="签到"
                                                                    style="width: 80px; height: 40px; font-size: 16px" />
                                                            </td>
                                                            <td></td>
                                                        </tr>
                                                    </table>
                                                </div>
                                            </div>
                                            <br>
                                            <div style="height: 50px;">
                                                <div style="width: auto; height: 100%; text-align: center; line-height: 22px; border: 1px solid #F1F0EE">
                                                    <asp:Label ID="labMsg" runat="server" EnableViewState="False"></asp:Label>
                                                </div>
                                            </div>
                                        </td>

                                    </tr>
                                </table>
                                <br />
                                <div style="margin: 10px">
                                    <asp:GridView ID="gvStu" runat="server" AutoGenerateColumns="False" CssClass="gridview1"
                                        DataKeyNames="AttendID,StuClassID,LessonDegreeID" OnRowCancelingEdit="gvStu_RowCancelingEdit"
                                        OnRowDataBound="gvStu_RowDataBound" OnRowDeleting="gvStu_RowDeleting" OnRowEditing="gvStu_RowEditing"
                                        OnRowUpdating="gvStu_RowUpdating">
                                        <Columns>
                                            <asp:BoundField DataField="LessonDegreeID" HeaderText="编号" ReadOnly="True" />
                                            <asp:BoundField DataField="StudentID" HeaderText="学号" ReadOnly="True" />
                                            <asp:TemplateField HeaderText="姓名">
                                                <ItemTemplate>
                                                    <%#Eval("StudentName")%>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="班号">
                                                <ItemTemplate>
                                                    <asp:Label ID="ClassID" runat="server" Text='<%# Eval("ClassID") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="班级名称">
                                                <ItemTemplate>
                                                    <asp:Label ID="ClassName" runat="server" Text='<%# Eval("ClassName") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="上课时段">
                                                <ItemTemplate>
                                                    <%# string.Format("{0}-{1}", Eval("StartDate", "{0:HH:mm}"),EndDate(Eval("EndDate")))%>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="出勤状态">
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="AtStateID" Text='<%# Rs.Items.GetAtState(Eval("AtStateID"))%>'></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:DropDownList ID="ddlAtStateID" runat="server">
                                                        <asp:ListItem Text="正常" Value="1"></asp:ListItem>
                                                        <asp:ListItem Text="迟到" Value="2"></asp:ListItem>
                                                        <asp:ListItem Text="早退" Value="3"></asp:ListItem>
                                                        <asp:ListItem Text="旷课" Value="4"></asp:ListItem>
                                                        <asp:ListItem Text="请假" Value="5"></asp:ListItem>
                                                    </asp:DropDownList>
                                                </EditItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="课时">
                                                <ItemTemplate>
                                                    <asp:Label ID="labCurrentLessons" runat="server" Text='<%#Eval("CurrentLessons") %>'></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:DropDownList ID="ddlLessons" runat="server">
                                                    </asp:DropDownList>
                                                </EditItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="备注">
                                                <ItemTemplate>
                                                    <asp:Label ID="RemarkText" runat="server" Text='<%#Eval("Remark")%>'></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="tbxRemark" runat="server" Columns="30" Rows="2" Text='<%#Eval("Remark")%>'
                                                        TextMode="SingleLine"></asp:TextBox>
                                                </EditItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="课时进度">
                                                <ItemTemplate>
                                                    <uc1:Progress ID="Progress1" runat="server" MaxNum='<%#Eval("Lessons") %>' MinNum='<%#Eval("CourseProgress") %>'
                                                        Width="90%" StartDate='<%#Eval("DateAndTime") %>' ExpiryDate='<%#Eval("ExpiryDate") %>'></uc1:Progress>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="打印">
                                                <ItemTemplate>
                                                    <asp:HyperLink ID="hlkPrint" runat="server" NavigateUrl='<%#string.Format("javascript:Print({0});void(0);",Eval("AttendID")) %>'
                                                        ImageUrl='<%# accTheme("print.gif")%>' CssClass="noborder"></asp:HyperLink>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CommandField HeaderText="编辑" EditText="编辑" CancelText="取消" UpdateText="更新" CausesValidation="False"
                                                ShowEditButton="True" />
                                            <asp:TemplateField HeaderText="清除">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lbnDelete" runat="server" CommandName="Delete" OnClientClick="<%# Rs.Messages.确定删除%>"
                                                        Text="清除"></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </asp:GridView>
                                    <asp:GridView ID="gvUser" runat="server" AutoGenerateColumns="False" CssClass="gridview1"
                                        DataKeyNames="TimecardID,DateAndTime,UserID" OnRowCancelingEdit="gvUser_RowCancelingEdit"
                                        OnRowDeleting="gvUser_RowDeleting" OnRowEditing="gvUser_RowEditing" OnRowUpdating="gvUser_RowUpdating" OnRowDataBound="gvUser_RowDataBound">
                                        <Columns>
                                            <asp:BoundField DataField="TimecardID" HeaderText="编号" ReadOnly="True" />
                                            <asp:BoundField DataField="TrueName" HeaderText="姓名" ReadOnly="True" />
                                            <asp:TemplateField HeaderText="上午">
                                                <ItemTemplate>
                                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("AMStart","{0:HH:mm:ss}") +"-"+Eval("AMEnd","{0:HH:mm:ss}") %>'></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="tbxAMStart" runat="server" Text='<%# Eval("AMStart","{0:HH:mm:ss}") %>'
                                                        Width="65px"></asp:TextBox>
                                                    -<asp:TextBox ID="tbxAMEnd" runat="server" Text='<%# Eval("AMEnd","{0:HH:mm:ss}") %>'
                                                        Width="65px"></asp:TextBox>
                                                </EditItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="下午">
                                                <ItemTemplate>
                                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("PMStart","{0:HH:mm:ss}") +"-"+Eval("PMEnd","{0:HH:mm:ss}") %>'></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="tbxPMStart" runat="server" Text='<%# Eval("PMStart","{0:HH:mm:ss}") %>'
                                                        Width="65px"></asp:TextBox>
                                                    -<asp:TextBox ID="tbxPMEnd" runat="server" Text='<%# Eval("PMEnd","{0:HH:mm:ss}") %>'
                                                        Width="65px"></asp:TextBox>
                                                </EditItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="晚上">
                                                <ItemTemplate>
                                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("NightStart","{0:HH:mm:ss}") +"-"+Eval("NightEnd","{0:HH:mm:ss}") %>'></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="tbxNightStart" runat="server" Text='<%# Eval("NightStart","{0:HH:mm:ss}") %>'
                                                        Width="65px"></asp:TextBox>
                                                    -<asp:TextBox ID="tbxNightEnd" runat="server" Text='<%# Eval("NightEnd","{0:HH:mm:ss}") %>'
                                                        Width="65px"></asp:TextBox>
                                                </EditItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="校区">
                                                <ItemTemplate>
                                                    <%# Eval("SchoolName") %>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:DropDownList ID="ddlSchool" runat="server" DataSource='<%#swq.Cache.GetSchool() %>' SelectedValue='<%# Eval("SchoolID") %>' DataValueField="SchoolID" DataTextField="SchoolName">
                                                    </asp:DropDownList>
                                                </EditItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CommandField CancelText="取消" CausesValidation="False" EditText="编辑" HeaderText="编辑"
                                                ShowEditButton="True" UpdateText="更新" />
                                            <asp:TemplateField HeaderText="清除">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lbnDelete0" runat="server" CommandName="Delete" OnClientClick="<%# Rs.Messages.确定删除%>"
                                                        Text="清除"></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </asp:GridView>
                                    <asp:GridView ID="gvStu2" runat="server" AutoGenerateColumns="False" CssClass="gridview1"
                                        DataKeyNames="StuClassID" OnRowCommand="gvStu2_RowCommand">
                                        <Columns>
                                            <asp:BoundField DataField="StuClassID" HeaderText="选班号" ReadOnly="True" />
                                            <asp:BoundField DataField="StudentID" HeaderText="学号" ReadOnly="True" />
                                            <asp:TemplateField HeaderText="姓名">
                                                <ItemTemplate>
                                                    <%#Eval("StudentName")%>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="班号">
                                                <ItemTemplate>
                                                    <asp:Label ID="ClassID" runat="server" Text='<%# Eval("ClassID") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="班级名称">
                                                <ItemTemplate>
                                                    <asp:Label ID="ClassName" runat="server" Text='<%# Eval("ClassName") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="课时进度">
                                                <ItemTemplate>
                                                    <uc1:Progress ID="Progress2" runat="server" MaxNum='<%#Eval("Lessons") %>' MinNum='<%#Eval("CourseProgress") %>'
                                                        Width="90%" />
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="选择">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lbnDelete1" runat="server" CommandName="Select" CommandArgument='<%#Eval("StudentID") +"$"+Eval("StuClassID") %>'
                                                        OnClientClick="return confirm('你确定选择的班级是正确的？');" Text="选择"></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </asp:GridView>
                                    <asp:GridView ID="gvStu3" runat="server" AutoGenerateColumns="False" CssClass="gridview1"
                                        DataKeyNames="AttendID,StuClassID,LessonDegreeID" OnRowCommand="gvStu3_RowCommand"
                                        OnRowDataBound="gvStu3_RowDataBound">
                                        <Columns>
                                            <asp:BoundField DataField="LessonDegreeID" HeaderText="编号" ReadOnly="True" />
                                            <asp:BoundField DataField="StudentID" HeaderText="学号" ReadOnly="True" />
                                            <asp:TemplateField HeaderText="姓名">
                                                <ItemTemplate>
                                                    <%#Eval("StudentName")%>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="班号">
                                                <ItemTemplate>
                                                    <asp:Label ID="ClassID" runat="server" Text='<%# Eval("ClassID") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="班级名称">
                                                <ItemTemplate>
                                                    <asp:Label ID="ClassName" runat="server" Text='<%# Eval("ClassName") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="上课时段">
                                                <ItemTemplate>
                                                    <%# string.Format("{0}-{1}", Eval("StartDate", "{0:HH:mm}"),EndDate(Eval("EndDate")))%>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="出勤状态">
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="AtStateID" Text='<%# Rs.Items.GetAtState(Eval("AtStateID"))%>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="课时">
                                                <ItemTemplate>
                                                    <asp:Label ID="labCurrentLessons" runat="server" Text='<%#Eval("CurrentLessons") %>'></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:DropDownList ID="ddlLessons" runat="server">
                                                    </asp:DropDownList>
                                                </EditItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="备注">
                                                <ItemTemplate>
                                                    <asp:Label ID="RemarkText" runat="server" Text='<%#Eval("Remark")%>'></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="tbxRemark" runat="server" Columns="30" Rows="2" Text='<%#Eval("Remark")%>'
                                                        TextMode="SingleLine"></asp:TextBox>
                                                </EditItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="课时进度">
                                                <ItemTemplate>
                                                    <uc1:Progress ID="Progress1" runat="server" MaxNum='<%#Eval("Lessons") %>' MinNum='<%#Eval("CourseProgress") %>'
                                                        Width="90%"></uc1:Progress>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="选择">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lbnSelect" runat="server" CommandName="Select" CommandArgument='<%#Eval("StudentID") +"$"+ Eval("LessonDegreeID") +"$"+Eval("StuClassID") %>'
                                                        OnClientClick="return confirm('你确定选择的班级是正确的？');" Text="选择"></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </asp:GridView>
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>

                    <div class=" divremark">
                        <b>注意事项：</b>
                        <br />
                        此功能仅供管理员admin用于考勤测试，正式考勤请部署麦田考勤客户端工具。<br />
                        ID卡号栏里同时可以输入学号、工号进行考勤。
                    </div>

                </div>
            </div>

        </div>
    </form>

</body>
</html>
