How to calculate commision based on referred memebrs?
Posted
by RAJKISHOR SAHU
on Stack Overflow
See other posts from Stack Overflow
or by RAJKISHOR SAHU
Published on 2010-03-27T05:43:31Z
Indexed on
2010/03/27
5:53 UTC
Read the original article
Hit count: 262
Hello everybody, I am developing a small software in C# WPF for a consultancy which does chain system business. I have coded tree structure to show who referred whom. Now it has commission depending on level. If 1 referred 2 & 3 then 1 will get level-1 commission. If 2 referred 4, 5 & 3 referred 6, 7 then 1 will receive level-2 commission. This chain will go on to certain total number. My problem is how I would implement this logic; I am able to calculate who has referred how many members via UDF written for adding TreeViewItem to TreeView. Or tell me how I can count items in treeview in certain level? Node adding UDF:
public void AddNodes(int uid, TreeViewItem tSubNode)
{
string query = "select fullname, id from members where refCode=" + uid + ";";
MySqlCommand cmd = new MySqlCommand(query, db.conn);
MySqlDataAdapter _DA = new MySqlDataAdapter(cmd);
DataTable _DT = new DataTable();
tSubNode.IsExpanded = true;
_DA.Fill(_DT);
foreach (DataRow _dr in _DT.Rows)
{
TreeViewItem tNode = new TreeViewItem();
tNode.Header = _dr["fullname"].ToString()+" ("+_dr["id"].ToString()+")";
tSubNode.Items.Add(tNode);
if (db.HasMembers(Convert.ToInt32(_dr["id"].ToString())))
{
AddNodes(Convert.ToInt32(_dr["id"]), tNode);
}
}
//This line tracks who has referred how many members
Console.WriteLine("Tree node Count : "+tSubNode.Items.Count.ToString()+", UID "+uid);
}
Help me PLEASE!!!!
© Stack Overflow or respective owner