146 lines
4.0 KiB
ObjectPascal
146 lines
4.0 KiB
ObjectPascal
unit U_LeftHelptree;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
|
||
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
|
||
cxGridCustomView, cxGrid, ADODB, ExtCtrls, StdCtrls;
|
||
|
||
type
|
||
TframeLeftHelpTree = class(TFrame)
|
||
cxGridt1: TcxGrid;
|
||
tt1: TcxGridDBTableView;
|
||
tt1codeName: TcxGridDBColumn;
|
||
cleveltt1: TcxGridLevel;
|
||
DS_LTree: TDataSource;
|
||
ADOQueryLTree: TADOQuery;
|
||
Panel1: TPanel;
|
||
tt1ParentCodeName: TcxGridDBColumn;
|
||
cxStyleRepository1: TcxStyleRepository;
|
||
cxStyle1: TcxStyle;
|
||
cxStyle2: TcxStyle;
|
||
cxStyle_gridRow: TcxStyle;
|
||
cxStyle_gridFoot: TcxStyle;
|
||
cxStyle_gridHead: TcxStyle;
|
||
cxStyle_gridGroupBox: TcxStyle;
|
||
cxStyle_yellow: TcxStyle;
|
||
cxStyle_Red: TcxStyle;
|
||
cxStyle_fontred: TcxStyle;
|
||
cxStyle_fontBlue: TcxStyle;
|
||
ComboBox1: TComboBox;
|
||
Edit1: TEdit;
|
||
procedure tt1FocusedRecordChanged(Sender: TcxCustomGridTableView;
|
||
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
|
||
ANewItemRecordFocusingChanged: Boolean);
|
||
procedure Edit1Change(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
public
|
||
fLeftSelValue:string;
|
||
fLeftSelCaption:string;
|
||
procedure DoLeftFilter();
|
||
procedure InitLTree(fromADOQ:TADOQuery;mTreeCaption:string;
|
||
mTreeKind,mTreeFlag,mOtherWhere:string;autoExpand:boolean);
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
/////////////////////////////////////////
|
||
//函数功能:初始化化树
|
||
//显示方式:
|
||
//mTreeCaption:树标题
|
||
//mTreeKind 客户;员工;机台;等
|
||
//mTreeFlag; 多种客户树的具体代号标志
|
||
//mOtherWhere:其他过滤条件
|
||
//autoExpand:数是否自动展开
|
||
/////////////////////////////////////////
|
||
procedure TframeLeftHelpTree.InitLTree(fromADOQ:TADOQuery;mTreeCaption:string;
|
||
mTreeKind,mTreeFlag,mOtherWhere:string;autoExpand:boolean);
|
||
begin
|
||
{
|
||
if mTreeCaption<>'' then
|
||
begin
|
||
Panel1.caption:=trim(mTreeCaption);
|
||
Panel1.Visible :=true;
|
||
end;
|
||
}
|
||
//if autoExpand then
|
||
TT1.DataController.Options:=[dcoGroupsAlwaysExpanded];
|
||
//else
|
||
// TT1.DataController.Options:=[];
|
||
try
|
||
ADOQueryLTree.Connection:=fromADOQ.Connection;
|
||
ADOQueryLTree.DisableControls ;
|
||
with ADOQueryLTree do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.Add('exec P_Get_WinLeftTree');
|
||
sql.Add(quotedStr(mTreeKind));
|
||
sql.Add(','+quotedStr(mTreeflag));
|
||
sql.Add(','+quotedStr(mOtherWhere));
|
||
Open;
|
||
end;
|
||
ADOQueryLTree.EnableControls;
|
||
except
|
||
application.MessageBox(pchar('初始化【'+mTreeCaption+'】树失败!'),'警告信息',0);
|
||
end;
|
||
end;
|
||
procedure TframeLeftHelpTree.tt1FocusedRecordChanged(
|
||
Sender: TcxCustomGridTableView; APrevFocusedRecord,
|
||
AFocusedRecord: TcxCustomGridRecord;
|
||
ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
if (tt1.Controller.FocusedRow is TcxGridGroupRow) then
|
||
begin
|
||
fLeftSelValue:='';
|
||
fLeftSelCaption:='';
|
||
end
|
||
else
|
||
begin
|
||
fLeftSelValue:=trim(ADOQueryLTree.fieldByName('code').AsString) ;
|
||
fLeftSelCaption:=trim(ADOQueryLTree.fieldByName('codeName').AsString) ;
|
||
end;
|
||
end;
|
||
///////////////////////////////////////////////////////////////
|
||
procedure TframeLeftHelpTree.DoLeftFilter();
|
||
var
|
||
mfilterStr:string;
|
||
begin
|
||
//名称
|
||
if (ComboBox1.ItemIndex=0) and (trim(edit1.Text) <>'') then
|
||
begin
|
||
mfilterStr:='codeName like '+quotedStr('%'+trim(edit1.Text)+'%');
|
||
end;
|
||
//编号
|
||
if (ComboBox1.ItemIndex=1) and (trim(edit1.Text) <>'') then
|
||
begin
|
||
mfilterStr:='code like '+quotedStr('%'+trim(edit1.Text)+'%');
|
||
end;
|
||
try
|
||
ADOQueryLTree.DisableControls ;
|
||
with ADOQueryLTree do
|
||
begin
|
||
filtered:=false;
|
||
if trim(mfilterStr)<>'' then
|
||
begin
|
||
filter:=mfilterStr;
|
||
filtered:=true;
|
||
end;
|
||
end;
|
||
finally
|
||
ADOQueryLTree.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TframeLeftHelpTree.Edit1Change(Sender: TObject);
|
||
begin
|
||
DoLeftFilter();
|
||
end;
|
||
|
||
end.
|