📄 bas100_01.pas.svn-base
字号:
unit Bas100_01;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, dxDBGrid, Wwdbgrid, DBCtrls, StdCtrls, Menus, ComCtrls, DB, WinSkinData,
wwdbdatetimepicker,ADODB,CommFun,StrUtils;
type
TBas100_01Form = class(TForm)
pmUISet: TPopupMenu;
mmiInterface: TMenuItem;
mmiLanguage: TMenuItem;
mmiTable: TMenuItem;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
IsInit:Boolean; //获取界面信息的开关
procedure GetLang(ALangInfo:TLangInfo);
procedure Component;
protected
ANum:integer;
AProgramID:string;
ARights:string[10];
AReportName:string; //报表名称
public
{ Public declarations }
end;
var
Bas100_01Form: TBas100_01Form;
implementation
uses SYSDATA;
{$R *.DFM}
procedure TBas100_01Form.FormClose(Sender: TObject;
var Action: TCloseAction);
var
I:Integer;
begin
for I:=0 to ComponentCount-1 do
begin
if (Components[I] is TPageControl) then
begin
TPageControl(Components[I]).ActivePageIndex:=0;
end;
end;
SaveToReg(Self);
SetLogOut(AProgramID); //记录在线情况表
Action := caFree;
end;
procedure TBas100_01Form.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_F1 then
HtmlHelp(Application.Handle, AHelpFile+'::/'+AProgramID+'.htm', $0000, nil);
if ActiveControl is TwwDBGrid then Exit;
if ActiveControl is TdxDBGrid then Exit;
if ActiveControl is TDBMemo then Exit;
if ActiveControl is TMemo then Exit;
if ActiveControl is TRichEdit then Exit;
if Key in [vk_Return] then PostMessage(handle,wm_keydown,vk_tab,0);
end;
procedure TBas100_01Form.FormCreate(Sender: TObject);
var
I:Integer;
S:String;
begin
//设置界面信息
Font.Name:=AFontName;
AProgramID:=copy(Name,1,6);
AReportName:=copy(Name,1,6)+'.frf';
ARights:=GetRights(AProgramID,AModule); //取得权限
SetLogIn(AProgramID); //记录在线情况表
for I:=0 to ComponentCount-1 do
begin
if (Components[I] is TLabel) then
begin
TLabel(Components[I]).Alignment:=taRightJustify;
if (TLabel(Components[I]).Tag=1) then
begin
TLabel(Components[I]).Font.Color:=AKeyColor;
TLabel(Components[I]).Font.Style:=AKeyStyle;
end;
end else
if (Components[I] is TDateTimeField) then
begin
S:=GetSysParams('SYS0002'); //日期格式
TDateTimeField(Components[I]).DisplayFormat:=ADateFormat[StrToInt(S)];
end else
if (Components[I] is TFloatField) then
begin
case Components[I].Tag of
0:TFloatField(Components[I]).DisplayFormat:=AQtyFormat[StrToInt(GetSysParams('SYS0003'))]; //数量格式
1:TFloatField(Components[I]).DisplayFormat:=APriceFormat[StrToInt(GetSysParams('SYS0004'))]; //单价格式
2:TFloatField(Components[I]).DisplayFormat:=AAmountFormat[StrToInt(GetSysParams('SYS0005'))]; //金额格式
3:TFloatField(Components[I]).DisplayFormat:=ARateFormat[StrToInt(GetSysParams('SYS0006'))]; //汇率格式
end;
//SYS0008 255 负数字体颜色 clRead
// ANegaColor:TColor; //负数字体颜色
end else
if (Components[I] is TwwDBDateTimePicker) then
begin
S:=GetSysParams('SYS0002'); //日期格式
TwwDBDateTimePicker(Components[I]).DisplayFormat:=ADateFormat[StrToInt(S)];
end else
if (Components[I] is TEdit) then
begin
if TEdit(Components[I]).Enabled then
TEdit(Components[I]).Color:=AEnableColor
else
TEdit(Components[I]).Color:=ADisableColor;
end else
if (Components[I] is TDBEdit) then
begin
if TDBEdit(Components[I]).Enabled then
TDBEdit(Components[I]).Color:=AEnableColor
else
TDBEdit(Components[I]).Color:=ADisableColor;
end else
if (Components[I] is TwwDBGrid) then
begin
TwwDBGrid(Components[I]).TitleColor:=AFormColor;
end;
end;
//获取界面信息的开关
IsInit:=False;
if IsInit then Component;
end;
procedure TBas100_01Form.GetLang(ALangInfo: TLangInfo);
var
AQuery:TAdoQuery;
I:integer;
AStr:string;
begin
AQuery:=TAdoQuery.Create(nil);
AQuery.Connection:=SYSDM.ADOC;
if ALangInfo.AComponentName<>'' then
begin
ANum:=ANum+1;
AStr:=Inttostr(ANum);
for I :=1 to (3-length(inttostr(ANum))) do
begin
AStr:='0'+AStr;
end;
ALangInfo.ACode:=LeftStr(Name,6)+MidStr(Name,8,2)+AStr;
AStr:=':=GetDBString('+''''+ALangInfo.ACode+''''+'); //';
ALangInfo.APostfix:=AStr;
AQuery.Close;
AQuery.SQL.Clear;
AQuery.SQL.Add('select * from Component where FormName='+''''+ALangInfo.AFormName+'''');
AQuery.Open;
if not AQuery.Locate('ComponentName',ALangInfo.AComponentName,[]) then
begin
if ALangInfo.AComponentCaption<>'' then
begin
AQuery.Append;
AQuery.FieldByName('FormName').Value:=ALangInfo.AFormName;
AQuery.FieldByName('ComponentName').Value:=ALangInfo.AComponentName;
AQuery.FieldByName('ComponentCaption').Value:=ALangInfo.AComponentCaption;
AQuery.FieldByName('Prefix').Value:=ALangInfo.APrefix;
AQuery.FieldByName('Postfix').Value:=ALangInfo.APostfix;
AQuery.FieldByName('Code').Value:=ALangInfo.ACode;
AQuery.Post;
end;
end;
end;
AQuery:=nil;
AQuery.Free;
end;
procedure TBas100_01Form.Component;
var
I,J:Integer;
ALang:TLangInfo;
begin
//设置界面信息
ANum:=0;
ALang.AFormName:=LeftStr(Name,9);
ALang.AComponentName:='Caption';
ALang.AComponentCaption:='Caption';
ALang.APrefix:='';
GetLang(ALang);
for I:=0 to ComponentCount-1 do
begin
if (Components[I] is TLabel) then
begin
ALang.AComponentName:=TLabel(Components[I]).Name;
ALang.AComponentCaption:=TLabel(Components[I]).Caption;
ALang.APrefix:='.Caption';
GetLang(ALang);
end else
if (Components[I] is TwwDBGrid) then
begin
if TwwDBGrid(Components[I]).DataSource.DataSet is TADODataSet then
TADODataSet(TwwDBGrid(Components[I]).DataSource.DataSet).CreateDataSet
else if TwwDBGrid(Components[I]).DataSource.DataSet is TDataSet then
TDataSet(TwwDBGrid(Components[I]).DataSource.DataSet).Open;
for J :=0 to TwwDBGrid(Components[I]).GetColCount-2 do
begin
ALang.AComponentName:=TwwDBGrid(Components[I]).Name+'.ColumnByName('+''''+TwwDBGrid(Components[I]).Columns[J].FieldName+''''+')';
ALang.AComponentCaption:=TwwDBGrid(Components[I]).Columns[J].DisplayLabel;
ALang.APrefix:='.DisplayLabel';
GetLang(ALang);
end;
end;
//ADOQuery语言信息
if (Components[I] is TADOQuery) then
begin
for J :=0 to TADOQuery(Components[I]).FieldCount-1 do
begin
if TADOQuery(Components[I]).Fields[J].Visible=True then
begin
ALang.AComponentName:=TADOQuery(Components[I]).Fields[J].Name;
ALang.AComponentCaption:=TADOQuery(Components[I]).Fields[J].DisplayLabel;
ALang.APrefix:='.DisplayLabel';
GetLang(ALang);
end;
end;
end;
if (Components[I] is TGroupBox) then
begin
ALang.AComponentName:=TGroupBox(Components[I]).Name;
ALang.AComponentCaption:=TGroupBox(Components[I]).Caption;
ALang.APrefix:='.Caption';
GetLang(ALang);
end;
if (Components[I] is TComboBox) then
begin
for J:=0 to TComboBox(Components[I]).Items.Count-1 do
begin
TComboBox(Components[I]).ItemIndex:=J;
ALang.AComponentName:=TComboBox(Components[I]).Name ;
ALang.AComponentCaption:=TComboBox(Components[I]).Text;
ALang.APrefix:='.Items.Add';
GetLang(ALang);
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -