本文介绍了请帮助MLM Logic绑定二叉树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经gon all

MLM逻辑

但不能为我工作或没有正确使用

i have already gon all
MLM logic
but not work for me or not got properly

TRID                 CID                  MCID                 PRDID      
-------------------- -------------------- -------------------- ----------- 
1                    1                    0                    1           
2                    2                    1                    1           
3                    3                    1                    3          
4                    4                    2                    2           
5                    5                    3                    2           
6                    6                    6                    3           
7                    7                    3                    2           
8                    8                    2                    2           
9                    9                    1                    2           
10                   10                   4                    4           
11                   11                   10                   2           





MCID主人ID和CID意味着孩子





MCID Master ID and CID means Child

MLM objMLM = new MLM();
  int q;
  protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          DataSet MLMUser = objMLM.SelectNode("1");
          if (MLMUser.Tables[0].Rows.Count > 0)
          {
              ChildNode(MLMUser);
          }
      }


  }
  private void ChildNode(DataSet Parent)
  {
      TreeLogic(Parent);

      if (Parent.Tables[0].Rows.Count > 0)
      {


          if (Parent.Tables[0].Rows[0]["MCID"].ToString() == Parent.Tables[0].Rows[0]["CID"].ToString())
          {
              q = 1;
          }
          else
          {
              q = 0;
          }
          for (int i = q; i < (Parent.Tables[0].Rows.Count); i++)
          {

              string MID = Parent.Tables[0].Rows[i]["CID"].ToString();
              DataSet MLMUserChild = objMLM.SelectNode(MID);
              if (MLMUserChild.Tables[0].Rows.Count > 0)
              {
                  ChildNode(MLMUserChild);
              }

          }



      }


  }
    private void TreeLogic(DataSet Parent)
  {
      TreeNode childnode, headnode;
      headnode = new TreeNode();
      if (TreeView1.Nodes.Count == 0)
      {



          headnode.Text = Parent.Tables[0].Rows[0]["MCID"].ToString();
          TreeView1.Nodes.Add(headnode);
          if (Parent.Tables[0].Rows[0]["MCID"].ToString() == Parent.Tables[0].Rows[0]["CID"].ToString())
          {
              q = 1;
          }
          else
          {
              q = 0;
          }
          //Loop for binding Parent Values
          for (int i = q; i < Parent.Tables[0].Rows.Count; i++)
          {
              TreeNode firstchild = new TreeNode();
              firstchild.Text = Parent.Tables[0].Rows[i]["MCID"].ToString();



              //Loop for binding Child Values.
              for (int j = 0; j < Parent.Tables[0].Rows.Count; j++)
              {
                  childnode = new TreeNode();
                  childnode.Text = Parent.Tables[0].Rows[j]["CID"].ToString();
                  headnode.ChildNodes.Add(childnode);

                  //more over can expand the list.

              }
              break;
          }
      }
      else
      {



          foreach (TreeNode node in TreeView1.Nodes)
          {




              TreeNodeCollection child = node.ChildNodes;


              for (int i = 0; i < child.Count; i++)
              {

                  for (int j = 0; j < Parent.Tables[0].Rows.Count; j++)
                  {
                     ["CID"].ToString();
                      if (child[i].Text == Parent.Tables[0].Rows[j]["MCID"].ToString())
                      {
                          childnode = new TreeNode();
                          childnode.Text = Parent.Tables[0].Rows[j]["CID"].ToString();
                          child[i].ChildNodes.Add(childnode);
                      }


                  }


              }







          }
    }
  }







ALTER PROCEDURE [dbo].[SelectNode]
	@User varchar(max)
AS
BEGIN
select * from TBL_TRN_PRODUCT where MCID=@User order by MCID
END



我得到此输出







但我希望以正确的方式作为MLM在其父母的其他孩子身边ld go



或者我想检查孩子是否存在然后加入dat孩子其他孩子



MCID 4 10是10和11的父母不来我的图片


I get this output
OutPut My


but i want in right way as MLM under its parent other child should go

or i want to check if Child exist then add in dat child other child

MCID 4 10 are parent of 10 and 11 not coming i pic

推荐答案



这篇关于请帮助MLM Logic绑定二叉树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 07:36