procedure TKHSP.Button1Click(Sender: TObject);
var i:integer;
begin
query2.Close;
query2.sql.clear;
query2.SQL.add('select * from kh_bmdw where Dwmc=:dwmc');
query2.Params[0].asstring:=dblookupcombobox1.Text ;
query2.Prepare ;
query2.open;
dwdm:=query2.fieldbyname('Dwdm').asstring;
query1.Close;
query1.sql.clear;
dbgrid1.Columns.Clear;
if khfs='1' //根据KHFS判断扣分表类型
then
begin
query1.sql.add('select a.fxnr,b.fz,b.sl from kh_bmfx a,kh_ydkfb b where b.bkhdw=:bkhdw and b.yd=:yd and a.tablecode=b.tablecode and a.dxbm=b.dxbm and a.xxbm=b.xxbm and a.fxbm=b.fxbm');
UpdateSQL1.ModifySQL.Clear;
UpdateSQL1.ModifySQL.append('update kh_ydkfb set fz=:fz,sl=:sl where fz=:OLD_fz and sl=:OLD_sl');
UpdateSQL1.InsertSQL.Clear;
UpdateSQL1.InsertSQL.append('insert into kh_ydkfb(fz,sl) values(,:fz,:sl)');
UpdateSQL1.DeleteSQL.Clear;
UpdateSQL1.DeleteSQL.append('delete from kh_ydkfb where fz=:OLD_fz and sl=:OLD_sl');
end
else if khfs='2'
then
begin
query1.sql.add('select a.fxnr,b.fz,b.sl from kh_bmfx a,kh_jdkfb b where b.bkhdw=:bkhdw and b.jd=:jd and a.tablecode=b.tablecode and a.dxbm=b.dxbm and a.xxbm=b.xxbm and a.fxbm=b.fxbm');
UpdateSQL1.ModifySQL.Clear;
UpdateSQL1.ModifySQL.append('update kh_jdkfb set fz=:fz,sl=:sl where fz=:OLD_fz and sl=:OLD_sl');
UpdateSQL1.InsertSQL.Clear;
UpdateSQL1.InsertSQL.append('insert into kh_jdkfb(fz,sl) values(,:fz,:sl)');
UpdateSQL1.DeleteSQL.Clear;
UpdateSQL1.DeleteSQL.append('delete from kh_jdkfb where fz=:OLD_fz and sl=:OLD_sl');
end
else
begin
query1.sql.add('select a.fxnr,b.fz,b.sl from kh_bmfx a,kh_ndkfb b where b.bkhdw=:bkhdw and b.nd=:nd and a.tablecode=b.tablecode and a.dxbm=b.dxbm and a.xxbm=b.xxbm and a.fxbm=b.fxbm');
UpdateSQL1.ModifySQL.Clear;
UpdateSQL1.ModifySQL.append('update kh_ndkfb set fz=:fz,sl=:sl where fz=:OLD_fz and sl=:OLD_sl');
UpdateSQL1.InsertSQL.Clear;
UpdateSQL1.InsertSQL.append('insert into kh_ndkfb(fz,sl) values(,:fz,:sl)');
UpdateSQL1.DeleteSQL.Clear;
UpdateSQL1.DeleteSQL.append('delete from kh_ndkfb where fz=:OLD_fz and sl=:OLD_sl');
end;
query1.Params[0].asstring:=dwdm;
if khfs='3' then query1.Params[1].asstring:=ye.Text
else query1.Params[1].asstring:=ye.Text+yuejd.Text;
query1.prepare;
query1.Open;
dbgrid1.Columns[0].Title.Caption:='考核分项内容';
dbgrid1.columns[0].title.Font:=dbgrid1.font;
dbgrid1.Columns[1].Title.Caption:='考核扣分';
dbgrid1.columns[1].title.Font:=dbgrid1.font;
dbgrid1.Columns[2].Title.Caption:='扣分次数';
dbgrid1.columns[2].title.Font:=dbgrid1.font;
dbgrid1.columns[0].Width:=500;
dbgrid1.columns[1].Width:=100;
dbgrid1.columns[2].Width:=100;
dbgrid1.columns[0].ReadOnly:=true;
dbgrid1.columns[1].ReadOnly:=true;
dbgrid1.columns[2].ReadOnly:=true;
end;
procedure TKHSP.FormClose(Sender: TObject; var Action: TCloseAction);
begin
query1.Close;
query1.SQL.clear;
end;
procedure TKHSP.BitBtn1Click(Sender: TObject);
begin
KHSP.FREE;
end;
procedure TKHSP.DBGrid1DblClick(Sender: TObject);
begin
SPXG:=TSPXG.Create(self);
SPXG.Visible:=true;
SPXG.label1.Caption:='';
SPXG.spinedit2.Visible:=false;
SPXG.spinedit2.Value:=1;
SPXG.bitbtn1.Enabled:=false;
SPXG.label1.Caption :=query1.fieldbyname('fxnr').asstring;
SPXG.spinedit1.value:=query1.fieldbyname('fz').asinteger;
SPXG.SpinEdit2.Visible:=true;
SPXG.SpinEdit2.Value:=query1.fieldbyname('sl').asinteger;
SPXG.dwmc.Visible:=true;
end;
procedure TKHSP.BitBtn2Click(Sender: TObject);
begin
dbgrid1.columns[0].ReadOnly:=false;
dbgrid1.columns[1].ReadOnly:=false;
dbgrid1.columns[2].ReadOnly:=false;
{if query3.canmodify then
begin
query1.Close;
query3.sql.clear;
if khfs='1' //根据KHFS取扣分表
then query3.sql.add('update kh_ydkfb set zt="1" where bkhdw=:bkhdw and yd=:yd')
else if khfs='2'
then query3.sql.add('update kh_jdkfb set zt="1" where bkhdw=:bkhdw and jd=:jd')
else query3.sql.add('update kh_ndkfb set zt="1" where bkhdw=:bkhdw and nd=:nd');
query3.Params[0].asstring:=dwdm;
if khfs='3' then query3.Params[1].asstring:=ye.Text
else query3.Params[1].asstring:=ye.Text+yuejd.Text;
query3.prepare;
query3.Execsql;
query3.Close;
end
else
begin
beep;
Application.MessageBox('审批数据未存入考核扣分表!','目标管理考核系统--错误信息',MB_OK + MB_ICONERROR);
end;
end; }
log.Database2.StartTransaction;
log.Database2.TransIsolation:=tiDirtyRead;
query3.Close;
query3.sql.clear;
if khfs='1' //根据KHFS判断扣分表类型
then
begin
query3.sql.add('update kh_ydkfb set zt="1" where bkhdw=:bkhdw and yd=:yd');
UpdateSQL2.ModifySQL.Clear;
UpdateSQL2.ModifySQL.append('update kh_ydkfb set zt="1" where zt=:OLD_zt');
end
else if khfs='2'
then
begin
query3.sql.add('update kh_jdkfb set zt="1" where bkhdw=:bkhdw and yd=:yd');
UpdateSQL2.ModifySQL.Clear;
UpdateSQL2.ModifySQL.append('update kh_jdkfb set zt="1" where zt=:OLD_zt');
end
else
begin
query3.sql.add('update kh_ndkfb set zt="1" where bkhdw=:bkhdw and yd=:yd');
UpdateSQL2.ModifySQL.Clear;
UpdateSQL2.ModifySQL.append('update kh_ndkfb set zt="1" where zt=:OLD_zt');
end;
query3.Params[0].asstring:=dwdm;
if khfs='3' then query3.Params[1].asstring:=ye.Text
else query3.Params[1].asstring:=ye.Text+yuejd.Text;
query3.prepare;
query3.execsql;
Try
KHSP.query3.ApplyUpdates;
log.Database2.Commit;
except
Begin
beep;
log.Database2.Rollback;
log.Database2.TransIsolation:=tiReadCommitted;
Application.MessageBox('审批数据未存入考核扣分表!','镇江国税目标考核管理系统--错误信息',MB_OK + MB_ICONERROR);
raise;
end;
end;
KHSP.query3.CommitUpdates;
log.Database2.TransIsolation:=tiReadCommitted;
end;