protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { if (Request.QueryString["id"] != "") { int id = int.Parse(Request.QueryString["id"]); imovel imo = new ImovelBusiness().SelecionarImovel(id); if (imo != null) { lbldescricao.Text = "Total de Área Construida: " + imo.areacon + "<br/><br/> Quantidade de Comodos: " + imo.qtdquartos + "<br/><br/> Metragem do Terreno:" + imo.areater + "<br/><br/> Valor:" + imo.valorvendalocacao; lblnome.Text = imo.finalidade; imgImovel.ImageUrl = "~/imoveis/" + imo.imagem1; lblvalor.Text = "Valor: R$ " + imo.valorvendalocacao; txtcodigo.Value = imo.id.ToString(); carregaGaleria(); } } else { Response.Redirect("index2.aspx"); } } } catch (Exception) { lbldescricao.Text = "Erro ao carregar os dados!"; } }
private void Corretores_Load(object sender, EventArgs e) { string nome = ""; ImovelBusiness catbus = new ImovelBusiness(); PessoaBusiness pesbus = new PessoaBusiness(); cbCategoria.DataSource = catbus.listarCategorias(nome); cbCategoria.ValueMember = "nome"; cbCategoria.DisplayMember = "nome"; }
private void cbCategoria_SelectionChangeCommitted(object sender, EventArgs e) { ImovelBusiness imovelbus = new ImovelBusiness(); List <ImovelEnderecoModel> imovellist = new List <ImovelEnderecoModel>(); //pessoa pes = cor.retornarPessoaPorCPF(); int cat = imovelbus.pegarIDCategoria(cbCategoria.SelectedValue.ToString()); imovellist = imovelbus.listarimovelPorCategoriaeValor(cat); //como pegar o cpf quando o cara selecionar dgvImovels.DataSource = imovellist; }//já esta buscando por categoria ! ai carai !
private void frmSelecionarImovel_Load(object sender, EventArgs e) { string nome = ""; ImovelBusiness catbus = new ImovelBusiness(); PessoaBusiness pesbus = new PessoaBusiness(); cbCategoria.DataSource = catbus.listarCategorias(nome); cbCategoria.ValueMember = "nome"; cbCategoria.DisplayMember = "nome"; cbValor.Items.Add("Valores para venda"); cbValor.Items.Add("");//fazer os filtros de preço para venda e locação agora }
private void btnCadastrarImovel_Click(object sender, EventArgs e) { string status = btnCadastrarImovel.Text; switch (status) { case "Cadastrar": if (VerificaCamposVazios_Imovel() && ValidarCampos_Imovel()) { // Envia os dados dos campos para o cadastro do imóvel do cliente. Cliente cliente = new Cliente(); cliente.Id_cliente = Convert.ToInt32(txtIdCliente_Imovel.Text); ImovelBusiness imovelBusiness = new ImovelBusiness(); Imovel imovel = new Imovel { Cliente = cliente, Endereco = txtEnderecoImovel.Text, Cidade = txtCidadeImovel.Text, Estado = cmbEstadoImovel.Text, Tipo = txtTipoImovel.Text, Valor = Convert.ToDecimal(txtValorImovel.Text), Data_aquisicao = dtpDataAquisicaoImovel.Value }; try { imovelBusiness.Inserir(imovel); MessageBox.Show("Imóvel cadastrado com sucesso!", "Cadastro de imóvel", MessageBoxButtons.OK, MessageBoxIcon.Information); // Limpa os campos para novo cadastro de imóvel do cliente. txtIdCliente_Imovel.Clear(); txtEnderecoImovel.Clear(); txtCidadeImovel.Clear(); cmbEstadoImovel.SelectedIndex = -1; txtTipoImovel.Clear(); txtValorImovel.Clear(); dtpDataAquisicaoImovel.Value = DateTime.Now; } catch (Exception) { MessageBox.Show("Cliente não cadastrado.", "Erro ao cadastrar imóvel", MessageBoxButtons.OK, MessageBoxIcon.Error); txtIdCliente_Imovel.SelectAll(); txtIdCliente_Imovel.Focus(); } } break; case "Alterar": if (VerificaCamposVazios_Imovel() && ValidarCampos_Imovel()) { // Envia os dados dos campos para o cadastro do imóvel do cliente. Cliente cliente = new Cliente(); cliente.Id_cliente = Convert.ToInt32(txtIdCliente_Imovel.Text); ImovelBusiness imovelBusiness = new ImovelBusiness(); Imovel imovel = new Imovel { Cliente = cliente, Endereco = txtEnderecoImovel.Text, Cidade = txtCidadeImovel.Text, Estado = cmbEstadoImovel.Text, Tipo = txtTipoImovel.Text, Valor = Convert.ToDecimal(txtValorImovel.Text), Data_aquisicao = dtpDataAquisicaoImovel.Value }; try { imovelBusiness.Alterar(imovel); MessageBox.Show("Imóvel alterado com sucesso!", "Alteração de imóvel", MessageBoxButtons.OK, MessageBoxIcon.Information); // Limpa os campos para novo cadastro de imóvel do cliente. txtIdCliente_Imovel.Clear(); txtEnderecoImovel.Clear(); txtCidadeImovel.Clear(); cmbEstadoImovel.SelectedIndex = -1; txtTipoImovel.Clear(); txtValorImovel.Clear(); dtpDataAquisicaoImovel.Value = DateTime.Now; tbcPrincipal.SelectedIndex = 0; btnCadastrarImovel.Text = "Cadastrar"; dgvImoveis.DataSource = null; } catch (Exception) { MessageBox.Show("Cliente não cadastrado.", "Erro ao alterar imóvel", MessageBoxButtons.OK, MessageBoxIcon.Error); txtIdCliente_Imovel.SelectAll(); txtIdCliente_Imovel.Focus(); } } break; default: break; } }