protected void btnAddCostCenter_Click(object sender, EventArgs e)
    {
        accountManager = new AccountManager(this);
        costCenter = new CostCenter();

        if (treCostCenter.SelectedNode != null)
        {
            CostCenter original_costCenter = accountManager.GetCostCenter(Convert.ToInt32(treCostCenter.SelectedNode.Value));
            costCenter.CopyPropertiesFrom(original_costCenter);

            if (!String.IsNullOrEmpty(cboTreeCostCenters.SelectedValue))
                costCenter.ParentId = Convert.ToInt32(cboTreeCostCenters.SelectedValue);
            else
                costCenter.ParentId = null;

            costCenter.Name = txtName.Text;
            accountManager.UpdateCostCenter(original_costCenter, costCenter);
        }
        else
        {
            costCenter.CompanyId = Company.CompanyId;
            costCenter.Name = txtName.Text;

            if (!String.IsNullOrEmpty(cboTreeCostCenters.SelectedValue))
                costCenter.ParentId = Convert.ToInt32(cboTreeCostCenters.SelectedValue);
            else
                costCenter.ParentId = null;

            accountManager.InsertCostCenter(costCenter);
        }

        BindTree();
    }