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

            Locacoes   loc   = new Locacoes();
            LocacoesBO locBO = new LocacoesBO();

            try
            {
                loc.CodLocacao = Convert.ToInt16(lblCodLocacao.Text);
                locBO.Deletar(loc);

                MessageBox.Show("Locação excluída com sucesso");

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

                mskHorarioInicio.Clear();
                mskHorarioTermino.Clear();
                txtBusca.Clear();
                panel1.Enabled     = false;
                btnAlterar.Enabled = false;
                btnExcluir.Enabled = false;
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
示例#2
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            //panel1.Enabled = true;
            //btnAlterar.Enabled = true;
            //btnExcluir.Enabled = true;

            Locacoes    loc    = new Locacoes();
            LocacoesBO  locBO  = new LocacoesBO();
            LocacoesDAO locDAO = new LocacoesDAO();

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

                    dataGridView1.DataSource = locDAO.BuscaAptoComCod(txtBusca.Text);
                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhuma locação encontrada");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
            if (rbtBloco.Checked)
            {
                try
                {
                    loc.BA.Bloco = txtBusca.Text;

                    dataGridView1.DataSource = locDAO.BuscaBlocoComCod(txtBusca.Text);
                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhuma locação encontrada");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
        }
示例#3
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            Locacoes    loc    = new Locacoes();
            LocacoesBO  locBO  = new LocacoesBO();
            LocacoesDAO locDAO = new LocacoesDAO();

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

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

                    dataGridView1.DataSource = locDAO.BuscaApto(txtBusca.Text);
                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhuma locação encontrada");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }

            if (rbtBloco.Checked)
            {
                try
                {
                    loc.BA.Bloco             = txtBusca.Text;
                    dataGridView1.DataSource = locDAO.BuscaBloco(txtBusca.Text);

                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhuma locação encontrada");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
        }
示例#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
                            {
                                Locacoes   loc   = new Locacoes();
                                LocacoesBO locBO = new LocacoesBO();

                                loc.CodLocacao           = Convert.ToInt16(lblCodLocacao.Text);
                                loc.Inicio               = Convert.ToDateTime(mskHorarioInicio.Text);
                                loc.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                loc.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                loc.Termino              = Convert.ToDateTime(mskHorarioTermino.Text);

                                locBO.Editar(loc);
                                MessageBox.Show("Locação editada com sucesso");

                                txtProprietario.Clear();
                                txtApto.Clear();
                                txtBloco.Clear();;
                                mskHorarioTermino.Clear();
                                mskHorarioInicio.Clear();
                                txtBusca.Clear();
                                panel1.Enabled     = false;
                                btnAlterar.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");
            }
        }
示例#5
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 pet
                                Locacoes   loca   = new Locacoes();
                                LocacoesBO locaBO = new LocacoesBO();

                                loca.Moradores.Nome       = txtProprietario.Text.ToUpper();
                                loca.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                loca.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                loca.Inicio  = Convert.ToDateTime(mskHorarioInicio.Text);
                                loca.Termino = Convert.ToDateTime(mskHorarioTermino.Text);


                                locaBO.Gravar(loca);
                                MessageBox.Show("Locação cadastrada com sucesso");

                                txtProprietario.Clear();
                                txtApto.Clear();
                                txtBloco.Clear();
                                mskHorarioInicio.Clear();
                                mskHorarioTermino.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");
            }
        }