-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Última aula 15122020(DB Mestre Detalhe) inserida
- Loading branch information
mateusschwede
committed
Dec 17, 2020
1 parent
7bb7276
commit 03539ac
Showing
24 changed files
with
8,042 additions
and
0 deletions.
There are no files selected for viewing
Binary file modified
BIN
+0 Bytes
(100%)
rad/08122020 (PesquisaBD e Relatórios)/lojaPesquisaAtiv/DB/DBLOJA.FDB
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
rad/08122020 (PesquisaBD e Relatórios)/lojaPesquisaAtiv/Loja.identcache
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
rad/08122020 (PesquisaBD e Relatórios)/lojaPesquisaRelatorio/Loja.identcache
Binary file not shown.
1,003 changes: 1,003 additions & 0 deletions
1,003
rad/15122020 (DB Mestre Detalhe)/Loja/Fontes/uClientes.dfm
Large diffs are not rendered by default.
Oops, something went wrong.
147 changes: 147 additions & 0 deletions
147
rad/15122020 (DB Mestre Detalhe)/Loja/Fontes/uClientes.pas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
rad/15122020 (DB Mestre Detalhe)/Loja/Fontes/uConsulta.dfm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
object frmPesquisar: TfrmPesquisar | ||
Left = 0 | ||
Top = 0 | ||
Caption = 'Pesquisar' | ||
ClientHeight = 289 | ||
ClientWidth = 718 | ||
Color = clBtnFace | ||
Font.Charset = DEFAULT_CHARSET | ||
Font.Color = clWindowText | ||
Font.Height = -11 | ||
Font.Name = 'Tahoma' | ||
Font.Style = [] | ||
OldCreateOrder = False | ||
Position = poScreenCenter | ||
PixelsPerInch = 96 | ||
TextHeight = 13 | ||
object Tabela: TLabel | ||
Left = 160 | ||
Top = 21 | ||
Width = 32 | ||
Height = 13 | ||
Caption = 'Tabela' | ||
end | ||
object rgSel: TRadioGroup | ||
Left = 8 | ||
Top = 8 | ||
Width = 137 | ||
Height = 105 | ||
Caption = ' Selecionar por ' | ||
ItemIndex = 0 | ||
Items.Strings = ( | ||
'C'#243'digo' | ||
'Descri'#231#227'o') | ||
TabOrder = 0 | ||
end | ||
object rgOrdem: TRadioGroup | ||
Left = 8 | ||
Top = 119 | ||
Width = 137 | ||
Height = 105 | ||
Caption = 'Ordem da apresenta'#231#227'o' | ||
ItemIndex = 0 | ||
Items.Strings = ( | ||
'Normal' | ||
'Ascendente' | ||
'Descendente') | ||
TabOrder = 1 | ||
end | ||
object edBusca: TEdit | ||
Left = 8 | ||
Top = 230 | ||
Width = 137 | ||
Height = 21 | ||
TabOrder = 2 | ||
end | ||
object btSel: TBitBtn | ||
Left = 8 | ||
Top = 257 | ||
Width = 137 | ||
Height = 25 | ||
Caption = 'Pesquisar' | ||
Glyph.Data = { | ||
36040000424D3604000000000000360000002800000010000000100000000100 | ||
2000000000000004000000000000000000000000000000000000000000000000 | ||
0000000000000000000000000000000000000000000000000000000000000000 | ||
0000000000000000000000000000000000000000000000000000000000000000 | ||
0000000000000000000000000000000000000000000000000000000000000000 | ||
0000000000000000000000000000000000000000000000000000000000020000 | ||
000A000000160000001B000000170000000B0000000200000000000000010000 | ||
00060000000B0000000F0000000C0000000600000001000000000000000F2616 | ||
1072583424D8693D2AFF4D2C1FD91D110B750000001200000003000000082416 | ||
1162513023CF613927FF45281BD01A0F0A630000000900000001291A136DA380 | ||
70FFD4C5BDFFEDE5E1FFCFBEB7FF907163FF1F120C770000000F2C1C1663A181 | ||
72FFD4C6BEFFEEE8E4FFCDC0B8FF866A5DFF190E096000000005734937DEE3D7 | ||
D1FFCEAE9EFFAF7957FFD0B39EFFD7C9C3FF553324E00000001B77503FD8E2D7 | ||
D2FFD0AD9BFFB37753FFD2B29AFFD6CBC5FF4A2B1ED90000000A8E5A47FBF8F6 | ||
F4FFAE725BFFE7AF66FFB27F5EFFF0EBE8FF744835FF000000489A6B55FFF8F6 | ||
F3FFB27056FFE8AF64FFB67E59FFEAE3DFFF613B29FA0000000B90604DF8F1E8 | ||
E4FFD2B0A5FFAA6C53FFD4B6A7FFCDC0BAFF71422FFF4C2920FF80513DFFF1E8 | ||
E3FFD3ADA1FFAE684FFFD4B2A1FFC5B6AFFF6A4231F700000009583C31A2CAAF | ||
A3FFF7F2EEFFFDFCFBFFEAE0DAFF9E847AFF774835FF663E36FF855944FFE8D9 | ||
CFFFF7F0EDFFFCFAF9FFDFD4CEFF8A6657FF452D229A000000050805041D9F72 | ||
5DF8E8DBD4FFE6D7CEFFCDB7AAFF8B6B5EFF7D4C3AFF865F56FF8B5F4BFFE9D8 | ||
CEFFEADCD4FFCFB9ACFF997B6DFF966A54F70705041600000001000000076047 | ||
3BA4D0B7ADFFEEE3DFFFD5C1B7FF93766CFF82533FFF734635FF926550FFECE0 | ||
D9FFEBDED8FFC4B0A5FF9B7868FF5F45389D0000000400000000000000022219 | ||
1541B89383FFF3EBE8FFD9C9C2FFA99389FFA67966FF00000026B48B76FFF0E7 | ||
E3FFEADED9FFBDA79FFFA67D6CFF211915390000000100000000000000000000 | ||
0007846554C6DDCCC4FFE6DCD8FFC2A99EFFA67E69F90000000CB38E79F8E0D1 | ||
C9FFE9DFDAFFBCA497FF846555C2000000030000000000000000000000000000 | ||
0002130F0D237D6152B7AF8673FA7B6050B9130E0C270000000414100E1E8365 | ||
58B3B68F79F9806455B3130F0D1E000000010000000000000000000000000000 | ||
0000000000010000000400000006000000050000000200000000000000000000 | ||
0001000000010000000100000000000000000000000000000000000000000000 | ||
0000000000000000000000000000000000000000000000000000000000000000 | ||
0000000000000000000000000000000000000000000000000000} | ||
Layout = blGlyphRight | ||
TabOrder = 3 | ||
OnClick = btSelClick | ||
end | ||
object DBGrid1: TDBGrid | ||
Left = 160 | ||
Top = 40 | ||
Width = 550 | ||
Height = 242 | ||
DataSource = dm.dsConsulta | ||
TabOrder = 4 | ||
TitleFont.Charset = DEFAULT_CHARSET | ||
TitleFont.Color = clWindowText | ||
TitleFont.Height = -11 | ||
TitleFont.Name = 'Tahoma' | ||
TitleFont.Style = [] | ||
end | ||
object cmbTabela: TComboBox | ||
Left = 198 | ||
Top = 13 | ||
Width = 145 | ||
Height = 21 | ||
Style = csDropDownList | ||
Sorted = True | ||
TabOrder = 5 | ||
Items.Strings = ( | ||
'Clientes' | ||
'Fornecedores' | ||
'Produtos') | ||
end | ||
end |
104 changes: 104 additions & 0 deletions
104
rad/15122020 (DB Mestre Detalhe)/Loja/Fontes/uConsulta.pas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
unit uConsulta; | ||
|
||
interface | ||
|
||
uses | ||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, | ||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls, | ||
Data.DB, Vcl.Grids, Vcl.DBGrids, uDM; | ||
|
||
type | ||
TfrmPesquisar = class(TForm) | ||
rgSel: TRadioGroup; | ||
rgOrdem: TRadioGroup; | ||
edBusca: TEdit; | ||
btSel: TBitBtn; | ||
DBGrid1: TDBGrid; | ||
cmbTabela: TComboBox; | ||
Tabela: TLabel; | ||
procedure btSelClick(Sender: TObject); | ||
private | ||
{ Private declarations } | ||
public | ||
{ Public declarations } | ||
end; | ||
|
||
var | ||
frmPesquisar: TfrmPesquisar; | ||
|
||
implementation | ||
|
||
{$R *.dfm} | ||
|
||
procedure TfrmPesquisar.btSelClick(Sender: TObject); | ||
var nmTab, vSQL : string; | ||
|
||
function RetCampoCodigo(aTab:string) : string; | ||
begin | ||
if aTab = 'CLIENTES' then | ||
Result := 'CDCLIENTE' | ||
else | ||
if aTab = 'FORNECEDORES' then | ||
Result := 'CDFORNECEDOR' | ||
else | ||
if aTab = 'PRODUTOS' then | ||
Result := 'CDPRODUTO' | ||
end; | ||
|
||
function RetCampoDesc(aTab:string) : string; | ||
begin | ||
if aTab = 'CLIENTES' then | ||
Result := 'DCCLIENTE' | ||
else | ||
if aTab = 'FORNECEDORES' then | ||
Result := 'DCFORNECEDOR' | ||
else | ||
if aTab = 'PRODUTOS' then | ||
Result := 'DCPRODUTO' | ||
end; | ||
|
||
begin | ||
nmTab := ''; | ||
|
||
if cmbTabela.ItemIndex = -1 then | ||
begin | ||
MessageDlg('Selecione uma tabela', mtError, [mbOk],0); | ||
Exit; | ||
end; | ||
|
||
if edBusca.Text = '' then | ||
begin | ||
MessageDlg('Digite algum valor', mtWarning, [mbOk],0); | ||
Exit; | ||
end; | ||
|
||
case cmbTabela.ItemIndex of | ||
0 : nmTab := 'CLIENTES'; | ||
1 : nmTab := 'FORNECEDORES'; | ||
2 : nmTab := 'PRODUTOS'; | ||
end; | ||
|
||
vSQL := 'SELECT * FROM ' + nmTab; | ||
|
||
case rgSel.ItemIndex of // #13 ======= ENTER - Trocar de linha | ||
0 : vSQL := vSQL + #13 + ' WHERE ' + RetCampoCodigo(nmTab) + ' = :PCD'; | ||
1 : vSQL := vSQL + #13 + ' WHERE ' + RetCampoDesc(nmTab) + ' CONTAINING :PCD'; | ||
end; | ||
|
||
case rgOrdem.ItemIndex of | ||
1 : vSQL := vSQL + #13 + ' ORDER BY ' + RetCampoCodigo(nmTab) + ' ASC '; //ASC opcional | ||
2 : vSQL := vSQL + #13 + ' ORDER BY ' + RetCampoCodigo(nmTab) + ' DESC '; | ||
end; | ||
|
||
dm.qrConsulta.Close; | ||
dm.qrConsulta.SQL.Text := vSQL; | ||
dm.qrConsulta.ParamByName('PCD').AsString := edBusca.Text; | ||
dm.qrConsulta.Open; | ||
|
||
if dm.qrConsulta.IsEmpty then | ||
begin | ||
MessageDlg('Nenhum resultado encontrado', mtInformation, [mbOk], 0); | ||
end; | ||
end; | ||
|
||
end. |
Oops, something went wrong.