Click here to Skip to main content
15,860,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
public class SalesData
    {
       

        //private string Product;
        //private short Quantity;

        public SalesData(string p, int p_2)
        {
            // TODO: Complete member initialization
            this.Product = p;
            this.Quantity = p_2;
        }

        public SalesData()
        {
            // TODO: Complete member initialization
        }
        public SalesData(string p, int p_2, int p_3, int p_4, int p_5)
        {
            // TODO: Complete member initialization
            this.Product = p;
            this.Quantity = p_2;
            this.Segment = p_3;
            this.YtdMax = p_4;
            this.YtdMin = p_5;
        }
        public SalesData(string p, int p_2, int p_3,int p_4,int p_5,string p_6)
        {
            // TODO: Complete member initialization
            this.Product = p;
            this.Quantity = p_2;
            this.Parent = p_6;
            this.Segment = p_3;
            this.YtdMax = p_4;
            this.YtdMin = p_5;
        }
        public string Product { get; set; }
        public int Quantity { get; set; }
        public string Parent { get; set; }
        public int Segment { get; set; }
        public int YtdMax { get; set; }
        public int YtdMin { get; set; }

        public IList<salesdata> Children { get; set; }

        /// <summary>
        /// Gets the desired tooltip content.
        /// </summary>
        public string ToolTip
        {
            get
            {
                StringBuilder outStr = new StringBuilder();
                outStr.Append("Product: ").Append(Product);
                outStr.Append("\nQuantity: ").Append(Quantity);
                outStr.Append("\nYtd: ").Append(Segment);
                outStr.Append("\nYtdMax: ").Append(YtdMax);
                outStr.Append("\nYtdMin: ").Append(YtdMin);
                
                return outStr.ToString();
            }
        }
        
    }

