/// <summary> /// Add this new account as child of the currently selected node /// </summary> public void AddNewAccount(GLSetupTDSAAccountRow AccountRow, AAccountHierarchyDetailRow HierarchyDetailRow) { trvAccounts.BeginUpdate(); TreeNode newNode = trvAccounts.SelectedNode.Nodes.Add(AccountRow.AccountCode); AccountNodeDetails NewAccount = AccountNodeDetails.AddNewAccount(newNode, AccountRow, HierarchyDetailRow); trvAccounts.EndUpdate(); FParentForm.SetSelectedAccount(NewAccount); }
private void InsertNodeIntoTreeView(GLSetupTDS MainDS, Int32 LedgerNumber, TreeNode AParent, DataView view, AAccountHierarchyDetailRow ADetailRow) { GLSetupTDSAAccountRow AccountRow = (GLSetupTDSAAccountRow)MainDS.AAccount.Rows.Find( new object[] { LedgerNumber, ADetailRow.ReportingAccountCode }); TreeNode Child = new TreeNode(); AccountNodeDetails NodeTag = AccountNodeDetails.AddNewAccount(Child, AccountRow, ADetailRow); NodeTag.IsNew = (ADetailRow.RowState == DataRowState.Added); SetNodeLabel(AccountRow, Child); if (AParent == null) { trvAccounts.Nodes.Add(Child); } else { InsertInOrder(AParent, Child); } // Now add the children of this node: view.RowFilter = AAccountHierarchyDetailTable.GetAccountHierarchyCodeDBName() + " = '" + ADetailRow.AccountHierarchyCode + "' AND " + AAccountHierarchyDetailTable.GetAccountCodeToReportToDBName() + " = '" + ADetailRow.ReportingAccountCode + "'"; if (view.Count > 0) { // An account cannot be deleted if it has children. NodeTag.CanDelete = false; NodeTag.Msg = Catalog.GetString("Child accounts must be deleted first."); NodeTag.CanHaveChildren = true; foreach (DataRowView rowView in view) { AAccountHierarchyDetailRow accountDetail = (AAccountHierarchyDetailRow)rowView.Row; InsertNodeIntoTreeView(MainDS, LedgerNumber, Child, view, accountDetail); } } }