- procedure TFrmTempSaleContract.Button1Click(Sender: TObject);
- var
- TestXML:TNativeXml;
- RootNode,MainNode,LineNode,TempNode:TXmlNode;
- begin
- inherited;
- try
- TestXML:=TNativeXml.CreateName('Test');
- TestXML.EncodingString:='GB2312';
- RootNode:=TestXML.Root;
- if CDSMain.ChangeCount>0 then
- TestCdsMain.Data:=CDSMain.Delta
- else
- TestCdsMain.Data:=CDSMain.Data;
- if CDSLine.ChangeCount>0 then
- TestCdsLine.Data:=CDSLine.Delta
- else
- TestCdsLine.Data:=CDSLine.Data;
- TestCdsMain.First;
- while not TestCdsMain.Eof do
- begin
- If TestCdsMain.UpdateStatus<>usUnmodified then
- begin
- if TestCdsMain.UpdateStatus=usInserted then
- begin
- MainNode:=RootNode.NodeNew('Main');
- MainNode.AttributeAdd('Job','New');
- TestCdsLine.First;
- while not TestCdsLine.Eof do
- begin
- LineNode:=MainNode.NodeNew('Line1');
- LineNode.AttributeAdd('Job','New');
- TestCdsLine.Next;
- end;
- end;
- if TestCdsMain.UpdateStatus=usModified then
- begin
- MainNode:=RootNode.NodeNew('Main');
- MainNode.AttributeAdd('Job','Update');
- TestCdsLine.First;
- while not TestCdsLine.Eof do
- begin
- LineNode:=MainNode.NodeNew('Line1');
- LineNode.AttributeAdd('Job','Update');
- TestCdsLine.Next;
- end;
- end;
- if TestCdsMain.UpdateStatus=usDeleted then
- begin
- MainNode:=RootNode.NodeNew('Main');
- MainNode.AttributeAdd('Job','Remove');
- TestCdsLine.First;
- while not TestCdsLine.Eof do
- begin
- LineNode:=MainNode.NodeNew('Line1');
- LineNode.AttributeAdd('Job','Remove');
- TestCdsLine.Next;
- end;
- end;
- end
- else
- begin
- MainNode:=RootNode.NodeNew('Main');
- MainNode.AttributeAdd('Job','None');
- TestCdsLine.First;
- while not TestCdsLine.Eof do
- begin
- if TestCdsLine.UpdateStatus<>usUnmodified then
- begin
- LineNode:=MainNode.NodeNew('Line1');
- if TestCdsLine.UpdateStatus=usModified then
- begin
- LineNode.AttributeAdd('Job','Update');
- end;
- if TestCdsLine.UpdateStatus=usInserted then
- begin
- LineNode.AttributeAdd('Job','New');
- end;
- if TestCdsLine.UpdateStatus=usDeleted then
- begin
- LineNode.AttributeAdd('Job','Remove');
- end;
- end;
- TestCdsLine.Next;
- end;
- end;
- TestCdsMain.Next;
- end;
- ShowMessage(TestXML.WriteToString);
- finally
- TestXML.Free;
- end;
- end;
ClientDataSet通过UpdateStatus方法配合Delta属性查找已删除的记录
最新推荐文章于 2019-04-22 15:20:40 发布