/// <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); } }
/// <summary> /// Form Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmChartOfAccount_Load(object sender, EventArgs e) { try { dtblItems.Columns.Add("name"); dtblItems.Columns.Add("type"); AccountGroupBll bllAccountGroup = new AccountGroupBll(); List<DataTable> ListObj = new List<DataTable>(); ListObj = bllAccountGroup.AccountGroupViewAllByGroupUnder(-1); foreach (DataRow dr in ListObj[0].Rows) { tvChartOfAccount.Nodes.Add(dr["accountGroupId"].ToString(), dr["accountGroupName"].ToString()); } foreach (TreeNode tn1 in tvChartOfAccount.Nodes) { FillTree(tn1); } } catch (Exception ex) { MessageBox.Show("COA:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }