📄 paraadd.pas
字号:
if ComboBox1.Text='动热稳定试验' then
begin
//设置不可编辑的单元格
if (StringGrid2.Row>3) or (StringGrid2.Col=0) then
StringGrid2.Options:=StringGrid1.Options-[goediting]
else
StringGrid2.Options:=StringGrid1.Options+[goediting];
end;
dxButton1.Enabled:=True;
end;
procedure TParaAddFrm.StringGrid2KeyPress(Sender: TObject; var Key: Char);
var
Str: String;
I: Integer;
begin
with StringGrid2 do
begin
if Col=1 then
begin
//只能输入数字和小数点
if key in ['0'..'9','.'] then
begin
Str:=Cells[1,Row];
if (key='.') and (Length(Str)>0) then
for I:=1 to Length(Str) do
if Str[I]='.' then
Key:=#0;
end
else
//允许回车键和退格键
if (key<>#8) and (key<>#13) then
key:=#0;
end;
end;
end;
procedure TParaAddFrm.dxButton1Click(Sender: TObject);
var
I,J,K:Integer;
str: array[1..8] of String;
tmp:Double;
tmpStr: String;
tmpDbl: Double;
begin
//判断输入数据的完整性
if Trim(Edit1.Text)='' then
if MessageBox(ParaAddFrm.Handle,'请输入委试单位!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
begin
Edit1.SetFocus;
Exit;
end;
if Trim(Edit2.Text)='' then
if MessageBox(ParaAddFrm.Handle,'请输入试品型号!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
begin
Edit2.SetFocus;
Exit;
end;
//判断输入数据的合法性
if ComboBox1.Text<>'自定义试验' then
begin
if (ComboBox1.Text<>'重合闸试验') and (ComboBox1.Text<>'动热稳定试验') then
begin
with StringGrid1 do
begin
for I:=1 to 4 do
for J:=I+1 to 5 do
if Cells[0,I]=Cells[0,J] then
if MessageBox(ParaAddFrm.Handle,'通道冲突,请重新设置!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
if ComboBox1.Text='单分试验' then
J:=7
else
if ComboBox1.Text='合分试验' then
J:=8;
for I:=1 to J do
if Trim(Cells[1,I])='' then
if MessageBox(ParaAddFrm.Handle,'持续时间值不能为空,请输入!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
end;
with StringGrid2 do
begin
if ComboBox1.Text='单分试验' then
J:=12
else
if ComboBox1.Text='合分试验' then
J:=13;
for I:=1 to J do
if Trim(Cells[1,I])='' then
if MessageBox(ParaAddFrm.Handle,'其它参数项输入不完整,请补全!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
end;
end;
if ComboBox1.Text='动热稳定试验' then
begin
with StringGrid1 do
for I:=1 to 3 do
if Trim(Cells[1,I])='' then
if MessageBox(ParaAddFrm.Handle,'持续时间值不能为空,请输入!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
with StringGrid2 do
for I:=1 to 3 do
if Trim(Cells[1,I])='' then
if MessageBox(ParaAddFrm.Handle,'其它参数项输入不完整,请补全!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
end;
for I:=1 to StringGrid1.RowCount do
if ComboBox3.Text=StringGrid1.Cells[0,I] then
if MessageBox(ParaAddFrm.Handle,'示波器通道和其它通道冲突,请重新设置!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
//退出命令
end;
if ComboBox1.Text='重合闸试验' then
begin
with StringGrid1 do
begin
if Cells[0,2]<>Cells[0,3] then
if MessageBox(ParaAddFrm.Handle,'两次试品分闸必须选择同一个通道,请重新设置!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
if Cells[0,4]<>Cells[0,5] then
if MessageBox(ParaAddFrm.Handle,'两次辅助开关分闸必须选择同一个通道,请重新设置!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
for I:=1 to 10 do
case I of
1,2: Str[I]:=Cells[0,I];
4: Str[I-1]:=Cells[0,I];
6..10: Str[I-2]:=Cells[0,I];
end;
for I:=1 to 7 do
for J:=I+1 to 8 do
if Str[I]=Str[J] then
if MessageBox(ParaAddFrm.Handle,'通道冲突,请重新设置!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
for I:=1 to 12 do
if Trim(Cells[1,I])='' then
if MessageBox(ParaAddFrm.Handle,'持续时间值不能为空,请输入!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
end;
with StringGrid2 do
for I:=1 to 23 do
if Trim(Cells[1,I])='' then
if MessageBox(ParaAddFrm.Handle,'其它参数项输入不完整,请补全!','错误',
MB_OK+MB_ICONERROR+MB_DEFBUTTON1+MB_APPLMODAL)=IDOK then
Exit;
end;
//进行保存
with SaveDialog1 do
begin
for I:=1 to 32 do
begin
cnnConImg[I].Tag:=0;
cnnConImg[I].Picture.LoadFromFile(Main.PictureDir+'Gray.bmp');
cnnVerImg[I].Picture.LoadFromFile(Main.PictureDir+'Gray.bmp');
end;
for I:=1 to 4 do
begin
cnnHighImg[I].Picture.LoadFromFile(Main.PictureDir+'Gray.bmp');
cnnArcImg[I].Picture.LoadFromFile(Main.PictureDir+'Gray.bmp');
end;
SaveDialog1.DefaultExt:='.mdb';
begin
if ComboBox1.Text='单分试验' then
SaveDialog1.InitialDir:=Main.ShuJuDir+'单分';
if ComboBox1.Text='合分试验' then
SaveDialog1.InitialDir:=Main.ShuJuDir+'合分';
if ComboBox1.Text='重合闸试验' then
SaveDialog1.InitialDir:=Main.ShuJuDir+'重合闸';
if ComboBox1.Text='动热稳定试验' then
SaveDialog1.InitialDir:=Main.ShuJuDir+'动热稳定';
if ComboBox1.Text='自定义试验' then
SaveDialog1.InitialDir:=Main.ShuJuDir+'自定义';
if (oneSave=0) then
if (SaveDialog1.Execute=True) then
begin
CopyFile(pChar(Main.DataDir+'Default.mdb'),pChar(SaveDialog1.FileName),False);
golFileName:=pChar(SaveDialog1.FileName);
end
else
Exit;
if ComboBox1.Text='单分试验' then
begin
K:=7;
with StringGrid2 do
begin
for I:=1 to 12 do
oldDbl[I]:=0;
oldDbl[1]:=BaseTime-StrToFloat(Cells[1,1])*10-
StrToFloat(Cells[1,2]);
oldDbl[2]:=BaseTime-StrToFloat(Cells[1,3])-
StrToFloat(Cells[1,4]);
oldDbl[3]:=BaseTime-StrToFloat(Cells[1,5])-
StrToFloat(Cells[1,6]);
oldDbl[5]:=BaseTime-StrToFloat(Cells[1,7])-
StrToFloat(Cells[1,8]);
oldDbl[4]:=BaseTime+StrToFloat(Cells[1,9])*10-
StrToFloat(Cells[1,10]);
oldDbl[6]:=BaseTime-StrToFloat(Cells[1,11]);
oldDbl[7]:=BaseTime-StrToFloat(Cells[1,12]);
end;
end;
if ComboBox1.Text='合分试验' then
begin
K:=8;
with StringGrid2 do
begin
for I:=1 to 12 do
oldDbl[I]:=0;
oldDbl[1]:=BaseTime-(StrToFloat(Cells[1,1])+2)*10-
StrToFloat(Cells[1,2]);
oldDbl[2]:=BaseTime-StrToFloat(Cells[1,1])*10-
StrToFloat(Cells[1,3]);
oldDbl[3]:=BaseTime-StrToFloat(Cells[1,4])-
StrToFloat(Cells[1,5]);
oldDbl[4]:=BaseTime-StrToFloat(Cells[1,6])-
StrToFloat(Cells[1,7]);
oldDbl[6]:=BaseTime-StrToFloat(Cells[1,8])-
StrToFloat(Cells[1,9]);
oldDbl[5]:=BaseTime+StrToFloat(Cells[1,10])*10-
StrToFloat(Cells[1,11]);
oldDbl[7]:=BaseTime-StrToFloat(Cells[1,12]);
oldDbl[8]:=BaseTime-StrToFloat(Cells[1,13]);
end;
end;
if ComboBox1.Text='重合闸试验' then
begin
K:=12;
with StringGrid2 do
begin
for I:=1 to 12 do
oldDbl[I]:=0;
oldDbl[1]:=BaseTime-StrToFloat(Cells[1,1])*10-StrToFloat(Cells[1,2])-
StrToFloat(Cells[1,3])*10-StrToFloat(Cells[1,4]);
oldDbl[2]:=BaseTime-StrToFloat(Cells[1,1])*10-StrToFloat(Cells[1,2])-
StrToFloat(Cells[1,5])-StrToFloat(Cells[1,6]);
oldDbl[3]:=BaseTime-StrToFloat(Cells[1,13])-StrToFloat(Cells[1,14]);
oldDbl[4]:=BaseTime-StrToFloat(Cells[1,1])*10-StrToFloat(Cells[1,2])-
StrToFloat(Cells[1,7])-StrToFloat(Cells[1,8])+
StrToFloat(Cells[1,9])*10;
oldDbl[5]:=BaseTime-StrToFloat(Cells[1,15])-StrToFloat(Cells[1,16]);
oldDbl[6]:=BaseTime-StrToFloat(Cells[1,1])*10-StrToFloat(Cells[1,10])-
StrToFloat(Cells[1,11])*10;
oldDbl[7]:=BaseTime-StrToFloat(Cells[1,1])*10-StrToFloat(Cells[1,12]);
oldDbl[9]:=BaseTime-StrToFloat(Cells[1,17])-StrToFloat(Cells[1,18]);
oldDbl[8]:=BaseTime+StrToFloat(Cells[1,19])*10-StrToFloat(Cells[1,20]);
oldDbl[10]:=BaseTime-StrToFloat(Cells[1,21]);
oldDbl[11]:=BaseTime-StrToFloat(Cells[1,22]);
oldDbl[12]:=BaseTime-StrToFloat(Cells[1,23]);
end;
end;
if ComboBox1.Text='动热稳定试验' then
begin
K:=3;
with StringGrid2 do
begin
for I:=1 to 12 do
oldDbl[I]:=0;
oldDbl[1]:=BaseTime-StrToFloat(Cells[1,1]);
oldDbl[2]:=BaseTime-StrToFloat(Cells[1,2]);
oldDbl[3]:=BaseTime-StrToFloat(Cells[1,3]);
end;
end;
if ComboBox1.Text='自定义试验' then
begin
K:=0;
with StringGrid2 do
for I:=1 to 12 do
oldDbl[I]:=0;
end;
if ComboBox1.Text<>'自定义试验' then
begin
//根据基准时间求值,然后平移时间坐标
oldDbl[0]:=oldDbl[1];
for I:=2 to K do
if oldDbl[I]<oldDbl[0] then
oldDbl[0]:=oldDbl[I];
tmp:=Trunc(oldDbl[0]) div 20;
//平移时间坐标
if oldDbl[0]<=0 then
begin
if MessageBox(ParaAddFrm.Handle,'出错!', '错误', MB_OK+MB_ICONERROR)=IDOK then
Exit;
end
else
begin
//如果最小值为正数
for I:=1 to K do
oldDbl[I]:=oldDbl[I]-tmp*20+StrToFloat(ComboBox4.Text);
BaseTime:=BaseTime-tmp*20+StrToFloat(ComboBox4.Text);
end;
end;
ADOConnection1.Close;
ADODataSet1.Close;
ADODataSet2.Close;
ADoConnection1.ConnectionString:=
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+SaveDialog1.FileName+
';Persist Security Info=False;Jet OLEDB:System database="";'+
'Jet OLEDB:Registry Path="";Jet OLEDB:Engine Type=5;'+
'Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;'+
'Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:Create System Database=False;';
ADOConnection1.Connected:=True;
ADODataSet1.CommandText:='outChannel';
DataSource1.DataSet:=ADODataSet1;
ADODataSet1.Connection:=ADOConnection1;
ADODataSet1.Open;
ADODataSet2.CommandText:='Information';
DataSource2.DataSet:=ADODataSet2;
ADODataSet2.Connection:=ADOConnection1;
ADODataSet2.Open;
if oneSave>0 then
begin
for I:=1 to ADODataSet1.RecordCount do
begin
ADODataSet1.Delete;
if I<>ADODataSet1.RecordCount then
ADODataSet1.Next;
end;
ADODataSet2.Delete;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -