请帮助MLM Logic绑定二叉树 [英] Please Help for MLM Logic to bind binary tree

查看:62
本文介绍了请帮助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



我得到此输出

OutPut My





但我希望以正确的方式作为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

推荐答案

我会给你两个建议:

1)你的代码正在生成垂直格式的树在视觉上不是很好。作为多层次营销用户的观点,我想看看谁是我的分支中的成员(横向)等等。

2)您正在迭代整个结果集并将找到的成员添加为树视图的子节点。这将使您的程序非常慢。



现在解决方案:

1)使用转发器控制并使用一些css创建从根成员到子成员的水平显示。

2)浏览这个 [ ^ ]例。这将为您生成最后一列。最后一列是创建水平树的关键。



好​​运。
I will give you two advices:
1) Your code is generating tree in vertical format which is visually not very good. As a multi level marketing user''s perspective, I want to see who is the member in my branch(horizontally) and so on.
2) You are iterating the whole set of result and adding the found member as a child node for treeview. This will make your program very slow.

Now the solution:
1) Use repeater control and play with some css to create a horizontal display starting from root member to child members.
2) Go through This[^] example. This will give you generation as last column. This last column is the key to create your horizontal tree.

Best of luck.


http://www.rajneeshverma.com/post/2011/11/09/Binary-Tree-Diagram-in-ASPNET.aspx [ ^ ]







访问此链接
http://www.rajneeshverma.com/post/2011/11/09/Binary-Tree-Diagram-in-ASPNET.aspx[^]



visit this link


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