📄 unit6.pas
字号:
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtDlgs, StdCtrls, Buttons, ExtCtrls,IniFiles;
type
TForm6 = class(TForm)
OpenPictureDialog1: TOpenPictureDialog;
Notebook1: TNotebook;
Panel1: TPanel;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Label3: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
Button2: TButton;
Button1: TButton;
Panel2: TPanel;
RadioGroup1: TRadioGroup;
Button3: TButton;
Panel3: TPanel;
Label4: TLabel;
Edit2: TEdit;
Label5: TLabel;
Edit3: TEdit;
Label6: TLabel;
Edit4: TEdit;
Label7: TLabel;
Edit5: TEdit;
Button4: TButton;
Button5: TButton;
procedure Button2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
uses unit5,unit3,unit1;
{$R *.dfm}
procedure TForm6.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TForm6.SpeedButton1Click(Sender: TObject);
begin
If OpenPictureDialog1.Execute then
begin
label2.Caption := OpenPictureDialog1.FileName;
end;
end;
procedure TForm6.FormShow(Sender: TObject);
begin
edit1.Text := '未命名维护段';
label2.Caption := '';
end;
procedure TForm6.Button1Click(Sender: TObject);
var
DKName,PathMainMap ,PathRailway: string;
begin
try
DKname := Trim(edit1.Text); //路段名
PathMainMap := Trim(Label2.Caption); //图片路径
PathRailway := Trim(Label3.Caption);
if DKname = '' then
begin
showmessage('所填写条件不完全!');
Exit;
end;
if not FileExists(PathMainMap) then
begin
showmessage('完整地图图片文件不存在!');
Exit;
end;
if not FileExists(PathRailway) then
begin
showmessage('铁路地图图片文件不存在!');
Exit;
end;
//添加图片信息到数据库
with DModule1.Qry_Map do
begin
Close;
SQL.Clear;
SQL.Add('insert into MapInfo (MapName,MapPath,MapX,MapY,MapRailWay)');
SQL.Add('Values(:Name1,:path1,:X1,:Y1,:Rail1)');
Parameters.ParamByName('Name1').Value := DKname;
Parameters.ParamByName('path1').Value := PathMainMap;
Parameters.ParamByName('X1').Value := Form5.MainNewX;
Parameters.ParamByName('Y1').Value := Form5.MainNewY;
Parameters.ParamByName('Rail1').Value := PathRailway;
ExecSQL;
end;
Form5.RefreashMain;
Close;
except
Showmessage('添加操作失败!');
DModule1.ADOConnection1.RollbackTrans;
end;
end;
procedure TForm6.SpeedButton2Click(Sender: TObject);
begin
If OpenPictureDialog1.Execute then
begin
label3.Caption := OpenPictureDialog1.FileName;
end;
end;
procedure TForm6.Button3Click(Sender: TObject);
var
FX : string;
begin
try
if RadioGroup1.ItemIndex = 0 then
FX := 'LU' //左上
else
if RadioGroup1.ItemIndex = 1 then
FX := 'LD' //左下
else
if RadioGroup1.ItemIndex = 2 then
FX := 'RU' //右上
else
if RadioGroup1.ItemIndex = 3 then
FX := 'RD' //右上
else
FX := 'LU'; //左上
//写入数据库
with DModule1.Qry_BrowTwo do
begin
Close;
SQL.Clear;
SQL.Add('Update StationXY set flaah=:Flaah1 where ComTag=:tag1 ');
Parameters.ParamByName('Flaah1').Value := FX;
Parameters.ParamByName('tag1').Value := Form1.changFXtag;
ExecSQL;
end;
Form1.RefrashThis;
Close;
except
DModule1.ADOConnection1.RollbackTrans;
Close;
end;
end;
procedure TForm6.Button5Click(Sender: TObject);
begin
Close;
end;
procedure TForm6.Button4Click(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;
Host1 := trim(Form6.Edit2.Text);
Username := trim(Form6.Edit3.Text);
password := trim(Form6.Edit4.Text);
DBname := trim(Form6.Edit5.Text);
MyIniFile := TIniFile.Create(Form1.LocalPath + 'Train.ini');
MyIniFile.WriteString('Host','HostName',Host1);
MyIniFile.WriteString('Host','Username',Username);
if password = '' then
MyIniFile.WriteString('Host','password','""')
else
MyIniFile.WriteString('Host','password',password);
MyIniFile.WriteString('Host','DBname',DBname);
MyIniFile.Free;
Close;
showmessage('系统配置成功完成,再次启动本系统将应用本配置!');
except
showmessage('系统配置失败!');
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -