type TLoadingThread =
class(TThread)
private
ThreadQuery:TUniQuery;
ThreadFilter, ThreadStation:
String;
protected
procedure Execute;
override;
public
property Filter :
String read ThreadFilter
write ThreadFilter;
property Station :
String read ThreadStation
write ThreadStation;
end;
procedure TfrmKundenwahl.FilterSetzen;
Begin
Filter := '
1=1';
if TRIM(E_Sortierfeld.Text) <> '
'
then
Filter := Filter + '
AND Sortierfeld like '+AnsiQuotedStr(Trim(E_Sortierfeld.Text), #39)+'
+''
%''
';
if TRIM(E_Name.Text) <> '
'
then
Filter := Filter + '
AND (Name1 like '+AnsiQuotedStr(Trim(E_Name.Text), #39)+'
+''
%''
'
+ '
OR Name2 like '+AnsiQuotedStr(Trim(E_Name.Text), #39)+'
+''
%''
)';
// und halt der Rest der Abfragen
// ...
ThLoading := TLoadingThread.Create(True);
//ThLoading ist im Private Teil der Unit Deklariert
ThLoading.Filter := Filter;
ThLoading.Station := IntToStr(Station_ID);
ThLoading.OnTerminate := ShowErgebnis;
ThLoading.FreeOnTerminate := True;
ThLoading.Start;
End;
procedure TLoadingThread.Execute;
begin
Verbindungsaufbau;
Daten.MSSQL_Connection.ExecSQL('
if Object_ID(''
MOBILE_Kunden_'+ThreadStation+#39+'
) is not null Drop Table MOBILE_Kunden_'+ThreadStation);
Daten.MSSQL_Connection.ExecSQL('
Select distinct Kunden_Nr as kdn, Sortierfeld as Sortierfeld_Vorschau, Name1 as Name1_Vorschau, Strasse as Strasse_Vorschau, PLZ as PLZ_Vorschau, Ort as Ort_Vorschau, 1 as Selected into MOBILE_Kunden_'+ThreadStation+'
from Kundenst where '+ThreadFilter);
ThreadQuery := TUniQuery.Create(Daten);
ThreadQuery.Connection := Daten.MSSQL_Connection;
ThreadQuery.SQL.Text := '
Select * from MOBILE_Kunden_'+ThreadStation;
ThreadQuery.Open;
End;
procedure TfrmKundenwahl.ShowErgebnis(Sender:TObject);
Begin
qVorschau := ThLoading.ThreadQuery;
qVorschau.AfterScroll := Q_VorschauAfterScroll;
BS_Vorschau.DataSet := qVorschau;
BS_Vorschau.DataSet.Open;
Show_Tab_Ergebnis.ExecuteTarget(self);
R_Loading.Visible := False;
end;