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

<!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("UserInfo_Form")%></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/Validator/JValidator.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/DatePicker/WdatePicker.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>
    <script src="/Themes/Scripts/TreeTable/jquery.treeTable.js" type="text/javascript"></script>
    <link href="/Themes/Scripts/TreeTable/css/jquery.treeTable.css" rel="stylesheet"
        type="text/css" />
    <link href="/Themes/Scripts/TreeView/treeview.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/TreeView/treeview.pack.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/jsAddress.js" type="text/javascript"></script>
    <script type="text/javascript" src="/Live/swfobject.js"></script>
    <script type="text/javascript">
        //初始化
        $(function () {
            Setform();
            treeAttrCss();
            $('#table2').hide();
            $('#table3').hide();
            $('#table4').hide();
            $('#table5').hide();
            $('#table6').hide();
            ChekOrgClick();
            
            $("#photo").hover(function () {
                $("#photo").css("width", "200px");
            }
            , function () {
                $("#photo").css("width", "50px");
            });
        });

        //点击切换面板
        var IsFixedTableLoad = 1;
        function panel(obj) {
            if (obj == 1) {
                $('#table1').show();
                $('#table2').hide();
                $('#table3').hide();
                $('#table4').hide();
                $('#table5').hide();
                $('#table6').hide();
            } else if (obj == 2) {
                $('#table1').hide();
                $("#table2").show();
                $('#table3').hide();
                $('#table4').hide();
                $('#table5').hide();
                $('#table6').hide();
            } else if (obj == 3) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').show();
                $('#table4').hide();
                $('#table5').hide();
                $('#table6').hide();
            } else if (obj == 4) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').hide();
                $('#table4').show();
                $('#table5').hide();
                $('#table6').hide();
            } else if (obj == 5) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').hide();
                $('#table4').hide();
                $('#table5').show();
                $('#table6').hide();            
            } else if (obj == 6) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').hide();
                $('#table4').hide();
                $('#table5').hide();
                $('#table6').show();
            }
                if (IsFixedTableLoad == 1) {
                    FixedTableHeader("#dnd-example", $(window).height() - 105);
                    IsFixedTableLoad = 0;
                }
            }
        
        //附加信息表单赋值
        function Setform() {
            var pk_id = GetQuery('key');
            if (IsNullOrEmpty(pk_id)) {
                var strArray = new Array();
                var strArray1 = new Array();
                var item_value = $("#AppendProperty_value").val(); //后台返回值
                strArray = item_value.split(';');
                for (var i = 0; i < strArray.length; i++) {
                    var item_value1 = strArray[i];
                    strArray1 = item_value1.split('|');
                    $("#" + strArray1[0]).val(strArray1[1]);
                }
            }
        }
        //获取表单值
        function CheckValid() {
            if (!CheckDataValid('#form1')) {
                return false;
            }
            if (!IsNullOrEmpty(ChekOrgVale)) {
                showWarningMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserStudent_Form_xzbm")%>");                
                return false;
            }
            var item_value = '';
            $("#AppendProperty_value").empty;
            $("#table2 tr").each(function (r) {
                $(this).find('td').each(function (i) {
                    $(this).find('input,select').each(function(ii){
                        var pk_id = $(this).attr('id');
                        if ($(this).val() != "" && $(this).val() != "==请选择==" && $(this).val() != undefined && pk_id!= undefined) {
                            item_value += pk_id + "|" + $(this).val() + ";";
                        }
                    });
                });
            });
            $("#AppendProperty_value").val(item_value);
            $("#checkbox_value").val(CheckboxValue())
            if (!confirm('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("AllotAuthority_Form_save")%>')) {
                return false;
            }
        }
        //验证所属部门必填
        var ChekOrgVale = "";
        function ChekOrgClick() {
            var pk_id = GetQuery('key');
            if (IsNullOrEmpty(pk_id)) {
                ChekOrgVale = 1;
            }
            $("#table3 [type = checkbox]").click(function () {
                ChekOrgVale = "";
                if ($(this).val() != "") {
                    if ($(this).attr("checked") == "checked") {
                        ChekOrgVale = 1;
                    };
                }
            })
        }

        var fujianID = "";
        //附件上传
        function shangchuan_fj(obj) {
            fujianID = $(obj).attr("data");
            var flashvars = {
                FileType: '*.bmp;*.jpg;*.jpge;*.gif;*.png;*.rar;*.zip;*.doc;*.docx;*.wps;*.avi;*.chm;*.mp3;*.mp4;*.xls;*.xlsx;*.txt;*.pdf;*.ppt;*.pptx',
                FileMaxCount: 1,
                FilePath: '/WeiXin/UploadImage.ashx',
                FileSize: 1024 * 300
            };
            FlexUpload(flashvars);
        }
        //Flex文件上传
        function FlexUpload(flashvars) {
            $("#tksup").show();
            $("#tksup").append("<div id='ad1'></div>");

            var swfVersionStr = "10.0.0";
            var xiSwfUrlStr = "/live/playerProductInstall.swf";
            var params = {};
            params.quality = "high";
            params.bgcolor = "#ffffff";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            var attributes = {};
            attributes.id = "ad1";
            attributes.name = "ad1";
            attributes.align = "middle";
            swfobject.embedSWF("/Live/TKS-UP.swf", "ad1", "600", "270", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
        }
        //Flex上传回调函数
        //---name:为文件名---data:FilePath地址返回值
        function uploadCompelete(name, data) {
            //附件
            var fujian = eval('(' + data + ')');
            //alert(fujian.error);
            if (fujian.error == "0") {
                $("#" + fujianID).val("<a target='_blank' href='" + fujian.url + "'>" + fujian.message + "</a>");
                showFaceMsg("<<"+fujian.message+">>上传成功");
               $("#" + fujianID).val("<a href='http://"+fujian.url+"'></a>");
            } else if (fujian.error == "1") {
                showFaceMsg(fujian.message);
            }
        }

         //全部文件上传结束后触发
        function uploadEnd(name) {
            $("#tksup").hide();
            $("#ad1").remove();
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">    
    <%-- 所有打勾复选框值--%>
    <input id="checkbox_value" type="hidden" runat="server" />
    <%--获取附加信息值--%>
    <input id="AppendProperty_value" type="hidden" runat="server" />
    <div class="frmtop">
        <table style="padding: 0px; margin: 0px;" cellpadding="0" cellspacing="0">
            <tr>
                <td id="menutab" style="vertical-align: bottom;">
                    <div id="tab0" class="Tabsel" onclick="GetTabClick(this);panel(1)">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Jbxx")%></div>
                    <div id="tab1" class="Tabremovesel" onclick="GetTabClick(this);panel(2);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Fjxx")%></div>
                    <div id="tab2" class="Tabremovesel" onclick="GetTabClick(this);panel(3);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Role_Form_ssbm")%></div>
                    <div id="tab3" class="Tabremovesel" onclick="GetTabClick(this);panel(4);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Role_Info_ssjc")%></div>
                    <div id="tab4" class="Tabremovesel" onclick="GetTabClick(this);panel(5);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Role_Info_ssgzz")%></div>
                    <div id="tab5" class="Tabremovesel" onclick="GetTabClick(this);panel(6);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Role_Info_sskm")%></div>
                </td>
            </tr>
        </table>
    </div>
    <div class="div-frm" style="height: 275px;">
        <%--基本信息--%>
        <table id="table1" border="0" cellpadding="0" cellspacing="0" class="frm">
            <tr>
                <th>
                    <input type="hidden" value="3" id="User_RoleType" runat="server" />
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Student_No")%>:
                </th>
                <td>
                    <input id="User_Code" runat="server" type="text" class="txt" datacol="yes" err="职工工号"
                        checkexpession="NotNull" style="width: 200px" />
                </td>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Student_name")%>:
                </th>
                <td>
                    <input id="User_Name" runat="server" type="text" class="txt" datacol="yes" err="学生姓名"
                        checkexpession="NotNull" style="width: 200px" />
                </td>
            </tr>
            <tr>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Student_sex")%>:
                </th>
                <td>
                    <select id="User_Sex" class="select" runat="server" style="width: 206px">
                    </select>
                </td>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Email")%>:
                </th>
                <td>
                    <input id="Email" runat="server" type="text" class="txt" datacol="yes" err="电子邮箱"
                        checkexpession="EmailOrNull" style="width: 200px" />
                </td>
            </tr>
            <tr>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Accout")%>:
                </th>
                <td>
                    <input id="User_Account" runat="server" type="text" class="txt" datacol="yes" err="登录账户"
                        checkexpession="NotNull" style="width: 200px" />
                </td>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Pwd")%>:
                </th>
                <td>
                    <input id="User_w" runat="server" type="text" class="txt" datacol="yes" err="登录密码"
                        checkexpession="NotNull" style="width: 200px" />
                </td>
            </tr>
            <tr>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("question_lxdh")%>:
                </th>
                <td colspan="3">
                    <input id="Phone" runat="server" type="text" class="txt" style="width: 200px" />
                </td>
            </tr>
            <tr>
            <th><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("user_area")%>:</th><td colspan="3">
                <asp:DropDownList ID="Province" runat="server">
                </asp:DropDownList>                
                <select id="City" runat="server"></select>　<select id="Area" runat="server"></select>
                <input type="text" style="display:none;"  id="txtProvince" runat="server" />
                <input type="text" style="display:none;" id="txtCity" runat="server" />
                <input type="text" style="display:none;" id="txtArea" runat="server" />
