受经济危机的影响,最近没有做什么大项目,弄了一个二叉树的HTML显示方法,代码如下:

 

 s)
    {
        string c1 = "", c2 = "";
        
if (coding == "左未注册" || coding == "右未注册")
        { c1 
= "<div style='background-color:#ccc;height:40px;line-height:40px;'> 左未注册</div>"; c2 = "<div style='background-color:#ccc;height:40px;line-height:40px;'>右未注册</div>"; }

        
else
        {
            
// c1 = "<div style='background-color:#0000ff;height:40px;line-height:40px;'> 左未注册</div>"; c2 = "<div style='background-color:#0000ff;height:40px;line-height:30px;'>右未注册</div>";

            c1 
= string.Format("<div style='background-color:#0000ff;height:40px;line-height:40px;'><a href=Register.aspx?anzhi={0}&site=0  class='qian'>{1}</a> </div>", coding, "左未注册");

            c2 
= string.Format("<div style='background-color:#0000ff;height:40px;line-height:40px;'><a href=Register.aspx?anzhi={0}&site=1  class='qian'>{1}</a> </div>", coding, "右未注册");

        }
        Sale.BLL.Customer bcustomer 
= new Sale.BLL.Customer();
        Sale.Model.Customer mcustomer 
= bcustomer.GetModel(coding);
        
if (i < 2)
        {


            i
++;

            
if (mcustomer != null)
            {
                
if (!string.IsNullOrEmpty(mcustomer.LeftChildCoding))
                {

                    c1 
= bf(i, mcustomer.LeftChildCoding, coding, s);
                }

                
else
                {


                    c1 
= bf(i, "左未注册", coding, s);

                }

                
if (!string.IsNullOrEmpty(mcustomer.RightChildCoding))
                {
                    c2 
= bf(i, mcustomer.RightChildCoding, coding, s);
                }

                
else
                {


                    c2 
= bf(i, "右未注册", coding, s);

                }
            }

            
else
            {
                c1 
= bf(i, "左未注册", coding, s);
                c2 
= bf(i, "右未注册", coding, s);


            }

        }

        
else
        {
            
if (mcustomer != null)
            {

                
if (!string.IsNullOrEmpty(mcustomer.LeftChildCoding))
                {
                  Sale.Model.Customer lcus
=bcustomer.GetModel(mcustomer.LeftChildCoding);

                                         c1 
= string.Format("<a href='NetTree.aspx?root={0}' class='{2}' >{0}<font style='color:Red; font-size:14px;'>({1}单)</font></a>", mcustomer.LeftChildCoding,lcus.RatingCoding, lcus.IsValid?"alan":"ahuang");
                }

                
if (!string.IsNullOrEmpty(mcustomer.RightChildCoding))
                {
                    Sale.Model.Customer rcus 
= bcustomer.GetModel(mcustomer.RightChildCoding);

                                         c2 
= string.Format("<a href='NetTree.aspx?root={0}' class='{2}'>{0}<font style='color:Red; font-size:14px;'>({1}单)</font></a>", mcustomer.RightChildCoding,rcus.RatingCoding,rcus.IsValid ? "alan" : "ahuang");
                }

            }


        }


        
if (coding == "左未注册" || coding == "右未注册")
        {
            
if (pcoding == "左未注册" || pcoding == "右未注册")
            {

                
return s.Replace("左孩子", c1).Replace("右孩子", c2).Replace("根节点"string.Format("<div style='background-color:#ccc;height:40px;line-height:40px;' class='qian'>{0}</a> </div>", coding));

            }
            
else


                
return s.Replace("左孩子", c1).Replace("右孩子", c2).Replace("根节点"string.Format("<div style='background-color:#0000ff;height:40px;line-height:40px;'><a href=Register.aspx?anzhi={0}&site={1} class='qian'>{2}</a> </div>", pcoding, coding == "左未注册" ? "0" : "1", coding));

        }
        
else
            
return s.Replace("左孩子", c1).Replace("右孩子", c2).Replace("根节点"string.Format("<a href='NetTree.aspx?root={0}' class='{2}'>{0}<font style='color:Red; font-size:14px;'>({1}单)</font></a>", coding, mcustomer.RatingCoding,mcustomer.IsValid?"alan":"ahuang"));

    }

 

调用时:

   

;
  
 string    str = this.bf(0,root_coding,"",s);

 

 

 

 

    .ahuang{
    width
:100%;
    display
:block; 
    background-color
:#FFFF00;
     height
:40px;
     line-height
:40px;
    
}
    
        .alan
{
    width
:100%;
    display
:block; 
    background-color
:#00ff00;
     height
:40px;
     line-height
:40px;
    
}
    
        .qian
{
    width
:100%;
    display
:block; 
    background-color
:#0563AB;
     height
:40px;
     line-height
:40px;
    
}
    
    
    </style>

相关文章:

  • 2021-11-11
  • 2021-07-03
  • 2021-07-14
  • 2021-12-19
  • 2021-12-14
  • 2022-12-23
  • 2022-01-01
  • 2021-10-31
猜你喜欢
  • 2022-01-16
  • 2022-12-23
  • 2021-07-24
  • 2021-08-29
  • 2021-09-21
  • 2021-07-07
  • 2022-12-23
相关资源
相似解决方案