Example #1
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvDados.SelectedRows.Count == 1)
         {
             int id = Convert.ToInt32(dgvDados.CurrentRow.Cells[0].Value);
             using (GastosContext db = new GastosContext())
             {
                 if (MessageBox.Show("Deseja excluir este cadastro?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                 {
                     controlador.Excluir(id);
                 }
                 LimparCampos();
                 exibirInfo();
             }
         }
         else
         {
             MessageBox.Show("Selecione um cadastro para Excluir!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Não foi possível excluir o cadastro" + ex, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            double valor;
            string descricao;

            if (btnEditar.Text == "Cancelar")
            {
                int             selectedRowIndex = dgvDados.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = dgvDados.Rows[selectedRowIndex];
                int             id    = Convert.ToInt32(selectedRow.Cells["Id"].Value);
                GastosContext   db    = new GastosContext();
                Gasto           gasto = db.Gastos.Where(a => a.Id == id).FirstOrDefault();
                gasto.Valor     = Convert.ToDouble(txtValor.Text);
                gasto.Descricao = txtDescricao.Text;
                gasto.Data      = dtpDataGasto.Value;
                controlador.Atualizar(gasto);
                LimparCampos();
                exibirInfo();
                btnNovo.Enabled    = true;
                btnExcluir.Enabled = true;
                btnEditar.Text     = "Editar";
            }
            else
            {
                if (txtValor.Text != "")
                {
                    valor = Convert.ToDouble(txtValor.Text);
                }
                else
                {
                    MessageBox.Show("Informe o Valor.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtValor.Focus();
                    return;
                }
                if (txtDescricao.Text != "")
                {
                    descricao = txtDescricao.Text;
                }
                else
                {
                    MessageBox.Show("Informe a Descrição.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDescricao.Focus();
                    return;
                }
                DateTime data  = dtpDataGasto.Value;
                Gasto    gasto = new Gasto(data, valor, descricao);
                controlador.Salvar(gasto);
                exibirInfo();
            }
        }
Example #3
0
        private void dgvDados_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            using (GastosContext db = new GastosContext())
            {
                if (dgvDados.SelectedRows.Count == 1)
                {
                    int             selectedRowIndex = dgvDados.SelectedCells[0].RowIndex;
                    DataGridViewRow selectedRow      = dgvDados.Rows[selectedRowIndex];
                    int             id       = Convert.ToInt32(selectedRow.Cells["Id"].Value);
                    var             consulta = (from p in db.Gastos.Where(a => a.Id == id) select p).First();

                    txtValor.Text      = consulta.Valor.ToString();
                    dtpDataGasto.Text  = consulta.Data.ToString();
                    txtDescricao.Text  = consulta.Descricao;
                    btnExcluir.Enabled = true;
                }
            }
        }
 public MovimentacaoRepository(GastosContext gastosContext, IMapper autoMapper)
 {
     _GastosContext = gastosContext;
     _IMapper       = autoMapper;
 }
 public RubroEfectivoRepo(GastosContext context)
 {
     _context = context;
 }
Example #6
0
 public TagsDA(GastosContext gastosContext)
 {
     this._gastosContext = gastosContext;
 }
 public MovEfectivoRepo(GastosContext context)
 {
     _context = context;
 }
Example #8
0
 public TagsRepository(GastosContext gastosContext, IMapper autoMapper)
 {
     _GastosContext = gastosContext;
     _IMapper       = autoMapper;
 }
 public RubroBancoRepo(GastosContext context)
 {
     _context = context;
 }