/* * Limpa a tela para uma nova inclusão */ private void LimparTela() { dtpData.Value = DateTime.Now; txtValor.ResetText(); txtLocal.Text = ""; cbxTipoGasto.SelectedItem = 1; gastosTO = new GastosTO(); }
public void Incluir() { carregarCombos(); gastosTO = new GastosTO(); gastosTO.StatusBD = StatusTransacao.Insert; this.ShowDialog(); }
/* * Recebe o objeto com os dados completos dos gastos e apresenta na tela */ private void PreencherValoresTela(GastosTO gastosTO) { carregarCombos(); txtLocal.Text = gastosTO.LOCAL.Trim(); txtValor.Text = gastosTO.VALOR.ToString(); dtpData.Value = gastosTO.DATA; cbxTipoGasto.SelectedValue = gastosTO.ID_TIPO_GASTOS; }
/* * Alteração de gastos */ public void Alterar(GastosTO objGastosTO) { GastosBLL gastoBLL = new GastosBLL(); this.gastosTO = gastoBLL.SelectScalar(objGastosTO.ID_GASTOS); if (gastosTO != null) { PreencherValoresTela(gastosTO); gastosTO.StatusBD = StatusTransacao.Update; } this.ShowDialog(); }
public void Excluir(GastosTO objGastosTO) { GastosBLL gastoBLL = new GastosBLL(); this.gastosTO = gastoBLL.SelectScalar(objGastosTO.ID_GASTOS); if (gastosTO != null) { PreencherValoresTela(gastosTO); gastosTO.StatusBD = StatusTransacao.Delete; } DesabilitarComponentes(); this.ShowDialog(); }
private void btnSalvar_Click(object sender, EventArgs e) { List <GastosTO> listaGastosSalvar = new List <GastosTO>(); ControlarTelaSalvar(); foreach (DataGridViewRow row in dgvGrid.Rows) { if (row == null) { continue; } GastosTO gasto = new GastosTO(); string local = String.Empty; string valor = String.Empty; string data = String.Empty; string tipoGasto = String.Empty; local = row.Cells["colLocal"].Value.ToString(); valor = row.Cells["colValor"].Value.ToString(); data = row.Cells["colData"].Value.ToString(); tipoGasto = row.Cells["colTipoGasto"].Value.ToString(); gasto.LOCAL = local; gasto.VALOR = Convert.ToDecimal(valor); gasto.DATA = OutrosUtil.StringToDate(data); gasto.ID_TIPO_GASTOS = Convert.ToInt32(tipoGasto); gasto.StatusBD = StatusTransacao.Insert; listaGastosSalvar.Add(gasto); } try { GastosBLL gastosBLL = new GastosBLL(); gastosBLL.Save(listaGastosSalvar); MessageBox.Show("Dados Salvos com Sucesso!"); IniciarTela(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnExcluir_Click(object sender, EventArgs e) { frmCadGasto frmCadGasto = new frmCadGasto(); GastosTO gastosTO = new GastosTO(); if (dgvListaGastos.CurrentRow != null) { DataGridViewRow row = this.dgvListaGastos.SelectedRows[0]; int idGastos = (int)row.Cells["codlIdGastos"].Value; gastosTO.ID_GASTOS = idGastos; frmCadGasto.Excluir(gastosTO); } else { MessageBox.Show("Selecionar um item na lista :)"); } BuscarDados(); }