private void dgList_DoubleClick(object sender, EventArgs e)
        {
            Finance financeVO = new Finance();

            financeVO.Id             = int.Parse(dgList.CurrentRow.Cells["clId"].Value.ToString());
            financeVO                = FinanceDAO.GetByID(financeVO);
            cmbCategory.SelectedItem = financeVO.FinanceCategorySub.FinanceCategory;
            this.ShowCmbCategorySub();
            cmbCategorySub.SelectedItem = financeVO.FinanceCategorySub;
            cmbPaymentForm.SelectedItem = financeVO.PaymentForm;
            txtValue.Text   = financeVO.Value.ToString();
            dtDateTime.Text = financeVO.Date.ToString();
            if (financeVO.Situation == FinanceU.SITUATION_PAGO)
            {
                rbSituationPago.Checked = true;
            }
            else
            {
                rbSituationPendente.Checked = true;
            }
            cmbPriority.SelectedIndex = financeVO.Priority;
            txtText.Text = financeVO.Text;
            txtId.Text   = financeVO.Id.ToString();

            btnExcluir.Enabled = true;
        }
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Deseja mesmo este registro?", "Finança", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         Finance financeVO = new Finance();
         financeVO.Id = int.Parse(txtId.Text);
         financeVO    = FinanceDAO.GetByID(financeVO);
         if (!FinanceDAO.UpdateDisable(financeVO))
         {
             MessageBox.Show("Erro: Ocorreu um erro inesperado excluir.");
         }
         else
         {
             MessageBox.Show("Excluído com sucesso.");
             this.ClearFields();
             this.showGrid();
         }
     }
 }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            Finance finance = new Finance();
            int     Id;

            if (int.TryParse(txtId.Text, out Id))
            {
                finance.Id = Id;
                finance    = FinanceDAO.GetByID(finance);
            }
            FinanceCategorySub financeCategorySub = new FinanceCategorySub();

            financeCategorySub         = (FinanceCategorySub)cmbCategorySub.SelectedItem;
            financeCategorySub         = FinanceCategorySubDAO.GetByID(financeCategorySub);
            finance.FinanceCategorySub = financeCategorySub;

            PaymentForm paymentForm = new PaymentForm();

            paymentForm         = (PaymentForm)cmbPaymentForm.SelectedItem;
            paymentForm         = PaymentFormDAO.GetByID(paymentForm);
            finance.PaymentForm = paymentForm;

            finance.Date = dtDateTime.Value;
            if (rbSituationPago.Checked)
            {
                finance.Situation = FinanceU.SITUATION_PAGO;
                finance.DateClose = finance.Date;
            }
            else
            {
                finance.Situation = FinanceU.SITUATION_PENDENTE;
                finance.DateClose = DateTime.Now;
            }
            finance.Text = txtText.Text;

            if (this.validateForm(finance))
            {
                if (finance.Id > 0)
                {
                    if (FinanceDAO.Update(finance))
                    {
                        MessageBox.Show("Alterado com sucesso.");
                        this.ClearFields();
                        this.showGrid();
                        return;
                    }
                    MessageBox.Show("Erro: Ocorreu um erro inesperado alterar.");
                }
                else
                {
                    if (FinanceDAO.Insert(finance))
                    {
                        MessageBox.Show("Cadastrado com sucesso.");
                        this.ClearFields();
                        this.showGrid();
                        return;
                    }
                    MessageBox.Show("Erro: Ocorreu um erro inesperado cadastrar.");
                }
            }
        }