示例#1
0
        private void BuildTree(int id)
        {
            tv.Nodes.Clear();
            if (id == 1 || id == 2)
            {
                NodeItems = BlLa.GetLa(3, 0, id.ToString());
            }
            else
            {
                NodeItems = BlIncomeExp.GetIncomeExp(4, 0, id.ToString());
            }
            if (NodeItems.Rows.Count > 0)
            {
                // add top level nodes
                DataView vw = NodeItems.DefaultView;
                vw.RowStateFilter = DataViewRowState.CurrentRows;
                vw.RowFilter      = "ParentID=0";
                // top level items

                // using the new (.net 2.0)in Memory Table Reader
                DataTable       tb  = vw.ToTable();
                DataTableReader rdr = tb.CreateDataReader();

                // Calls BuildChildNodes for each top level node - it's recursive for nested branches
                while (rdr.Read())
                {
                    TreeNode node = new TreeNode();
                    node.Text  = rdr["Org_Category_Name"].ToString();
                    node.Value = rdr["ID"].ToString();

                    // could use ordinal for more speed, using column name for clarity
                    this.tv.Nodes.Add(node);
                    // get children recursively
                    Int32 parentID = Convert.ToInt32(rdr[0]);
                    // first column is item ID
                    this.BuildChildNodes(parentID, ref node);
                }

                rdr.Close();
            }

            // add to cache

            System.Collections.Generic.List <TreeNode> nds = new System.Collections.Generic.List <TreeNode>();
            foreach (TreeNode nd in this.tv.Nodes)
            {
                nds.Add(nd);
            }
        }
示例#2
0
 private void GetDetails(int id)
 {
     txt_roottopic.Enabled = true;
     if (id == 1 || id == 2)
     {
         DataTable dt = BlLa.GetLa(10, 0, tv.SelectedNode.Value);
         if (dt.Rows.Count > 0)
         {
             txt_roottopic.Text     = dt.Rows[0]["Parent"].ToString();
             txtRootCode.Text       = dt.Rows[0]["ParentCode"].ToString();
             txtParticular.Text     = dt.Rows[0]["LA"].ToString();
             txtParticularcode.Text = dt.Rows[0]["LA_Code"].ToString();
             if (dt.Rows[0]["LA_Child"] != null)
             {
                 //ddlUnder.SelectedValue = dt.Rows[0]["LA_Child"].ToString();
             }
             chkPrimary.Checked    = Convert.ToBoolean(dt.Rows[0]["LA_Primary"].ToString());
             chkIsNeeded.Checked   = Convert.ToBoolean(dt.Rows[0]["IsNeeded"].ToString());
             btnSubmit.CommandName = "Update";
             btnSubmit.Text        = "Update";
         }
     }
     else if (id == 3 || id == 4)
     {
         DataTable dt = BlIncomeExp.GetIncomeExp(17, 0, tv.SelectedNode.Value);
         if (dt.Rows.Count > 0)
         {
             txt_roottopic.Text     = dt.Rows[0]["Parent"].ToString();
             txtRootCode.Text       = dt.Rows[0]["ParentCode"].ToString();
             txtParticular.Text     = dt.Rows[0]["IE"].ToString();
             txtParticularcode.Text = dt.Rows[0]["IE_Code"].ToString();
             if (dt.Rows[0]["IE_Child"] != null)
             {
                 //ddlUnder.SelectedValue = dt.Rows[0]["IE_Child"].ToString();
             }
             chkPrimary.Checked    = Convert.ToBoolean(dt.Rows[0]["IE_Primary"].ToString());
             chkIsNeeded.Checked   = Convert.ToBoolean(dt.Rows[0]["IsNeeded"].ToString());
             btnSubmit.CommandName = "Update";
             btnSubmit.Text        = "Update";
         }
     }
     else
     {
     }
 }