<%@ Page Language="C#" AutoEventWireup="true" Inherits="Admin_Exam_ztee" Codebehind="SelectKM.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>选择会计科目</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <script src="/KS_Inc/Jquery.js" type="text/javascript"></script>
	<script src="/KS_Inc/ztree/jquery.ztree.all-3.5.min.js"  type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" media="screen" href="/KS_Inc/ztree/zTreeStyle/zTreeStyle.css" />
    <script type="text/javascript">
        var setting = {           
            view: {
                showLine: true
            },
            data: {
                simpleData: {
                    enable: true
                }
            },

            callback: {
                onClick: function (event, treeId, treeNode, clickFlag) {
                    if (true) {
                        document.getElementById("text1").value = treeNode.name;
                      // alert(" 节点id是：" + treeNode.id + ", 节点文本是：" + treeNode.name);
                    }
                },
                onDblClick: function (event, treeId, treeNode, clickFlag) {
                    setReturn();
                }

            }
        }
        
       var zNodes = <%=sb.ToString()%>
        function filter(treeId, parentNode, childNodes) {
        if (!childNodes)
            return null;
        for (var i = 0, l = childNodes.length; i < l; i++) {
            childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
        }
        return childNodes;
        }

    $(document).ready(function(){
        $.fn.zTree.init($("#tree"), setting, zNodes);
    });

    function winClose() {
        try {
            top.box.close();
        } catch (e) {
            window.close();
        }
    }

    function setReturn() {
        var v=$("#text1").val();
        if (v==''){
            alert('没有选择科目！');
            return false;
        }else{
            <%
         if (KSCMS.S("from")=="admin"){
        %>
            top.frames["main"].document.getElementById("<%=KSCMS.S("FieldID")%>").value = v;
            top.box.close();
            <%}
         else if (KSCMS.S("from")=="paper"){
        %>
            $("input[name=<%=KSCMS.S("FieldID")%>]", parent.document).val(v);
           // top.document.getElementById("<%=KSCMS.S("FieldID")%>").value = v;
           top.box.close();
            <%}
         else if (KSCMS.S("from") == "editst")
         {%>
            window.returnValue = v;
            window.close();
            <%}%>
        }
    }
        window.onunload=SetReturnValue;
        function SetReturnValue() {
            if (typeof (window.returnValue) != 'string') window.returnValue = '';
        }
    </script> 
</head>

<body>
    <form id="form1" runat="server">
        <div style="text-align:center;margin-top:2px;">
            <input type="button" value="确定" onclick="setReturn();"/>
            <input type="button" value="取消" onclick="winClose();" />
        </div>
    <div>
     <ul id="tree" class="ztree"></ul>
    </div>

     <input class="text" id="text1" type="hidden"/> 

        <div style="text-align:center">
            <input type="button" value="确定" onclick="setReturn();"/>
            <input type="button" value="取消" onclick="winClose();" />
        </div>

    </form>
</body>
</html>
