看看我的保存吧
procedure TFrmkp.n_saveClick(Sender: TObject);
var
ErrorCount:integer;
s_hint:string;
begin
if isinsert then
begin
{ DM.clientdatasetxsdtb.Filter := 'xsdid=' + '''' + dbedit1.Text + '''';
DM.clientdatasetxsdtb.filtered := true;
// DM.clientdatasetxsdtb.IndexFieldNames := 'chid';
}
DM.clientdatasetxsdtb2.Close;
DM.clientdatasetxsdtb2.CommandText:='';
DM.clientdatasetxsdtb2.CommandText :='select * from xsdtb where xsdid='+''''+dbedit1.Text +'''';
DM.clientdatasetxsdtb2.Open ;
if DM.clientdatasetxsdtb2.RecordCount <> 0 then
begin
s_hint := '销售发票号重复';
application.MessageBox(pchar(s_hint), '远程销售系统', mb_iconinformation + mb_defbutton1);
exit;
end;
end;
DM.ClientDataSetxsdzb.First;
DM.ClientDataSetxsdtb.Post;
DM.ClientDataSetxsdtb.ApplyUpdates(-1);
ErrorCount:=dm.ClientDataSetxsdtb.ApplyUpdates(-1);
if ErrorCount>0 then
showmessage(format('提交时产生%d条错误!',[ErrorCount]));
button_valid;
dbedit1.Enabled :=false;
//因为不许变发票号,所以当编辑发票时,发票号框变为不可。保存后变为可。现在变为不可。
end;