Inserir dados de um combobox em uma tabela com Delphi

23/08/2018

0

Bom dia a todos, sou novo aqui e esse é meu primeiro post.
Sou novo em programação, na verdade estou aprendendo ainda...
Me passaram um "projetinho" onde eu trabalho e neste projeto eu esbarrei com uma parte onde eu pretendo que os valores de algumas combobox sejam inseridos em uma tabela, isso porque esses valores de combobox serão fixos na tabela, alguns outros valores serão deiferentes a cada situação.
Serão três combobox que pretendo inserir os valores na tabela.
Estou usando Delphi Tokyo, PostgreSQL e FireDac e não tenho idéia ainda de como inserir esses dados.
No PostgreSql eu criei quatro tabelas sendo que dessas quatro, três armazenarão os valores das combobox que terão valores fixos, todas as chaves primarias e estrangeiras já foram criadas e testadas, a aplicação no delphi é que está me deixando de cabelo em pé.
Não sei se consegui explicar direito mas segue o código de captura nos combobox que tenho até agora:

procedure TfrmMain.cbxBrandChange(Sender: TObject);
begin
FDQuery1.Close;
case cbxBrand.ItemIndex of
0 : FDQuery1.Open(''SELECT NOME FROM MARCA WHERE IDMARCA = 1'');
1 : FDQuery1.Open(''SELECT NOME FROM MARCA WHERE IDMARCA = 2'');
2 : FDQuery1.Open(''SELECT NOME FROM MARCA WHERE IDMARCA = 3'');
3 : FDQuery1.Open(''SELECT NOME FROM MARCA WHERE IDMARCA = 4'');
4 : FDQuery1.Open(''SELECT NOME FROM MARCA WHERE IDMARCA = 5'');
5 : FDQuery1.Open(''SELECT NOME FROM MARCA WHERE IDMARCA = 6'');
end;
end;

procedure TfrmMain.cbxModelChange(Sender: TObject);
begin
FDQuery1.Close;
case cbxModel.ItemIndex of
0 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 1'');
1 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 2'');
2 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 3'');
3 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 4'');
4 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 5'');
5 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 6'');
6 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 7'');
7 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 8'');
8 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 9'');
9 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 10'');
10 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 11'');
11 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 12'');
12 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 13'');
13 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 14'');
14 : FDQuery1.Open(''SELECT NOME FROM MODELO WHERE IDMODELO = 15'');
end;
end;

procedure TfrmMain.cbxSectionChange(Sender: TObject);
begin
FDQuery1.Close;
case cbxSection.ItemIndex of
0 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 1'');
1 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 2'');
2 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 3'');
3 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 4'');
4 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 5'');
5 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 6'');
6 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 7'');
7 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 8'');
8 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 9'');
9 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 10'');
10 : FDQuery1.Open(''SELECT NOME FROM SETOR WHERE IDSETOR = 11'');
end;
end;
Gabriel

Gabriel

Responder

Posts

23/08/2018

Raimundo Pereira

Tem skype?<br />
Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar