Пример #1
0
        private void BtnDeletaIngrediente_Click(object sender, EventArgs e)
        {
            // Confirma se o usuário realmente deseja sair do sistema
            DialogResult apagar = MessageBox.Show("Deseja realmente excluir esse ingrediente do banco de dados?", "Excluir ingrediente", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);

            if (apagar.ToString().ToUpper() == "YES")
            {
                //Resgatando o objeto
                Ingrediente ingrediente = new Ingrediente();
                ingrediente.Id = idIngredienteDetalhe;
                if (ingrediente.Apagar())
                {
                    MessageBox.Show("Exclusão do ingrediente foi bem sucedida", "Exclusão realizada", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);

                    //Voltando para tela de ingredientes.
                    TelaIngrediente telaIngrediente = new TelaIngrediente()
                    {
                        telaInicio = telaInicialDetalhe
                    };
                    telaIngrediente.Show();
                    telaInicialDetalhe.Hide();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Não foi possível excluir o ingrediente", "Erro na exclusão", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
                }
            }
        }
Пример #2
0
        private void BtnMenuIngrediente_Click_1(object sender, EventArgs e)
        {
            TelaIngrediente telaIngrediente = new TelaIngrediente()
            {
                telaInicio = this
            };                      // Formulário "public" recebe a tela desta classe

            telaIngrediente.Show(); // Exibe a tela de ingredientes com o clique do usuário
            this.Hide();            // Esconde a tela inicial do programa
        }
Пример #3
0
        private void BtnVoltaIngrediente_Click(object sender, EventArgs e)
        {
            TelaIngrediente telaIngrediente = new TelaIngrediente()
            {
                telaInicio = telaInicialDetalhe
            };

            telaIngrediente.Show();
            telaInicialDetalhe.Hide();
            this.Hide();
        }
Пример #4
0
        private void BtnCancelaRegistro_Click(object sender, EventArgs e)
        {
            TelaIngrediente telaIngrediente = new TelaIngrediente()
            {
                telaInicio = telaInicialRegistro
            };

            telaIngrediente.Show();
            telaInicialRegistro.Hide();
            this.Hide();
        }
Пример #5
0
        private void BtnAlteraIngrediente_Click_1(object sender, EventArgs e)
        {
            //Resgatando o objeto
            Ingrediente ingrediente = new Ingrediente();

            ingrediente.Id = idIngredienteDetalhe;

            //Atribuindo novos valores.
            ingrediente.Nome               = txtNomeIngrediente.Text;
            ingrediente.Preco              = double.Parse(txtValorIngrediente.Text);
            ingrediente.Quantidade         = double.Parse(txtQuantidadeIngrediente.Text);
            ingrediente.UnidadeMedidaPreco = cboUnidadeIngrediente.SelectedItem.ToString();

            if ((!txtNomeIngrediente.Text.Equals("")) &&
                (!txtValorIngrediente.Text.Equals("")) &&
                (!txtQuantidadeIngrediente.Text.Equals("")) &&
                (!cboUnidadeIngrediente.SelectedItem.ToString().Equals(""))
                )
            {
                if (ingrediente.Alterar())
                {
                    MessageBox.Show("Alteração realizada com sucesso", "Alteração realizada", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                    TelaIngrediente telaIngrediente = new TelaIngrediente()
                    {
                        telaInicio = telaInicialDetalhe
                    };
                    telaIngrediente.Show();
                    telaInicialDetalhe.Hide();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Não foi possível alterar os dados", "Erro na alteração", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
                }
            }
            else
            {
                MessageBox.Show("Todos os campos devem ser preenchidos", "Erro na alteração", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
            }
        }
Пример #6
0
        private void BtnConfirmaRegistro_Click(object sender, EventArgs e)
        {
            //Resgatando o objeto
            Ingrediente ingrediente = new Ingrediente();

            if ((!txtNomeIngrediente.Text.Equals("")) &&
                (!txtValorIngrediente.Text.Equals("")) &&
                (!txtQuantidadeIngrediente.Text.Equals("")) &&
                (!cboUnidadeRegistroIngrediente.SelectedItem.ToString().Equals(""))
                )
            {
                //Atribuindo novos valores.
                ingrediente.Nome               = txtNomeIngrediente.Text;
                ingrediente.Preco              = double.Parse(txtValorIngrediente.Text);
                ingrediente.Quantidade         = double.Parse(txtQuantidadeIngrediente.Text);
                ingrediente.UnidadeMedidaPreco = cboUnidadeRegistroIngrediente.SelectedItem.ToString();

                if (ingrediente.Cadastrar())
                {
                    MessageBox.Show("Registro realizado com sucesso", "Registro realizado", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                }
                else
                {
                    MessageBox.Show("Não foi possível cadastrar o novo ingrediente", "Erro no registro", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                }
            }
            else
            {
                MessageBox.Show("Todos os campos devem ser preenchidos", "Erro no registro", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
            }
            TelaIngrediente telaIngrediente = new TelaIngrediente()
            {
                telaInicio = telaInicialRegistro
            };

            telaIngrediente.Show();
            telaInicialRegistro.Hide();
            this.Hide();
        }