📄 unit5.pas
字号:
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AxCtrls, OleCtrls, TabDlg_TLB, Buttons, jpeg, ExtCtrls, Menus,IniFiles;
type
TForm5 = class(TForm)
Image1: TImage;
PopupMenu1: TPopupMenu;
PopupMenu2: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
MainMenu1: TMainMenu;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
PopupMenu3: TPopupMenu;
N18: TMenuItem;
procedure FormShow(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure N1Click(Sender: TObject);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure N2Click(Sender: TObject);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure N7Click(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure N17Click(Sender: TObject);
procedure N11Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure N18Click(Sender: TObject);
private
{ Private declarations }
public
NameOfMap, //记录打开的地图标题
PathofMap, //完整地图文件
PathOfRailWay : string; //铁路地图文件路径
PIDm : integer;
MainNewX,MainNewY : integer; //添加新维护段的坐标
SonLeftLeave,SonTopLeave : integer; //子地图的移动量
DKMoveBegin,IfkeyDown : Boolean;
MoveSpeedBtn : Tspeedbutton;
procedure logoutInfo;
procedure loginInfo;
procedure MainMapClick(Sender: TObject); //大地图单击进入小地图
procedure RefreashMain ;//刷新主图
procedure StationDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer); //道口移动开始标志
procedure StationUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);//道口删除移动结束用
{ Public declarations }
end;
var
Form5: TForm5;
implementation
uses unit1,Unit3,Unit6,unit7,unit8,unit9,unit10;
{$R *.dfm}
procedure TForm5.FormShow(Sender: TObject);
begin
try
Image1.Picture.LoadFromFile(Form1.LocalPath + '吉林.JPG');
DKMoveBegin := false;
IfkeyDown := false;
RefreashMain;
except
Application.MessageBox('打开地图文件错误?','错误警告',MB_OK ) ;
Application.Terminate;
end;
end;
//大地图单击进入小地图
procedure TForm5.MainMapClick(Sender: TObject);
begin
try
NameOfMap := TSpeedButton(sender).Hint;
with DModule1.Qry_Map do
begin
Close;
SQL.text := 'select * from MapInfo where MapName='+''''+NameOfMap+'''';
Open;
if recordcount > 0 then
begin
PathofMap := fieldbyname('MapPath').AsString; //完整地图文件名
PathOfRailWay := fieldbyname('MapRailWay').AsString; //铁路地图文件
PIDm := fieldbyname('ID').AsInteger;
end
else
begin
showmessage('打开'+NameOfMap+'地图文件失败!');
Exit;
end;
end;
// SonLeftLeave := Form1.SSTab1.Left;
// SonTopLeave := Form1.SSTab1.Top;
//showmessage(inttostr(Form1.SSTab1.Left)+' '+inttostr(Form1.SSTab1.Top));
Form1.ShowModal;
except
Application.MessageBox('打开地图文件错误!','错误警告',MB_OK ) ;
Application.Terminate;
end;
end;
procedure TForm5.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if Application.MessageBox('你确定要离开本窗口吗?','提示',MB_YESNO + MB_ICONQUESTION)=ID_NO then
begin
Canclose:=false;
end;
end;
procedure TForm5.N1Click(Sender: TObject);
begin
try
if Application.MessageBox('确认添加新维护段吗?','提示',MB_YESNO + MB_ICONQUESTION) <> 6 then
exit;
Form6.Notebook1.ActivePage := 'change';
Form6.ShowModal;
except
end;
end;
procedure TForm5.RefreashMain;
var
SpeedCDS : Tspeedbutton;
i : integer;
MyShape : Tshape;
begin
try
//
for i := 0 to Form5.ControlCount -1 do
begin
if Form5.Controls[i].ClassType = TSpeedButton then
begin
// showmessage(inttostr(I) + ' ' +Form1.Controls[i].Name);
TSpeedButton(Form5.Controls[i]).Free;
end;
end;
with DModule1.Qry_Map do
begin
Close;
SQL.Text := 'Select * from MapInfo order by MapName';
Open;
First;
While Not EOF do
begin
//MyShape := TShape.Create(self);
SpeedCDS := TSpeedButton.Create(self);
//MyShape.Brush.Style := bsClear;
SpeedCDS.Parent := Form5;
// MyShape.Parent := Form5;;
// SpeedCDS.PopupMenu := PopupMenu2;
// SpeedCDS.Glyph.LoadFromFile(Form1.LocalPath + 'Main.Bmp');
SpeedCDS.Flat := true;
SpeedCDS.Height := 130;
SpeedCDS.Width := 170;
//MyShape.Height := 131;
//MyShape.Width := 171;
SpeedCDS.Left := fieldbyname('MapX').AsInteger;
SpeedCDS.Top := fieldbyname('MapY').AsInteger;
//SpeedCDS.Left := MyShape.Left;
//SpeedCDS.Top := MyShape.Top;
SpeedCDS.Hint := fieldbyname('MapName').AsString;
SpeedCDS.ShowHint := True;
SpeedCDS.OnClick := MainMapClick;
SpeedCDS.OnMouseDown := StationDown;
SpeedCDS.OnMouseUp := StationUp;
SpeedCDS.Cursor := crHandPoint;
SpeedCDS.show;
Next;
end;
end;
except
RefreashMain;
end;
end;
procedure TForm5.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
ThisNameMain : string;
begin
try
MainNewX := X; MainNewY := Y;
if DKMoveBegin and IfkeyDown then
begin
ThisNameMain := MoveSpeedBtn.Hint;
DKMoveBegin := false; //移动标志结束
IfkeyDown := false;
MoveSpeedBtn.Left := X;
MoveSpeedBtn.Top := Y;
MoveSpeedBtn.Visible := true;
//向数据库中添加坐标改动
with DModule1.Qry_BrowTwo do
begin
Close;
SQL.Clear;
SQL.Add('Update MapInfo set MapX=:Left1,MapY=:Top1 where MapName=:Name1');
Parameters.ParamByName('left1').Value := X;
Parameters.ParamByName('Top1').Value := Y;
Parameters.ParamByName('Name1').Value := ThisNameMain;
ExecSQL;
end;
RefreashMain;
end;
except
showmessage('添加操作失败!');
DModule1.ADOConnection1.RollbackTrans;
RefreashMain;
end;
end;
procedure TForm5.N2Click(Sender: TObject);
begin
try
if Application.MessageBox('确认要移动该道口位置吗?','提示',MB_YESNO) <> 6 then
exit;
DKMoveBegin := true; //移动标志开始
except
DKMoveBegin := false;
end;
end;
procedure TForm5.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
MyRect : TRect;
MyDC : Hdc;
begin
//移动应该在这里写
{try
if DKMoveBegin and IfkeyDown then //移动
begin
//控件本身不移动,画一个矩形跟着鼠标Move
MyRect := Rect(X,Y,X+90,Y+90);
MyDc := Getdc(Image1.Handle);
if not (DrawFocusRect(MyDc,MyRect)) then //用API画
showmessage('画框错误');
ReleaseDC(Image1.Handle,Mydc);
Image1.Repaint ;
end;
except
end; }
end;
procedure TForm5.StationDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
{ try
if (Button = MBleft) and DKMoveBegin then
begin
IfkeyDown := true;
MoveSpeedBtn := TSpeedButton(Sender);
MoveSpeedBtn.Visible := false;
end;
except
IfkeyDown := false;
end; }
end;
procedure TForm5.StationUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
ThisTag : integer;
begin
try
if Button = MBleft then
begin
if DKMoveBegin and IfkeyDown then
begin
end;
end
else if Button = mbRight then//删除准备
begin
end;
except
end;
end;
procedure TForm5.N7Click(Sender: TObject);
begin
if userON.username = 'admin' then
Newuser.ShowModal
else showmessage('对不起您没有这个权限,请与管理员联系!');
end;
//人员基本信息
procedure TForm5.N13Click(Sender: TObject);
begin
try
Form7.OperaType := 'HumanInfo';
Form7.DataName := 'Human';
Form7.OrderByName := 'Man_Code';
Form7.Notebook1.ActivePage := 'GZZD';
//Form7.Notebook2.ActivePage := 'Human';
Form7.Brow_Dic(Form7.DataName);
Form7.OtherPanel := Form7.Panel4;
Form7.Caption := '组织结构';
Form7.OLDTag:=1;
form7.OldID:=1;
//添加文本描述
if FileExists(Form1.LocalPath+'ZZJG.txt') then
Form7.Memo4.Lines.LoadFromFile(Form1.LocalPath+'ZZJG.txt')
else
begin
Form7.Memo4.Lines.Clear;
showmessage('文件未找到,请在本系统目录下建立一个文件:ZZJG.txt !');
//CreateField(Form1.LocalPath+'ZZJG.txt');
end;
Form7.EmpSome_Dic;
Form7.Speedbutton5.Click;
Form7.ShowModal;
except
showmessage('组织结构信息错误!');
end;
end;
procedure TForm5.N14Click(Sender: TObject);
begin
try
Form7.OperaType := 'GZZDInfo';
Form7.DataName := 'GZZD';
Form7.OrderByName := 'GZ_Name';
Form7.Notebook1.ActivePage := 'PersonInfo';
Form7.Notebook2.ActivePage := 'GZZD';
Form7.Brow_Dic(Form7.DataName);
Form7.OtherPanel := Form7.Panel3;
Form7.Caption := '规章制度';
Form7.EmpSome_Dic;
Form7.ShowModal;
except
showmessage('规章制度信息错误!');
end;
end;
//相关事件
procedure TForm5.N15Click(Sender: TObject);
begin
try
Form7.OperaType := 'AboutInfo';
Form7.DataName := 'AboutHappen';
Form7.OrderByName := 'About_Time';
Form7.Notebook1.ActivePage := 'PersonInfo';
Form7.Notebook2.ActivePage := 'Happen';
Form7.Brow_Dic(Form7.DataName);
Form7.OtherPanel := Form7.Panel8;
Form7.Caption := '相关事件';
Form7.EmpSome_Dic;
Form7.ShowModal;
except
showmessage('相关事件信息错误!');
end;
end;
//系统参数配置
procedure TForm5.N17Click(Sender: TObject);
var
MyIniFile: TIniFile;
Host1,username,password,DBname : string;
begin
try
if not FileExists(Form1.LocalPath + 'Train.ini') then
begin
showmessage('数据库连接配置文件Train.ini 不存在,无法完成配置!');
Exit;
end;
MyIniFile := TIniFile.Create(Form1.LocalPath + 'Train.ini');
Host1 := MyIniFile.ReadString('Host','HostName','127.0.0.1') ;
Username := MyIniFile.ReadString('Host','Username','sa') ;
password := MyIniFile.ReadString('Host','password','') ;
DBname := MyIniFile.ReadString('Host','DBname','TestC');
Form6.Edit2.Text := Host1 ;
Form6.Edit3.Text := Username;
Form6.Edit4.Text :=password;
Form6.Edit5.Text := DBname;
MyIniFile.Free;
Form6.Notebook1.ActivePage := 'SYSpz';
Form6.Height := 185;
Form6.Width := 390;
Form6.Caption := '系统参数设置';
Form6.ShowModal;
except
showmessage('系统配置失败!');
end;
end;
procedure TForm5.N11Click(Sender: TObject);
begin
Close;
end;
procedure TForm5.N8Click(Sender: TObject);
begin
logoutinfo;
useron.Show;
end;
procedure TForm5.N9Click(Sender: TObject);
begin
changepass.ShowModal;
end;
procedure Tform5.logoutInfo;
begin
with DModule1.Qry_user do
begin
close;
sql.Clear;
sql.Add('insert into userlogininfo (userID,datetime,sta)' );
sql.Add('values((:UID),(:DT),(:St))');
parameters.ParamByName('UID').Value:=useron.UserName;
parameters.ParamByName('DT').Value:=now;
parameters.ParamByName('St').Value:='logout';
execsql;
end;
end;
procedure Tform5.loginInfo;
begin
with DModule1.Qry_user do
begin
close;
sql.Clear;
sql.Add('insert into userlogininfo (userID,datetime,sta)' );
sql.Add('values((:UID),(:DT),(:St))');
parameters.ParamByName('UID').Value:=useron.userName;
parameters.ParamByName('DT').Value:=now;
parameters.ParamByName('St').Value:='login';
execsql;
end;
end;
procedure TForm5.FormClose(Sender: TObject; var Action: TCloseAction);
begin
logoutInfo;
end;
procedure TForm5.N18Click(Sender: TObject);
begin
form5.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -