procedure TOtptForm.BitBtn2Click(Sender: TObject);
var
i: Integer;
fw: TextFile;
TmpInt: Integer;
TmpStr: String;
Buffer: Array[0..1023] of Char;
begin
if Length(Edit1.Text)=0 then Exit;
if FileExists(Edit1.Text) then
begin
TmpStr := '文件 '+Edit1.Text+#13+#10+'已经存在,替换它吗?';
StrPCopy(Buffer,TmpStr);
TmpInt := MB_ICONINFORMATION+MB_YESNOCANCEL+MB_DEFBUTTON3;
TmpInt := MessageBox(Handle,Buffer,'导出数据',TmpInt);
if TmpInt<>ID_YES then Exit;
end;
for TmpInt := 0 to RcdCnt-1 do DrawBrick(TmpInt,0);
Label1.Caption := '正在导出..';
Edit1.Enabled := False;
BitBtn1.Enabled := False;
BitBtn2.Enabled := False;
BitBtn3.Caption := '取消(&C)';
try
AssignFile(fw,Edit1.Text);
ReWrite(fw);
DataModule1.Table1.First;
for TmpInt := 0 to RcdCnt - 1 do
begin
DrawBrick(TmpInt,1);
Application.ProcessMessages;
if (ModalResult=mrCancel) then
begin
ModalResult := mrNone;
if MessageBox(Handle,'正在导出原始数据,中止操作吗?',
'导出数据',MB_ICONINFORMATION+MB_YESNOCANCEL+
MB_DEFBUTTON3)=ID_YES then Break;
end;
Write(fw,DataModule1.Table1['SEQUNUMB'],',');
Write(fw,DataModule1.Table1['MOTOKIND'],',');
Write(fw,DataModule1.Table1['FRAMNUMB'],',');
Write(fw,DataModule1.Table1['ENGINUMB'],',');
Write(fw,DataModule1.Table1['CERTNUMB'],',');
Write(fw,DataModule1.Table1['MOTOCOLO'],',');
Write(fw,DataModule1.Table1['MANUDATE'],',');
if DataModule1.Table1['MAINRECO']='有' then
begin
Write(fw,'有,');
DataModule1.Table2.First;
for i := 1 to DataModule1.Table2.RecordCount do
begin
Write(fw,DataModule1.Table2['PARTNAME'],',');
Write(fw,DataModule1.Table2['BADPHENO'],',');
DataModule1.Table2.Next;
end;
Writeln(fw,';');
end
else
Writeln(fw,'无,;');
DrawBrick(TmpInt,2);
ShowProgress(TmpInt);
DataModule1.Table1.Next;
end;
CloseFile(fw);
finally
BitBtn3.Caption := '关闭(&C)';
BitBtn2.Enabled := True;
BitBtn1.Enabled := True;
Edit1.Enabled := True;
Label1.Caption := '导出至文件';
end;
end;