Minha Unit ta com um erro de violação... bla bla bla...
Abaixo segue o código de uma Unit que fazer a leitura em meu banco de dados e retorna os resultados na tela para alteração.
Quando eu executo ela da primeira vez tudo funciona perfeitamente. Quanto eu vou na Grid e chamo para exibir um outro registro diferente, da um erro:
Access violation at address 00000000. Read of address 00000000.
O que pode ser?
Abraços
unit uEditarImovel;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Buttons, ComCtrls, ExtDlgs, Spin, DB, ZAbstractRODataset, ZAbstractDataset, ZDataset, Mask, DBCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP, Gauges;type TfrmEditarImovel = class(TForm) Panel1: TPanel; Shape1: TShape; PageControl1: TPageControl; TabSheet1: TTabSheet; TabSheet2: TTabSheet; ScrollBox1: TScrollBox; Image13: TImage; ZQuery1: TZQuery; BitBtn1: TBitBtn; DataSource1: TDataSource; ZQuery2: TZQuery; ZQuery3: TZQuery; DataSource2: TDataSource; Panel2: TPanel; GroupBox1: TGroupBox; OpenDlg: TOpenDialog; GroupBox2: TGroupBox; IdFTP1: TIdFTP; ProgressBar1: TProgressBar; ScrollBox3: TScrollBox; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; Label16: TLabel; Label17: TLabel; Label18: TLabel; Label19: TLabel; Label20: TLabel; Shape2: TShape; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; Label25: TLabel; Label26: TLabel; Shape3: TShape; Label27: TLabel; Shape4: TShape; Label28: TLabel; Shape5: TShape; Label29: TLabel; Shape6: TShape; Label30: TLabel; Label31: TLabel; Label32: TLabel; Label33: TLabel; Label34: TLabel; Label35: TLabel; Label36: TLabel; Label37: TLabel; Label38: TLabel; Label39: TLabel; Label1: TLabel; CheckBox1: TCheckBox; CheckBox2: TCheckBox; CheckBox3: TCheckBox; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: TEdit; Edit6: TEdit; Edit8: TEdit; Edit9: TEdit; Edit10: TEdit; Edit11: TEdit; Edit12: TEdit; Edit13: TEdit; CheckBox4: TCheckBox; UpDown1: TUpDown; Edit14: TEdit; Edit15: TEdit; Edit16: TEdit; Edit17: TEdit; UpDown2: TUpDown; UpDown3: TUpDown; UpDown4: TUpDown; CheckBox5: TCheckBox; Edit18: TEdit; UpDown5: TUpDown; RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton3: TRadioButton; ScrollBox5: TScrollBox; ComboBox6: TComboBox; ComboBox7: TComboBox; Edit19: TEdit; ComboBox8: TComboBox; Edit20: TEdit; ComboBox9: TComboBox; Edit21: TEdit; Edit22: TEdit; Edit23: TEdit; Memo1: TMemo; Edit24: TEdit; Edit25: TEdit; UpDown6: TUpDown; UpDown7: TUpDown; Edit26: TEdit; UpDown8: TUpDown; MaskEdit1: TMaskEdit; Edit7: TEdit; ScrollBox4: TScrollBox; ScrollBox2: TScrollBox; Edit29: TEdit; Label40: TLabel; ZQuery4: TZQuery; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure BitBtn1Click(Sender: TObject); procedure CheckBox5Click(Sender: TObject); procedure CheckBox3Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); procedure IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); private { Private declarations } procedure CheckBoxDependencia(rotulo: string; id, coluna, linha, marcado2: integer); procedure CheckBoxDetalhes (rotulo: string; id, coluna, linha: integer); procedure RadioButtonTipo(rotulo: string; id, coluna, linha, marcado: integer); public { Public declarations } procedure Carrega(codImovel: integer); end;var frmEditarImovel: TfrmEditarImovel; arrayFotos : Array of String; arrayMapas : Array of String; arrayBancoFotos : Array of String; arrayBancoMapas : Array of String; bytesToTransfer: integer;implementationuses uSobre, uConexao, uPrincipal, uMd5, uBancoDeDados, uCadastrarImoveis;{$R *.dfm}procedure TfrmEditarImovel.CheckBoxDependencia(rotulo: string; id, coluna, linha, marcado2: integer);var check: TCheckBox;begincheck:=TCheckBox.Create(Self);check.Parent := ScrollBox4;check.Caption := rotulo;if marcado2 = 1 then check.Checked := true;check.Tag := id;check.Top:=(linha * 17) - 17;check.Width:=120;check.Left:=(coluna * 160) - 160;end;procedure TfrmEditarImovel.CheckBoxDetalhes(rotulo: string; id, coluna, linha: integer);var check: TCheckBox;begincheck:=TCheckBox.Create(Self);check.Parent := ScrollBox5;check.Caption := rotulo;check.Tag := id;check.Top:=(linha * 17) - 17;check.Width:=120;check.Left:=(coluna * 160) - 160;end;procedure TfrmEditarImovel.RadioButtonTipo(rotulo: string; id, coluna, linha, marcado: integer);var check: TRadioButton;begincheck:=TRadioButton.Create(Self);check.Parent := ScrollBox2;check.Caption := rotulo;if marcado = 1 then check.Checked := trueelse check.Checked := false;check.Tag := id;check.Top:=(linha * 17) - 17;check.Width:=120;check.Left:=(coluna * 160) - 160;end;procedure TfrmEditarImovel.FormClose(Sender: TObject; var Action: TCloseAction);begin Action := caFree; frmCadastrarImoveis := nil;end;function splitstr(valor, caracter: string; index: integer): string;varanterior,i,contador:integer;begincontador:=0;for i:=0 to length(valor) dobegin if valor[i]=caracter then begin if (contador = index-1) then begin result:=copy(valor,anterior+1,i-anterior-1); exit; end; anterior:=i; inc(contador,1); end; if i=length(valor) then begin result:=copy(valor,anterior+1,i-anterior); exit; end; if index=1 then begin result:=copy(valor,0,pos(caracter,valor)-1); exit; end;end;end;function geraNome(aQuant: integer): string;var i: integer;const str = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';begin for i:= 1 to aQuant do begin Randomize; Result := Result + str[Random(Length(str))+1]; end;end;procedure TfrmEditarImovel.BitBtn1Click(Sender: TObject);var x0, x1, x2, i, a, b, contadorFoto, idRetorno: integer; sql, sqlFoto, guardaNome : string; diretorio : string; id_tb_cliente, tipo_cliente, em_destaque, tipo_de_imovel: string; imovel_de_alto_padrao, destaque_da_semana, codigo_de_referencia: string; edificio, numero_de_pavimentos, pavimentos_do_imovel: string; numero_de_imoveis_por_pavimento, endereco, numero, bairro: string; cidade, cep, estado, entre_rua_1a, entre_rua_1b, entre_rua_2a: string; entre_rua_2b, ponto_de_referencia, linhas_urbanas, finalidadeVenda: string; finalidadeLocacao, finalidadeLocacaoTemporada, situacao_do_imovel: string; situacao_finaceira, area_total, medida_area_total, area_construida: string; medida_area_construida, dados_do_imovel, valor, valor_condominio: string; iptu: string; total_de_quartos, numero_de_quartos, numero_de_suites_simples, numero_de_suites_master: integer; vagas_na_garagem, vaga_coberta, dependencias_do_imovel, observacoes, numero_de_banheiro, url_destaque: string;begin for x0 := 0 to ComponentCount - 1 do if Components[x0].ClassType = TRadioButton then if TRadioButton(Components[x0]).Parent = ScrollBox2 then if TRadioButton(Components[x0]).Checked then begin tipo_de_imovel := IntToStr(TRadioButton(Components[x0]).Tag); if tipo_de_imovel = '' then begin ShowMessage('Selecione um tipo de imóvel.'); ScrollBox3.VertScrollBar.Position := 0; Label1.Font.Color := clRed; end else begin Label1.Font.Color := clBlack; if Edit3.Text = '' then begin PageControl1.ActivePage := TabSheet1; showmessage('Digite o endereço do imóvel.'); ScrollBox3.VertScrollBar.Position := 0; Label9.Font.Color := clRed; Edit3.SetFocus; end else begin Label9.Font.Color := clBlack; if Edit4.Text = '' then begin PageControl1.ActivePage := TabSheet1; showmessage('Digite o número do endereço do imóvel.'); ScrollBox3.VertScrollBar.Position := 0; Label10.Font.Color := clRed; Edit4.SetFocus; end else begin Label10.Font.Color := clBlack; if Edit5.Text = '' then begin PageControl1.ActivePage := TabSheet1; showmessage('Digite o bairro do imóvel.'); ScrollBox3.VertScrollBar.Position := 0; Label11.Font.Color := clRed; Edit5.SetFocus; end else begin Label11.Font.Color := clBlack; if Edit6.Text = '' then begin PageControl1.ActivePage := TabSheet1; showmessage('Digite o nome da cidade.'); ScrollBox3.VertScrollBar.Position := 0; Label12.Font.Color := clRed; Edit6.SetFocus; end else begin Label12.Font.Color := clBlack; if (CheckBox3.Checked) and (Edit7.Text = '') then begin PageControl1.ActivePage := TabSheet1; showmessage('Digite o endereco(URL) eletrônico do lançamento.'); ScrollBox3.VertScrollBar.Position := 0; Label39.Font.Color := clRed; Edit7.SetFocus; end else begin Label39.Font.Color := clBlack; if Edit29.Text = '' then begin PageControl1.ActivePage := TabSheet1; showmessage('Selecione o estado.'); ScrollBox3.VertScrollBar.Position := 0; Label14.Font.Color := clRed; Edit29.Setfocus; end else begin Label14.Font.Color := clBlack; if (not RadioButton1.Checked) AND (not RadioButton2.Checked) AND (not RadioButton3.Checked) then begin PageControl1.ActivePage := TabSheet1; showmessage('Você deve selecionar uma finalidade.'); ScrollBox3.VertScrollBar.Position := 604; Label28.Font.Color := clRed; end else begin Label28.Font.Color := clBlack; if Edit21.Text = '' then begin PageControl1.ActivePage := TabSheet1; showmessage('Você deve digitar um valor.'); ScrollBox3.VertScrollBar.Position := 855; Label35.Font.Color := clRed; Edit21.SetFocus; exit; end else begin Label35.Font.Color := clBlack; { Gravando os dados } // Grava o ID do usuario conectado id_tb_cliente := frmPrincipal.idUsuario; // Grava o tipo de usuario tipo_cliente := frmPrincipal.tipoDePessoa; // Em Destaque if CheckBox1.Checked then begin em_destaque := 'ON'; end else begin em_destaque := ''; end; // Imovel de alto padrao if CheckBox2.Checked then begin imovel_de_alto_padrao := 'ON'; end else begin imovel_de_alto_padrao := ''; end; // Lançamento if CheckBox3.Checked then begin url_destaque := Edit7.Text; end else begin url_destaque := ''; end; // Codigo de referencia codigo_de_referencia := Edit1.Text; // Edificil edificio := Edit2.Text; // Numero de andares numero_de_pavimentos := Edit24.Text; // Andar do imovel pavimentos_do_imovel := Edit25.Text; // Numero de imoveis por andar numero_de_imoveis_por_pavimento := Edit26.Text; // Endereço endereco := Edit3.Text; // numero numero := Edit4.Text; // bairro bairro := Edit5.Text; // cidade cidade := Edit6.Text; // CEP cep := MaskEdit1.Text; // Estado estado := Edit29.Text; // Entre ruas 1a entre_rua_1a := Edit8.Text; // Entre ruas 1b entre_rua_1b := Edit9.Text; // Entre ruas 2a entre_rua_2a := Edit10.Text; // Entre ruas 2b entre_rua_2b := Edit11.Text; // ponto de referencia ponto_de_referencia := Edit12.Text; // Linhas urbanas linhas_urbanas := Edit13.Text; // Dependencias do imovel dependencias_do_imovel := ''; for x1:=0 to ComponentCount - 1 do if Components[x1].ClassType = TCheckBox then if TCheckBox(Components[x1]).Parent = ScrollBox4 then if TCheckBox(Components[x1]).Checked then begin if dependencias_do_imovel <> '' then dependencias_do_imovel := dependencias_do_imovel + ';'; dependencias_do_imovel := dependencias_do_imovel + IntToStr(TCheckBox(Components[x1]).Tag); end; // Numero de quartos numero_de_quartos := StrToInt(Edit14.Text); // Numero de suites simples numero_de_suites_simples := StrToInt(Edit15.Text); // Numero de suites master numero_de_suites_master := StrToInt(Edit16.Text); // Total de quartos total_de_quartos := numero_de_quartos + numero_de_suites_simples + numero_de_suites_master; // Vagas na garagem vagas_na_garagem := Edit17.Text; // Vaga coberta if CheckBox4.Checked then begin vaga_coberta := 'ON'; end else begin vaga_coberta := ''; end; // banheiro if CheckBox5.Checked then begin numero_de_banheiro := Edit18.Text; end else begin numero_de_banheiro := '0'; end; // finalidade Venda if RadioButton1.Checked then begin finalidadeVenda := 'ON'; end else begin finalidadeVenda := ''; end; // finalidade Locação if RadioButton2.Checked then begin finalidadeLocacao := 'ON'; end else begin finalidadeLocacao := ''; end; // finalidade Locação Temporada if RadioButton2.Checked then begin finalidadeLocacaoTemporada := 'ON'; end else begin finalidadeLocacaoTemporada := ''; end; // Detalhes do Imovel dados_do_imovel := ''; for x2:=0 to ComponentCount - 1 do if Components[x2].ClassType = TCheckBox then if TCheckBox(Components[x2]).Parent = ScrollBox5 then if TCheckBox(Components[x2]).Checked then begin if dados_do_imovel <> '' then dados_do_imovel := dados_do_imovel + ';'; dados_do_imovel := dados_do_imovel + IntToStr(TCheckBox(Components[x2]).Tag); end; // Situação do Imovel if ComboBox6.Text = '' then begin situacao_do_imovel := ''; end else begin situacao_do_imovel := ComboBox6.Text; end; // Situação financeira if ComboBox7.Text = '' then begin situacao_finaceira := ''; end else begin situacao_finaceira := ComboBox7.Text; end; // área total area_total := Edit19.Text; // tipo media total medida_area_total := ComboBox8.Text; // Area construida area_construida := Edit20.Text; // medida area contruida medida_area_construida := ComboBox9.Text; // Valor valor := Edit21.Text; // valor do condominio valor_condominio := Edit22.Text; // valor do iptu iptu := Edit23.Text; // observações observacoes := Memo1.Text; Panel2.Visible := true; end; if Application.MessageBox('Deseja continuar com o cadastro?','Cadastro de imóvel',mb_iconquestion+mb_yesno+mb_defbutton1) = idyes then begin if conecta(true) then begin try Label40.Visible := true; Label40.Caption := 'Gravando os dados...'; frmCadastrarImoveis.Repaint; // Gravando no banco ZQuery1.Active := false; ZQuery1.SQL.Clear; sql := 'INSERT INTO tb_imovel values ("","'+id_tb_cliente+'","'+tipo_cliente+'","'+em_destaque+'","'+tipo_de_imovel+'","'+imovel_de_alto_padrao+'","'+destaque_da_semana+'","'+codigo_de_referencia+'","'+edificio+'","'+numero_de_pavimentos+'","'+pavimentos_do_imovel+'","'+numero_de_imoveis_por_pavimento+'","'+endereco+'","'+numero+'","'+bairro+'","'+cidade+'","'+cep+'","'+estado+'","'+entre_rua_1a+'","'+entre_rua_1b+'","'+entre_rua_2a+'","'+entre_rua_2b+'","'+ponto_de_referencia+'","'+linhas_urbanas+'","'+finalidadeVenda+'","'+finalidadeLocacao+'","'+finalidadeLocacaoTemporada+'","'+situacao_do_imovel+'","'+situacao_finaceira+'","'+area_total+'","'+medida_area_total+'","'+area_construida+'","'+medida_area_construida+'","'+dados_do_imovel+'","'+valor+'","'+valor_condominio+'","'+iptu+'","'+IntToStr(numero_de_quartos)+'","'+IntToStr(numero_de_suites_simples)+'","'; sql := sql + ''+IntToStr(numero_de_suites_master)+'","'+IntToStr(total_de_quartos)+'","'+vagas_na_garagem+'","'+vaga_coberta+'","'+dependencias_do_imovel+'","'+observacoes+'","'+numero_de_banheiro+'","'+url_destaque+'","0")'; ZQuery1.SQL.Add( sql ); ZQuery1.ExecSQL; ///// Pegando o ID do ultimo registro ///// ZQuery1.Active := false; ZQuery1.SQL.Clear; sql := 'select id from tb_imovel order by id desc'; ZQuery1.SQL.Add( sql ); ZQuery1.Open; idRetorno := ZQuery1.FieldByName('id').Value; Label40.Visible := false; frmCadastrarImoveis.Repaint; except ShowMessage('Código do erro: SQL-001'+#13+'Não foi possível executar a instrução SQL.'); end; end else begin ShowMessage('Código do erro: CS-020'+#13+'Não foi possível conectar ao servidor.'); end; conecta(false); /////////////////////// // Enviando as FOTOS // /////////////////////// { Verifica se o array não esta vazio } // FOTOS \\ If (Length(arrayFotos)) > 0 then begin try IdFTP1.Host := 'www.londriimoveis.com.br'; IdFTP1.Username := 'roni'; IdFTP1.Password := 'rcf123'; if IdFTP1.Connected then begin IdFTP1.Disconnect; end else begin IdFTP1.Connect(); end; IdFTP1.ChangeDir('/public_html/admin_admin/fotos'); ProgressBar1.Visible := true; Label40.Visible := true; try for i := 0 to (Length(arrayFotos) - 1) do begin guardaNome := ''; guardaNome := geraNome(35); if arrayFotos[i] <> '' then begin Label40.Caption := arrayFotos[i]; frmCadastrarImoveis.Repaint; IdFTP1.Put(arrayFotos[i], guardaNome + '.jpg'); end; end; except on E: Exception do begin MessageDlg('[Fotos] Erro ao enviar as imagens!', mtError, [mbOK], 0); exit; end; end; finally Label40.Visible := false; ProgressBar1.Visible := false; IdFTP1.Disconnect; end; if conecta(true) then begin ////////////////////////////////////////////////////////////// /// Insere os dados das Fotos e Mapas no banco de dados /// ////////////////////////////////////////////////////////////// Label40.Visible := true; Label40.Caption := 'Gravando os dados...'; frmCadastrarImoveis.Repaint; for i := 0 to (Length(arrayBancoFotos) - 1) do begin ZQuery1.Active := false; ZQuery1.SQL.Clear; ZQuery1.SQL.Add( 'insert into tb_imovel_foto values ("","'+ IntToStr(idRetorno) +'","'+ arrayBancoFotos[i] +'")' ); ZQuery1.ExecSQL; end; Label40.Visible := false; frmCadastrarImoveis.Repaint; end else begin ShowMessage('Código do erro: CS-021'+#13+'Não foi possível conectar ao servidor.'); end; end;// Fim da verificação do array // MAPAS \\ If (Length(arrayMapas)) > 0 then begin try IdFTP1.Host := 'www.londriimoveis.com.br'; IdFTP1.Username := 'roni'; IdFTP1.Password := 'rcf123'; if IdFTP1.Connected then begin IdFTP1.Disconnect; end else begin IdFTP1.Connect(); end; IdFTP1.ChangeDir('/public_html/admin_admin/mapas'); ProgressBar1.Visible := true; Label40.Visible := true; try for i := 0 to (Length(arrayMapas) - 1) do begin guardaNome := ''; guardaNome := geraNome(35); if arrayMapas[i] <> '' then begin Label40.Caption := arrayMapas[i]; frmCadastrarImoveis.Repaint; IdFTP1.Put(arrayMapas[i], guardaNome + '.jpg'); end; end; except on E: Exception do begin MessageDlg('[Mapas] Erro ao enviar as imagens!', mtError, [mbOK], 0); exit; end; end; finally Label40.Visible := false; ProgressBar1.Visible := false; IdFTP1.Disconnect; end; if conecta(true) then begin ////////////////////////////////////////////////////////////// /// Insere os dados das Fotos e Mapas no banco de dados /// ////////////////////////////////////////////////////////////// Label40.Visible := true; Label40.Caption := 'Gravando os dados...'; frmCadastrarImoveis.Repaint; for i := 0 to (Length(arrayBancoMapas) - 1) do begin ZQuery1.Active := false; ZQuery1.SQL.Clear; ZQuery1.SQL.Add( 'insert into tb_imovel_mapa values ("","'+ IntToStr(idRetorno) +'","'+ arrayBancoMapas[i] +'")' ); ZQuery1.ExecSQL; end; Label40.Visible := false; frmCadastrarImoveis.Repaint; end else begin ShowMessage('Código do erro: CS-022'+#13+'Não foi possível conectar ao servidor.'); end; end;// Fim da verificação do array showmessage('Cadastro concluído com sucesso!'+#13+#13+'O formulário será fechado.'); frmCadastrarImoveis.Close; end; end; end; end; end; end; end; end; end; end;end;procedure TfrmEditarImovel.CheckBox5Click(Sender: TObject);begin if CheckBox5.Checked then begin Edit18.Enabled := true; UpDown5.Enabled := true; Label27.Enabled := true; end else begin Edit18.Enabled := false; UpDown5.Enabled := false; Label27.Enabled := false; Edit18.Text := '0'; end;end;procedure TfrmEditarImovel.Carrega(codImovel: integer);var x1, x2, y1, y2, pulo, marcado, x, i, l1, marcado2, marcado3 : integer; sql01, sql02, dep, aux1: string; concluido: boolean;begin PageControl1.ActivePage := TabSheet1; ScrollBox3.VertScrollBar.Position := 0; // Conecta ao servidor frmPrincipal.Processando(TRUE); if conecta(True) then begin ZQuery4.Active := false; ZQuery4.SQL.Clear(); sql02 := 'SELECT *FROM tb_imovel WHERE id='+IntToStr(codImovel); ZQuery4.SQL.Add(sql02); ZQuery4.Open; frmEditarImovel.Caption := 'Editar Imóvel [ Ref.: '+ZQuery4.FieldByName('codigo_de_referencia').AsString+']'; // Em Destaque if ZQuery4.FieldByName('em_destaque').AsString = 'ON' then CheckBox1.Checked := TRUE else CheckBox1.Checked := FALSE; // Imovel de Alto Padrão if ZQuery4.FieldByName('imovel_de_alto_padrao').AsString = 'ON' then CheckBox2.Checked := TRUE else CheckBox2.Checked := FALSE; Edit1.Text := ZQuery4.FieldByName('codigo_de_referencia').AsString; Edit2.Text := ZQuery4.FieldByName('edificio').AsString; Edit24.Text := ZQuery4.FieldByName('numero_de_pavimentos').AsString; Edit25.Text := ZQuery4.FieldByName('pavimentos_do_imovel').AsString; Edit26.Text := ZQuery4.FieldByName('numero_de_imoveis_por_pavimento').AsString; Edit3.Text := ZQuery4.FieldByName('endereco').AsString; Edit4.Text := ZQuery4.FieldByName('numero').AsString; Edit5.Text := ZQuery4.FieldByName('bairro').AsString; Edit6.Text := ZQuery4.FieldByName('cidade').AsString; MaskEdit1.Text := ZQuery4.FieldByName('cep').AsString; Edit29.Text := ZQuery4.FieldByName('estado').AsString; Edit8.Text := ZQuery4.FieldByName('entre_rua_1a').AsString; Edit9.Text := ZQuery4.FieldByName('entre_rua_1b').AsString; Edit10.Text := ZQuery4.FieldByName('entre_rua_2a').AsString; Edit11.Text := ZQuery4.FieldByName('entre_rua_2b').AsString; Edit12.Text := ZQuery4.FieldByName('ponto_de_referencia').AsString; Edit13.Text := ZQuery4.FieldByName('linhas_urbanas').AsString; Edit14.Text := ZQuery4.FieldByName('numero_de_quartos').AsString; Edit15.Text := ZQuery4.FieldByName('numero_de_suites_simples').AsString; Edit16.Text := ZQuery4.FieldByName('numero_de_suites_master').AsString; Edit17.Text := ZQuery4.FieldByName('vagas_na_garagem').AsString; if ZQuery4.FieldByName('vaga_coberta').AsString = 'ON' then CheckBox4.Checked := TRUE else CheckBox4.Checked := FALSE; if ZQuery4.FieldByName('numero_de_banheiro').AsInteger > 0 then begin CheckBox5.Enabled := true; CheckBox5.Checked := true; Edit18.Enabled := true; UpDown5.Enabled := true; Label27.Enabled := true; Edit18.Text := IntToStr( ZQuery4.FieldByName('numero_de_banheiro').AsInteger ); end; // Tipo de imóvel ZQuery1.Active := false; ZQuery1.SQL.Clear(); sql01 := 'select *from tb_imovel_tipo'; ZQuery1.SQL.Add( sql01 ); ZQuery1.Open; x1 := 1; y1 := 1; ZQuery1.First; while not ZQuery1.EOF do begin if ZQuery1.FieldByName('id').Value = ZQuery4.FieldByName('tipo_de_imovel').Value then marcado := 1; RadioButtonTipo( ZQuery1.FieldByName('descricao').Value, ZQuery1.FieldByName('id').Value, y1, x1, marcado); if (y1 = 3) then begin y1 := 1; inc(x1); end else begin inc(y1); end; ZQuery1.Next; end; // fim do while // Dependencia // preenchendo as dependencias do imovel ZQuery1.Active := false; ZQuery1.SQL.Clear(); sql01 := 'select *from tb_imovel_dependencias'; ZQuery1.SQL.Add( sql01 ); ZQuery1.Open; ZQuery1.Active := true; x1 := 1; y1 := 1; ZQuery1.First; dep := ZQuery4.FieldByName('dependencias_do_imovel').AsString; while not ZQuery1.EOF do begin if dep <> '' then begin l1 := 1; for i:=1 to length( dep ) do begin if dep[i] = ';' then begin Delete(aux1,Pos(';',aux1),1); if aux1 <> '' then if ZQuery1.FieldByName('id').Value = aux1 then marcado2 := 1; aux1 := ''; inc(l1); end else begin aux1 := aux1 + dep[i]; end; end; end; CheckBoxDependencia( ZQuery1.FieldByName('descricao').Value, ZQuery1.FieldByName('id').Value, y1, x1, marcado2); if (y1 = 4) then begin y1 := 1; inc(x1); end else begin inc(y1); end; ZQuery1.Next; end; // fim do while if ZQuery4.FieldByName('finalidadeVenda').AsString = 'ON' then RadioButton1.Checked := true; if ZQuery4.FieldByName('finalidadeLocacao').AsString = 'ON' then RadioButton2.Checked := true; if ZQuery4.FieldByName('finalidadeLocacaoTemporada').AsString = 'ON' then RadioButton3.Checked := true; if ZQuery4.FieldByName('situacao_do_imovel').AsString = 'Ocupado' then Combobox6.ItemIndex := 1; if ZQuery4.FieldByName('situacao_do_imovel').AsString = 'Desocupado' then Combobox6.ItemIndex := 2; if ZQuery4.FieldByName('situacao_finaceira').AsString = 'Quitado' then Combobox7.ItemIndex := 2; if ZQuery4.FieldByName('situacao_finaceira').AsString = 'Financiado' then Combobox7.ItemIndex := 1; Edit19.Text := ZQuery4.FieldByName('area_total').AsString; Edit20.Text := ZQuery4.FieldByName('area_construida').AsString; if ZQuery4.FieldByName('medida_area_total').AsString = 'M²' then Combobox8.ItemIndex := 0; if ZQuery4.FieldByName('medida_area_total').AsString = 'Km²' then Combobox8.ItemIndex := 1; if ZQuery4.FieldByName('medida_area_total').AsString = 'Hectares' then Combobox8.ItemIndex := 2; if ZQuery4.FieldByName('medida_area_total').AsString = 'Alqueires' then Combobox8.ItemIndex := 3; if ZQuery4.FieldByName('medida_area_construida').AsString = 'M²' then Combobox9.ItemIndex := 0; if ZQuery4.FieldByName('medida_area_construida').AsString = 'Km²' then Combobox9.ItemIndex := 1; if ZQuery4.FieldByName('medida_area_construida').AsString = 'Hectares' then Combobox9.ItemIndex := 2; if ZQuery4.FieldByName('medida_area_construida').AsString = 'Alqueires' then Combobox9.ItemIndex := 3; Edit21.Text := ZQuery4.FieldByName('valor').Value; Edit22.Text := ZQuery4.FieldByName('valor_condominio').Value; Edit23.Text := ZQuery4.FieldByName('iptu').Value; Memo1.Text := ZQuery4.FieldByName('observacoes').Value; // Detalhes ZQuery1.Active := false; ZQuery1.SQL.Clear(); sql01 := 'select *from tb_imovel_dados'; ZQuery1.SQL.Add( sql01 ); ZQuery1.Open; ZQuery1.Active := true; x1 := 1; y1 := 1; ZQuery1.First; while not ZQuery1.EOF do begin CheckBoxDetalhes( ZQuery1.FieldByName('descricao').Value, ZQuery1.FieldByName('id').Value, y1, x1); if (y1 = 4) then begin y1 := 1; inc(x1); end else begin inc(y1); end; ZQuery1.Next; end; // fim do while end; conecta(false); frmPrincipal.Processando(FALSE); end;procedure TfrmEditarImovel.CheckBox3Click(Sender: TObject);begin if CheckBox3.Checked then begin Label39.Visible := true; Edit7.Visible := true; end else begin Label39.Visible := false; Edit7.Visible := false; end;end;Procedure Inserir_Foto (Nome_Foto : String);Begin //Incrementa o Array... SetLength(arrayFotos,(Length(arrayFotos)+1)); //Assimila o valor do nome da foto ao array... arrayFotos[(Length(arrayFotos) -1)] := Nome_Foto;End;Procedure Inserir_Mapa (Nome_Mapa : String);Begin //Incrementa o Array... SetLength(arrayMapas,(Length(arrayMapas)+1)); //Assimila o valor do nome da foto ao array... arrayMapas[(Length(arrayMapas) -1)] := Nome_Mapa;End;procedure TfrmEditarImovel.Button1Click(Sender: TObject);var i : Integer;begin try IdFTP1.Host := 'www.londriimoveis.com.br'; IdFTP1.Username := 'roni'; IdFTP1.Password := 'rcf123'; if IdFTP1.Connected then begin IdFTP1.Disconnect; end else begin IdFTP1.Connect(); end; IdFTP1.ChangeDir('/public_html/admin_admin/diney/fotos'); ProgressBar1.Visible := true; try If (Length(arrayFotos)) > 0 then begin //para i = 0 até o tamanho do array - 1... for i := 0 to (Length(arrayFotos) - 1) do begin IdFTP1.Put(arrayFotos[i], 'novas-'+ IntToStr(i) +'.jpg'); end; end; except on E: Exception do begin MessageDlg('Erro ao enviar as imagens!', mtError, [mbOK], 0); exit; end; end; finally ProgressBar1.Visible := false; IdFTP1.Disconnect; end;end;procedure TfrmEditarImovel.IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);begin //incrementa o ProgressBar ProgressBar1.Position := AWorkCount;end;procedure TfrmEditarImovel.IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);begin ProgressBar1.Position := 0; if AWorkCountMax > 0 then ProgressBar1.Max := AWorkCountMax else ProgressBar1.Max := bytesToTransfer;end;end.Discussão (12)
Carregando comentários...