F
fuxin198311
Unregistered / Unconfirmed
GUEST, unregistred user!
就是我以数据进行增加,修改时 如果后台的表是很大的话代码量是非常大的 不易维护 这是我关于数据增加的代码 谁有更好的代码或方法让代码简单呢
procedure TT1010Form.BitBtn1Click(Sender: TObject);
begin
combobox5.Visible:=false;
edit1.Visible:=true;
if (edit1.Text='')or(edit2.Text='')or(edit3.Text='')or(combobox3.Text='')or(combobox1.Text='')or(combobox1.Text ='')or(edit19.Text='') then
begin
showmessage('内容还未填完!');
exit;
end;
try
with adoquery1 do
begin
sql.Clear ;
sql.Add ('insert into T1010(F01,F02,F03,F04,F05,F06,F07,F08,F09,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23)'+
'valuesF01,:F02,:F03,:F04,:F05,:F06,:F07,:F08,:F09,:F10,:F11,:F12,:F13,:F14,:F15,:F16,:F17,:F18,:F19,:F20,:F21,:F22,:F23)');
Parameters.ParamByName('f01').Value:=trim(pchar(edit1.Text));
Parameters.ParamByName('f02').Value:=trim(pchar(edit2.Text));
Parameters.ParamByName('f03').Value:=trim(pchar(edit3.Text));
Parameters.ParamByName('f04').Value:=trim(pchar(edit4.Text));
Parameters.ParamByName('f05').Value:=trim(pchar(edit5.Text));
Parameters.ParamByName('f06').Value:=trim(pchar(edit6.Text));
Parameters.ParamByName('f07').Value:=trim(pchar(edit7.Text));
Parameters.ParamByName('f08').Value:=trim(pchar(edit9.Text));
Parameters.ParamByName('f09').Value:=trim(pchar(edit8.Text));
Parameters.ParamByName('f10').Value:=trim(pchar(edit10.Text));
parameters.ParamByName('F11').Value:=dateEdit1.Date ;
// Parameters.ParamByName('f11').Value:=datetimepicker1.DateTime ;
Parameters.ParamByName('f12').Value:=trim(pchar(edit18.Text));
Parameters.ParamByName('f13').Value:=trim(pchar(edit11.Text));
Parameters.ParamByName('f14').Value:=trim(pchar(edit12.Text));
Parameters.ParamByName('f15').Value:=trim(pchar(edit13.Text));
Parameters.ParamByName('f16').Value:=trim(pchar(edit14.Text));
Parameters.ParamByName('f17').Value:=trim(pchar(edit15.Text));
Parameters.ParamByName('f18').Value:=trim(pchar(edit16.Text));
Parameters.ParamByName('f19').Value:=trim(pchar(edit17.Text));
Parameters.ParamByName('f20').Value:=trim (combobox1.Text) ;
Parameters.ParamByName('f21').Value:=comboedit1.Text;
Parameters.ParamByName('f22').Value:=trim(pchar(combobox3.Text));
Parameters.ParamByName('f23').Value:=trim(pchar(edit19.Text));
execsql;
iniform;
end;
except
showmessage('入库错误!');
end;
end;
procedure TT1010Form.BitBtn1Click(Sender: TObject);
begin
combobox5.Visible:=false;
edit1.Visible:=true;
if (edit1.Text='')or(edit2.Text='')or(edit3.Text='')or(combobox3.Text='')or(combobox1.Text='')or(combobox1.Text ='')or(edit19.Text='') then
begin
showmessage('内容还未填完!');
exit;
end;
try
with adoquery1 do
begin
sql.Clear ;
sql.Add ('insert into T1010(F01,F02,F03,F04,F05,F06,F07,F08,F09,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23)'+
'valuesF01,:F02,:F03,:F04,:F05,:F06,:F07,:F08,:F09,:F10,:F11,:F12,:F13,:F14,:F15,:F16,:F17,:F18,:F19,:F20,:F21,:F22,:F23)');
Parameters.ParamByName('f01').Value:=trim(pchar(edit1.Text));
Parameters.ParamByName('f02').Value:=trim(pchar(edit2.Text));
Parameters.ParamByName('f03').Value:=trim(pchar(edit3.Text));
Parameters.ParamByName('f04').Value:=trim(pchar(edit4.Text));
Parameters.ParamByName('f05').Value:=trim(pchar(edit5.Text));
Parameters.ParamByName('f06').Value:=trim(pchar(edit6.Text));
Parameters.ParamByName('f07').Value:=trim(pchar(edit7.Text));
Parameters.ParamByName('f08').Value:=trim(pchar(edit9.Text));
Parameters.ParamByName('f09').Value:=trim(pchar(edit8.Text));
Parameters.ParamByName('f10').Value:=trim(pchar(edit10.Text));
parameters.ParamByName('F11').Value:=dateEdit1.Date ;
// Parameters.ParamByName('f11').Value:=datetimepicker1.DateTime ;
Parameters.ParamByName('f12').Value:=trim(pchar(edit18.Text));
Parameters.ParamByName('f13').Value:=trim(pchar(edit11.Text));
Parameters.ParamByName('f14').Value:=trim(pchar(edit12.Text));
Parameters.ParamByName('f15').Value:=trim(pchar(edit13.Text));
Parameters.ParamByName('f16').Value:=trim(pchar(edit14.Text));
Parameters.ParamByName('f17').Value:=trim(pchar(edit15.Text));
Parameters.ParamByName('f18').Value:=trim(pchar(edit16.Text));
Parameters.ParamByName('f19').Value:=trim(pchar(edit17.Text));
Parameters.ParamByName('f20').Value:=trim (combobox1.Text) ;
Parameters.ParamByName('f21').Value:=comboedit1.Text;
Parameters.ParamByName('f22').Value:=trim(pchar(combobox3.Text));
Parameters.ParamByName('f23').Value:=trim(pchar(edit19.Text));
execsql;
iniform;
end;
except
showmessage('入库错误!');
end;
end;