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

<%@ Register Src="../../UserControl/LoadButton.ascx" TagName="LoadButton" TagPrefix="uc2" %>
<!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">
<script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="/Themes/Scripts/Validator/JValidator.js" type="text/javascript"></script>
<script src="/Themes/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
<script src="../../Themes/Scripts/artDialog/artDialog.js" type="text/javascript"></script>
<script src="../../Themes/Scripts/artDialog/iframeTools.js" type="text/javascript"></script>
<head id="Head1" runat="server">
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <title>
        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Student_situ")%></title>
    <style type="text/css">
        td a { color: Blue; }
        op_Result</style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="btnbartitle">
        <div>
            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Student_situ")%>
        </div>
    </div>
    <div class="btnbarcontetn">
        <div style="text-align: right;">
            <uc2:LoadButton ID="LoadButton1" runat="server" />
        </div>
    </div>
    <div class="div-body">
        <table class="grid" id="table1">
            <thead>
                <tr id="jsonhead">
                    <th style="width: 30px; text-align: center;">
                        <%--  <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_Form_no")%>--%>
                    </th>
                    <th style="width: 60px; text-align: center;">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_Form_no")%>
                    </th>
                    <th style="width: 80px; text-align: center;">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Name")%>
                    </th>
                    <th style="width: 100px; text-align: center;">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Accout")%>
                    </th>
                    <th style="width: 50px; text-align: center;">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Sex")%>
                    </th>
                    <th style="width: 200px; text-align: center;">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Title")%>
                    </th>
                    <th style="width: 200px; text-align: center;">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("mail_emailname")%>
                    </th>
                    <th>
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("user_prov")%>
                    </th>
                    <th>
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("user_city")%>
                    </th>
                    <th>
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("user_area")%>
                    </th>
                    <th>
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Phone")%>
                    </th>
                    <th>
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_CreatDate")%>
                    </th>
                    <th>
                    状态
                    </th>
                </tr>
            </thead>
            <tbody id="tbodys">
            </tbody>
        </table>
    </div>
    </form>
    <script type="text/javascript">
        $(function () {          
            divresize(90);
            FixedTableHeader("#table1", $(window).height() - 121);
            var param = '<%=json %>';
            //筛选后页面跳转进来 如果json不为空 则在弹框中显示，那么 需要跳转到外页
            //首次不加载数据 不等于空时，进行筛选查询
            if (param != "") {    
                Script(param);
            }
        });

        //查询数据
        function Script(param) {
        alert(param);
            getAjax("/Training/UserStudents/User_serlect.ashx", "json=" + param, function (result) {
                if (result != 1) {
                    var userlist = eval('(' + result + ')');
                    ShowHtml(eval('(' + userlist.usertb + ')'), eval('(' + userlist.jsonhead + ')'));
                } else {
                    showTipsMsg(lgwzdrhxx, 1000, 5);
                }
            });
        }

        //查询
        function select() {
            var url = "/Training/UserStudents/User_select_Info.aspx";
            top.openDialog(url, 'User_select_Info', '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_Index")%>', 800, 350, 50, 50);

        }

        //数据呈现
        function ShowHtml(userlist, jsonhead) {
            var htm = "";
            for (var i in jsonhead) {$("#jsonhead").append("<th>" + jsonhead[i] + "</th>");}
            for (var i = 0; i < userlist.length; i++) {
                htm += "<tr>";
                for (var x in userlist[i]) {
                    if (x == "User_ID") {
                        htm += "<td><input type=\"checkbox\" name=\"userid\" value=\"" + GetNull(userlist[i]["User_ID"]) + "\"></td>";
                    }else {
                        var uistr=GetNull(userlist[i][x]);
                        if(x=="CreateDate"){
                            uistr=JsonDate(uistr);
                        }else if(x=="User_Sex"){ 
                            if (uistr == 1) {
                                uistr="男";
                            }else if (uistr == 0) {
                                uistr= "女"; 
                            }
                        }else if(x=="deletemark"){
                            if (uistr == 1) {
                                uistr="<span style=\"color: blue;\">正常</span>";
                            }else if (uistr == 2) {
                                uistr= "<font color=\"red\">未授权</font>"; 
                            }
                        }
                        htm += "<td>" + uistr + "</td>";
                    }
                }
                htm += "</tr>";
            }
            $("#tbodys").append(htm);
        }

        function GetNull(obj) {
            if (obj == null|| obj == "" || obj == undefined) {
                return "";
            } /*else if (obj == 1) {
                return "男";
            } else if (obj == 0) {
                return "女";
            } else if (obj.indexOf("Date") > 0) {
                return JsonDate(obj);
            }*/ else {
                return obj;
            }
            return obj;
        }

        function JsonDate(obj) {
            var data = obj;
            var date = new Date(parseInt(data.replace("/Date(", "").replace(")/", ""), 10));
            return date.getFullYear() + "-" + (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-" + (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " " + (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":" + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes());
        }

        //导出
        function inport() {

            var html = "<table border=1>" + $("#table1").html() + "</table>";
            post('/RMBase/SysWindows/WindowsExport.ashx', { ExportType: "not", ExportHTML: html, TableName: "result" });
            GoTableExport("not", "table1");
        }

        //提交数据，下载导出文件
        function post(URL, PARAMS) {
            var temp = document.createElement("form");
            temp.action = URL;
            temp.method = "post";
            temp.style.display = "none";
            for (var x in PARAMS) {
                var opt = document.createElement("textarea");
                opt.name = x;
                opt.value = PARAMS[x];
                //alert(opt.name);      
                temp.appendChild(opt);
            }
            document.body.appendChild(temp);
            temp.submit();
            return temp;
        }

         //授 权
        function accredit() {
            var key = CheckboxValue();
            alert(key);
            if (IsEditdata(key)) {
                var parm = 'action=accredit&user_ID=' + key;
                showConfirmMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_sqm")%>', function (r) {
                    if (r) {
                        getAjax('/RMBase/SysUser/UserInfo.ashx', parm, function (rs) {
                            if (parseInt(rs)==1) {
                                showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_sqcg")%>！", 2000, 4);
                                windowload();
                            }else if(parseInt(rs)==2)
                            {
                               showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_ashx_NullSysPostemail")%>！", 4000, 5);
                                windowload();
                            }else if(parseInt(rs)==3)
                            {
                              showTipsMsg("<span style='color:red'><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_ashx_Postemail")%></span>", 4000, 5);
                                windowload();
                            }
                            else {
                                showTipsMsg("<span style='color:red'><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_sqsb")%></span>", 4000, 5);
                            }
                        });
                    }
                });
            }
        }
        
          //修改
        function edit() {
            var key = CheckboxValue();
            if (IsEditdata(key)) {
                var url = "/Training/UserStudents/UserStudent_Form.aspx?key=" + key;
                top.openDialog(url, 'UserInfo_Form', '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_Index")%> - <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Edit")%>', 700, 350, 50, 50);
            }
        }
        
    </script>
</body>
</html>
