<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserList_List.aspx.cs"
    Inherits="RM.Web.Training.Certificate.UserList_List" %>

<%@ Register Src="../../UserControl/PageControl.ascx" TagName="PageControl" TagPrefix="uc1" %>
<!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> <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_information")%></title>
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script type="text/javascript">
        //回车键
        document.onkeydown = function (e) {
            if (!e) e = window.event; //火狐中是 window.event
            if ((e.keyCode || e.which) == 13) {
                var obtnSearch = document.getElementById("lbtSearch");
                obtnSearch.click();
            }
        }
        $(function () {
            if (QueryString('key').length < 1) {
                showTipsMsg(' <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CertificateUser_choose")%>', 3000, 3);
                top.frames["main"].location = '/Training/Certificate/CertificateManager.aspx';
                return;
            }
            divresize(90);
            FixedTableHeader("#table1", $(window).height() - 118);
            document.getElementById('delCertificate').onclick = function () {
                var value = CheckboxValue();
                if (value.length < 1) {
                    showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CertificateUser_certificate")%>', 2000, 3);
                    return false;
                }
                var users = value.split(',');
                for (var i = 0, len = users.length; i < len; i++) {
                    users[i] = '\'' + users[i] + '\'';
                }
                value = users.join(',');

                var zsbh = $("#zsbh").val();
                if (zsbh.length < 1) {
                    showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("certificate_zsbh")%>！', 2000, 3);
                    return false;
                }
                //预览证书样式
                //颁发给选中的用户
                $.ajax({
                    url: "/Training/Certificate/AwardCertificate.ashx",
                    type: "post",
                    contentType: 'application/x-www-form-urlencoded',
                    //  contentType: 'application/json',
                    //  ajax ContentType请求为application/json，有时候一般处理程序并不能解析到参数，在监控了jQuery.post()方法后将请求头修改的和post一样，测试通过，可以接收到参数，目前原因未知。
                    data: { users: value, key: QueryString('key'), zsbh: zsbh },
                    dataType: "json",
                    success: function (data) {
                        switch (data) {
                            case 0:
                                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CG")%>！', 2500, 4); 
                                UsersWindowsClose();
                                break;
                            case 1:
                                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("SB")%>', 4000, 3);
                                break;
                            case 2:
                                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("SB")%>', 4000, 3);
                                break;
                            case undefined:
                            case null:
                                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("SB")%>', 4000, 3);
                                break;
                            default:
                                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("SB")%>', 4000, 3);
                                break;
                        }
                    },
                    error: function () {
                        showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Abnormal network connection")%>', 2000, 3);
                    }
                });
                return false;
            };
        });
        //颁发证书
        function GetusersWindows() {
            var value = CheckboxValue();
            if (value.length < 1) {
                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CertificateUser_certificate")%>！', 2000, 3);                
                return ;
            }
            var users = value.split(',');
            if (users.length > 1) {
                
                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("certificate_selone")%>！', 2000, 3);
                return ;
            }
            
             
            $("#GetUserWindows_bg").show();
            $("#GetUserWindows").show();
        }
        //验证用户信息
        function validateUser() {
            var value = CheckboxValue();
            if (value.length < 1) {
                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserList_yzxyxx")%>！', 2000, 3);      
                return;
            }
            var users = value.split(',');
            if (users.length > 1) {

                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("certificate_selone")%>！', 2000, 3);
                return;
            }            
            var url = "/Training/Face/Face_List.aspx?userid=" + value;
            top.openDialog(url, 'certificateTypeAdd', '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Certificate_issued")%> - <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserList_selUser")%>', 900, 400, 50, 50);
        }

        function UsersWindowsClose() {
            $("#GetUserWindows_bg").hide();
            $("#GetUserWindows").hide();
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="btnbartitle">
        <div>
            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Certificate_issued")%> - <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_information")%>
        </div>
    </div>
    <div class="btnbarcontetn">
        <div style="float: left;">
            <select id="Searchwhere" class="Searchwhere" runat="server">
            </select>
            <input type="text" id="txt_Search" class="txtSearch SearchImg" runat="server" style="width: 100px;" />
            <asp:LinkButton ID="lbtSearch" runat="server" class="button green" OnClick="lbtSearch_Click"><span class="icon-botton"
            style="background: url('../../Themes/images/Search.png') no-repeat scroll 0px 4px;">
        </span><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Name")%></asp:LinkButton>
        </div>
        <div style="text-align: right">

        <%--<a class="button green" href="javascript:validateUser();" title="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserList_selUser")%>">
                <span class="icon-botton" style="background: url('/Themes/images/16/book_open_mark.png') no-repeat scroll 0px 4px;">
                </span><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserList_selUser")%></a>--%>

            <a class="button green" href="javascript:GetusersWindows();" title="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CertificateUser_certificate")%>">
                <span class="icon-botton" style="background: url('/Themes/images/16/book_open_mark.png') no-repeat scroll 0px 4px;">
                </span><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Certificate_issued")%></a>
        </div>
    </div>
    <div class="div-body">
        <table id="table1" class="grid">
            <thead>
                <tr>
                    <td style="width: 20px; text-align: left;">
                        <label id="checkAllOff" onclick="CheckAllLine()" title="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Quanxuan")%>">
                            &nbsp;</label>
                    </td>
                    <td style="width: 60px; text-align: center;">
                       <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_code")%> 
                    </td>
                    <td style="width: 80px; text-align: center;">
                       <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Name")%> 
                    </td>
                    <td style="width: 100px; text-align: center;">
                       <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Accout")%> 
                    </td>
                    <td style="width: 50px; text-align: center;">
                       <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Sex")%> 
                    </td>
                    <td style="width: 200px; text-align: center;">
                       <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Title")%> 
                    </td>
                    <td style="width: 50px; text-align: center;">
                       <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_State")%> 
                    </td>
                    <td>
                       <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Description")%> 
                    </td>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="rp_Item" runat="server" OnItemDataBound="rp_ItemDataBound">
                    <ItemTemplate>
                        <tr>
                            <td style="width: 20px; text-align: left;">
                                <input type="checkbox" value="<%#Eval("User_ID")%>" name="checkbox" />
                            </td>
                            <td style="width: 60px; text-align: center;">
                                <%#Eval("User_Code")%>
                            </td>
                            <td style="width: 80px; text-align: center;">
                                <a href="javascript:void()">
                                    <%#Eval("User_Name")%></a>
                            </td>
                            <td style="width: 100px; text-align: center;">
                                <%#Eval("User_Account")%>
                            </td>
                            <td style="width: 50px; text-align: center;">
                                <asp:Label ID="lblUser_Sex" runat="server" Text='<%#Eval("User_Sex")%>'></asp:Label>
                            </td>
                            <td style="width: 200px; text-align: center;">
                                <%#Eval("Title")%>
                            </td>
                            <td style="width: 50px; text-align: center;">
                                <asp:Label ID="lblDeleteMark" runat="server" Text='<%#Eval("DeleteMark")%>'></asp:Label>
                            </td>
                            <td>
                                <%#Eval("User_Remark")%>
                            </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        <% if (rp_Item != null)
                           {
                               if (rp_Item.Items.Count == 0)
                               {
                                   Response.Write("<tr><td colspan='8' style='color:red;text-align:center'> "+RM.Common.DotNetConfig.LanguageHelper.GetKey("Null")+"</td></tr>");
                               }
                           } %>
                    </FooterTemplate>
                </asp:Repeater>
            </tbody>
        </table>
    </div>
    <uc1:PageControl ID="PageControl1" runat="server" />
    </form>
    <div id='GetUserWindows_bg' style='display: none; position: absolute;width:100%;height:100%; top: 0px;left: 0px;right:0px;background-color: #777;filter:progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75);opacity: 0.6;z-index:98;'></div>
    <div id="GetUserWindows" style="position: absolute; display: none; background-color:#fff; top:20%;z-index:99; left:30%; padding:3%; text-align:center; "><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("certificate_zsnum")%>：<input type="text" class="txt" id="zsbh" /> <br /><br />    
     <input type="button" value="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Save")%>" id="delCertificate" class="button"  /> &nbsp;  &nbsp;  &nbsp; <input type="button" onclick="UsersWindowsClose()" value="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Close")%>" class="button" /></div>
</body>
</html>
