📄 unitsr.~pas
字号:
unit Unitsr;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtDlgs, StdCtrls, ExtCtrls, DB, ADODB;
type
TFormsr = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
OpenDialog1: TOpenDialog;
Label2: TLabel;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Formsr: TFormsr;
type
TFileData = record
name:array [0..999] of char;
end;
var
filename:string;
var
FileStream: TFileStream;
filedata:Tfiledata;
procedure CreateFile(TFileName: string);
implementation
uses unitmodule;
{$R *.dfm}
procedure TFormsr.Button1Click(Sender: TObject);
begin
inherited;
if opendialog1.Execute then
begin
edit1.text:=opendialog1.FileName;
end;
end;
procedure TFormsr.Button3Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure CreateFile(TFileName: string);
Begin
If Not FileExists(TFileName) Then
Begin
FileStream := TFileStream.Create(TFileName, fmCreate);
End
Else
Begin
FileStream := TFileStream.Create(TFileName, fmOpenReadWrite);
End;
End;
procedure TFormsr.Button2Click(Sender: TObject);
var i,k,a,b,c:integer;
m,j,n,d,e,hh,hhh,fm,sj,dy:string;
s:array [0..999] of char;
f:array [0..999] of char;
begin
if edit1.Text='' then
showmessage('请输入打开路径')
else
begin
filename:=edit1.Text;
//FileStream := TFileStream.Create(TFileName, fmOpenReadWrite);
createfile(filename);
// FileStream.Seek(1, soFromBeginning);
// FileStream.Read(FileData, SizeOf(FileData));
FileStream.Read(filedata, SizeOf(filedata));
m:=filedata.name;
strpcopy(s,m);
if inttohex(ord(s[0]),2)+inttohex(ord(s[1]),2)<>'AA55'
then showmessage('输入格式有误')
else
begin
for i:=0 to ((length(m)-3) div 18) do
begin
c:=i;
j:=inttohex(ord(s[2+c*18]),2)+inttohex(ord(s[3+c*18]),2)+inttohex(ord(s[4+c*18]),2)+inttohex(ord(s[5+c*18]),2)+inttohex(ord(s[6+c*18]),2)+inttohex(ord(s[7+c*18]),2);
n:=inttohex(ord(s[8+c*18]),2);
d:=inttohex(ord(s[9+c*18]),2);
e:=inttohex(ord(s[10+c*18]),2);
hh:=inttohex(ord(s[11+c*18]),2);
hhh:=inttohex(ord(s[12+c*18]),2);
fm:=inttohex(ord(s[13+c*18]),2);
sj:=inttohex(ord(s[14+c*18]),2)+inttohex(ord(s[15+c*18]),2);
{with DADOQuery1 do
begin
close;
SQL.Clear;
SQL.Add('select 道岔名 from 道岔管理表 where 道岔号=:a');
Parameters.ParamByName('a').Value := Trim(n);
open;
end;
if ADOQuery1.FieldByName('道岔名').Value <> null then
hh := DataModule1.ADOQuery3.FieldByName('道岔名').Value
else hh:='0';//
{with Datamodule1.ADOQuery2 do
begin
close;
SQL.Clear;
SQL.Add('select ') }
with DataModule2.ADOQuery1 do
begin
close;
SQL.Clear;
SQL.Add('insert into 表1 values (:a,:b,:c,:d,:e)');
Parameters.ParamByName('a').Value :=j;
Parameters.ParamByName('b').Value :=n;
Parameters.ParamByName('c').Value :=d;
Parameters.ParamByName('d').Value :=fm;
Parameters.ParamByName('e').Value :=sj;
//Parameters.ParamByName('f').Value :=hhh;
// Parameters.ParamByName('g').Value :=fm;
// Parameters.ParamByName('h').Value :=sj;
// Parameters.ParamByName('i').Value :=dy;
execsql;
end;
end;
//edit2.Text:=j;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -