/// <summary>
 /// Function to fill ledgers as TreeMode
 /// </summary>
 /// <param name="tn"></param>
 public void FillTree(TreeNode tn)
 {
     try
     {
         List<DataTable> ListObj = new List<DataTable>();
         AccountGroupBll bllAccountGroup = new AccountGroupBll();
         ListObj = bllAccountGroup.AccountGroupViewAllByGroupUnder(Convert.ToDecimal(tn.Name));
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         if (ListObj[0].Rows.Count > 0)
         {
             foreach (DataRow dr in ListObj[0].Rows)
             {
                 tn.Nodes.Add(dr["accountGroupId"].ToString(), dr["accountGroupName"].ToString());
                 tn.ExpandAll();
                 if (tn.LastNode != null)
                 {
                     tn.LastNode.ForeColor = Color.Red;
                 }
                 else
                 {
                     tn.LastNode.ForeColor = Color.Blue;
                 }
             }
             foreach (TreeNode tn1 in tn.Nodes)
             {
                 FillTree(tn1);
                 List<DataTable> ListObjLedger= bllAccountLedger.AccountLedgerViewAllByLedgerName(Convert.ToDecimal(tn1.Name));
                 foreach (DataRow dr in ListObjLedger[0].Rows)
                 {
                     tn1.Nodes.Add(dr["ledgerId"].ToString(), dr["ledgerName"].ToString());
                     tn1.ExpandAll();
                     if (tn1.LastNode != null)
                     {
                         tn1.LastNode.ForeColor = Color.Blue;
                     }
                     else
                     {
                         tn.LastNode.ForeColor = Color.Red;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("COA:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }