Esempio n. 1
0
        private void buttonCadastrar_Click(object sender, EventArgs e)
        {
            Registro registro = new Registro();

            try
            {
                int result;
                registro.Nome       = textBoxNome.Text;
                registro.Quantidade = int.Parse(textBoxQuantidade.Text);
                registro.Tamanho    = comboBox1.Text;

                result = control.Cadastrar(registro);

                if (result > 0)
                {
                    MessageBox.Show(String.Format("{0} Produto(s) Cadastrado(s)!!", result, "Aviso"));
                    int countPedidos = int.Parse(labelContador.Text);
                    countPedidos++;
                    labelContador.Text = countPedidos.ToString();
                }
                else
                {
                    MessageBox.Show("Nenhuma Produto registrada!!", "Erro de inserção");
                }

                comboBox1.SelectedIndex = -1;
                UpdateDataGrid();
            }

            catch (Exception)
            {
                MessageBox.Show("Preencha todos os campos!!", "Impossível cadastrar");
            }
        }
Esempio n. 2
0
        //=========================== INSERT ================================

        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            Registro registro = new Registro();

            try
            {
                int result;
                registro.Idade = int.Parse(txtBoxIdade.Text);
                registro.Tipo  = comboBoxTipo.Text;
                registro.Nivel = comboBoxNivel.Text;

                result = control.Cadastrar(registro);

                if (result > 0)
                {
                    MessageBox.Show(String.Format("{0} Abelha cadastrada!!", result));
                    dataGridView1.Refresh();

                    if (registro.Tipo == "Operarias")
                    {
                        int countOperarias = int.Parse(lbQtdOperarias.Text);
                        countOperarias++;
                        lbQtdOperarias.Text = countOperarias.ToString();
                    }

                    if (registro.Tipo == "Patrulheiras")
                    {
                        int countRanger = int.Parse(lbQtdRanger.Text);
                        countRanger++;
                        lbQtdRanger.Text = countRanger.ToString();
                    }

                    if (registro.Tipo == "Rainhas")
                    {
                        int countQueen = int.Parse(lbQtdQueen.Text);
                        countQueen++;
                        lbQtdQueen.Text = countQueen.ToString();
                    }
                }
                else
                {
                    MessageBox.Show("Nenhuma abelha registrada!!", "Erro de inserção");
                }

                txtBoxIdade.Clear();
                comboBoxTipo.SelectedIndex  = -1;
                comboBoxNivel.SelectedIndex = -1;
                UpdateDataGrid();
            }

            catch (Exception)
            {
                MessageBox.Show("Preencha todos os campos!!", "Impossível cadastrar");
            }
        }