Exemplo n.º 1
0
        private bool validateForm(FinanceCategorySub financeCategorySub)
        {
            if (cmbType.SelectedIndex.Equals(0) || cmbType.Text.Trim().Equals(""))
            {
                lblErrorType.Text = "Campo obrigatório";
                cmbType.Focus();
                return(false);
            }
            lblErrorType.Text = "";

            if (cmbCategory.SelectedItem == null)
            {
                lblErrorCategory.Text = "Campo obrigatório";
                cmbCategory.Focus();
                return(false);
            }
            lblErrorCategory.Text = "";

            financeCategorySub.Name = txtName.Text.Trim();
            if (financeCategorySub.Name.Equals(""))
            {
                lblErrorName.Text = "Campo obrigatório.";
                txtName.Focus();
                return(false);
            }
            if (FinanceCategorySubDAO.CountByName(financeCategorySub) > 0)
            {
                lblErrorName.Text = "Já consta cadastrado.";
                return(false);
            }
            lblErrorName.Text = "";

            return(true);
        }
Exemplo n.º 2
0
        private void dgList_DoubleClick(object sender, EventArgs e)
        {
            FinanceCategorySub financeCategorySubVO = new FinanceCategorySub();

            financeCategorySubVO.Id = int.Parse(dgList.CurrentRow.Cells["clId"].Value.ToString());
            financeCategorySubVO    = FinanceCategorySubDAO.GetByID(financeCategorySubVO);
            cmbType.SelectedIndex   = financeCategorySubVO.FinanceCategory.Type;
            this.ShowCmbCategory();
            cmbCategory.SelectedItem = financeCategorySubVO.FinanceCategory;
            txtName.Text             = financeCategorySubVO.Name;
            txtId.Text = financeCategorySubVO.Id.ToString();

            btnExcluir.Enabled = true;
        }
Exemplo n.º 3
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Deseja mesmo este registro?", "Sub-Categoria", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         FinanceCategorySub financeCategorySubVO = new FinanceCategorySub();
         financeCategorySubVO.Id = int.Parse(txtId.Text);
         financeCategorySubVO    = FinanceCategorySubDAO.GetByID(financeCategorySubVO);
         if (!FinanceCategorySubDAO.UpdateDisable(financeCategorySubVO))
         {
             MessageBox.Show("Erro: Ocorreu um erro inesperado excluir.");
         }
         else
         {
             MessageBox.Show("Excluído com sucesso.");
             this.ClearFields();
             this.showGrid();
         }
     }
 }
Exemplo n.º 4
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            FinanceCategorySub financeCategorySub = new FinanceCategorySub();
            int Id;

            if (int.TryParse(txtId.Text, out Id))
            {
                financeCategorySub.Id = Id;
                financeCategorySub    = FinanceCategorySubDAO.GetByID(financeCategorySub);
            }
            FinanceCategory financeCategory = new FinanceCategory();

            financeCategory = (FinanceCategory)cmbCategory.SelectedItem;
            financeCategory = FinanceCategoryDAO.GetByID(financeCategory);
            financeCategorySub.FinanceCategory = financeCategory;
            if (this.validateForm(financeCategorySub))
            {
                if (financeCategorySub.Id > 0)
                {
                    if (FinanceCategorySubDAO.Update(financeCategorySub))
                    {
                        MessageBox.Show("Alterado com sucesso.");
                        this.ClearFields();
                        this.showGrid();
                        return;
                    }
                    MessageBox.Show("Erro: Ocorreu um erro inesperado alterar.");
                }
                else
                {
                    if (FinanceCategorySubDAO.Insert(financeCategorySub))
                    {
                        MessageBox.Show("Cadastrado com sucesso.");
                        this.ClearFields();
                        this.showGrid();
                        return;
                    }
                    MessageBox.Show("Erro: Ocorreu um erro inesperado cadastrar.");
                }
            }
        }
Exemplo n.º 5
0
        private void showGrid()
        {
            FinanceCategory    financeCategory    = new FinanceCategory();
            FinanceCategorySub financeCategorySub = new FinanceCategorySub();

            if (cmbBuscarType.SelectedIndex != 0)
            {
                financeCategory.Type = cmbBuscarType.SelectedIndex;
            }
            if (cmbBuscarCategory.SelectedItem != null)
            {
                financeCategory = (FinanceCategory)cmbBuscarCategory.SelectedItem;
            }

            financeCategorySub.FinanceCategory = financeCategory;
            dgList.Rows.Clear();
            foreach (FinanceCategorySub x in FinanceCategorySubDAO.ListAllBy(financeCategorySub))
            {
                dgList.Rows.Add(x.Id, x.Name, x.FinanceCategory.Name);
            }
        }
Exemplo n.º 6
0
        private void ShowCmbCategorySub()
        {
            FinanceCategorySub fcSub = new FinanceCategorySub();

            fcSub.FinanceCategory = (FinanceCategory)cmbCategory.SelectedItem;
            if (cmbCategory.SelectedItem == null)
            {
                return;
            }

            cmbCategorySub.Items.Clear();
            cmbCategorySub.Items.Add("Carregando ...");
            cmbCategorySub.Items.Clear();
            foreach (FinanceCategorySub x in FinanceCategorySubDAO.ListAllBy(fcSub))
            {
                cmbCategorySub.Items.Add(x);
            }

            cmbCategorySub.ValueMember   = "Id";
            cmbCategorySub.DisplayMember = "Name";
        }
Exemplo n.º 7
0
        private void cmbBuscarCategory_SelectedValueChanged(object sender, EventArgs e)
        {
            FinanceCategorySub fcSub = new FinanceCategorySub();

            fcSub.FinanceCategory = (FinanceCategory)cmbBuscarCategory.SelectedItem;
            if (fcSub.FinanceCategory == null)
            {
                return;
            }

            cmbBuscarCategorySub.Items.Clear();
            cmbBuscarCategorySub.Items.Add("Carregando ...");
            cmbBuscarCategorySub.Items.Clear();
            foreach (FinanceCategorySub x in FinanceCategorySubDAO.ListAllBy(fcSub))
            {
                cmbBuscarCategorySub.Items.Add(x);
            }

            cmbBuscarCategorySub.ValueMember   = "Id";
            cmbBuscarCategorySub.DisplayMember = "Name";
        }
Exemplo n.º 8
0
        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.");
                }
            }
        }