using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using SysCore;
using SysCore.Control;
using SysCore.Model;
using SysCore.DAL;

public partial class Base_Cost_Cost_Tree : System.Web.UI.Page
{
    public Hashtable xview = new Hashtable();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            CreateTree();
        }
    }
    /// <summary>
    /// 绑定控件数据源
    /// </summary>
    public void CreateTree()
    {
        DataTable tb = new CostDAL().GetListAll("");

        DTree dt = new DTree("dt");
        dt.AddChildNode("0", "-1", "费用", "javascript:SelectCategory(\\'0\\')", "", "", "../../Scripts/dtree/images/folder.gif");
        foreach (DataRow dr in tb.Rows)
        {
            string cst_id = dr["cst_id"].ToString();
            string parent_id = dr["parent_id"].ToString();
            string cst_code = dr["cst_code"].ToString(); 
            string cst_name = dr["cst_name"].ToString();
            dt.AddChildNode(cst_id, parent_id, cst_code + " " + cst_name, "javascript:SelectCategory(\\'" + cst_id + "\\')", "", "", "../../Scripts/dtree/images/folder.gif");
        }

        xview.Add("dtree", dt.GetTree());
    }
}
