📄 procedurep.pas
字号:
unit ProcedureP;
interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,Forms, Dialogs, StdCtrls,
Db, DBTables,Grids,DBGrids,QuickRpt,Qrctrls,qrprntr,Printers,WinSpool,menus;
Function UserLog(ModuleName:String;Gh:String;ID:String='';Memo:String=''):String;
Function PrintGrid(TempTitle : string; TmpForm , TmpGrid : TObject) : Boolean;
procedure setFunVisible(Formname:TForm;GH:string);
implementation
{
*******************************************************************
* 作者:陈庭昀 编写日期:2001-09-16 *
* *
* 过程:UserLog *
* 功能:登记用户操作日志 *
* 参数:ModuleName 用户操作摸块名 *
* GH 操作者工号 *
* Memo 其他说明(默认值:'') *
* Sign 日志的ID号码(默认值:'') *
* 返回值:日志ID号码 *
* *
* 基本要求: *
* *
*******************************************************************
}
Function UserLog(ModuleName:String;Gh:String;ID:String='';Memo:String=''):String;
Var
QUserLog:TQuery;
Seq:String; //USERLOG系列号
DT:String; //系统时间
begin
Application.CreateForm(TQuery,QUserLog);
QUserLog.DatabaseName:='db_vipdl';
QUserLog.Close;
QUserLog.SQL.Clear;
QUserLog.SQL.Add('select sysdate DT from dual');
QUserLog.Open;
DT:=FormatDateTime('YYYY-MM-DD HH:NN:SS',QUserLog.FieldByName('DT').AsDateTime);
If ID='' Then
Begin
QUserLog.Close;
QUserLog.SQL.Clear;
QUserLog.SQL.Add('select userlog_id.nextval id from dual');
QUserLog.Open;
SEQ:=QUserLog.FieldByName('ID').AsString;
Result:=SEQ;
QUserLog.Close;
QUserLog.SQL.Clear;
QUserLog.SQL.Add('insert into userlog Values ('+SEQ+','''+Trim(ModuleName)+''','''+DT+''','''','''+Trim(Memo)+''','''+GH+''')');
QUserLog.ExecSQL;
End
Else
Begin
QUserLog.Close;
QUserLog.SQL.Clear;
QUserLog.SQL.Add('Update UserLog Set EndDate='''+DT+''' Where ID='+ID);
QUserLog.ExecSQL;
Result:=ID;
End;
QUserLog.Free;
end;
{
***************************************************************************************
* 作者:黄志文 编写日期:2001-09-17 *
* *
* 函数:PrintGrid *
* 功能:将StringGrid组合中的值传至Report中,动态生成报表 *
* 参数:TempTitle:报表标题名; TmpForm:StringGrid所在的窗体名,TmpGrid:StringGrid名称 * *
* 返回值:预览成功则返回True,否则返回False; *
* *
* 基本要求:无 * *
***************************************************************************************
}
Function PrintGrid(TempTitle : string; TmpForm , TmpGrid : TObject) : Boolean;
var
tmpqrband : tqrband;
TempForm : TForm;
TempQuickRep : TQuickRep;
TmpTitle : array [0..255] of TQRLabel;
TempQrLabel : array [0..255] of TQRLabel;
TmpQRShape : array [0..255] of TQRShape;
TempRowC,TempColC,TempQrLabelC,TempTop,TempLeft,TempTop_Shape,TempLeft_Shape : integer;
TotalWidth : integer;
begin
try
Result := True;
TempForm := TForm.Create(nil);
TempForm.Name := 'TempForm';
TempForm.Caption := 'Form2';
TotalWidth := 0;
if TmpForm is TForm then
begin
if TmpGrid is TStringGrid then
begin
with TForm(TmpForm) do
begin
for TempColC := 0 to TStringGrid(TmpGrid).ColCount -1 do
begin
TotalWidth := TotalWidth + TStringGrid(TmpGrid).ColWidths[TempColC];
end;
end;
end;
end;
TempQuickRep := TQuickRep.Create(nil);
TempQuickRep.Name := 'TempForm';
TempQuickRep.Font.Name := '宋体';
TempQuickRep.Font.Size := 12;
TempQuickRep.Page.PaperSize := TQrPaperSize(custom);
if TotalWidth > 210 then
begin
TempQuickRep.Page.Orientation := TPrinterOrientation(poLandscape);
TempQuickRep.Page.Width := TotalWidth;
Printer.Orientation := poLandscape;
end
else
begin
TempQuickRep.Page.Orientation := TPrinterOrientation(poPortrait);
TempQuickRep.Page.Width := 210;
Printer.Orientation := poPortrait;
end;
TempQuickRep.Parent := TempForm;
tmpqrband := TQrBand.Create(nil);
tmpqrband.Parent := TempQuickRep;
tmpqrband.BringToFront;
tmpqrband.Show;
tmpqrband.Width := screen.Width;
tmpqrband.Height := screen.Height;
TmpTitle[0] := TQRLabel.Create(nil);
TmpTitle[0].Name := 'TmpTitle';
TmpTitle[0].Parent := TempQuickRep;
TmpTitle[0].caption := TempTitle;
TmpTitle[0].Font.Style := [FsBold];
TmpTitle[0].Font.Size := 20;
TmpTitle[0].Top := 12;
TmpTitle[0].Left := Round((TempQuickRep.Page.Width - Length(TmpTitle[0].Caption))/2);
if TmpForm is TForm then
begin
if TmpGrid is TStringGrid then
begin
with TForm(TmpForm) do
begin
TempRowC := 0;
TempQrLabelC := 1;
TempTop_Shape := 80;
TempLeft_Shape := Round((TempQuickRep.Page.Width - TotalWidth/10)/2);
for TempRowC := 0 to (TStringGrid(TmpGrid).RowCount) -1 do
begin
for TempColC := 0 to TStringGrid(TmpGrid).ColCount -1 do
begin
TmpQRShape[TempQrLabelC] := TQrShape.Create(nil);
with TmpQRShape[TempQrLabelC] do
begin
parent := TempQuickRep;
Top := TempTop_Shape;
Left := TempLeft_Shape;
Width := TStringGrid(TmpGrid).ColWidths[TempColC];
Height := TStringGrid(TmpGrid).RowHeights[TempRowC];
if (TempQrLabelC mod TStringGrid(TmpGrid).ColCount) = 0 then
TempTop_Shape := TmpQRShape[TempQrLabelC - 1].Top + TmpQRShape[TempQrLabelC - 1].Height;
if (TempQrLabelC mod TStringGrid(TmpGrid).ColCount) = 0 then
begin
TempLeft_Shape := Round((TempQuickRep.Page.Width - TotalWidth/10)/2);
end
else
begin
if TempQrLabelC >= 1 then
TempLeft_Shape := TmpQRShape[TempQrLabelC].Left + TmpQRShape[TempQrLabelC].Width;
end;
visible := True;
SendToBack;
Show;
end;
TempQrLabel[TempQrLabelC]:=TQrLabel.Create(nil);
with TempQrLabel[TempQrLabelC] do
begin
Name := 'TempQrLabel' + inttostr(TempQrLabelC);
parent := TempQuickRep;
if Length(trim(TStringGrid(TmpGrid).Cells[TempColC,TempRowC])) = 0 then
Caption := ''
else
Caption := TStringGrid(TmpGrid).Cells[TempColC,TempRowC];
AutoSize := true;
Alignment := taLeftJustify;
Font := TempForm.Font;
Font.Color := ClRed;
Top := TmpQRShape[TempQrLabelC].Top + 2;
Left := TmpQRShape[TempQrLabelC].Left + 2;
visible := True;
TransParent := True;
BringToFront;
Show;
end;
Inc(TempQrLabelC);
end;
end;
end;
end;
end;
try
TempQuickRep.Preview;
except
Result := False;
end;
finally
TempQuickRep.Free;
end;
end;
{
*******************************************************************
* 作者:郭壮煌 编写日期:2001-11-27 *
* *
* 函数:setFunVisible *
* 功能:设置窗体功能键 *
* 参数:Formname 窗体名称 *
* GH 使用人工号 *
* 返回值:无 *
* *
* 基本要求:无 *
* *
*******************************************************************
}
procedure setFunVisible(Formname:TForm;GH:string);
var QueryTmp: TQuery;
i:integer;
begin
{
Application.CreateForm(TQuery,QueryTmp);
QueryTmp.DatabaseName:='db_vipdl';
with QueryTmp do
begin
close;
sql.clear;
sql.add('select fun_Code');
sql.add(' from setfun');
sql.add(' where (form_code=:sTmp1)');
sql.add(' and ((fun_state=''N'')');
sql.add(' or(FUN_ID not in (select FUN_ID ');
sql.add(' from set_access_fun ');
sql.add(' where (GH=:sTmp2)))) ');
ParambyName('sTmp1').AsString:=Formname.name;
ParambyName('sTmp2').AsString:=GH;
open;
while not eof do
begin
for i:=0 to Formname.ComponentCount-1 do
if Formname.Components[i].Name =Fields[0].AsString then
begin
if Formname.Components[i] is TControl then
(Formname.Components[i] as TControl).visible := False;
if Formname.Components[i] is TMenuItem then
(Formname.Components[i] as TMenuItem).visible := False;
Break;
end;{if}
{
next;
end;{while}
// end;
// QueryTmp.Destroy;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -