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
| //--------------------------------------------------------------------------
// PREPARATION FICHIER
//--------------------------------------------------------------------------
procedure TQRFeuille.SQLFiltre;
const Select = 'SELECT * FROM MATIERES';
var i,j : Word;
begin
Master.Close;
Master.SQL.Clear;
Master.SQL.Add(Select);
Where:=False;
// Clause Where
if Normale1.Checked then
begin // Normale
// N° de Matière
if (Length(DeMat.Text)>0) OR (Length(AMat.Text)>0) then
begin
if Length(AMat.Text)=0 then begin
if Where=false then Master.SQL.Add('WHERE');
Master.SQL.Add('CODE >='''+DeMat.Text+'''');
end
else
if Length(DeMat.Text)=0 then begin
if Where=false then Master.SQL.Add('WHERE');
Master.SQL.Add('CODE <='''+AMat.Text+'''');
end
else begin
if Where=false then Master.SQL.Add('WHERE');
Master.SQL.Add('CODE BETWEEN '''+DeMat.Text+
''' AND '''+AMat.Text+'''');
end;
Where:=true;
end;
// niveau
if Select_Niveau.Value>=0 then
begin
if Where=false then Master.SQL.Add('WHERE') else Master.SQL.Add('AND');
Master.SQL.Add('NIVEAU='+IntToStr(Select_Niveau.Value));
Where:=true;
end;
// Gestionnaire
if Gestionnaire.KeyValue<>null then
begin
if Where=false then Master.SQL.Add('WHERE') else Master.SQL.Add('AND');
Master.SQL.Add('CATEGORIE='''+Gestionnaire.KeyValue+'''');
Where:=true;
end;
// Atelier
if Atelier.KeyValue<>null then
begin
if Where=false then Master.SQL.Add('WHERE') else Master.SQL.Add('AND');
Master.SQL.Add('ATELIER='''+Atelier.KeyValue+'''');
Where:=true;
end;
// type matière
if TypeMat.KeyValue<>null then
begin
if Where=false then Master.SQL.Add('WHERE') else Master.SQL.Add('AND');
Master.SQL.Add('TYPE='''+TypeMat.KeyValue+'''');
Where:=true;
end;
// famille
if Famille.KeyValue<>null then
begin
if Where=false then Master.SQL.Add('WHERE') else Master.SQL.Add('AND');
Master.SQL.Add('CODE_FAMILLE='''+famille.KeyValue+'''');
Where:=true;
end;
if Master.SQL.Count>2 then
begin
SQLMemo1.Clear;
for j:=2 to Master.SQL.Count-1 do SQLMemo1.Lines.Add(Master.SQL[j]);
end;
end
else
begin // SQL Memo
if SQLMemo1.Lines.Count>0 then
begin
Master.SQL.Add('WHERE');
Where:=true;
for i:=0 to SQLMemo1.Lines.Count-1 do Master.SQL.Add(SQLMemo1.Lines[i]);
end;
end;
// Clause ORDER
if Nom1.Checked then Master.SQL.Add('ORDER BY DESIGNATION')
else Master.SQL.Add('ORDER BY CODE');
Master.Open;
end; |
Partager