unit Uthread;
interface
uses
Classes, Ufrm_Selection, SysUtils, ExtCtrls, ComCtrls, ADODB;
type
TSelectFac = class(TThread)
private
{ Private declarations }
Fpnltext: TStatusBar;
fsqlstr:String;
protected
procedure Execute;
override;
public
constructor Create(stspnl: TStatusBar;
bool: boolean;
sqlstr:String);
end;
implementation
procedure TSelectFac.Execute;
var
Facquery:TADOQuery;
begin
{ Place thread code here }
try
Coinitialize(nil);
Facquery:=TADOQuery.create(nil);
Facquery.connectionstring:='..';
Facquery.SQL.Clear;
Facquery.SQL.Add(fSQLstr);
Facquery.Open;
Couninitialize;
exit;
except
...
end;
end;
constructor TSelectFac.Create(stspnl: TStatusBar;
bool: boolean;
Sqlstr:string
;
begin
inherited create(bool);
FpnlText :=stspnl;
fsqlstr:=sqlstr;
end;
unit Ufrm_selection;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxLookAndFeelPainters, cxMaskEdit,
cxDropDownEdit, StdCtrls, cxButtons, cxTextEdit, cxContainer, cxLabel,
ComCtrls, cxGridLevel, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
ExtCtrls, cxPC, ADODB, BusinessSkinForm;
type
TFrmSelect = class(TForm)
SelConnection: TADOConnection;
FDataSource: TDataSource;
bsBusinessSkinForm1: TbsBusinessSkinForm;
Itemquery: TADOQuery;
Facquery: TADOQuery;
MtDataSource: TDataSource;
FTYPCorquery: TADOQuery;
UpdateQuery: TADOQuery;
FTYPCorDataSource: TDataSource;
MtTYPCorQuery: TADOQuery;
MtTYPCorDataSource: TDataSource;
cxPageControl1: TcxPageControl;
cxTabSheet1: TcxTabSheet;
Splitter2: TSplitter;
Panel4: TPanel;
cxGrid1: TcxGrid;
cxGrid1DBTableView1: TcxGridDBTableView;
cxGrid1DBTableView1DBColumn1: TcxGridDBColumn;
cxGrid1DBTableView1DBColumn2: TcxGridDBColumn;
cxGrid1DBTableView1DBColumn3: TcxGridDBColumn;
cxGrid1DBTableView1DBColumn4: TcxGridDBColumn;
cxGrid1DBTableView1DBColumn5: TcxGridDBColumn;
cxGrid1DBTableView1DBColumn6: TcxGridDBColumn;
cxGrid1DBTableView1DBColumn7: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
StatusBar2: TStatusBar;
Panel5: TPanel;
Panel6: TPanel;
GroupBox2: TGroupBox;
cxLabel4: TcxLabel;
cxTextEdit3: TcxTextEdit;
cxTextEdit4: TcxTextEdit;
cxLabel5: TcxLabel;
cxLabel6: TcxLabel;
cxButton3: TcxButton;
cxButton4: TcxButton;
cxComboBox2: TcxComboBox;
Panel7: TPanel;
cxButton5: TcxButton;
cxLabel7: TcxLabel;
cxTextEdit5: TcxTextEdit;
cxTabSheet2: TcxTabSheet;
Splitter1: TSplitter;
Panel1: TPanel;
Panel3: TPanel;
GroupBox1: TGroupBox;
cxTextEdit1: TcxTextEdit;
cxLabel1: TcxLabel;
cxTextEdit2: TcxTextEdit;
cxLabel2: TcxLabel;
cxLabel3: TcxLabel;
cxButton1: TcxButton;
cxButton2: TcxButton;
cxComboBox1: TcxComboBox;
Panel2: TPanel;
cxGrid2: TcxGrid;
cxGrid2DBTableView1: TcxGridDBTableView;
cxGrid2DBTableView1DBColumn1: TcxGridDBColumn;
cxGrid2DBTableView1DBColumn2: TcxGridDBColumn;
cxGrid2DBTableView1DBColumn3: TcxGridDBColumn;
cxGrid2DBTableView1DBColumn4: TcxGridDBColumn;
cxGrid2DBTableView1DBColumn5: TcxGridDBColumn;
cxGrid2DBTableView1DBColumn6: TcxGridDBColumn;
cxGrid2DBTableView1DBColumn7: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
StatusBar1: TStatusBar;
Panel8: TPanel;
cxButton6: TcxButton;
cxButton7: TcxButton;
procedure cxButton3Click(Sender: TObject);
procedure cxButton1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure cxButton4Click(Sender: TObject);
procedure cxButton2Click(Sender: TObject);
procedure cxButton5Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
selFnumber: string;
selFName: string;
selFTYPCor: string;
procedure ThreadDone(Sender: TObject);
public
{ Public declarations }
procedure SelFacTerminate;
end;
implementation
uses
Uthread;
procedure TFrmSelect.cxButton3Click(Sender: TObject);
var
strSQL: widestring;
begin
statusbar2.Panels[1].Text :='请稍后,系统进行处理.......';
selFnumber :=trim(cxTextEdit3.Text);
selFname :=trim(cxTextEdit4.Text);
selFTYPCor :=trim(cxComboBox2.Text);
strSQL :='SELECT DISTINCT FitemId, Fnumber, FName, Ftax, TYPCor FROM CPSup WHERE ';
if selFnumber <> '' then
strSQL := strSQL + ' Fnumber LIKE ' + '''%' + selFnumber + '%''' + ' AND';
if selFName <> '' then
strSQL := strSQL + ' FName LIKE ' + '''%' + selFname + '%''' + ' AND';
if selFTYPCor <> '' then
strSQL := strSQL + ' TYPCor LIKE ' + '''%' + selFTYPCor + '%''' + ' AND';
strSQL := Copy( strSQL, 1, Length(strSQL)- 4);
strSQL :=trim(strSQL);
SelFacSQL :=strSQL;
ThSelFac:= TSelectFac.Create(StatusBar2, False,strsql);
ThSelFac.FreeOnTerminate :=True;
ThSelFac.OnTerminate :=ThreadDone;
ThSelFac.Resume;
end;
procedure TForm1.threaddo(Sender: TObject);
begin
th:=nil;
end;