protected void btnDeleteCostCenter_Command(object sender, CommandEventArgs e) { if (e.CommandName == "Select") { var node = treCostCenter.FindNodeByValue(e.CommandArgument.ToString()) ?? new Telerik.Web.UI.RadTreeNode(); cboTreeCostCenters.SelectedValue = String.Empty; if (node.ParentNode != null) cboTreeCostCenters.SelectedValue = node.ParentNode.Value; txtName.Text = node.Text; } else if (e.CommandName == "Delete") { accountManager = new AccountManager(this); costCenter = accountManager.GetCostCenter(Convert.ToInt32(e.CommandArgument)); if (costCenter != null) { if (costCenter.CostCenters.Any() || costCenter.Bills.Any() || costCenter.Invoices.Any()) { ShowError(Resources.Exception.DeletingRegisterWithForeignKey); return; } try { accountManager.DeleteCostCenter(costCenter); } catch { ShowError(Resources.Exception.DeletingRegisterWithForeignKey); return; } } BindTree(); } }