private void btnExcluir_Click(object sender, EventArgs e) { for (int i = 0; i < dataGridView1.RowCount; i++) { dataGridView1.Rows[i].DataGridView.Columns.Clear(); } Moradores mor = new Moradores(); MoradoresBO morBO = new MoradoresBO(); try { mor.CodMorador = Convert.ToInt16(lblMoradorCod.Text); morBO.Deletar(mor); MessageBox.Show("Morador excluído com sucesso"); txtNome.Clear(); mskDataNasc.Clear(); cbbSituacao.SelectedIndex = -1; mskTelefone.Clear(); mskCelular.Clear(); txtApto.Clear(); txtBloco.Clear(); panel1.Enabled = false; btnAlterar.Enabled = false; btnExcluir.Enabled = false; txtBusca.Clear(); txtBuscaNome.Clear(); } catch { MessageBox.Show("Preencha corretamente os campos e/ou verifique se esses dados não estão sendo usados"); txtNome.Clear(); mskDataNasc.Clear(); cbbSituacao.SelectedIndex = -1; mskTelefone.Clear(); mskCelular.Clear(); txtApto.Clear(); txtBloco.Clear(); panel1.Enabled = false; btnAlterar.Enabled = false; btnExcluir.Enabled = false; } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow linhaSelecionada; linhaSelecionada = dataGridView1.CurrentRow; txtApto.Text = linhaSelecionada.Cells[0].Value.ToString(); txtBloco.Text = linhaSelecionada.Cells[1].Value.ToString(); txtProprietario.Text = linhaSelecionada.Cells[2].Value.ToString(); mskHorarioInicio.Text = linhaSelecionada.Cells[3].Value.ToString(); mskHorarioTermino.Text = linhaSelecionada.Cells[4].Value.ToString(); lblCodLocacao.Text = linhaSelecionada.Cells[5].Value.ToString(); panel1.Enabled = true; btnAlterar.Enabled = true; btnExcluir.Enabled = true; try { //puxar codigo do BA BA ba = new BA(); BABO babo = new BABO(); ba.Apto = txtApto.Text; ba.Bloco = txtBloco.Text; babo.BuscaCodBA(ba); lblBACod.Text = Convert.ToString(ba.Ba_Cod); //puxar codigo do MORADOR Moradores mor = new Moradores(); MoradoresBO morBO = new MoradoresBO(); mor.Nome = txtProprietario.Text; morBO.Buscar(mor); lblMoradorCod.Text = Convert.ToString(mor.CodMorador); } catch { MessageBox.Show("Verifique os dados e tente novamente"); } }
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"); } }
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"); } }
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); 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 veiculos Veiculos veiculos = new Veiculos(); VeiculosBO veiculosBO = new VeiculosBO(); veiculos.Modelo = txtModelo.Text; veiculos.Placa = mskPlaca.Text.ToUpper();; if ((veiculos.Modelo == "") || (veiculos.Modelo == null) || (veiculos.Placa == " -")) { MessageBox.Show("Preencha todos os campos"); } else { veiculos.Placa = mskPlaca.Text.ToUpper();; veiculos.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text); veiculos.BA.Ba_Cod = Convert.ToInt16(lblBACod.Text); veiculos.Modelo = txtModelo.Text.ToUpper(); veiculos.Cor = cbbCor.SelectedItem.ToString(); veiculosBO.Gravar(veiculos); MessageBox.Show("Veículo cadastrado com sucesso"); txtProprietario.Clear(); txtApto.Clear(); txtBloco.Clear(); txtModelo.Clear(); cbbCor.SelectedIndex = -1; mskPlaca.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"); } }
private void btnBuscar_Click(object sender, EventArgs e) { Moradores moradores = new Moradores(); MoradoresBO moradoresBO = new MoradoresBO(); MoradorDAO moradordao = new MoradorDAO(); this.dataGridView1.DefaultCellStyle.Font = new Font("Arial", 10); if (rbtNome.Checked) { try { moradores.Nome = txtBuscaNome.Text; dataGridView1.DataSource = moradordao.BuscaMenor(txtBuscaNome.Text); for (int i = 0; i == dataGridView1.RowCount; i++) { MessageBox.Show("Nenhuma criança encontrada"); txtBuscaNome.Clear(); } } catch { MessageBox.Show("Preencha corretamente as informações"); } } if (rbtApto.Checked) { try { moradores.BA.Apto = txtBusca.Text; dataGridView1.DataSource = moradordao.BuscaAptoMenor(txtBusca.Text); for (int i = 0; i == dataGridView1.RowCount; i++) { MessageBox.Show("Nenhuma criança encontrada"); txtBusca.Clear(); } } catch { MessageBox.Show("Preencha corretamente as informações"); } } if (rbtBloco.Checked) { try { moradores.BA.Bloco = txtBusca.Text; dataGridView1.DataSource = moradordao.BuscaBlocoMenor(txtBusca.Text); for (int i = 0; i == dataGridView1.RowCount; i++) { MessageBox.Show("Nenhuma criança encontrada"); txtBusca.Clear(); } } catch { MessageBox.Show("Preencha corretamente as informações"); } } }
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"); } }
private void btnAlterar_Click(object sender, EventArgs e) { for (int i = 0; i < dataGridView1.RowCount; i++) { dataGridView1.Rows[i].DataGridView.Columns.Clear(); } 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); try { Moradores mor = new Moradores(); MoradoresBO morBO = new MoradoresBO(); mor.Nome = txtNome.Text; if (mor.Nome == "") { MessageBox.Show("Criança não identificada"); txtNome.Clear(); } else { mor.CodMorador = Convert.ToInt16(lblMoradorCod.Text); mor.Nome = txtNome.Text.ToUpper(); mor.DataNasc = Convert.ToDateTime(mskDataNasc.Text); mor.Situacao = cbbSituacao.SelectedItem.ToString(); mor.Telefone = mskTelefone.Text; mor.Celular = mskCelular.Text; mor.BA.Ba_Cod = Convert.ToInt16(lblBACod.Text); morBO.Editar(mor); MessageBox.Show("Criança editada com sucesso"); txtNome.Clear(); mskDataNasc.Clear(); cbbSituacao.SelectedIndex = -1; mskTelefone.Clear(); mskCelular.Clear(); txtApto.Clear(); txtBloco.Clear(); panel1.Enabled = false; btnAlterar.Enabled = false; btnExcluir.Enabled = false; txtBusca.Clear(); txtBuscaNome.Clear(); } } catch { MessageBox.Show("Verifique os dados e tente novamente"); } } } catch { MessageBox.Show("Verifique os dados e tente novamente"); } }
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"); } }
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); //cadastrar morador try { Moradores mor = new Moradores(); MoradoresBO morBO = new MoradoresBO(); mor.Nome = txtNome.Text; if ((mor.Nome == "") || (mor.Nome == null)) { MessageBox.Show("Nome do morador não identificado"); } else { mor.Nome = txtNome.Text.ToUpper(); mor.DataNasc = Convert.ToDateTime(mskDataNasc.Text); mor.Situacao = cbbSituacao.SelectedItem.ToString(); mor.Telefone = mskTelefone.Text; mor.Celular = mskCelular.Text; mor.BA.Ba_Cod = Convert.ToInt16(lblBACod.Text); morBO.Gravar(mor); MessageBox.Show("Morador cadastrado com sucesso"); txtApto.Clear(); txtBloco.Clear(); txtNome.Clear(); mskDataNasc.Clear(); cbbSituacao.SelectedIndex = -1; mskTelefone.Clear(); mskCelular.Clear(); } } catch { MessageBox.Show("Verifique os dados e tente novamente"); } } } catch { MessageBox.Show("Verifique os dados e tente novamente"); } }
private void btnBuscar_Click(object sender, EventArgs e) { Moradores mor = new Moradores(); MoradoresBO morBO = new MoradoresBO(); MoradorDAO DAO = new MoradorDAO(); if (rbtNome.Checked) { try { mor.Nome = txtBuscaNome.Text; dataGridView1.DataSource = DAO.BuscaMaior(txtBuscaNome.Text); for (int i = 0; i == dataGridView1.RowCount; i++) { MessageBox.Show("Nenhum morador encontrado"); txtBuscaNome.Clear(); } } catch { MessageBox.Show("Preencha corretamente as informações"); } } if (rbtApto.Checked) { try { mor.BA.Apto = txtBusca.Text; dataGridView1.DataSource = DAO.BuscaAptoMaior(txtBusca.Text); for (int i = 0; i == dataGridView1.RowCount; i++) { MessageBox.Show("Nenhum morador encontrado"); txtBusca.Clear(); } } catch { MessageBox.Show("Preencha corretamente as informações"); } } if (rbtBloco.Checked) { try { mor.BA.Bloco = txtBusca.Text; dataGridView1.DataSource = DAO.BuscaBlocoMaior(txtBusca.Text); for (int i = 0; i == dataGridView1.RowCount; i++) { MessageBox.Show("Nenhum morador encontrado"); txtBusca.Clear(); } } catch { MessageBox.Show("Preencha corretamente as informações"); } } }
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"); } }
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 veiculo try { Veiculos veiculos = new Veiculos(); VeiculosBO veiculosBO = new VeiculosBO(); veiculos.Modelo = txtModelo.Text; if ((veiculos.Modelo == "") || (veiculos.Modelo == null) || (veiculos.Placa == " -")) { MessageBox.Show("Preencha todos os campos"); } else { veiculos.Placa = mskPlaca.Text.ToUpper(); veiculos.Modelo = txtModelo.Text.ToUpper(); veiculos.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text); veiculos.BA.Ba_Cod = Convert.ToInt16(lblBACod.Text); veiculos.Cor = cbbCor.SelectedItem.ToString(); veiculosBO.Editar(veiculos); MessageBox.Show("Veículo editado com sucesso"); mskPlaca.Clear(); txtApto.Clear(); txtBloco.Clear();; txtModelo.Clear(); txtProprietario.Clear(); txtBusca.Clear(); cbbCor.SelectedIndex = -1; 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"); } }