📄 unit_queryoperationuse.pas
字号:
unit Unit_QueryOperationUse;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Unit_custbrowsebase_P, TFlatCheckListBoxUnit, StdCtrls, CheckLst,
ImgList, Menus, Db, DBTables, Grids, DBGrids, ComCtrls,
TFlatCheckBoxUnit, TFlatSpinEditUnit, ToolWin, TFlatEditUnit,
TFlatComboBoxUnit, TFlatButtonUnit, ExtCtrls, TFlatListBoxUnit,
TFlatRadioButtonUnit;
const
INVALI='1'; //无效值
VALI='2'; //有效值
FUNCLOSE='0'; // 关
FUNOPEN='1'; //开通
MAXFunCount=40;//最大功能数
type
TFRM_QueryOperationUse = class(TForm_custbrowsebase_P)
cbGR_Fun: TFlatCheckBox;
btnGR_FunFull: TFlatButton;
BtnGR_FunNone: TFlatButton;
clbGR_Fun: TCheckListBox;
procedure btnGR_FunFullClick(Sender: TObject);
procedure BtnGR_FunNoneClick(Sender: TObject);
procedure cbGR_FunClick(Sender: TObject);
procedure FlatButton3Click(Sender: TObject);
procedure FlatButton2Click(Sender: TObject);
private
ifunCount:integer;
arrayfun:string[40];
arrayfunvalues:array [1..MAXFunCount] of integer;
arrayfundesc:array [1..MAXFunCount] of string;
{ Private declarations }
protected
procedure pro_initother(sender:tobject);override;
procedure pro_GR_getid(sender:tobject);override;
procedure pro_GR_OpenDataSet(sender:tobject;strsql:string);override;
procedure pro_GR_getsqlwhere(sender:tobject);override;
procedure pro_GR_checkcondition(sender:tobject);override;
function fun_getFunField(sender:tobject):string;
//根据列表框中的选中列生成相应的查询条件
function fun_getFunCheck(sender:tobject):string;
public
{ Public declarations }
end;
var
FRM_QueryOperationUse: TFRM_QueryOperationUse;
implementation
uses dmmain,PrintFrmForm;
Function Fun_ExportData(pFileName:String;pReportTitle:String;pObjectSource:TObject):Boolean;stdcall;external'winfun.dll';
{$R *.DFM}
procedure TFRM_QueryOperationUse.btnGR_FunFullClick(Sender: TObject);
var
i:integer;
begin
inherited;
with clbGR_Fun do
begin
for i:=0 to items.Count-1 do
begin
checked[i]:=true;
end;
end;
end;
procedure TFRM_QueryOperationUse.pro_GR_checkcondition(sender: tobject);
begin
inherited;
end;
procedure TFRM_QueryOperationUse.pro_GR_getid(sender: tobject);
begin
inherited;
end;
procedure TFRM_QueryOperationUse.pro_GR_getsqlwhere(sender: tobject);
begin
inherited;
//
GR_sqlwhere:=GR_sqlwhere+fun_getFuncheck(self);
end;
procedure TFRM_QueryOperationUse.pro_GR_OpenDataSet(sender: tobject;
strsql: string);
begin
with browse_normal do
begin
close;
sql.clear;
sql.add('select * from T_V_GR_QueryOperationUse');
sql.Add('where 1=1');
sql.add(strsql);
// memo1.text:=sql.Text;
open;
end;
end;
procedure TFRM_QueryOperationUse.pro_initother(sender: tobject);
var
tmpstr:string;
i,j,iPos:integer;
begin
inherited;
with query_tmp do
begin
close;
sql.clear;
sql.add('select fun,PAR_Desc,par_Values from T_V_Fun');
open;
iFunCount:=recordcount;
clbGR_Fun.Items.Clear;
arrayFun:='';
// i:=0;
first;
while not eof do
begin
iPos:=strtoint(trim(fieldbyname('PAR_values').asstring));
if not((pos('无效',fieldbyname('PAR_Desc').asstring)>0) or (pos('未定义',fieldbyname('PAR_Desc').asstring)>0)) then
begin
//clbGR_Fun.Items.Add(trim(fieldbyname('PAR_Desc').asstring));
arrayfunvalues[iPos]:=iPos;
arrayfundesc[iPos]:=trim(fieldbyname('PAR_Desc').asstring);
arrayfun[iPos]:=VALI; //有效
for j:=0 to dbgGR.Columns.Count-1 do
begin
if trim(dbgGR.Columns[j].FieldName)=trim(fieldbyname('fun').asstring) then
begin
dbgGR.Columns[j].Title.Caption:=trim(fieldbyname('PAR_Desc').asstring);
break;
end;
end;
end
else
begin
arrayfunvalues[iPos]:=0;
arrayfun[iPos]:=INVALI; //无效
for j:=0 to dbgGR.Columns.Count-1 do
begin
if trim(dbgGR.Columns[j].FieldName)=trim(fieldbyname('fun').asstring) then
begin
dbgGR.Columns[j].Visible:=false;
break;
end;
end;
end;
next;
// inc(i)
end;
end;
for i:=1 to MAXFunCount do
begin
if arrayfun[i] = VALI then
clbGR_Fun.Items.Add(arrayfundesc[i]);
end;
end;
procedure TFRM_QueryOperationUse.BtnGR_FunNoneClick(Sender: TObject);
var
i:integer;
begin
inherited;
with clbGR_Fun do
begin
for i:=0 to items.Count-1 do
begin
checked[i]:=false;
end;
end;
end;
procedure TFRM_QueryOperationUse.cbGR_FunClick(Sender: TObject);
begin
inherited;
if cbGR_Fun.Checked then
begin
clbGR_Fun.Color:=clwindow;
clbGR_Fun.Enabled:=true;
btnGR_FunFull.enabled:=true;
BtnGR_FunNone.enabled:=true
end
else
begin
clbGR_Fun.Color:=clBtnFace;
clbGR_Fun.Enabled:=false;
btnGR_FunFull.enabled:=false;
BtnGR_FunNone.enabled:=false
end;
end;
function TFRM_QueryOperationUse.fun_getFunField(sender: tobject): string;
var
i:integer;
tmpstr:string;
begin
result:='';
for i:=0 to iFunCount-1 do
begin
if arrayfun[i]=VALI then
begin
tmpstr:=tmpstr+',Fun'+inttostr(i+1)+' '+inttostr(arrayfunvalues[i]);
end;
end;
result:=tmpstr;
end;
function TFRM_QueryOperationUse.fun_getFunCheck(sender: tobject): string;
var
i,j:integer;
tmpstr:string;
begin
result:='';
i:=0;
j:=0;
for i:=0 to clbGR_Fun.Items.Count-1 do
if clbGR_Fun.checked[i] then
for j:=1 to MAXFunCount do
if arrayfundesc[j]=trim(clbGR_Fun.Items[i]) then
begin
tmpstr:=tmpstr+' and fun'+inttostr(arrayfunvalues[j])+'='+FUNOPEN;
break;
end;
result:=tmpstr;
end;
procedure TFRM_QueryOperationUse.FlatButton3Click(Sender: TObject);
begin
inherited;
if browse_normal.Active then
if not (browse_normal.Bof and browse_normal.Eof) then
Fun_ExportData('大客户业务使用','大客户业务使用',dbgGR);
end;
procedure TFRM_QueryOperationUse.FlatButton2Click(Sender: TObject);
begin
inherited;
if browse_normal.Active then
if not (browse_normal.Bof and browse_normal.Eof) then
begin
try
PrintDbGrid(dbgGR.datasource.dataset,dbgGR,'大客户业务使用个人客户');
except
Application.MessageBox('系统在执行过程中发生错误!','提示',MB_ICONINFORMATION);
exit;
end;//try
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -