procedure TFrm_gzjl.BitBtn5Click(Sender: TObject);
var
vygbh:string;
begin
if flag='addnew' then
begin
with adoqgzjl do
{新增数据}
begin
close;
sql.Clear;
sql.Add('insert t_gzjl values
gh,:rzrq,:lzrq,:rzgs,:zw,:bz)');
parameters.ParamByName('gh').value:=trim(edit1.Text);
parameters.ParamByName('rzrq').value:=dateTostr(DateTimePicker1.Date);
parameters.ParamByName('lzrq').value:=dateTostr(DateTimePicker2.Date);
parameters.ParamByName('rzgs').value:=trim(edit3.Text);
parameters.ParamByName('zw').value:=trim(combobox2.Text);
parameters.ParamByName('bz').value:=trim(edit4.Text);
if not prepared then
prepared;
begin
trans;
try
ExecSQL;
commit;
except
rollback;
end;
end
else
begin
vygbh:=edit1.text;
//修改数据
with adoqgzjl do
begin
Close;
SQL.Clear;
SQL.Add('update t_gzjl set gh=:gh,rzrq=:rzrq,lzrq=:lzrq,rzgs=:rzgs,zw=:zw,bz=:bz');
SQL.Add('where');
SQL.Add('gh='''+trim(vygbh)+'''');
parameters.ParamByName('gh').value:=trim(edit1.Text);
parameters.ParamByName('rzrq').value:=dateTostr(DateTimePicker1.Date);
parameters.ParamByName('lzrq').value:=dateTostr(DateTimePicker2.Date);
parameters.ParamByName('rzgs').value:=trim(edit3.Text);
parameters.ParamByName('zw').value:=trim(combobox2.Text);
parameters.ParamByName('bz').value:=trim(edit4.Text);
ExecSQL;
end;
end;
with adoqgzjl do
//刷新表格//
begin
close;
sql.Clear;
sql.add('select * from t_gzjl where gh='''+trim(edit1.text)+'''');
If Not prepared then
adoqgzjl.Prepared;
open;
end;
setbutton;
//panel1.enabled:=false;}
end;
这个有错吗?