use Query:
dm.Qexist.Close;
dm.Qexist.ParamByName('pempNo').asstring:=dm.Qclass0.FieldByName('empNo').value;
dm.Qexist.ParamByName('pmonth').asstring:=EGatherMonth.Text;
dm.Qexist.open;
if dm.Qexist.fieldbyname('okok').value=1 then
begin
dm.Qup300.Close;
dm.Qup300.ParamByName('pempNo').asstring:=dm.Qclass0.FieldByName('empNo').value;
dm.Qup300.ParamByName('p300').asfloat:=iTotalHours;
dm.Qup300.ParamByName('pmonthG').asstring:=EGatherMonth.Text;
dm.Qup300.execsql;
end
else
begin
dm.Qins300.Close;
dm.Qins300.ParamByName('pempNo').asstring:=dm.Qclass0.FieldByName('empNo').value;
dm.Qins300.ParamByName('p300').asfloat:=iTotalHours;
dm.Qins300.ParamByName('pmonthG').asstring:=EGatherMonth.Text;
dm.Qins300.execsql;
end;
Qexist:select count(*) okok from yourtable
where empNo=
empNo
and monthG=
month
Qup300 update yourtable
set over300=over300+
300
where empNo=
empNo
and monthG=
monthG
Qins300: insert into yourtable
(empNo,monthG,over300,status)
values
pempNo,
monthG,
300,'T')
对不起,不想改了,你自己改吧。