protected void btnAddAccountingPlan_Click(object sender, EventArgs e)
    {
        accountManager = new AccountManager(this);
        accountingPlan = new AccountingPlan();

        if (String.IsNullOrEmpty(cboTreeAccountingPlan.SelectedValue))
        {
            ShowError("Selecione um plano de contas pai!");
            return;
        }

        if (treAccountingPlan.SelectedNode != null)
        {
            AccountingPlan original_accountingPlan = accountManager.GetAccountingPlan(Company.CompanyId,Convert.ToInt32(treAccountingPlan.SelectedValue));
            
            accountingPlan.CopyPropertiesFrom(original_accountingPlan);

            accountingPlan.Name = txtName.Text.ToUpper();

            accountingPlan.ParentId = Convert.ToInt32(cboTreeAccountingPlan.SelectedValue);

            accountManager.UpdateAccountingPlan(original_accountingPlan, accountingPlan);
        }
        else
        {
            accountingPlan.CompanyId = Company.CompanyId;
            accountingPlan.Name = txtName.Text.ToUpper();

            accountingPlan.ParentId = Convert.ToInt32(cboTreeAccountingPlan.SelectedValue);

            accountManager.InsertAccountingPlan(accountingPlan);
        }
        BindTree();
    }