Ir para conteúdo
Fórum Script Brasil

Tiago Garcia2015

Membros
  • Total de itens

    4
  • Registro em

  • Última visita

Tudo que Tiago Garcia2015 postou

  1. amigo vou te passar o form não funcionou aqui. unit ClienteDadosU; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ModeloDadosU, Data.DB, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls, Vcl.Mask, Vcl.DBCtrls, Vcl.RibbonLunaStyleActnCtrls, Vcl.Ribbon, Vcl.Grids, Vcl.Samples.Calendar, IdContext, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdCmdTCPClient, Vcl.ScreenTips, Soap.InvokeRegistry, Soap.WSDLIntf, Soap.SOAPPasInv, Soap.SOAPHTTPPasInv; type TfrmClienteDados = class(TfrmModeloDados) lbnome: TLabel; nome: TDBEdit; lbempresa: TLabel; empresa: TDBEdit; lbie: TLabel; lbendereco: TLabel; endereco: TDBEdit; lbdata_cadastro: TLabel; data_cadastro: TDBEdit; lbdata_inativo: TLabel; data_inativo: TDBEdit; lblimite: TLabel; lbultima_nf: TLabel; ultima_nf: TDBEdit; Label1: TLabel; dbcidade: TDBComboBox; lbcidade: TLabel; lbestado: TLabel; DBComboBox1: TDBComboBox; Label2: TLabel; dbpais: TDBComboBox; lbpessoa: TLabel; ComboBox: TDBComboBox; Label3: TLabel; DBEdit1: TDBEdit; lbsexo: TLabel; dbsexo: TDBComboBox; DBATIVO: TDBComboBox; DBEdit2: TDBEdit; Label4: TLabel; DBEdit3: TDBEdit; Label6: TLabel; MaskEdit1: TMaskEdit; MaskEdit2: TMaskEdit; MaskEdit3: TMaskEdit; DBEdit5: TDBEdit; procedure cnpjKeyPress(Sender: TObject; var Key: Char); procedure ieKeyPress(Sender: TObject; var Key: Char); procedure limiteKeyPress(Sender: TObject; var Key: Char); procedure ultima_nfKeyPress(Sender: TObject; var Key: Char); procedure btnSalvarClick(Sender: TObject); procedure data_cadastroClick(Sender: TObject); procedure ComboBoxClick(Sender: TObject); procedure MaskEdit1Exit(Sender: TObject); private function cpf(num: string): boolean; public { Public declarations } end; var frmClienteDados: TfrmClienteDados; implementation {$R *.dfm} Uses DmU; procedure TfrmClienteDados.ultima_nfKeyPress(Sender: TObject; var Key: Char); begin inherited; If not( key in['0'..'9',#08] ) then key:=#0; end; procedure TfrmClienteDados.btnSalvarClick(Sender: TObject); begin DmOS.ztbCliente.FindField('c_id,c_nome'); if DmOS.ztbClientec_ativo.Value = 'N ' then begin DmOS.ztbClientec_data_inativo.Value := Now; end else begin // end; DmOS.ztbCliente.Post; end; procedure TfrmClienteDados.cnpjKeyPress(Sender: TObject; var Key: Char); begin If not( key in['0'..'9',#08] ) then key:=#0; end; procedure TfrmClienteDados.ComboBoxClick(Sender: TObject); begin inherited; if ComboBox.Items.Strings[ComboBox.ItemIndex] = 'Física' then begin Label6.Caption := 'CPF'; // seria o seu label onde o caption é c_cnpj lbie.Caption := 'RG'; MaskEdit2.EditMask := '000.000.000-00'; MaskEdit3.EditMask := '##############'; DmOS.ztbCliente.Edit; DmOS.ztbClientec_pessoa.Value := 'Física'; end; if ComboBox.Items.Strings[ComboBox.ItemIndex] = 'Juridica' then begin Label6.Caption := 'CNPJ'; // seria o seu label onde o caption é c_cnpj lbie.Caption := 'INSCR.EST'; MaskEdit2.EditMask := '000.000.000/0000-00'; MaskEdit3.EditMask := '000.000.000-000'; DmOS.ztbCliente.Edit; DmOS.ztbClientec_pessoa.Value := 'Juridica'; end; end; function TfrmClienteDados.cpf(num: string): boolean; var n1,n2,n3,n4,n5,n6,n7,n8,n9: integer; d1,d2: integer; digitado, calculado: string; begin if MaskEdit2.text = '' then exit; if MaskEdit2.text <> ' . . - ' then begin n1:=StrToInt(num[1]); n2:=StrToInt(num[2]); n3:=StrToInt(num[3]); n4:=StrToInt(num[5]); n5:=StrToInt(num[6]); n6:=StrToInt(num[7]); n7:=StrToInt(num[9]); n8:=StrToInt(num[10]); n9:=StrToInt(num[11]); d1:=n9*2+n8*3+n7*4+n6*5+n5*6+n4*7+n3*8+n2*9+n1*10; d1:=11-(d1 mod 11); if d1>=10 then d1:=0; d2:=d1*2+n9*3+n8*4+n7*5+n6*6+n5*7+n4*8+n3*9+n2*10+n1*11; d2:=11-(d2 mod 11); if d2>=10 then d2:=0; calculado:=inttostr(d1)+inttostr(d2); digitado:=num[13]+num[14]; if calculado=digitado then cpf:=true else cpf:=false; end; end; function CalculaCnpjCpf(Numero : String) : String; var i,j,k, Soma, Digito : Integer; CNPJ : Boolean; begin Result := Numero; case Length(Numero) of 9: CNPJ := False; 12: CNPJ := True; else Exit; end; for j := 1 to 2 do begin k := 2; Soma := 0; for i := Length(Result) downto 1 do begin Soma := Soma + (Ord(Result)-Ord('0'))*k; Inc(k); if (k > 9) and CNPJ then k := 2; end; Digito := 11 - Soma mod 11; if Digito >= 10 then Digito := 0; Result := Result + Chr(Digito + Ord('0')); end; end; function ValidaCNPJ(I:string): Boolean; var cnpj: array[1..14] of integer; apoio: array[0..13] of integer; f: integer;//para uso no for total: integer;//para totalização dos valores D1: integer;//primeiro dígito calculado D2: integer;//segundo dígito calculado begin //Primeiro teste: o número de algarismos if (Length(I)<>14) then result:=false else begin //Antes do teste propriamente dito temos que montar a matriz com os //os algarismos do CNPJ e depois uma matriz apoio) que terá os números //que ajudarão a verificar so dígitos verificadores for f := 1 to 14 do begin cnpj[f]:=0; apoio[f-1]:=0; end; //Monta matriz cnpj for f := 1 to 14 do begin cnpj[f]:=strtoint(I[f]); end; end; //Monta matriz de apoio apoio[0]:=6;//só será usada no cálculo do segundo dígito verificador apoio[1]:=5; apoio[2]:=4; apoio[3]:=3; apoio[4]:=2; apoio[5]:=9; apoio[6]:=8; apoio[7]:=7; apoio[8]:=6; apoio[9]:=5; apoio[10]:=4; apoio[11]:=3; apoio[12]:=2; //Começa cálculo do primeiro dígito verificador total:=0;//variável que conterá a soma da operação com os números for f := 1 to 12 do begin total:=total+(cnpj[f]*apoio[f]); end; D1 := total mod 11; if (D1<2) then D1:=0 else D1:=11-D1; if (D1<>cnpj[13]) then begin //Primeiro dígito verificador não confere Result:=false; end else begin //Entrou aqui, então o primeiro dígito confere! total:=0; for f := 0 to 12 do begin total:=total+(cnpj[f+1]*apoio[f]); end; D2 :=total mod 11; if (D2<2) then D2:=0 else D2:=11-D2; if (D2<>cnpj[14]) then begin //Segunod digito verificador não confere Result:=false; end else Result:=true; end; end; procedure TfrmClienteDados.data_cadastroClick(Sender: TObject); begin inherited; if DmOS.ztbCliente.State in [dsInsert] then begin data_cadastro.text:= DateTimeToStr(Now); data_cadastro.Enabled:= false; end else begin data_cadastro.Enabled:= false; end; end; procedure TfrmClienteDados.ieKeyPress(Sender: TObject; var Key: Char); begin inherited; If not( key in['0'..'9',#08] ) then key:=#0; end; procedure TfrmClienteDados.limiteKeyPress(Sender: TObject; var Key: Char); begin inherited; If not( key in['0'..'9',#08] ) then key:=#0; end; procedure TfrmClienteDados.MaskEdit1Exit(Sender: TObject); VAR S, s2 : boolean; s1 : string; begin inherited; try if Label6.Caption = 'CPF' then begin if MaskEdit2.text = '' then exit; s := cpf(MaskEdit2.text); if s = true then //showmessage('CIC/CPF Valido') else begin showmessage('CIC/CPF Inválido'); MaskEdit2.Text := '000.000.000-00'; end; end; except MaskEdit2.Text := '000.000.000-00'; end; try if Label6.Caption = 'CNPJ' then begin if MaskEdit2.text = '' then exit; s1 := MaskEdit2.Text; while Pos('.', S1) > 0 do delete(s1,Pos('.', S1),1); while Pos('/', S1) > 0 do delete(s1,Pos('/', S1),1); while Pos('-', S1) > 0 do delete(s1,Pos('-', S1),1); if Pos('0', S1) = 1 then delete(s1,Pos('0', S1),1); s2 := ValidaCNPJ(s1); if s2 = true then //showmessage('CNPJ Valido') else begin showmessage('CNPJ Inválido'); MaskEdit2.Text := '000.000.000/0000-00'; end; end; except MaskEdit2.Text := '000.000.000/0000-00'; end; DBEdit5.Text := MaskEdit2.Text; end; end.
  2. ok obrigado amigo vou transcrever e posto o resultado. o label do campo é Label6.
  3. Boa Jhonas o campo que esta física e uma combo ( ComboBox) esse é o nome dele esta com 2 itens ( juridica e fisica). e o campo c_cnpj o nome dele é DBEdit4.
  4. Ola AMIGO BOA NOITE PRECISAVA DE UMA AJUDINHA DE vocês. Bem, tenho um form que nele contem alguns edits e uma combobox, nela tenho a opção pessoa juridica ou fisica. Queria fazer o seguinte ao clicar em pessoa fisica na combobox o campo C_cnpj ficasse com a opção para cnpj e se clicar em juridico ficasse com a opção de cnpj. Segue a imagem: http://www.tickimg.com.br/uploads/_combobox.jpg alguém poderia me dar uma luz, sou iniciante em delphi. Uso banco Mysql com wamper e uso zeos para conexão.
×
×
  • Criar Novo...