procedure Tmodify_form.Button2Click(Sender: TObject);
var strtemp:integer;
var strtemp1:integer;
var at, am:integer;
var i :integer;
begin
if combobox1.text<>'' then
begin
strtemp:=query1.fieldbyname('alarmtypeid').asinteger;
query2.DatabaseName:= dialogform.Database1.databasename;
query2.close ;
query2.sql.clear;
query2.sql.add('select typelevelid from alarmtypelevel where alarmtypeid='+inttostr(strtemp));
query2.open;
DBEdit1.datafield:='typelevelid';
strtemp1:=strtoint(DBEdit1.text);
table2.databasename:= dialogform.Database1.databasename;
table2.tablename:='ALARMTYPELEVEL';
table2.active:=true;
table2.First;
for i:=1 to table2.RecordCount do
begin
if table2.fieldbyname('alarmtypeid').asinteger=strtemp1 then
if (table2.fieldbyname('status').asstring='Y')or (table2.fieldbyname('status').asstring='y') then
begin
table2.edit;
table2.fieldbyname('status').asstring:='N' ;
table2.post;
end;
table2.next;
end;
dbedit1.DataField:='';
query2.close;
query2.sql.Clear;
query2.sql.add('select max(typelevelid) from alarmtypelevel');
query2.open;
dbedit1.DataField:='max(typelevelid)';
at:=strtoint(dbedit1.text)+1;
table2.append; <= 出错处
table2.FieldValues['typelevelid'].asinteger:=at;
table2.FieldValues['alarmtypeid'].asinteger:=strtemp;
table2.FieldValues['alarmlevelid'].asinteger:=combobox1.itemindex ;
table2.FieldValues['status'].asstring:='Y';
table2.FieldValues['alarmmodifytime'].asdatetime:=now;
table2.Post ;
query1.Refresh ;
dbgrid1.refresh;
end
else
showmessage('no level!');
end;