📄 chheadunit.pas
字号:
unit chHeadUnit;
interface
Uses Windows, Messages, SysUtils, Classes, Dialogs,
ComCtrls, Variants, Graphics, Controls, Forms,
DB, ADODB, StdCtrls, ExtCtrls, Grids, DBGrids, Buttons,
DBCtrls, Mask, DBGridEh;
Const conSEPCHAR = ';';
g_conMSERIALMASK = '>L000000\-00999;1;_';
g_conSERIALMASK = '>L000000\-00999\-L00099;1;_';
g_conInforBackColor = $00E4F9FC;
type
TUserInfo = Record
FuserId:string;
FUserName : String;
ENd;
Var
g_uInfo : TUserInfo;
fst: string;
i:integer=1;
procedure tabventer(tabform: TForm; var vKey: Char);
procedure TitClick(Dbgrid:TDbgrid;Column: TColumn);
procedure entertray(reform:Tform;retable:Tadotable);
procedure exittray(reform:Tform;retable:Tadotable);
procedure dblist(mdbcombobox:Tdbcombobox;madotable:Tadotable;vid:string;
vname:string;cd:integer);
procedure combolist(mcombobox:Tcombobox;madotable:Tadotable;vid:string;
vname:string;cd:integer);
procedure ehtitclick(column:TColumnEh);
// procedure memosele(Index:integer);
Function getbmh(vstr : string):String;
implementation
Function getbmh(vstr : string):String;
Begin
result:=copy(trim(vstr),0,pos('|',trim(vstr))-1);
End;
procedure tabventer(tabform: TForm; var vKey: Char); {回车代替TAB}
begin
if vkey=#13 then { 判断是按执行键}
if not (tabform.ActiveControl is TDbgrid) Then
Begin { 不是在TDbgrid控件内}
vkey:=#0;
tabform.perform(WM_NEXTDLGCTL,0,0);{移动到下一个控件}
end else
if (tabform.ActiveControl is TDbgrid) Then{是在 TDbgrid 控件内}
begin
With TDbgrid(tabform.ActiveControl) Do
if Selectedindex<(FieldCount-1) then
Selectedindex:=Selectedindex+1{ 移动到下一字段}
else Selectedindex:=0;
end;
end;
procedure TitClick(Dbgrid:TDbgrid;Column: TColumn); {单击表格列头排序}
begin
if column.FieldName <>'' then
begin
if column.Grid.DataSource.DataSet.Active=true then begin
if column.Grid.Tag=0 then begin
(column.Grid.DataSource.DataSet as TADOquery).Sort:=Column.FieldName+' ASC';
Dbgrid.Columns[i].Title.caption:=Dbgrid.Columns[i].Field.displayname;
column.Title.Caption := column.Field.DisplayName+'△';
column.Grid.Tag:=1;
i:=column.Index ;
end
else begin
(column.Grid.DataSource.DataSet as TADOquery).Sort:=Column.FieldName+' DESC';
Dbgrid.Columns[i].Title.caption:=Dbgrid.Columns[i].Field.displayname;
column.Title.Caption := column.Field.DisplayName+'▽';
column.Grid.Tag:=0;
i:=column.Index ;
end;
end;
end;
end;
procedure ehTitClick(Column: TColumnEh); {单击表格列头排序eh}
begin
if Column.FieldName<>'' then
begin
if column.Title.SortMarker=smDownEh then
begin
Column.Title.SortMarker := smupEh;
(column.Grid.DataSource.DataSet as TADOquery).Sort:=Column.FieldName+' DESC';
end
else
begin
Column.Title.SortMarker := smDownEh;
(column.Grid.DataSource.DataSet as TADOquery).Sort:=Column.FieldName+' ASC';
end;
end;
end;
procedure entertray(reform:Tform;retable:Tadotable); {进入系统}
begin
retable.Append ;
retable['citem']:='进入'+reform.caption;
retable['ctm']:=now();
retable['cworkerid']:=g_uInfo.fuserid;
retable['cname']:=g_uInfo.fusername;
retable.Post ;
end;
procedure exittray(reform:Tform;retable:Tadotable); {退出系统}
begin
retable.Append ;
retable['citem']:='退出'+reform.caption;
retable['ctm']:=now();
retable['cworkerid']:=g_uInfo.fuserid;
retable['cname']:=g_uInfo.fusername;
retable.Post ;
end;
procedure dblist(mdbcombobox:Tdbcombobox;madotable:Tadotable;vid:string;
vname:string;cd:integer); {给下拉表列出内容}
begin
mdbcombobox.Items.Clear;
madotable.First ;
while not madotable.Eof do
begin
// vid
if cd=2 then
mdbcombobox.Items.Append(trim(madotable[vid])+'|'+madotable[vname])
else
mdbcombobox.Items.Append(trim(madotable[vid]));
madotable.next;
end;
end;
procedure combolist(mcombobox:Tcombobox;madotable:Tadotable;vid:string;
vname:string;cd:integer);
begin
mcombobox.Items.Clear;
madotable.First ;
while not madotable.Eof do
begin
// vid
if cd=2 then
mcombobox.Items.Append(trim(madotable[vid])+'|'+madotable[vname])
else
mcombobox.Items.Append(trim(madotable[vid]));
madotable.next;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -