-
Notifications
You must be signed in to change notification settings - Fork 2
/
lotofacil_comparacao_de_bolas_na_mesma_coluna.pas
97 lines (79 loc) · 2.78 KB
/
lotofacil_comparacao_de_bolas_na_mesma_coluna.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
unit lotofacil_comparacao_de_bolas_na_mesma_coluna;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, ZConnection, ZDataset, Grids, Dialogs;
procedure exibir_status_da_comparacao_de_bolas_na_mesma_coluna(sql_conexao: TZConnection; sgr_controle: TStringGrid);
procedure atualizar_status_da_comparacao_de_bolas_na_mesma_coluna(sql_conexao: TZConnection);
implementation
procedure exibir_status_da_comparacao_de_bolas_na_mesma_coluna(sql_conexao: TZConnection; sgr_controle: TStringGrid);
var
sql_query: TZQuery;
coluna_atual: TGridColumn;
uA: integer;
qt_registros: longint;
begin
sgr_controle.Columns.Clear;
sql_query := TZQuery.Create(nil);
sql_query.Connection := sql_conexao;
sql_query.Sql.Clear;
sql_query.Sql.Add('Select concurso, status from lotofacil.v_ltf_res_comparacao_de_bolas_na_mesma_coluna_status');
sql_query.Sql.Add('order by concurso desc');
sql_query.Open;
sql_query.First;
sql_query.Last;
qt_registros := sql_query.RecordCount;
if qt_registros = 0 then
begin
MessageDlg('', 'Nenhum registro localizado.', mtError, [mbOK], 0);
Exit;
end;
sgr_controle.Columns.Clear;
coluna_atual := sgr_controle.Columns.Add;
coluna_atual.Alignment := taCenter;
coluna_atual.Title.Caption := 'Concurso';
coluna_atual.Title.Alignment := taCenter;
coluna_atual := sgr_controle.Columns.Add;
coluna_atual.Alignment := taCenter;
coluna_atual.Title.Caption := 'Status';
coluna_atual.Title.Alignment := taCenter;
sgr_controle.FixedRows := 1;
sgr_controle.FixedCols := 0;
sgr_controle.RowCount := qt_registros + 1;
sql_query.First;
for uA := 1 to qt_registros do
begin
sgr_controle.Cells[0, uA] := sql_query.FieldByName('concurso').AsString;
sgr_controle.Cells[1, uA] := sql_query.FieldByName('status').AsString;
sql_query.Next;
end;
sgr_controle.AutoSizeColumns;
sql_query.Close;
sql_query.Connection.Connected := False;
FreeAndNil(sql_query);
end;
procedure atualizar_status_da_comparacao_de_bolas_na_mesma_coluna(sql_conexao: TZConnection);
var
sql_query: TZQuery;
begin
try
sql_query := TZQuery.Create(nil);
sql_query.connection := sql_conexao;
sql_query.Connection.AutoCommit := False;
sql_query.Sql.Clear;
sql_query.Sql.Add('Select from lotofacil.fn_lotofacil_resultado_comparacao_de_bolas_na_mesma_coluna()');
sql_query.ExecSql;
sql_query.Connection.Commit;
sql_query.Close;
sql_query.Connection.Connected := False;
FreeAndNil(sql_query);
except
On exc: Exception do
begin
MessageDlg('', 'Erro: ' + exc.Message, mtError, [mbOK], 0);
FreeAndNil(sql_query);
Exit;
end;
end;
end;
end.