Beispiel #1
0
        private void btnApagar_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value);

            ComestiveisRepository repositorio = new ComestiveisRepository();

            repositorio.Apagar(id);
            MessageBox.Show("Apagado com sucesso!");
        }
Beispiel #2
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value);

            ComestiveisRepository repositorio = new ComestiveisRepository();
            Comestivel            comestivel  = repositorio.ObterPeloID(id);

            ProdutosComestiveisEditar editar = new ProdutosComestiveisEditar(comestivel);

            editar.ShowDialog();
        }
Beispiel #3
0
        public void AtualizarLista()
        {
            ComestiveisRepository repositorio = new ComestiveisRepository();
            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.Marca, comestivel.Valor, comestivel.Quantidade, comestivel.Vencimento.ToString("dd/MM/yyyy")
                });
            }
        }
Beispiel #4
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            Comestivel comestivel = new Comestivel();

            comestivel.Nome       = txtNome.Text;
            comestivel.Marca      = txtMarca.Text;
            comestivel.Quantidade = Convert.ToInt32(txtQuantidade.Text);
            comestivel.Valor      = Convert.ToDecimal(txtValor.Text);
            comestivel.Vencimento = dtpVencimento.Value;

            ComestiveisRepository repositorio = new ComestiveisRepository();

            repositorio.Inserir(comestivel);

            MessageBox.Show("Cadastrado com sucesso!");
            Close();
        }