delphi+cxgrid+dbgrid....都可... 以下給你一段數據提交時的代碼,供你參考之:procedure TRes_Cq_HrQj_F.btnSB_SaveClick(Sender: TObject); begin inherited; if not btnSB_New.Enabled then begin if (Trim(cx_jb.Text)='') and (Trim(cx_gh.Text)='') and (Trim(cx_qjlb.Text)='') and (Trim(cx_sqrq.Text)='') and (Trim(cx_ksrq.Text)='') and (Trim(cx_jsrq.Text)='') and (Trim(cx_qjyy.Text)='') then begin MessageDlg('操作提示:數據不完整,如果不保存請點擊“取消”終止操作!',mtWarning,[mbOK],0); exit; end; if qry_hrqj.State in [dsedit,dsinsert] then begin try isSave:=true; qry_hrqj.Post; finally ChangeStatus(sBrowse); end; end; end; end;
搞定了 ~~呼呼~~又克服了一个难题~~~~~~谢谢大家~~~~~~~~ procedure TForm1.Button4Click(Sender: TObject); begin adoquery1.UpdateBatch; exit; if Application.MessageBox('确实保存数据吗?','提示',mb_YesNo)=ID_Yes then begin try ADOQuery1.Append; Application.MessageBox('保存成功','提示',64); except Application.MessageBox('系统出错','提示',64); end; end; end;
以下給你一段數據提交時的代碼,供你參考之:procedure TRes_Cq_HrQj_F.btnSB_SaveClick(Sender: TObject);
begin
inherited;
if not btnSB_New.Enabled then
begin
if (Trim(cx_jb.Text)='') and
(Trim(cx_gh.Text)='') and
(Trim(cx_qjlb.Text)='') and
(Trim(cx_sqrq.Text)='') and
(Trim(cx_ksrq.Text)='') and
(Trim(cx_jsrq.Text)='') and
(Trim(cx_qjyy.Text)='') then
begin
MessageDlg('操作提示:數據不完整,如果不保存請點擊“取消”終止操作!',mtWarning,[mbOK],0);
exit;
end;
if qry_hrqj.State in [dsedit,dsinsert] then
begin
try
isSave:=true;
qry_hrqj.Post;
finally
ChangeStatus(sBrowse);
end;
end;
end;
end;
DBGrid不可用,就不能自动提交了嘛,点保存或者取消后,DBGrid、增加、修改、删除按钮恢复可用做程序开发思维很重要的
begin
adoquery1.UpdateBatch;
exit;
if Application.MessageBox('确实保存数据吗?','提示',mb_YesNo)=ID_Yes then
begin
try
ADOQuery1.Append;
Application.MessageBox('保存成功','提示',64);
except
Application.MessageBox('系统出错','提示',64);
end;
end;
end;