Oi pessoal estou começando aprender a mexer no delphi, só que pelo curso que estou fazendo esta me dando erro ao compilar o projeto, se puderem me ajudar agradeço!
unit Clientes;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DBCtrls, DB, Mask, DBTables, ComCtrls,
Buttons;
type
TFormClientes = class(TForm)
PanelBotoes: TPanel;
ScrollBoxDados: TScrollBox;
TableClientes: TTable;
TableClientesCodigo: TAutoIncField;
TableClientesRazaoSocial: TStringField;
TableClientesFantasia: TStringField;
TableClientesTipo: TStringField;
TableClientesCGC_CPF: TStringField;
TableClientesInsc_RG: TStringField;
TableClientesEndereco: TStringField;
TableClientesBairro: TStringField;
TableClientesCidade: TStringField;
TableClientesUF: TStringField;
TableClientesCEP: TStringField;
TableClientesTelefone: TStringField;
TableClientesFax: TStringField;
TableClientesEMail: TStringField;
TableClientesHomePage: TStringField;
TableClientesObs: TBlobField;
TableClientesCadastro: TDateField;
TableClientesAtivo: TBooleanField;
Label1: TLabel;
DBEditCodigo: TDBEdit;
DataSourceClientes: TDataSource;
LabelRazaoSocial: TLabel;
DBEditRazaoSocial: TDBEdit;
LabelFantasia: TLabel;
DBEditFantasia: TDBEdit;
DBRadioGroupTipo: TDBRadioGroup;
Label4: TLabel;
DBEditCGC_CPF: TDBEdit;
Label5: TLabel;
DBEditInsc_RG: TDBEdit;
Label6: TLabel;
DBEditEndereco: TDBEdit;
Label7: TLabel;
DBEditBairro: TDBEdit;
Label8: TLabel;
DBEditCidade: TDBEdit;
Label9: TLabel;
DBEditUF: TDBEdit;
Label10: TLabel;
DBEditCEP: TDBEdit;
Label11: TLabel;
DBEditTelefone: TDBEdit;
Label12: TLabel;
DBEditFax: TDBEdit;
Label13: TLabel;
DBEditEMail: TDBEdit;
Label14: TLabel;
DBEditHomePage: TDBEdit;
Label15: TLabel;
DBRichEditObs: TDBRichEdit;
Label16: TLabel;
DBEditCadastro: TDBEdit;
DBCheckBoxAtivo: TDBCheckBox;
DBNavigatorClientes: TDBNavigator;
BitBtnFechar: TBitBtn;
BitBtnProcurar: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TableClientesNewRecord(DataSet: TDataSet);
procedure TableClientesBeforeInsert(DataSet: TDataSet);
procedure TableClientesBeforeEdit(DataSet: TDataSet);
procedure TableClientesBeforeDelete(DataSet: TDataSet);
procedure TableClientesBeforePost(DataSet: TDataSet);
procedure DBRadioGroupTipoClick(Sender: TObject);
procedure TableClientesAfterScroll(DataSet: TDataSet);
procedure BitBtnProcurarClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FormClientes: TFormClientes;
implementation
uses Principal;
{$R *.dfm}
procedure TFormClientes.FormCreate(Sender: TObject);
begin
TableClientes.Open;
end;
procedure TFormClientes.FormDestroy(Sender: TObject);
begin
TableClientes.Close;
end;
procedure TFormClientes.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree; //Remove o Form da Memoria
FormClientes:=NIL; //informa que foi destruido(não Criado)
end;
procedure TFormClientes.TableClientesNewRecord(DataSet: TDataSet);
begin
TableClientesCadastro.AsDateTime:=Date; //atribui a data atual
TableClientesAtivo.AsBoolean:=True; //cliente ativo
end;
procedure TFormClientes.TableClientesBeforeInsert(DataSet: TDataSet);
begin
DBEditRazaoSocial.SetFocus; //posiciona o cursor neste controle
end;
procedure TFormClientes.TableClientesBeforeEdit(DataSet: TDataSet);
begin
DBEditRazaoSocial.SetFocus; //posiciona o cursor neste controle
end;
procedure TFormClientes.TableClientesBeforeDelete(DataSet: TDataSet);
begin
if Application.MessageBox('Deseja excluir o registro atual?','Comfirme',MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2)= IDNO then
Abort; //interrompe e não exclui o registro
end;
procedure TFormClientes.TableClientesBeforePost(DataSet: TDataSet);
If DBEditRazaoSocial.Text = '' then //nada foi digitado
begin
ShowMessage('Digite a Razão Social/Nome');
DBEditRazaoSocial.SetFocus; //posiciona o cursor
Abort; //não grava e continua editando
end;
procedure TFormClientes.DBRadioGroupTipoClick(Sender: TObject);
If DBRadioGroupTipo.ItemIndex:= 0 then //pessoa fisica
begin
LabelRazaoSocial.Caption:='Nome';
LabelFantasia.Caption:='Apelido';
TableClientesCGC_CPF.EditMask:='999\.999\.999\-99;0;_';
end
else //pessoa Juridica
begin
LabelRazaoSocial.Caption:='Razao Social';
LabelFantasia.Caption:='Fantasia';
TableClientesCGC_CPF.EditMask:='99\.999\.999\/9999\-99;0;_';
end;
procedure TFormClientes.TableClientesAfterScroll(DataSet: TDataSet);
if TableClientesTipo.AsString = 'F' then //pessoa fisica
begin
LabelRazaoSocial.Caption:='Nome';
LabelFantasia.Caption:='Apelido';
TableClientesCGC_CPF.EditMask:='999\.999\.999\-99;0;_';
end
else //pessoa juridica
begin
LabelRazaoSocial.Caption:='Razao Social';
LabelFantasia.Caption:='Fantasia';
TableClientesCGC_CPF.EditMask:='99\.999\.999\/9999\-99;0;_';
end;
procedure TFormClientes.BitBtnProcurarClick(Sender: TObject);
var
Nome: String;
begin
Nome:=''; //inicia definindo uma string vazia
if InputQuery('Procurar','Razao Social/Nome',Nome)then
if not TableClientes.Locate('RazaoSocial',Nome,[IoCaseInsensitive, IoPartialKey]) then
ShowMessage('Razao Social/Nome não encontrado');
end;
end.
[Error] Clientes.pas(138): Declaration expected but 'IF' found
[Error] Clientes.pas(146): Declaration expected but 'IF' found
[Error] Clientes.pas(152): ';' expected but 'ELSE' found
Pergunta
Tiago_Costa
Oi pessoal estou começando aprender a mexer no delphi, só que pelo curso que estou fazendo esta me dando erro ao compilar o projeto, se puderem me ajudar agradeço!
unit Clientes; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, DBCtrls, DB, Mask, DBTables, ComCtrls, Buttons; type TFormClientes = class(TForm) PanelBotoes: TPanel; ScrollBoxDados: TScrollBox; TableClientes: TTable; TableClientesCodigo: TAutoIncField; TableClientesRazaoSocial: TStringField; TableClientesFantasia: TStringField; TableClientesTipo: TStringField; TableClientesCGC_CPF: TStringField; TableClientesInsc_RG: TStringField; TableClientesEndereco: TStringField; TableClientesBairro: TStringField; TableClientesCidade: TStringField; TableClientesUF: TStringField; TableClientesCEP: TStringField; TableClientesTelefone: TStringField; TableClientesFax: TStringField; TableClientesEMail: TStringField; TableClientesHomePage: TStringField; TableClientesObs: TBlobField; TableClientesCadastro: TDateField; TableClientesAtivo: TBooleanField; Label1: TLabel; DBEditCodigo: TDBEdit; DataSourceClientes: TDataSource; LabelRazaoSocial: TLabel; DBEditRazaoSocial: TDBEdit; LabelFantasia: TLabel; DBEditFantasia: TDBEdit; DBRadioGroupTipo: TDBRadioGroup; Label4: TLabel; DBEditCGC_CPF: TDBEdit; Label5: TLabel; DBEditInsc_RG: TDBEdit; Label6: TLabel; DBEditEndereco: TDBEdit; Label7: TLabel; DBEditBairro: TDBEdit; Label8: TLabel; DBEditCidade: TDBEdit; Label9: TLabel; DBEditUF: TDBEdit; Label10: TLabel; DBEditCEP: TDBEdit; Label11: TLabel; DBEditTelefone: TDBEdit; Label12: TLabel; DBEditFax: TDBEdit; Label13: TLabel; DBEditEMail: TDBEdit; Label14: TLabel; DBEditHomePage: TDBEdit; Label15: TLabel; DBRichEditObs: TDBRichEdit; Label16: TLabel; DBEditCadastro: TDBEdit; DBCheckBoxAtivo: TDBCheckBox; DBNavigatorClientes: TDBNavigator; BitBtnFechar: TBitBtn; BitBtnProcurar: TBitBtn; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TableClientesNewRecord(DataSet: TDataSet); procedure TableClientesBeforeInsert(DataSet: TDataSet); procedure TableClientesBeforeEdit(DataSet: TDataSet); procedure TableClientesBeforeDelete(DataSet: TDataSet); procedure TableClientesBeforePost(DataSet: TDataSet); procedure DBRadioGroupTipoClick(Sender: TObject); procedure TableClientesAfterScroll(DataSet: TDataSet); procedure BitBtnProcurarClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var FormClientes: TFormClientes; implementation uses Principal; {$R *.dfm} procedure TFormClientes.FormCreate(Sender: TObject); begin TableClientes.Open; end; procedure TFormClientes.FormDestroy(Sender: TObject); begin TableClientes.Close; end; procedure TFormClientes.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; //Remove o Form da Memoria FormClientes:=NIL; //informa que foi destruido(não Criado) end; procedure TFormClientes.TableClientesNewRecord(DataSet: TDataSet); begin TableClientesCadastro.AsDateTime:=Date; //atribui a data atual TableClientesAtivo.AsBoolean:=True; //cliente ativo end; procedure TFormClientes.TableClientesBeforeInsert(DataSet: TDataSet); begin DBEditRazaoSocial.SetFocus; //posiciona o cursor neste controle end; procedure TFormClientes.TableClientesBeforeEdit(DataSet: TDataSet); begin DBEditRazaoSocial.SetFocus; //posiciona o cursor neste controle end; procedure TFormClientes.TableClientesBeforeDelete(DataSet: TDataSet); begin if Application.MessageBox('Deseja excluir o registro atual?','Comfirme',MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2)= IDNO then Abort; //interrompe e não exclui o registro end; procedure TFormClientes.TableClientesBeforePost(DataSet: TDataSet); If DBEditRazaoSocial.Text = '' then //nada foi digitado begin ShowMessage('Digite a Razão Social/Nome'); DBEditRazaoSocial.SetFocus; //posiciona o cursor Abort; //não grava e continua editando end; procedure TFormClientes.DBRadioGroupTipoClick(Sender: TObject); If DBRadioGroupTipo.ItemIndex:= 0 then //pessoa fisica begin LabelRazaoSocial.Caption:='Nome'; LabelFantasia.Caption:='Apelido'; TableClientesCGC_CPF.EditMask:='999\.999\.999\-99;0;_'; end else //pessoa Juridica begin LabelRazaoSocial.Caption:='Razao Social'; LabelFantasia.Caption:='Fantasia'; TableClientesCGC_CPF.EditMask:='99\.999\.999\/9999\-99;0;_'; end; procedure TFormClientes.TableClientesAfterScroll(DataSet: TDataSet); if TableClientesTipo.AsString = 'F' then //pessoa fisica begin LabelRazaoSocial.Caption:='Nome'; LabelFantasia.Caption:='Apelido'; TableClientesCGC_CPF.EditMask:='999\.999\.999\-99;0;_'; end else //pessoa juridica begin LabelRazaoSocial.Caption:='Razao Social'; LabelFantasia.Caption:='Fantasia'; TableClientesCGC_CPF.EditMask:='99\.999\.999\/9999\-99;0;_'; end; procedure TFormClientes.BitBtnProcurarClick(Sender: TObject); var Nome: String; begin Nome:=''; //inicia definindo uma string vazia if InputQuery('Procurar','Razao Social/Nome',Nome)then if not TableClientes.Locate('RazaoSocial',Nome,[IoCaseInsensitive, IoPartialKey]) then ShowMessage('Razao Social/Nome não encontrado'); end; end.[Error] Clientes.pas(138): Declaration expected but 'IF' found
[Error] Clientes.pas(146): Declaration expected but 'IF' found
[Error] Clientes.pas(152): ';' expected but 'ELSE' found
[Error] Clientes.pas(154): Undeclared identifier: 'LabelRazaoSocial'
[Error] Clientes.pas(154): Missing operator or semicolon
[Error] Clientes.pas(155): Undeclared identifier: 'LabelFantasia'
Link para o comentário
Compartilhar em outros sites
3 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.