Esempio n. 1
0
        private void BtnCadastrar_Click(object sender, EventArgs e) // Botão para cadastrar um dado no lote
        {
            Reset();
            panelAlterar.Visible = false;
            Set_DadosLote();
            clsLote Lote = new clsLote();

            Lote.getNumeroLote();
            txbNumero.Text = Lote.Numero.ToString();
            txbAves.Clear();
            cmbCrescimento.ResetText();
            txbPeso.Clear();
            txbMortalidade.Clear();
            panelDadosLote.Visible = true;
        }
Esempio n. 2
0
        private void BtnEscolherLote_Click(object sender, EventArgs e) // Botão para carrega o segundo painel de alterar os dados
        {
            Reset();
            panelAlterar.Visible = false;
            Set_AlterarDados();
            clsLote Lote = new clsLote();

            Lote.Numero = int.Parse(cmbLote.Text);
            Lote.getDadosTabela();
            txbNumeroAlterar.Text = cmbLote.Text;
            txbAvesAlterar.Text   = Lote.QntAves.ToString();
            cmbCrescimentoAlterar.SelectedIndex = cmbCrescimentoAlterar.FindString(Lote.FaseCrescimento);
            txbPesoAlterar.Text        = Lote.PesoMedio.ToString();
            txbMortalidadeAlterar.Text = Lote.Mortalidade.ToString();
            panelAlterarDados.Visible  = true;
        }
Esempio n. 3
0
        private void BtnSalvarAlterar_Click(object sender, EventArgs e)   // Botão de salvar os dados alterados no lote
        {
            clsLote Lote = new clsLote();

            Lote.Numero = int.Parse(cmbLote.Text);
            Lote.getDadosTabela();
            try {
                Lote.QntAves = int.Parse(txbAvesAlterar.Text);
            } catch (FormatException) {
                MessageBox.Show("Quantidade de aves inválida!\n");
                return;
            }
            if (cmbCrescimentoAlterar.Text.Length == 0)
            {
                MessageBox.Show("Selecione a fase de crescimento!\n");
                return;
            }
            Lote.FaseCrescimento = cmbCrescimentoAlterar.Text;
            try {
                Lote.PesoMedio = double.Parse(txbPesoAlterar.Text);
                if (!txbPesoAlterar.Text.Contains(","))
                {
                    throw new FormatException();
                }
            } catch (FormatException) {
                MessageBox.Show("Peso Médio inválido!\n");
                return;
            }
            try {
                Lote.Mortalidade = int.Parse(txbMortalidadeAlterar.Text);
            } catch (FormatException) {
                MessageBox.Show("Número de mortalidades inválida!\n");
                return;
            }
            if (Lote.Salvar(true))
            {
                MessageBox.Show("Salvo com sucesso!\n");
            }
            else
            {
                MessageBox.Show("Erro ao salvar!\n");
            }
            Reset();
            panelAlterarDados.Visible = false;
        }
Esempio n. 4
0
        private void BtnOkPesquisar_Click(object sender, EventArgs e)
        {
            clsLote Lote = new clsLote();

            if (!chkNumero.Checked)
            {
                try {
                    int menor = int.Parse(txbNMenor.Text);
                    int maior = int.Parse(txbNMaior.Text);
                    if (maior < menor)
                    {
                        throw new Exception("O número do lote do  primeiro bloco deve ser menor do que o do segundo!");
                    }
                } catch (FormatException) {
                    MessageBox.Show("Número do lote inválido!\n");
                    return;
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            if (!chkAves.Checked)
            {
                try {
                    int menor = int.Parse(txbAvesMenor.Text);
                    int maior = int.Parse(txbAvesMaior.Text);
                    if (maior < menor)
                    {
                        throw new Exception("O número de aves do primeiro bloco deve ser menor do que o do segundo!\n");
                    }
                } catch (FormatException) {
                    MessageBox.Show("Formato inválido na seção Número!\n");
                    return;
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            if (cmbFasePesquisa.Text.Length == 0 && !chkFase.Checked)
            {
                MessageBox.Show("Selecione a fase de crescimento!\n");
                return;
            }
            if (!chkPeso.Checked)
            {
                try {
                    double menor = double.Parse(txbPesoMenor.Text);
                    double maior = double.Parse(txbPesoMaior.Text);
                    if (maior < menor)
                    {
                        throw new Exception("O peso do primeiro bloco deve ser menor que o do segundo!\n");
                    }
                    if (!txbPesoMenor.Text.Contains(",") || !txbPesoMaior.Text.Contains(","))
                    {
                        throw new FormatException();
                    }
                } catch (FormatException) {
                    MessageBox.Show("Formato inválido na seção Peso!\n");
                    return;
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            if (!chkMortalidade.Checked)
            {
                try {
                    int menor = int.Parse(txbMortalidadeMenor.Text);
                    int maior = int.Parse(txbMortalidadeMaior.Text);
                    if (maior < menor)
                    {
                        throw new Exception("O número de mortalidades do primeiro bloco dever ser menor do que o do segundo!\n");
                    }
                } catch (FormatException) {
                    MessageBox.Show("Formato inválido na seção Mortalidade!\n");
                    return;
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            List <KeyValuePair <string, string> > ls = new List <KeyValuePair <string, string> >();

            if (chkNumero.Checked)
            {
                ls.Add(new KeyValuePair <string, string>("any", "any"));
            }
            else
            {
                ls.Add(new KeyValuePair <string, string>(txbNMenor.Text, txbNMaior.Text));
            }
            if (chkAves.Checked)
            {
                ls.Add(new KeyValuePair <string, string>("any", "any"));
            }
            else
            {
                ls.Add(new KeyValuePair <string, string>(txbAvesMenor.Text, txbAvesMaior.Text));
            }
            if (chkFase.Checked)
            {
                ls.Add(new KeyValuePair <string, string>("any", "any"));
            }
            else
            {
                ls.Add(new KeyValuePair <string, string>(cmbFasePesquisa.Text, "selected"));
            }
            if (chkPeso.Checked)
            {
                ls.Add(new KeyValuePair <string, string>("any", "any"));
            }
            else
            {
                ls.Add(new KeyValuePair <string, string>(txbPesoMenor.Text, txbPesoMaior.Text));
            }
            if (chkMortalidade.Checked)
            {
                ls.Add(new KeyValuePair <string, string>("any", "any"));
            }
            else
            {
                ls.Add(new KeyValuePair <string, string>(txbMortalidadeMenor.Text, txbMortalidadeMaior.Text));
            }
            Reset();
            panelPesquisar.Visible = false;
            Set_DataGrid();
            clsLote.CarregaGrid(dgv, ls);
            panelDataGrid.Visible = true;
        }