📄 umain.pas
字号:
unit uMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, Jpeg, ExtCtrls, ComObj, ComCtrls, IniFiles, ImgList, ActnList,
DB, ADODB, ToolWin, WinSkinStore, WinSkinData;
type
TfrmMain = class(TForm)
mnuPer: TMainMenu;
miSys: TMenuItem;
miChgPwd: TMenuItem;
miAdmin: TMenuItem;
miLogin: TMenuItem;
space01: TMenuItem;
miExit: TMenuItem;
tmrMain: TTimer;
sbMain: TStatusBar;
tmrTime: TTimer;
miStaff: TMenuItem;
miStaInfo: TMenuItem;
miSet: TMenuItem;
miDep: TMenuItem;
miHelp: TMenuItem;
miOther: TMenuItem;
ilPer: TImageList;
alPer: TActionList;
actDep: TAction;
actChgpwd: TAction;
actOther: TAction;
actAdmin: TAction;
actLogin: TAction;
actExitSystem: TAction;
actStaInfo: TAction;
actAdd: TAction;
actEdit: TAction;
actDel: TAction;
actSet: TAction;
actTrans: TAction;
actBackup: TAction;
actPress: TAction;
actRestore: TAction;
actInqu: TAction;
actExport: TAction;
actInport: TAction;
miLog: TMenuItem;
miAbout: TMenuItem;
actLog: TAction;
actAbout: TAction;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
ToolButton9: TToolButton;
ToolButton10: TToolButton;
ToolButton12: TToolButton;
ToolButton13: TToolButton;
ToolButton14: TToolButton;
ToolButton15: TToolButton;
ToolButton16: TToolButton;
ToolButton17: TToolButton;
ToolButton11: TToolButton;
imgMain: TImage;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton18: TToolButton;
ToolButton19: TToolButton;
ToolButton20: TToolButton;
procedure tmrMainTimer(Sender: TObject);
procedure tmrTimeTimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure actChgpwdExecute(Sender: TObject);
procedure actAdminExecute(Sender: TObject);
procedure actLoginExecute(Sender: TObject);
procedure actExitSystemExecute(Sender: TObject);
procedure actStaInfoExecute(Sender: TObject);
procedure actDepExecute(Sender: TObject);
procedure actOtherExecute(Sender: TObject);
procedure actLogExecute(Sender: TObject);
procedure actAboutExecute(Sender: TObject);
private
{ Private declarations }
procedure InitData;
procedure OnRestore(Sender: TObject);
public
{ Public declarations }
procedure OnHint(Sender: TObject);
end;
var
frmMain: TfrmMain;
implementation
uses uLogin, uChgpwd, uGlobal, uAdmin, uStainfo, uDepset, uAbout, uData,
uOtherset, uLogInfo;
{$R *.dfm}
procedure TfrmMain.InitData;
var
iFile: TIniFile;
begin
MyApp.Image := imgMain;
iFile := TIniFile.Create(MyApp.Path + 'perset.ini');
try
MyApp.Topic := iFile.ReadString('sTopic', 'topic', AppCaption);
MyApp.ImgStr := iFile.ReadString('sysbg', 'bground', 'main.jpg');
MyApp.StaBirth := iFile.ReadBool('staff', 'sbirth', False);
finally
iFile.Free;
end;
if MyApp.Topic = '' then MyApp.Topic := AppCaption;
if (MyApp.ImgStr = '') or not FileExists(MyApp.Path + MyApp.ImgStr) then MyApp.ImgStr := 'main.jpg';
Caption := MyApp.Topic;
sbMain.Panels[0].Text := '管理员:还没有登录';
sbMain.Panels[1].Text := MyApp.Topic;
Application.ShowHint := True;
Application.HintColor := clLime;
Constraints.MaxWidth := 800;
Constraints.MaxHeight := 600;
end;
procedure TfrmMain.OnHint(Sender: TObject);
begin
if Application.Hint <> '' then
sbMain.Panels[1].Text := Application.Hint
else sbMain.Panels[1].Text := MyApp.Topic;
end;
procedure TfrmMain.OnRestore(Sender: TObject);
begin
if WindowState = wsMaximized then FormResize(Sender);
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
Application.OnHint := OnHint;
Application.OnRestore := OnRestore;
InitData;
end;
procedure TfrmMain.tmrMainTimer(Sender: TObject);
begin
tmrMain.Enabled := False;
frmLogin := TfrmLogin.Create(Self);
if frmLogin.ShowModal <> mrOk then Close;
FreeAndNil(frmLogin);
miLog.Visible := MyApp.Admin;
Caption := MyApp.Topic + ' 管理员:' + MyApp.UserID;
sbMain.Panels[0].Text := '管理员:' + MyApp.UserID;
if MyApp.Admin then
begin
Caption := Caption + ' --系统管理员';
sbMain.Panels[0].Text := sbMain.Panels[0].Text + ' 您是系统管理员';
end
else sbMain.Panels[0].Text := sbMain.Panels[0].Text + ' 您是普通管理员';
end;
procedure TfrmMain.tmrTimeTimer(Sender: TObject);
var
wdStr: string;
begin
case DayOfWeek(Date) of
1: wdStr := '星期日';
2: wdStr := '星期一';
3: wdStr := '星期二';
4: wdStr := '星期三';
5: wdStr := '星期四';
6: wdStr := '星期五';
7: wdStr := '星期六';
end;
sbMain.Panels[2].Text := FormatDateTime('yyyy年mm月dd日 hh时nn分ss秒', Now) + ' [' + wdStr + ']';
end;
procedure TfrmMain.actChgpwdExecute(Sender: TObject);
begin
frmChgPwd := TfrmChgPwd.Create(self);
if frmChgPwd.ShowModal = mrOk then
MessageBox(Handle, '密码更新成功!', '提示', mb_IconInformation + mb_Ok);
FreeAndNil(frmChgPwd);
end;
procedure TfrmMain.actAdminExecute(Sender: TObject);
begin
if MyApp.Admin then
ShowFormModal(Self, TfrmAdmin)
else
MessageBox(Handle, '这是系统管理员的权限!', '提示', mb_IconWarning + mb_Ok);
end;
procedure TfrmMain.actLoginExecute(Sender: TObject);
begin
tmrMainTimer(Sender);
end;
procedure TfrmMain.actExitSystemExecute(Sender: TObject);
begin
if MessageBox(Handle, '要退出系统么?', '提示', mb_IconQuestion + mb_YesNo) = idYes then
Close;
end;
procedure TfrmMain.actStaInfoExecute(Sender: TObject);
begin
if not Assigned(frmStainfo) then
frmStainfo := TfrmStainfo.Create(Application)
else if IsIconic(frmStainfo.Handle) then
frmStainfo.WindowState := wsNormal;
end;
procedure TfrmMain.actDepExecute(Sender: TObject);
begin
ShowFormModal(Self, TfrmDepset);
end;
procedure TfrmMain.actOtherExecute(Sender: TObject);
begin
ShowFormModal(Self, TfrmOtherset);
end;
procedure TfrmMain.actLogExecute(Sender: TObject);
begin
ShowFormModal(Self, TfrmLog);
end;
procedure TfrmMain.actAboutExecute(Sender: TObject);
begin
ShowFormModal(Self, TfrmAbout);
end;
procedure TfrmMain.FormResize(Sender: TObject);
begin
if Screen.Width = 800 then Exit;
Left := Trunc((Screen.Width - Width) / 2);
Top := Trunc((Screen.Height - Height) / 2);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -