Esempio n. 1
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            Ocorrencias    ocorrencias    = new Ocorrencias();
            OcorrenciasBO  ocorrenciasBO  = new OcorrenciasBO();
            OcorrenciasDAO ocorrenciasDAO = new OcorrenciasDAO();

            this.dataGridView1.DefaultCellStyle.Font = new Font("Arial", 10);

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

                    dataGridView1.DataSource = ocorrenciasDAO.BuscaApto(txtBusca.Text);

                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhuma ocorrência encontrada");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
            if (rbtBloco.Checked)
            {
                try
                {
                    ocorrencias.BA.Bloco = txtBusca.Text;

                    dataGridView1.DataSource = ocorrenciasDAO.BuscaBloco(txtBusca.Text);

                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhuma ocorrência encontrada");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
        }
Esempio n. 2
0
        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 = txtProprietario.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Proprietário não encontrado");
                            txtProprietario.Clear();
                        }

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

                            try
                            {
                                //add ocorrencias
                                Ocorrencias   ocorrencias   = new Ocorrencias();
                                OcorrenciasBO ocorrenciasBO = new OcorrenciasBO();
                                ocorrencias.Motivo = txtMotivo.Text;

                                if ((ocorrencias.Motivo == "") || (ocorrencias.Motivo == null))
                                {
                                    MessageBox.Show("Motivo não identificado");
                                }
                                else
                                {
                                    ocorrencias.Motivo = txtMotivo.Text.ToUpper();
                                    ocorrencias.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                    ocorrencias.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                    ocorrencias.Data = Convert.ToDateTime(mskData.Text);

                                    ocorrenciasBO.Gravar(ocorrencias);
                                    MessageBox.Show("Ocorrência cadastrada com sucesso");

                                    txtProprietario.Clear();
                                    txtApto.Clear();
                                    txtBloco.Clear();
                                    txtMotivo.Clear();
                                    mskData.Clear();
                                }
                            }
                            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");
            }
        }
Esempio n. 3
0
        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 = txtProprietario.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Proprietário não encontrado");
                            txtProprietario.Clear();
                        }

                        else
                        {
                            lblMoradorCod.Text = Convert.ToString(mor.CodMorador);
                            //altera A  ocorrencia
                            try
                            {
                                Ocorrencias   ocorrencias   = new Ocorrencias();
                                OcorrenciasBO ocorrenciasBO = new OcorrenciasBO();

                                ocorrencias.Motivo = txtMotivo.Text.ToUpper();
                                if ((ocorrencias.Motivo == "") || (ocorrencias.Motivo == null))
                                {
                                    MessageBox.Show("Motivo não identificado");
                                }
                                else
                                {
                                    ocorrencias.CodOcorrencia        = Convert.ToInt16(lblCodOcorrencia.Text);
                                    ocorrencias.Motivo               = txtMotivo.Text.ToUpper();
                                    ocorrencias.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                    ocorrencias.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                    ocorrencias.Data = Convert.ToDateTime(mskData.Text);

                                    ocorrenciasBO.Editar(ocorrencias);
                                    MessageBox.Show("Ocorrência editada com sucesso");

                                    txtProprietario.Clear();
                                    txtApto.Clear();
                                    txtBloco.Clear();;
                                    txtMotivo.Clear();
                                    mskData.Clear();
                                    txtBusca.Clear();
                                    panel1.Enabled     = false;
                                    btnAlterar.Enabled = false;


                                    lblCodOcorrencia.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");
            }
        }