private void btnApagar_Click(object sender, EventArgs e) { int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value); ComestiveisRepositorio repositorio = new ComestiveisRepositorio(); repositorio.Apagar(id); dataGridView1.Rows.RemoveAt(dataGridView1.CurrentCell.RowIndex); }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value); ComestiveisRepositorio repositorio = new ComestiveisRepositorio(); Comestivel comestivel = repositorio.ObterPeloId(id); ComestivelEditar comestivelEditar = new ComestivelEditar(comestivel); comestivelEditar.ShowDialog(); }
private void btnSalvar_Click_1(object sender, EventArgs e) { Comestivel comestivel = new Comestivel(); comestivel.nome = txtNome.Text; comestivel.valor = Convert.ToDecimal(txtValor.Text); comestivel.dataVencimento = Convert.ToDateTime(dtpDataVencimento.Text); comestivel.quantidade = Convert.ToInt32(txtQuantidade.Text); comestivel.marca = txtMarca.Text; ComestiveisRepositorio repositorio = new ComestiveisRepositorio(); repositorio.Inserir(comestivel); Close(); }
private void AtualizarTabela() { ComestiveisRepositorio repositorio = new ComestiveisRepositorio(); List <Comestivel> comestiveis = repositorio.Obtertodos(); dataGridView1.Rows.Clear(); for (int i = 0; i < comestiveis.Count; i++) { Comestivel comestivel = comestiveis[i]; dataGridView1.Rows.Add( new object[] { comestivel.id, comestivel.nome, comestivel.valor, comestivel.quantidade, comestivel.marca } ); } }
private void btnSalvar_Click(object sender, EventArgs e) { Comestivel comestivel = new Comestivel(); comestivel.id = Convert.ToInt32(txtCodigo.Text); comestivel.nome = txtNome.Text; comestivel.valor = Convert.ToDecimal(txtValor.Text); comestivel.dataVencimento = Convert.ToDateTime(dtpDataVencimento.Text); comestivel.quantidade = Convert.ToInt32(txtQuantidade.Text); comestivel.marca = txtMarca.Text; ComestiveisRepositorio repositorio = new ComestiveisRepositorio(); repositorio.Atualizar(comestivel); MessageBox.Show("Editado com sucesso. "); Close(); }