//and in service code file i have initialised it as

 SalesData node = new SalesData();
        //node.Product = name;
        node.Product = "VCN"+name;

        node.Quantity = 0;//Convert.ToInt16(random.Next(30, 300));
        node.Segment = segmentID;
        node.Children = new SalesData[0];
        
        node.Children = new List<salesdata>();
        
        SalesData node1 = new SalesData();
        node1.Product = "HCN" + name;
        node1.Quantity = Convert.ToInt16(random.Next(30, 300));
        node1.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node1.YtdMax = 300;//Ytd
        node1.YtdMin = 30;//Ytd
       // node1.Segment = segmentID;
        node1.Children = new SalesData[0];

        node1.Children = new List<salesdata>();

        SalesData node2 = new SalesData();
        node2.Product = "ABC" + name;
        node2.Quantity = Convert.ToInt16(random.Next(30, 300));
        node2.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node2.YtdMax = 300;//Ytd
        node2.YtdMin = 30;//Ytd
        //node2.Segment = segmentID;
        node2.Children = new SalesData[0];

        node2.Children = new List<salesdata>();
         
        SalesData node3 = new SalesData();
        node3.Product = "def" + name;
        node3.Quantity = Convert.ToInt16(random.Next(30, 300));
        node3.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node3.YtdMax = 300;//Ytd
        node3.YtdMin = 30;//Ytd
        //node3.Segment = segmentID;
        node3.Children = new SalesData[1];
        node3.Children = new List<salesdata>();

        SalesData node4 = new SalesData();
        node4.Product = "ghi" + name;
        node4.Quantity = Convert.ToInt16(random.Next(30, 300));
        node3.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node3.YtdMax = 300;//Ytd
        node3.YtdMin = 30;//Ytd
        //node4.Segment = segmentID;
        node4.Children = new SalesData[0];

        node4.Children = new List<salesdata>();

        SalesData node5 = new SalesData();
        node5.Product = "jkm" + name;
        node5.Quantity = Convert.ToInt16(random.Next(30, 300));
        node3.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node3.YtdMax = 300;//Ytd
        node3.YtdMin = 30;//Ytd
        //node5.Segment = segmentID;
        node5.Children = new SalesData[0];

        node5.Children = new List<salesdata>();


        node3.Children.Add(node5);
        node3.Children.Add(node4);
        node3.Children.Add(node1);
        node3.Children.Add(node2);

        node.Children.Add(node3);


        SalesData node31 = new SalesData();
        node31.Product = "VCN" + name;

        node31.Quantity = 0;//Convert.ToInt16(random.Next(30, 300));
        node31.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node31.YtdMax= 300;//Ytd
        node31.YtdMin = 30;//Ytd
       // node31.Segment = segmentID;
        node31.Children = new SalesData[0];

        node31.Children = new List<salesdata>();

        SalesData node11 = new SalesData();
        node11.Product = "HCN" + name;
        node11.Quantity = Convert.ToInt16(random.Next(30, 300));
        node11.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node11.YtdMax = 300;//Ytd
        node11.YtdMin = 30;//Ytd
        //node11.Segment = segmentID;
        node11.Children = new SalesData[0];

        node11.Children = new List<salesdata>();

        SalesData node12 = new SalesData();
        node12.Product = "ABC" + name;
        node12.Quantity = Convert.ToInt16(random.Next(30, 300));
        node12.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node12.YtdMax = 300;//Ytd
        node12.YtdMin = 30;//Ytd
        //node12.Segment = segmentID;
        node12.Children = new SalesData[0];

        node12.Children = new List<salesdata>();

        SalesData node13 = new SalesData();
        node13.Product = "def" + name;
        node13.Quantity = Convert.ToInt16(random.Next(30, 300));
        node13.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node13.YtdMax = 300;//Ytd
        node13.YtdMin = 30;//Ytd
        //node13.Segment = segmentID;
        node13.Children = new SalesData[1];
        node13.Children = new List<salesdata>();

        SalesData node14 = new SalesData();
        node14.Product = "ghi" + name;
        node14.Quantity = Convert.ToInt16(random.Next(30, 300));
        node14.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node14.YtdMax = 300;//Ytd
        node14.YtdMin = 30;//Ytd
        // node14.Segment = segmentID;
        node14.Children = new SalesData[0];

        node14.Children = new List<salesdata>();

        SalesData node15 = new SalesData();
        node15.Product = "jkm" + name;
        node15.Quantity = Convert.ToInt16(random.Next(30, 300));
        node15.Segment = Convert.ToInt16(random.Next(30, 300));//Ytd
        node15.YtdMax = 300;//Ytd
        node15.YtdMin = 30;//Ytd
        //node15.Segment = segmentID;
        node15.Children = new SalesData[0];

        node15.Children = new List<salesdata>();


        node13.Children.Add(node15);
        node13.Children.Add(node14);
        node13.Children.Add(node11);
        node13.Children.Add(node12);

        node31.Children.Add(node13);

        SalesData node21 = new SalesData();
        node21.Product = "VCN" + name;

        node21.Quantity = 0;//Convert.ToInt16(random.Next(30, 300));
        node21.Segment = segmentID;
        node21.Children = new SalesData[0];

        node21.Children = new List<salesdata>();

        node21.Children.Add(node31);
        node21.Children.Add(node);

Now what i want

fetch the records having name "VCN" and at any level node how can i access.

[edit]Code block modified to encode HTML characters (get rid of spurious closing tags) - OriginalGriff[/edit]
Posted
Updated 14-Nov-11 2:50am
v3
Comments
Pandya Anil 14-Nov-11 8:37am    
use propper tagings.. if question looks good to read you will get answer soon. :)
Mehdi Gholam 14-Nov-11 8:56am    
Why are you nesting like this?
pankajbhoi007 14-Nov-11 9:24am    
I use it as datasource to treemap control of silverlight 4 toolkit

1 solution

i dont understand well but try this my friend:

listName.FindAll(p => p.Product == "VCN")


by this way you can search via a list and find all items that contain a specific value of a specific attribute
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900