コード例 #1
0
        //BTN CADASTRAR PET
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (Preenche() == true)
            {
                try
                {
                    Pet    pet    = new Pet();
                    PetsBO petsBo = new PetsBO();

                    pet.Cliente.Codigo = Convert.ToInt32(txtDono.Text);
                    pet.Nome           = txtNome.Text;
                    pet.Especie        = txtEspecie.Text;
                    pet.Raca           = txtRaca.Text;
                    pet.Porte          = txtPorte.Text;
                    pet.Sexo           = txtSexo.Text;
                    pet.Cor            = txtCor.Text;

                    petsBo.Cadastrar(pet);
                    MyMessageBox.Show(this, "O pet foi cadastrado com sucesso!", "Pet Cadastrado!");
                }
                catch
                {
                    MyMessageBox.Show(this, "Por favor, preencha todas as caixas corretamente.", "Pet NÃO Cadastrado!");
                }
            }
        }
コード例 #2
0
ファイル: frmPets2.cs プロジェクト: CarinaEtec/RIGOR
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                dataGridView1.Rows[i].DataGridView.Columns.Clear();
            }

            Pets   pet   = new Pets();
            PetsBO petBO = new PetsBO();

            try
            {
                pet.CodPet = Convert.ToInt16(lblCodPet.Text);
                petBO.Deletar(pet);

                MessageBox.Show("Pet excluído com sucesso");

                txtNome.Clear();
                txtApto.Clear();
                txtBloco.Clear();;
                txtTutor.Clear();
                cbbEspecie.SelectedIndex = -1;
                txtBusca.Clear();
                panel1.Enabled     = false;
                btnAlterar.Enabled = false;
                btnExcluir.Enabled = false;

                lblCodPet.Text = "";
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
コード例 #3
0
ファイル: frmPets2.cs プロジェクト: CarinaEtec/RIGOR
        private void btnBuscar_Click_1(object sender, EventArgs e)
        {
            Pets    pet     = new Pets();
            PetsBO  petBO   = new PetsBO();
            PetsDAO petsDAO = new PetsDAO();


            if (rbtApto.Checked)
            {
                try
                {
                    pet.BA.Apto = txtBusca.Text;

                    dataGridView1.DataSource = petsDAO.BuscaAptoComCod(txtBusca.Text);

                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhum pet encontrado");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
            if (rbtBloco.Checked)
            {
                try
                {
                    pet.BA.Bloco = txtBusca.Text;

                    dataGridView1.DataSource = petsDAO.BuscaBlocoComCod(txtBusca.Text);

                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhum pet encontrado");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
        }
コード例 #4
0
ファイル: frmPets2.cs プロジェクト: CarinaEtec/RIGOR
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                dataGridView1.Rows[i].DataGridView.Columns.Clear();
            }


            try
            {
                //pega codigo bloco apartamento
                BA   ba   = new BA();
                BABO babo = new BABO();

                ba.Apto  = txtApto.Text;
                ba.Bloco = txtBloco.Text;

                babo.BuscaCodBA(ba);

                if ((ba.Bloco == "") || (ba.Apto == ""))
                {
                    MessageBox.Show("Bloco/Apartamento não encontrado");
                    txtApto.Clear();
                    txtBloco.Clear();
                }

                else
                {
                    lblBACod.Text = Convert.ToString(ba.Ba_Cod);


                    try
                    {   //pega codigo morador
                        Moradores   mor   = new Moradores();
                        MoradoresBO morBO = new MoradoresBO();


                        mor.Nome = txtTutor.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Tutor não encontrado");
                            txtTutor.Clear();
                        }

                        else
                        {
                            lblMoradorCod.Text = Convert.ToString(mor.CodMorador);
                            //altera o pet
                            try
                            {
                                Pets   pets   = new Pets();
                                PetsBO petsBO = new PetsBO();
                                pets.Nome = txtNome.Text;


                                if ((pets.Nome == "") || (pets.Nome == null))
                                {
                                    MessageBox.Show("Nome do pet não identificado");
                                }
                                else
                                {
                                    pets.CodPet = Convert.ToInt16(lblCodPet.Text);
                                    pets.Nome   = txtNome.Text.ToUpper();
                                    pets.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                    pets.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                    pets.Especie = cbbEspecie.SelectedItem.ToString();

                                    petsBO.Editar(pets);
                                    MessageBox.Show("Pet editado com sucesso");

                                    txtNome.Clear();
                                    txtApto.Clear();
                                    txtBloco.Clear();;
                                    txtTutor.Clear();
                                    cbbEspecie.SelectedIndex = -1;
                                    txtBusca.Clear();
                                    panel1.Enabled     = false;
                                    btnAlterar.Enabled = false;
                                    btnExcluir.Enabled = false;
                                    lblCodPet.Text     = "";
                                }
                            }
                            catch
                            {
                                MessageBox.Show("Verifique os dados e tente novamente");
                            }
                        }
                    }

                    catch
                    {
                        MessageBox.Show("Verifique os dados e tente novamente");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
コード例 #5
0
ファイル: frmPets.cs プロジェクト: CarinaEtec/RIGOR
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                //puxar codigo do ba
                BA   ba   = new BA();
                BABO babo = new BABO();

                ba.Apto  = txtApto.Text;
                ba.Bloco = txtBloco.Text;

                babo.BuscaCodBA(ba);

                if ((ba.Bloco == "") || (ba.Apto == ""))
                {
                    MessageBox.Show("Bloco/Apartamento não encontrado");
                    txtApto.Clear();
                    txtBloco.Clear();
                }

                else
                {
                    lblBACod.Text = Convert.ToString(ba.Ba_Cod);
                    //ouxar codigo do morador
                    try
                    {
                        Moradores   mor   = new Moradores();
                        MoradoresBO morBO = new MoradoresBO();


                        mor.Nome = txtTutor.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Tutor não encontrado");
                            txtTutor.Clear();
                        }

                        else
                        {
                            lblMoradorCod.Text = Convert.ToString(mor.CodMorador);

                            try
                            {
                                //add pet
                                Pets   pets   = new Pets();
                                PetsBO petsBO = new PetsBO();

                                pets.Nome = txtNome.Text;

                                if ((pets.Nome == "") || (pets.Nome == null))
                                {
                                    MessageBox.Show("Nome do pet não identificado");
                                }
                                else
                                {
                                    pets.Nome = txtNome.Text.ToUpper();
                                    pets.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                    pets.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                    pets.Especie = cbbEspecie.SelectedItem.ToString();
                                    petsBO.Gravar(pets);
                                    MessageBox.Show("Pet cadastrado com sucesso");

                                    txtNome.Clear();
                                    txtApto.Clear();
                                    txtBloco.Clear();
                                    txtTutor.Clear();
                                    cbbEspecie.SelectedIndex = -1;
                                }
                            }
                            catch
                            {
                                MessageBox.Show("Verifique os dados e tente novamente");
                            }
                        }
                    }

                    catch
                    {
                        MessageBox.Show("Verifique os dados e tente novamente");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }