176 lines
4.4 KiB
ObjectPascal
176 lines
4.4 KiB
ObjectPascal
unit U_CustHelp_right;
|
|
|
|
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, ImgList, StdCtrls, ExtCtrls, ComCtrls, ToolWin,
|
|
ADODB;
|
|
|
|
type
|
|
TfrmCustHelp_right = class(TForm)
|
|
ToolBar1: TToolBar;
|
|
BtnOk: TToolButton;
|
|
BtnCancel: TToolButton;
|
|
Panel1: TPanel;
|
|
Label1: TLabel;
|
|
Edit1: TEdit;
|
|
ImageList24: TImageList;
|
|
cxGrid1: TcxGrid;
|
|
tv1: TcxGridDBTableView;
|
|
tv1customNo: TcxGridDBColumn;
|
|
tv1customName: TcxGridDBColumn;
|
|
cxGrid1Level1: TcxGridLevel;
|
|
cxGridt1: TcxGrid;
|
|
tt1: TcxGridDBTableView;
|
|
tt1ParentCodeName: TcxGridDBColumn;
|
|
tt1codeName: TcxGridDBColumn;
|
|
cleveltt1: TcxGridLevel;
|
|
DataSource1: TDataSource;
|
|
ADOQueryHelp: TADOQuery;
|
|
ADOConnection1: TADOConnection;
|
|
DS_Left: TDataSource;
|
|
ADOQueryLeft: TADOQuery;
|
|
tv1shortName: TcxGridDBColumn;
|
|
cxStyleRepository1: TcxStyleRepository;
|
|
cxStyle1: TcxStyle;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure BtnCancelClick(Sender: TObject);
|
|
procedure Edit1Change(Sender: TObject);
|
|
procedure tt1FocusedRecordChanged(Sender: TcxCustomGridTableView;
|
|
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
|
|
ANewItemRecordFocusingChanged: Boolean);
|
|
procedure BtnOkClick(Sender: TObject);
|
|
procedure tv1DblClick(Sender: TObject);
|
|
procedure FormShow(Sender: TObject);
|
|
private
|
|
fisLoad:Boolean;
|
|
procedure InitLeftTree();
|
|
procedure InitGrid();
|
|
public
|
|
fValidCustFlag:Boolean; //是否显示无效客户
|
|
fDispCustomName:Boolean; //是否显示全称
|
|
end;
|
|
|
|
var
|
|
frmCustHelp_right: TfrmCustHelp_right;
|
|
|
|
implementation
|
|
uses
|
|
U_global;
|
|
{$R *.dfm}
|
|
|
|
procedure TfrmCustHelp_right.FormCreate(Sender: TObject);
|
|
begin
|
|
cxGrid1.Align :=alClient;
|
|
with ADOConnection1 do
|
|
begin
|
|
Connected:=false;
|
|
ConnectionString:=gConString;
|
|
Connected:=true;
|
|
end;
|
|
InitLeftTree();
|
|
InitGrid();
|
|
end;
|
|
|
|
procedure TfrmCustHelp_right.BtnCancelClick(Sender: TObject);
|
|
begin
|
|
close;
|
|
end;
|
|
//////////////////////////////////////////////////////////////
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
procedure TfrmCustHelp_right.InitGrid();
|
|
var
|
|
mfiler:string;
|
|
mWhere:string;
|
|
begin
|
|
mWhere:='';
|
|
if trim(edit1.Text)<>'' then
|
|
mWhere :=' and (A.CustomName Like '+quotedStr('%'+trim(edit1.Text)+'%')+
|
|
' or A.ShortName Like '+quotedStr('%'+trim(edit1.Text)+'%')+
|
|
' or A.CustomNo Like '+quotedStr('%'+trim(edit1.Text)+'%')+')';
|
|
mfiler:='';
|
|
if not ADOQueryLeft.IsEmpty then
|
|
mfiler:='ywycode ='+quotedStr(trim(ADOQueryLeft.fieldBYName('ywycode').AsString)) ;
|
|
try
|
|
ADOQueryHelp.DisableControls ;
|
|
with ADOQueryHelp do
|
|
begin
|
|
close;
|
|
sql.clear;
|
|
filtered:=false;
|
|
sql.Add('exec P_Get_CustomerInfo');
|
|
sql.Add('2');
|
|
sql.Add(','+quotedStr(gUserId));
|
|
sql.Add(',1');
|
|
sql.Add(','+quotedStr(mWhere));
|
|
Open;
|
|
if trim(mfiler)<>'' then
|
|
begin
|
|
filter:=mfiler;
|
|
filtered:=true;
|
|
end;
|
|
end;
|
|
finally
|
|
ADOQueryHelp.EnableControls ;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCustHelp_right.Edit1Change(Sender: TObject);
|
|
begin
|
|
InitGrid();
|
|
end;
|
|
////////////////////////////////////////////////////
|
|
//
|
|
////////////////////////////////////////////////////
|
|
procedure TfrmCustHelp_right.InitLeftTree();
|
|
begin
|
|
try
|
|
fisLoad:=false;
|
|
ADOQueryLeft.DisableControls ;
|
|
with ADOQueryLeft do
|
|
begin
|
|
close;
|
|
sql.clear;
|
|
sql.Add('EXEC P_select_UserDept');
|
|
sql.Add(quotedStr(guserId));
|
|
sql.Add(',1');
|
|
Open;
|
|
end;
|
|
finally
|
|
ADOQueryLeft.EnableControls ;
|
|
fisLoad:=true;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCustHelp_right.tt1FocusedRecordChanged(
|
|
Sender: TcxCustomGridTableView; APrevFocusedRecord,
|
|
AFocusedRecord: TcxCustomGridRecord;
|
|
ANewItemRecordFocusingChanged: Boolean);
|
|
begin
|
|
if fisLoad then
|
|
InitGrid();
|
|
end;
|
|
|
|
procedure TfrmCustHelp_right.BtnOkClick(Sender: TObject);
|
|
begin
|
|
if ADOQueryHelp.IsEmpty then exit;
|
|
ModalResult := 1;
|
|
end;
|
|
|
|
procedure TfrmCustHelp_right.tv1DblClick(Sender: TObject);
|
|
begin
|
|
BtnOk.Click ;
|
|
end;
|
|
|
|
procedure TfrmCustHelp_right.FormShow(Sender: TObject);
|
|
begin
|
|
tv1customName.Visible := fDispCustomName;
|
|
end;
|
|
|
|
end.
|