</td>
            </tr>
            <tr>
            <tr>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Student_Remark")%>:
                </th>
                <td colspan="3">
                    <textarea id="User_Remark" class="txtRemark" runat="server" style="width: 552px;
                        height: 83px;"></textarea>
                </td>
            </tr>
            <tr>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Photo")%>
                </th>
                <td colspan="3" style="border: 1px #ccc solid;">
                    <asp:FileUpload ID="FileUpload1" runat="server" Style="width: 252px;" />
                    <img src="/Mall/User_Image.ashx?id=<%=_key %>" width="50" style="position: absolute;
                        top: 30px; left: 0;" id="photo" />
                </td>
            </tr>
        </table>
        <%--附加信息--%>
        <table id="table2" border="0" cellpadding="0" cellspacing="0" class="frm">
            <%=str_OutputHtml.ToString()%>
        </table>
        <%--所属部门--%>
        <div id="table3">
            <div class="btnbartitle">
                <div>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Organization")%>
                </div>
            </div>
            <div class="div-body" style="height: 245px;">
                <ul class="strTree">
                    <%=strOrgHtml.ToString()%>
                </ul>
            </div>
        </div>
        <%--所属角色--%>
        <div id="table4">
            <div class="btnbartitle">
                <div>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Role_Info_ssjc")%>
                </div>
            </div>
            <div class="div-body" style="height: 245px;">
                <ul class="strTree">
                    <%=strRoleHtml.ToString()%>
                </ul>
            </div>
        </div>
        <%--所属工作组--%>
        <div id="table5">
            <div class="btnbartitle">
                <div>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroup")%>
                </div>
            </div>
            <div class="div-body" style="height: 245px;">
                <ul class="strTree">
                    <%=strUserGroupHtml.ToString()%>
                </ul>
            </div>
        </div>
        <%--所属选科目--%>
        <div id="table6">
            <div class="btnbartitle">
                <div>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterIndex_xzkm")%>
                </div>
            </div>
            <div class="div-body" style="height: 245px;">
                <ul class="strTree">
                    <%=strUserkemuHtml.ToString()%>
                </ul>
            </div>
        </div>
    </div>
    <div class="frmbottom">
        <asp:LinkButton ID="Save" runat="server" class="l-btn" OnClientClick="return CheckValid();"
            OnClick="Save_Click"><span class="l-btn-left">
            <img src="/Themes/Images/disk.png" alt="" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Save")%></span></asp:LinkButton>
        <a class="l-btn" href="javascript:void(0)" onclick="OpenClose();"><span class="l-btn-left">
            <img src="/Themes/Images/cancel.png" alt="" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Close")%></span></a>
    </div>
    </form>

    <div id="tksup" style="display: none; border: 1px #ccc solid; width: 610px; margin-left: 10px;background-color: White; padding-left: 10px;position: absolute;top:30px;left:0px;"></div>
</body>
</html>
<script type="text/javascript">
    
    $(function () {
        if ("<%=ordertype%>" == "2") {
            $("#tab3").hide();
            $("#tab4").hide();
        }
        addressInit('Province', 'City', 'Area', '<%=ProvinceStr %>', '<%=CityStr %>', '<%=AreaStr %>');
    });


    window.onload = function () {
        $("input[class=file]").each(function () {
            var thval = $(this).val();
            if (thval != "") {
                $(this).after("　" + thval);
                var imgsrc = thval.substr(thval.indexOf("href=")+6, thval.indexOf(">") - thval.indexOf("href=")-7);                
                $(this).after("<img src=\""+imgsrc+"\" width=\"50\" />");
            }
        });
                
        $("input[value=<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("AnnexUpload")%>]").each(function () {
            $(this).hide();
        });
    }

</script>
