procedure Tbj_frm.GetAllFileName(sourcepath:string);
var
Found:Integer;
sr: TSearchRec;
imagejpg:TJPEGImage; //jpg图片
MyStm:TMemoryStream;
begin
Found:=FindFirst(SourcePath+'\*.*',faAnyFile,sr);
while Found=0 do
begin //!!!
if (sr.Name='.') or (sr.Name='..') then //如果是父目录则推出进入下次循环
begin
Found := FindNext(sr);
continue;
end
else
begin
if not(sr.Attr and faDirectory > 0) then //非子目录
begin
Memo1.Lines.Add(SourcePath+'\'+sr.Name); //将文件的路径写到Memo中,你可以写到数据库中
//readYCfile()
Memo2.Lines.Add(sr.Name); end
else //是子目录
GetAllFileName(SourcePath+'\'+sr.Name);
end;
Found:= FindNext(sr);
end;
FindClose(sr);
end;
procedure Tbj_frm.BitBtn2Click(Sender: TObject);
begin
close;
end;procedure Tbj_frm.Button2Click(Sender: TObject);
var
i,j,k:integer;
line,tower:integer;
cjq_l,cjq_t,cjq_iso,l,t,iso:string;
Isolate:array[0..5]of string;
bmp1:TBitmap;
jpg1:TJpegImage;
f,str:string;
shebei,tongdao,rq,sj,temp,hum,vol,fengsu:string;
FS:TFileStream;
ReciveFrame:array[0..8]of byte;
id:longint;
path:pchar;
sr1:TSearchRec;
label re1;begin
edit1.Text:='C:\lmckdata\picture';
GetAllFileName(edit1.Text);
bmp1:=TBitmap.Create;
jpg1:=TJpegImage.Create;
Table_history_data.Open;
Table_history_data.Last;
k:=Memo1.Lines.Count;
//f:=GetAllFileName('C:\lmckdata\picture');
if Table_history_data.RecordCount=0 then
id:=0
else
id:=Table_history_data.RecordCount;
for k:=0 to Memo1.Lines.Count-1 do
begin
f:=Memo1.Lines.Strings[k];
jpg1.LoadFromFile(f);
re1:str:=ExtractFileName(f);//运行到这儿有错误
if str<>''then
begin
bmp1.Assign(jpg1);
Image1.Picture.Bitmap.Assign(bmp1);
if length(str) <>37 then
goto re1
else
begin
ReciveFrame[0]:=strtoint(copy(str,13,3));
ReciveFrame[1]:=strtoint(copy(str,17,2));
ReciveFrame[2]:=strtoint(copy(str,19,2));
ReciveFrame[3]:=strtoint(copy(str,21,2));
ReciveFrame[4]:=strtoint(copy(str,23,2));
ReciveFrame[5]:=strtoint(copy(str,16,1));
if (ReciveFrame[0]=0)and (ReciveFrame[1]=0)and(ReciveFrame[2]=0) then goto re1; line:=0;
tower:=0;
cjq_l:=format('%4d',[line]);
while Pos(' ', cjq_l) > 0 do
cjq_l[Pos(' ', cjq_l)] := '0';
cjq_t:=format('%4d',[tower]);
while Pos(' ', cjq_t) > 0 do
cjq_t[Pos(' ', cjq_t)] := '0';
i:=strtoint(copy(str,12,1));
Isolate[i]:=copy(str,12,1);
shebei:=copy(str,1,11);
Editshebei.Text:=shebei;
tongdao:=copy(str,12,1);
Edittongdao.Text:=tongdao;
Editriqi.Text:=rq;
Editshijian.Text:=sj;
temp:=copy(str,25,3);
Edittemp.text:=temp;
hum:=copy(str,28,3);
edithum.Text:=hum;
vol:=copy(str,31,3);
Editvoltage.Text:=vol;
fengsu:=copy(str,34,3);
Editfengsu.Text:=fengsu;
bmp1.Assign(jpg1);
Image1.Picture.Bitmap.Assign(bmp1);
if (ReciveFrame[1]>12)then goto re1;
if (ReciveFrame[2]>31)then goto re1;
if (ReciveFrame[0]<=0)then goto re1;
if (ReciveFrame[1]<=0)then goto re1;
if (ReciveFrame[2]<=0)then goto re1;
if (ReciveFrame[3]>23)then goto re1;
if (ReciveFrame[4]>59)then goto re1;
rq:=format('%d',[ReciveFrame[0]])+format('%d',[ReciveFrame[5]])+'-'+format('%d',[ReciveFrame[1]])+'-'+format('%d',[ReciveFrame[2]]);
if strtodate(rq)>date then goto re1;
sj:=format('%d',[ReciveFrame[3]])+':'+format('%d',[ReciveFrame[4]]); cjq_iso:=format('%4d',[strtoint(Isolate[i])+1]);
while Pos(' ', cjq_Iso) > 0 do
cjq_Iso[Pos(' ', cjq_Iso)]:= '0'; with query1 do
begin
Close;
sql.Clear;
SQL.Add('select line_num,tower_num,Isolate_num');
SQL.add('from CJQ_set');
sql.add('where shouji_num=:jh');
sql.add('and tongdaohao=:ih');
parambyname('jh').asstring:=Editshebei.Text;
parambyname('ih').asstring:=cjq_iso;
active:=true;
end;
if query1.recordcount=0 then goto re1;
l:=query1.Fields[0].AsString;
t:=query1.Fields[1].AsString;
iso:=query1.Fields[2].AsString;
with query1 do
begin
close;
sql.clear;
sql.add('select * from history_data');
sql.add('where riqi=:rqsj');
sql.add('and line_num=:lh');
sql.add('and tower_num=:th');
sql.add('and isolate_num=:ih');
parambyname('rqsj').asdatetime:=strtodatetime(rq+' '+sj);
parambyname('lh').asstring:=l;
parambyname('th').asstring:=t;
parambyname('ih').asstring:=iso;
active:=true;
end;
query1.Last;
if query1.RecordCount=0 then
begin
Table_history_data.Append;
{if extractfileext(openpicturedialog1.filename)='.jpg' then
//dbimage1.Picture.Graphic.Assign(jpg1);
begin
FS:=TFileStream.create(openpicturedialog1.filename,fmopenread);
savetoimage(Fs,Table_history_data.FieldbyName('image'));
FS.free;
end; }
Table_history_data.FieldByName('image').Assign(Image1.Picture);
Table_history_data.FieldValues['recnum']:=id+1;
Table_history_data.FieldValues['riqi']:=strtodatetime(rq+' '+sj);
Table_history_data.FieldValues['Line_Num']:='0001';
Table_history_data.FieldValues['Tower_Num']:=trim(t);
Table_history_data.FieldValues['Isolate_Num']:=trim(Iso);
Table_history_data.fieldbyname('shouji_Num').asstring:=Editshebei.Text;
Table_history_data.fieldbyname('tongdaohao').asstring:=trim(Iso);
Table_history_data.FieldValues['data_temperature']:=strtoint(Edittemp.text);
Table_history_data.FieldValues['data_humidity']:=strtoint(edithum.text);
Table_history_data.FieldValues['voltage']:=strtoint(Editvoltage.Text)/10;
Table_history_data.FieldValues['data_fengsu']:=strtoint(Editfengsu.Text)/10;
Table_history_data.Post;
Table_history_data.Refresh;
end;
end;
jpg1.Free;
bmp1.Free;
end;
end;
end;
var
Found:Integer;
sr: TSearchRec;
imagejpg:TJPEGImage; //jpg图片
MyStm:TMemoryStream;
begin
Found:=FindFirst(SourcePath+'\*.*',faAnyFile,sr);
while Found=0 do
begin //!!!
if (sr.Name='.') or (sr.Name='..') then //如果是父目录则推出进入下次循环
begin
Found := FindNext(sr);
continue;
end
else
begin
if not(sr.Attr and faDirectory > 0) then //非子目录
begin
Memo1.Lines.Add(SourcePath+'\'+sr.Name); //将文件的路径写到Memo中,你可以写到数据库中
//readYCfile()
Memo2.Lines.Add(sr.Name); end
else //是子目录
GetAllFileName(SourcePath+'\'+sr.Name);
end;
Found:= FindNext(sr);
end;
FindClose(sr);
end;
procedure Tbj_frm.BitBtn2Click(Sender: TObject);
begin
close;
end;procedure Tbj_frm.Button2Click(Sender: TObject);
var
i,j,k:integer;
line,tower:integer;
cjq_l,cjq_t,cjq_iso,l,t,iso:string;
Isolate:array[0..5]of string;
bmp1:TBitmap;
jpg1:TJpegImage;
f,str:string;
shebei,tongdao,rq,sj,temp,hum,vol,fengsu:string;
FS:TFileStream;
ReciveFrame:array[0..8]of byte;
id:longint;
path:pchar;
sr1:TSearchRec;
label re1;begin
edit1.Text:='C:\lmckdata\picture';
GetAllFileName(edit1.Text);
bmp1:=TBitmap.Create;
jpg1:=TJpegImage.Create;
Table_history_data.Open;
Table_history_data.Last;
k:=Memo1.Lines.Count;
//f:=GetAllFileName('C:\lmckdata\picture');
if Table_history_data.RecordCount=0 then
id:=0
else
id:=Table_history_data.RecordCount;
for k:=0 to Memo1.Lines.Count-1 do
begin
f:=Memo1.Lines.Strings[k];
jpg1.LoadFromFile(f);
re1:str:=ExtractFileName(f);//运行到这儿有错误
if str<>''then
begin
bmp1.Assign(jpg1);
Image1.Picture.Bitmap.Assign(bmp1);
if length(str) <>37 then
goto re1
else
begin
ReciveFrame[0]:=strtoint(copy(str,13,3));
ReciveFrame[1]:=strtoint(copy(str,17,2));
ReciveFrame[2]:=strtoint(copy(str,19,2));
ReciveFrame[3]:=strtoint(copy(str,21,2));
ReciveFrame[4]:=strtoint(copy(str,23,2));
ReciveFrame[5]:=strtoint(copy(str,16,1));
if (ReciveFrame[0]=0)and (ReciveFrame[1]=0)and(ReciveFrame[2]=0) then goto re1; line:=0;
tower:=0;
cjq_l:=format('%4d',[line]);
while Pos(' ', cjq_l) > 0 do
cjq_l[Pos(' ', cjq_l)] := '0';
cjq_t:=format('%4d',[tower]);
while Pos(' ', cjq_t) > 0 do
cjq_t[Pos(' ', cjq_t)] := '0';
i:=strtoint(copy(str,12,1));
Isolate[i]:=copy(str,12,1);
shebei:=copy(str,1,11);
Editshebei.Text:=shebei;
tongdao:=copy(str,12,1);
Edittongdao.Text:=tongdao;
Editriqi.Text:=rq;
Editshijian.Text:=sj;
temp:=copy(str,25,3);
Edittemp.text:=temp;
hum:=copy(str,28,3);
edithum.Text:=hum;
vol:=copy(str,31,3);
Editvoltage.Text:=vol;
fengsu:=copy(str,34,3);
Editfengsu.Text:=fengsu;
bmp1.Assign(jpg1);
Image1.Picture.Bitmap.Assign(bmp1);
if (ReciveFrame[1]>12)then goto re1;
if (ReciveFrame[2]>31)then goto re1;
if (ReciveFrame[0]<=0)then goto re1;
if (ReciveFrame[1]<=0)then goto re1;
if (ReciveFrame[2]<=0)then goto re1;
if (ReciveFrame[3]>23)then goto re1;
if (ReciveFrame[4]>59)then goto re1;
rq:=format('%d',[ReciveFrame[0]])+format('%d',[ReciveFrame[5]])+'-'+format('%d',[ReciveFrame[1]])+'-'+format('%d',[ReciveFrame[2]]);
if strtodate(rq)>date then goto re1;
sj:=format('%d',[ReciveFrame[3]])+':'+format('%d',[ReciveFrame[4]]); cjq_iso:=format('%4d',[strtoint(Isolate[i])+1]);
while Pos(' ', cjq_Iso) > 0 do
cjq_Iso[Pos(' ', cjq_Iso)]:= '0'; with query1 do
begin
Close;
sql.Clear;
SQL.Add('select line_num,tower_num,Isolate_num');
SQL.add('from CJQ_set');
sql.add('where shouji_num=:jh');
sql.add('and tongdaohao=:ih');
parambyname('jh').asstring:=Editshebei.Text;
parambyname('ih').asstring:=cjq_iso;
active:=true;
end;
if query1.recordcount=0 then goto re1;
l:=query1.Fields[0].AsString;
t:=query1.Fields[1].AsString;
iso:=query1.Fields[2].AsString;
with query1 do
begin
close;
sql.clear;
sql.add('select * from history_data');
sql.add('where riqi=:rqsj');
sql.add('and line_num=:lh');
sql.add('and tower_num=:th');
sql.add('and isolate_num=:ih');
parambyname('rqsj').asdatetime:=strtodatetime(rq+' '+sj);
parambyname('lh').asstring:=l;
parambyname('th').asstring:=t;
parambyname('ih').asstring:=iso;
active:=true;
end;
query1.Last;
if query1.RecordCount=0 then
begin
Table_history_data.Append;
{if extractfileext(openpicturedialog1.filename)='.jpg' then
//dbimage1.Picture.Graphic.Assign(jpg1);
begin
FS:=TFileStream.create(openpicturedialog1.filename,fmopenread);
savetoimage(Fs,Table_history_data.FieldbyName('image'));
FS.free;
end; }
Table_history_data.FieldByName('image').Assign(Image1.Picture);
Table_history_data.FieldValues['recnum']:=id+1;
Table_history_data.FieldValues['riqi']:=strtodatetime(rq+' '+sj);
Table_history_data.FieldValues['Line_Num']:='0001';
Table_history_data.FieldValues['Tower_Num']:=trim(t);
Table_history_data.FieldValues['Isolate_Num']:=trim(Iso);
Table_history_data.fieldbyname('shouji_Num').asstring:=Editshebei.Text;
Table_history_data.fieldbyname('tongdaohao').asstring:=trim(Iso);
Table_history_data.FieldValues['data_temperature']:=strtoint(Edittemp.text);
Table_history_data.FieldValues['data_humidity']:=strtoint(edithum.text);
Table_history_data.FieldValues['voltage']:=strtoint(Editvoltage.Text)/10;
Table_history_data.FieldValues['data_fengsu']:=strtoint(Editfengsu.Text)/10;
Table_history_data.Post;
Table_history_data.Refresh;
end;
end;
jpg1.Free;
bmp1.Free;
end;
end;
end;
解决方案 »
- 有"a,b,c,d,e......"每三个一组,能有多少种组合模式?
- Delphi调用存储过程赋值给edit的问题,在线等!!!
- 调用Dll的问题
- 关于TREEVIEW的用法!!在线等
- 新手想大家问一个问题!为啥这条直线画不出来!(在线等!)
- DexExpress Grid 4 Bug 多多,大家小心
- 极度郁闷,快要疯了,放血自杀
- 如何编程实现禁止指定程序的运行!请各位高手帮忙
- 在delphi中如何声明和调用含有传址参数的DLL函数?
- 程序发布问题。高手帮忙
- 百分送上.如何用正则取出str中的超连接列表?
- 如何设置excelworksheet.cell[1,2]的内容文本居左或居右,居中的处理?
001011299011200508120626076064059000.bmp与
001011299011200508120626076064059000.JPG,
字段内容 长度
00101129901 1-11 11 设备号
1 12 1 通道号
2005 13-16 4 年
08 17-18 2 月
12 19-20 2 日
06 21-22 2 时
26 23-24 2 分
076 25-27 3 温度
064 28-30 3 湿度
059 31-33 3 电压
000 34-36 3 风速 .bmp
.bmp 37-40 4 文件类型
procedure Tbj_frm.GetAllFileName(sourcepath:string);
var
Found:Integer;
sr: TSearchRec;
imagejpg:TJPEGImage; //jpg图片
MyStm:TMemoryStream;
begin
Found:=FindFirst(SourcePath+'\*.*',faAnyFile,sr);
while Found=0 do
begin //!!!
if (sr.Name='.') or (sr.Name='..') then //如果是父目录则推出进入下次循环
begin
Found := FindNext(sr);
continue;
end
else
begin
if not(sr.Attr and faDirectory > 0) then //非子目录
begin
Memo1.Lines.Add(SourcePath+'\'+sr.Name); //将文件的路径写到Memo中,你可以写到数据库中
//readYCfile()
Memo2.Lines.Add(sr.Name); end
else //是子目录
GetAllFileName(SourcePath+'\'+sr.Name);
end;
Found:= FindNext(sr);
end;
FindClose(sr);
end;
procedure Tbj_frm.BitBtn2Click(Sender: TObject);
begin
close;
end;procedure Tbj_frm.Button2Click(Sender: TObject);
var
i,j,k:integer;
line,tower:integer;
cjq_l,cjq_t,cjq_iso,l,t,iso:string;
Isolate:array[0..5]of string;
bmp1:TBitmap;
jpg1:TJpegImage;
f,str:string;
shebei,tongdao,rq,sj,temp,hum,vol,fengsu:string;
FS:TFileStream;
ReciveFrame:array[0..8]of byte;
id:longint;
path:pchar;
sr1:TSearchRec;
label re1;begin
edit1.Text:='C:\lmckdata\picture';
GetAllFileName(edit1.Text);
bmp1:=TBitmap.Create;
jpg1:=TJpegImage.Create;
Table_history_data.Open;
Table_history_data.Last;
k:=Memo1.Lines.Count;
//f:=GetAllFileName('C:\lmckdata\picture');
if Table_history_data.RecordCount=0 then
id:=0
else
id:=Table_history_data.RecordCount;
for k:=0 to Memo1.Lines.Count-1 do
begin
f:=Memo1.Lines.Strings[k];
jpg1.LoadFromFile(f);
re1:str:=ExtractFileName(f);//运行到这儿有错误
if str<>''then
begin
bmp1.Assign(jpg1);
Image1.Picture.Bitmap.Assign(bmp1);
if length(str) <>37 then
goto re1
else
begin
ReciveFrame[0]:=strtoint(copy(str,13,3));
ReciveFrame[1]:=strtoint(copy(str,17,2));
ReciveFrame[2]:=strtoint(copy(str,19,2));
ReciveFrame[3]:=strtoint(copy(str,21,2));
ReciveFrame[4]:=strtoint(copy(str,23,2));
ReciveFrame[5]:=strtoint(copy(str,16,1));
if (ReciveFrame[0]=0)and (ReciveFrame[1]=0)and(ReciveFrame[2]=0) then goto re1; line:=0;
tower:=0;
cjq_l:=format('%4d',[line]);
while Pos(' ', cjq_l) > 0 do
cjq_l[Pos(' ', cjq_l)] := '0';
cjq_t:=format('%4d',[tower]);
while Pos(' ', cjq_t) > 0 do
cjq_t[Pos(' ', cjq_t)] := '0';
i:=strtoint(copy(str,12,1));
Isolate[i]:=copy(str,12,1);
shebei:=copy(str,1,11);
Editshebei.Text:=shebei;
tongdao:=copy(str,12,1);
Edittongdao.Text:=tongdao;
Editriqi.Text:=rq;
Editshijian.Text:=sj;
temp:=copy(str,25,3);
Edittemp.text:=temp;
hum:=copy(str,28,3);
edithum.Text:=hum;
vol:=copy(str,31,3);
Editvoltage.Text:=vol;
fengsu:=copy(str,34,3);
Editfengsu.Text:=fengsu;
bmp1.Assign(jpg1);
Image1.Picture.Bitmap.Assign(bmp1);
if (ReciveFrame[1]>12)then goto re1;
if (ReciveFrame[2]>31)then goto re1;
if (ReciveFrame[0]<=0)then goto re1;
if (ReciveFrame[1]<=0)then goto re1;
if (ReciveFrame[2]<=0)then goto re1;
if (ReciveFrame[3]>23)then goto re1;
if (ReciveFrame[4]>59)then goto re1;
rq:=format('%d',[ReciveFrame[0]])+format('%d',[ReciveFrame[5]])+'-'+format('%d',[ReciveFrame[1]])+'-'+format('%d',[ReciveFrame[2]]);
if strtodate(rq)>date then goto re1;
sj:=format('%d',[ReciveFrame[3]])+':'+format('%d',[ReciveFrame[4]]); cjq_iso:=format('%4d',[strtoint(Isolate[i])+1]);
while Pos(' ', cjq_Iso) > 0 do
cjq_Iso[Pos(' ', cjq_Iso)]:= '0'; with query1 do
begin
Close;
sql.Clear;
SQL.Add('select line_num,tower_num,Isolate_num');
SQL.add('from CJQ_set');
sql.add('where shouji_num=:jh');
sql.add('and tongdaohao=:ih');
parambyname('jh').asstring:=Editshebei.Text;
parambyname('ih').asstring:=cjq_iso;
active:=true;
end;
if query1.recordcount=0 then goto re1;
l:=query1.Fields[0].AsString;
t:=query1.Fields[1].AsString;
iso:=query1.Fields[2].AsString;
with query1 do
begin
close;
sql.clear;
sql.add('select * from history_data');
sql.add('where riqi=:rqsj');
sql.add('and line_num=:lh');
sql.add('and tower_num=:th');
sql.add('and isolate_num=:ih');
parambyname('rqsj').asdatetime:=strtodatetime(rq+' '+sj);
parambyname('lh').asstring:=l;
parambyname('th').asstring:=t;
parambyname('ih').asstring:=iso;
active:=true;
end;
query1.Last;
if query1.RecordCount=0 then
begin
Table_history_data.Append;
{if extractfileext(openpicturedialog1.filename)='.jpg' then
//dbimage1.Picture.Graphic.Assign(jpg1);
begin
FS:=TFileStream.create(openpicturedialog1.filename,fmopenread);
savetoimage(Fs,Table_history_data.FieldbyName('image'));
FS.free;
end; }
Table_history_data.FieldByName('image').Assign(Image1.Picture);
Table_history_data.FieldValues['recnum']:=id+1;
Table_history_data.FieldValues['riqi']:=strtodatetime(rq+' '+sj);
Table_history_data.FieldValues['Line_Num']:='0001';
Table_history_data.FieldValues['Tower_Num']:=trim(t);
Table_history_data.FieldValues['Isolate_Num']:=trim(Iso);
Table_history_data.fieldbyname('shouji_Num').asstring:=Editshebei.Text;
Table_history_data.fieldbyname('tongdaohao').asstring:=trim(Iso);
Table_history_data.FieldValues['data_temperature']:=strtoint(Edittemp.text);
Table_history_data.FieldValues['data_humidity']:=strtoint(edithum.text);
Table_history_data.FieldValues['voltage']:=strtoint(Editvoltage.Text)/10;
Table_history_data.FieldValues['data_fengsu']:=strtoint(Editfengsu.Text)/10;
Table_history_data.Post;
Table_history_data.Refresh;
end;
end;
jpg1.Free;
bmp1.Free;
end;
end;
end;