Ejemplo n.º 1
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                dataGridView1.Rows[i].DataGridView.Columns.Clear();
            }

            Obras   obras   = new Obras();
            ObrasBO obrasBO = new ObrasBO();

            try
            {
                obras.CodObras = Convert.ToInt16(lblCodObra.Text);
                obrasBO.Deletar(obras);

                MessageBox.Show("Obra excluída com sucesso");

                mskData.Clear();
                txtApto.Clear();
                txtBloco.Clear();;
                txtProprietario.Clear();

                txtBusca.Clear();
                panel1.Enabled     = false;
                btnAlterar.Enabled = false;
                btnExcluir.Enabled = false;
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
Ejemplo n.º 2
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            Obras    obras    = new Obras();
            ObrasBO  obrasBO  = new ObrasBO();
            ObrasDAO obrasDAO = new ObrasDAO();

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

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

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

                    dataGridView1.DataSource = obrasDAO.BuscaBloco(txtBusca.Text);
                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhuma obra encontrada");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
        }
Ejemplo n.º 3
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");
                    txtBloco.Clear();
                    txtApto.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 obras
                                Obras   obras   = new Obras();
                                ObrasBO obrasBO = new ObrasBO();


                                obras.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                obras.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                obras.DataHora             = Convert.ToDateTime(mskData.Text);


                                obrasBO.Gravar(obras);
                                MessageBox.Show("Obra cadastrada com sucesso");

                                txtProprietario.Clear();
                                txtApto.Clear();
                                txtBloco.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");
            }
        }
Ejemplo n.º 4
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 o pet
                            try
                            {
                                Obras   obras   = new Obras();
                                ObrasBO obrasBO = new ObrasBO();


                                obras.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                obras.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                obras.DataHora             = Convert.ToDateTime(mskData.Text);
                                obras.CodObras             = Convert.ToInt16(lblCodObra.Text);

                                obrasBO.Editar(obras);
                                MessageBox.Show("Obra editada com sucesso");

                                txtProprietario.Clear();
                                txtApto.Clear();
                                txtBloco.Clear();
                                mskData.Clear();

                                txtBusca.Clear();
                                panel1.Enabled     = false;
                                btnAlterar.Enabled = false;
                                btnExcluir.Enabled = false;
                            }
                            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");
            }
        }