RTFormwork/public10/ThreeFun/Form/U_UserHelp.pas

217 lines
5.6 KiB
ObjectPascal
Raw Normal View History

2024-07-07 09:35:27 +08:00
unit U_UserHelp;
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,
2024-11-15 17:18:34 +08:00
cxLookAndFeels, cxLookAndFeelPainters, cxTLdxBarBuiltInMenu,
cxNavigator, dxDateRanges, System.ImageList;
2024-07-07 09:35:27 +08:00
type
TfrmUserHelp = class(TForm)
ToolBar2: TToolBar;
TOk: TToolButton;
TBClose: TToolButton;
cxDBTreeList1: TcxDBTreeList;
cxDBTreeList1cxDBTreeListColumn2: TcxDBTreeListColumn;
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;
Splitter1: TSplitter;
ThreeImgList: TImageList;
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);
private
procedure InitTree();
procedure DoQuery();
procedure FilterData(strdepotno,strcode,strname:string);
public
fFrameNo:string;
fFrameName:string;
fIsYwy:boolean;
end;
var
frmUserHelp: TfrmUserHelp;
implementation
uses
U_DataLink;
{$R *.dfm}
///////////////////////////////////////////////////////////
//////<2F><><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
///////////////////////////////////////////////////////////
procedure TfrmUserHelp.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.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.FormShow(Sender: TObject);
begin
InitTree();
end;
procedure TfrmUserHelp.FormCreate(Sender: TObject);
begin
cxGrid1.Align :=alclient;
with ADOConnection1 do
begin
Connected:=false;
ConnectionString:=DConString;
Connected:=true;
end;
end;
//////////////////////////////////////////////////
//
//////////////////////////////////////////////////
procedure TfrmUserHelp.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;
end;
procedure TfrmUserHelp.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmUserHelp.TOkClick(Sender: TObject);
begin
if ADOQueryHelp.IsEmpty then
begin
ModalResult:=-1
end
else
ModalResult:=1;
end;
procedure TfrmUserHelp.tv1DblClick(Sender: TObject);
begin
Tok.Click ;
end;
procedure TfrmUserHelp.Edt_nameChange(Sender: TObject);
begin
FilterData('',edt_code.Text,Edt_name.Text);
end;
procedure TfrmUserHelp.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;
end.