246 lines
6.4 KiB
ObjectPascal
246 lines
6.4 KiB
ObjectPascal
|
unit U_UserHelp_Dx;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, cxFilter,
|
|||
|
cxData, cxDataStorage, cxEdit, DB, cxDBData, StdCtrls, cxGridLevel,
|
|||
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
|
|||
|
cxControls, cxGridCustomView, cxGrid, cxInplaceContainer, cxDBTL,
|
|||
|
cxTLData, ComCtrls, ToolWin, ADODB, ImgList,StrUtils, ExtCtrls, DBClient;
|
|||
|
|
|||
|
type
|
|||
|
TfrmUserHelp_Dx = class(TForm)
|
|||
|
ToolBar2: TToolBar;
|
|||
|
TOk: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
tv1: TcxGridDBTableView;
|
|||
|
tv1Code: TcxGridDBColumn;
|
|||
|
tv1Name: TcxGridDBColumn;
|
|||
|
DBGrid1Level1: TcxGridLevel;
|
|||
|
GroupBox1: TGroupBox;
|
|||
|
ADOQueryDept: TADOQuery;
|
|||
|
DataSource1: TDataSource;
|
|||
|
ADOConnection1: TADOConnection;
|
|||
|
tv1Column1: 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;
|
|||
|
ADOQueryHelp: TADOQuery;
|
|||
|
DataSource2: TDataSource;
|
|||
|
Label1: TLabel;
|
|||
|
Edt_name: TEdit;
|
|||
|
ImageList1: TImageList;
|
|||
|
cxStyleTree: TcxStyle;
|
|||
|
Label2: TLabel;
|
|||
|
Edt_Code: TEdit;
|
|||
|
ThreeImgList: TImageList;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
Tv2: TcxGridDBTableView;
|
|||
|
cxGridDBColumn1: TcxGridDBColumn;
|
|||
|
cxGridDBColumn2: TcxGridDBColumn;
|
|||
|
cxGridDBColumn3: TcxGridDBColumn;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
GroupBox2: TGroupBox;
|
|||
|
CDS_sel: TClientDataSet;
|
|||
|
DataSourceSel: TDataSource;
|
|||
|
cxDBTreeList1: TcxDBTreeList;
|
|||
|
cxDBTreeList1cxDBTreeListColumn2: TcxDBTreeListColumn;
|
|||
|
Splitter1: TSplitter;
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure TOkClick(Sender: TObject);
|
|||
|
procedure tv1DblClick(Sender: TObject);
|
|||
|
procedure Edt_nameChange(Sender: TObject);
|
|||
|
procedure cxDBTreeList1Click(Sender: TObject);
|
|||
|
procedure Tv2DblClick(Sender: TObject);
|
|||
|
private
|
|||
|
procedure InitTree();
|
|||
|
procedure DoQuery();
|
|||
|
procedure FilterData(strdepotno,strcode,strname:string);
|
|||
|
public
|
|||
|
fFrameNo:string;
|
|||
|
fFrameName:string;
|
|||
|
fIsYwy:boolean;
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmUserHelp_Dx: TfrmUserHelp_Dx;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_DataLink,U_Fun10;
|
|||
|
{$R *.dfm}
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
//////<2F><><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
procedure TfrmUserHelp_Dx.FilterData(strdepotno,strcode,strname:string);
|
|||
|
var
|
|||
|
filterStr:string;
|
|||
|
begin
|
|||
|
filterStr:='';
|
|||
|
if trim(strdepotno)<>'' then
|
|||
|
filterStr:=filterStr+' and dept like '+quotedstr('%'+trim(strdepotno)+'%');
|
|||
|
if trim(strcode)<>'' then
|
|||
|
filterStr:=filterStr+' and userID like '+quotedstr('%'+trim(strcode)+'%');
|
|||
|
if trim(strname)<>'' then
|
|||
|
filterStr:=filterStr+' and userName like '+quotedstr('%'+trim(strname)+'%');
|
|||
|
|
|||
|
try
|
|||
|
ADOQueryHelp.DisableControls ;
|
|||
|
if trim(filterStr)='' then
|
|||
|
begin
|
|||
|
ADOQueryHelp.Filtered:=false;
|
|||
|
ADOQueryHelp.EnableControls;
|
|||
|
exit;
|
|||
|
end;
|
|||
|
filterStr:=trim(RightBStr(filterStr,length(filterStr)-5));
|
|||
|
// showmessage(filterStr);
|
|||
|
with ADOQueryHelp do
|
|||
|
begin
|
|||
|
filtered:=false;
|
|||
|
filter:=filterStr;
|
|||
|
filtered:=true;
|
|||
|
end;
|
|||
|
finally
|
|||
|
ADOQueryHelp.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
//////////////////////////////////////////////////////
|
|||
|
procedure TfrmUserHelp_Dx.InitTree();
|
|||
|
var
|
|||
|
strsql,strwhere:string;
|
|||
|
begin
|
|||
|
strsql:=' SELECT distinct UDept=''ALL'',UDeptTop='''',UDeptName=''<27><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>'',Framelevel=0 '+
|
|||
|
' union '+
|
|||
|
' SELECT distinct UDept,UDeptTop=''ALL'',UDept,Framelevel=1 '+
|
|||
|
' FROM BD_staff A '+
|
|||
|
' WHERE USERID<>''ADMIN'' and ISNULL(UDept,'''')<>'''' ';
|
|||
|
|
|||
|
strwhere:=' where A.Valid=''Y'' ';
|
|||
|
{ if fIsYwy then
|
|||
|
strwhere:=strwhere+' and A.YWYFlag=''Y'' ';
|
|||
|
if trim(fFrameNo)<>'' then
|
|||
|
strwhere:=strwhere+' and A.dept='+quotedstr(trim(fFrameNo));
|
|||
|
if trim(fFrameName)<>'' then
|
|||
|
strwhere:=strwhere+' and B.frameName like '+quotedstr('%'+trim(fFrameName)+'%');
|
|||
|
strsql:=strsql+ strwhere; }
|
|||
|
|
|||
|
with ADOQueryDept do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear ;
|
|||
|
sql.Add( strsql);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
cxDBTreeList1.FullExpand;
|
|||
|
|
|||
|
DoQuery();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmUserHelp_Dx.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
InitTree();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmUserHelp_Dx.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
GroupBox2.Align :=alclient;
|
|||
|
with ADOConnection1 do
|
|||
|
begin
|
|||
|
Connected:=false;
|
|||
|
ConnectionString:=DConString;
|
|||
|
Connected:=true;
|
|||
|
end;
|
|||
|
end;
|
|||
|
//////////////////////////////////////////////////
|
|||
|
//
|
|||
|
//////////////////////////////////////////////////
|
|||
|
procedure TfrmUserHelp_Dx.DoQuery();
|
|||
|
var
|
|||
|
strsql,strwhere:string;
|
|||
|
begin
|
|||
|
strsql:=' select * '+
|
|||
|
' from BD_staff A '+
|
|||
|
' where isnull(UserID,'''')<>''ADMIN'' ';
|
|||
|
strwhere:=' and A.Valid=''Y'' ';
|
|||
|
if fIsYwy then
|
|||
|
strwhere:=strwhere+' and A.Isywy=1 ';
|
|||
|
|
|||
|
strsql:=strsql+ strwhere +' order by A.userID ';
|
|||
|
|
|||
|
with ADOQueryHelp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear ;
|
|||
|
sql.Add( strsql);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
|
|||
|
sCreateCDS20(ADOQueryHelp,cds_sel);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmUserHelp_Dx.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmUserHelp_Dx.TOkClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryHelp.IsEmpty then
|
|||
|
begin
|
|||
|
ModalResult:=-1
|
|||
|
end
|
|||
|
else
|
|||
|
ModalResult:=1;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmUserHelp_Dx.tv1DblClick(Sender: TObject);
|
|||
|
var
|
|||
|
i:integer;
|
|||
|
begin
|
|||
|
if ADOQueryHelp.IsEmpty then exit;
|
|||
|
|
|||
|
if CDS_Sel.Locate('userID',trim(adoqueryHelp.fieldbyname('userID').AsString),[]) then exit;
|
|||
|
with CDS_Sel do
|
|||
|
begin
|
|||
|
CDS_Sel.append;
|
|||
|
for i:=0 to ADOQueryHelp.FieldCount-1 do
|
|||
|
begin
|
|||
|
fields[i].Value:=ADOQueryHelp.Fields[i].Value;
|
|||
|
end;
|
|||
|
CDS_Sel.Post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmUserHelp_Dx.Edt_nameChange(Sender: TObject);
|
|||
|
begin
|
|||
|
FilterData('',edt_code.Text,Edt_name.Text);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmUserHelp_Dx.cxDBTreeList1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryDept.IsEmpty then exit;
|
|||
|
if trim(ADOQueryDept.FieldByName('Framelevel').AsString)='0' then
|
|||
|
FilterData('','','')
|
|||
|
else
|
|||
|
FilterData(ADOQueryDept.FieldByName('UDept').AsString,'','');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmUserHelp_Dx.Tv2DblClick(Sender: TObject);
|
|||
|
begin
|
|||
|
IF cds_sel.IsEmpty then exit;
|
|||
|
cds_sel.Delete;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|