Exemplo 03: Salvando na base
29/05/2023
0
procedure TfDevedor.btSalvarClick(Sender: TObject); begin btSalvar.Enabled:= false; btCancelar.Enabled:= false; btInserir.Enabled:= true; btDeletar.Enabled:= true; naviDevedor.Enabled:= true; aux:= fDMDevedor.conexao.ExecSQLScalar ('SELECT CPF FROM devedor WHERE CPF = :cpf', [dbeCPF.Text]); if aux = dbeCPF.Text then begin ShowMessage('Devedor(a) já cadastrado!'); end else fDMDevedor.conexao.ExecSQL ('INSERT INTO devedor (NomeDevedor, CPF, Enderecos) VALUES (:nomedevedor, :cpf, :enderecos)', [dbeNome.Text, dbeCPF.Text, dmemoEnderecos.Text]); fDMDevedor.tbDevedor.Close; fDMDevedor.tbDevedor.Open; dbeNome.ReadOnly:= true; dbeCPF.ReadOnly:= true; dmemoEnderecos.ReadOnly:= true; fDMDevedor.tbDevedor.First; end; procedure TfDevedorIntimacao.btSalvarClick(Sender: TObject); begin btSalvar.Enabled:= false; btCancelar.Enabled:= false; btInserir.Enabled:= true; btDeletar.Enabled:= true; btGravar.Enabled:= true; naviDevedorIntimacao.Enabled:= true; aux:= fDMDevedor.conexao.ExecSQLScalar ('SELECT Protocolo FROM devedorintimacao WHERE Protocolo = :protocolo', [StrToInt(dbeProtocolo.Text)]); if aux = dbeProtocolo.Text then begin ShowMessage('Protocolo já cadastrado!'); end else fDMDevedor.conexao.ExecSQL ('INSERT INTO devedorintimacao (Protocolo, Contrato, Matricula, Descricao, IDDevedor, IDCredor) VALUES (:protocolo, :contrato, :matricula, :descricao, :iddevedor, :idcredor)', [StrToInt(dbeProtocolo.Text), dbeContrato.Text, dbeMatricula.Text, dmemoDescricao.Text, StrToInt(dbListaDevedor.ListSource.DataSet.FieldByName(dbListaDevedor.KeyField).Value), StrToInt(dbListaCredor.ListSource.DataSet.FieldByName(dbListaCredor.KeyField).Value)]); fDMDevedor.tbDevedorIntimacao.Close; fDMDevedor.tbDevedorIntimacao.Open; dbeProtocolo.ReadOnly:= true; dbeMatricula.ReadOnly:= true; dmemoDescricao.ReadOnly:= true; dbeContrato.ReadOnly:= true; fDMDevedor.tbDevedorIntimacao.First; end;
Thalita Reis
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)