www.pudn.com > DelphiCDSService2010.rar > Unit1.pas, change:2009-12-25,size:1676b


unit Unit1; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, Service1, Grids, DBGrids, DB, DBClient, StdCtrls, ExtCtrls, 
  InvokeRegistry, Rio, SOAPHTTPClient; 
 
type 
  TForm1 = class(TForm) 
    Panel1: TPanel; 
    Button1: TButton; 
    Button2: TButton; 
    DataSource1: TDataSource; 
    ClientDataSet1: TClientDataSet; 
    DBGrid1: TDBGrid; 
    HTTPRIO1: THTTPRIO; 
    procedure Button1Click(Sender: TObject); 
    procedure Button2Click(Sender: TObject); 
  private 
    function Buf_GetBuleService: Service1Soap; 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  Form1: TForm1; 
 
implementation 
 
{$R *.dfm} 
 
function TForm1.Buf_GetBuleService: Service1Soap; 
var 
defURL: string; 
begin 
    defURL := 'http://localhost:1935/Service1.asmx'; 
    HTTPRIO1.HTTPWebNode.UseUTF8InHeader := true; // 
    Result := GetService1Soap(false,defURL,HTTPRIO1); 
end; 
 
procedure TForm1.Button1Click(Sender: TObject); 
var 
ls_Table: string; 
ls_Service: Service1Soap; 
begin 
  ls_Service := Buf_GetBuleService; 
  ls_Table := 'Customers'; 
  ClientDataSet1.XMLData := ls_Service.Buf_GetADONetToCDSXml('Northwind',ls_Table,'select * from '+ls_Table); 
end; 
 
procedure TForm1.Button2Click(Sender: TObject); 
var 
ls_Table: string; 
ls_Service: Service1Soap; 
begin 
  ls_Service := Buf_GetBuleService; 
  ls_Table := 'Customers'; 
  if ClientDataSet1.State in [dsEdit,dsInsert] then 
     ClientDataSet1.Post; 
  if ClientDataSet1.ChangeCount>0 then 
     ls_Service.Buf_PutCDSXmlToADONet('Northwind',ls_Table,ClientDataSet1.XMLData); 
end; 
 
end.