unit U_SetCompany; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, StdCtrls, wwdblook, Grids, Wwdbigrd, Wwdbgrid, kbmMemTable,u_op_seae_DsWebService,SoapHTTPClient,InvokeRegistry, bsSkinCtrls, DBCtrls, RxLookup; type Tfrm_SetCompany = class(TForm) MT1: TkbmMemTable; MT1ServerCompanyName: TStringField; MT1LocalName: TStringField; MT1SPXNO: TStringField; spxcompanyDS: TDataSource; wwDBGrid2: TwwDBGrid; qry1: TADOQuery; ds1: TDataSource; bsSkinPanel3: TbsSkinPanel; edt1: TEdit; bsSkinButton10: TbsSkinButton; bsSkinButton2: TbsSkinButton; SetCompany: TADOQuery; RxDBLookupCombo8: TRxDBLookupCombo; procedure GetCompanyInfo(str:string); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); private XML:String; mServiceSoap_Ds:DsWebServiceSoap; mHttpRIO_ds:THTTPRIO; public procedure getwebservice_ds; end; var frm_SetCompany: Tfrm_SetCompany; implementation uses u_main,u_data_share,my_sys_function; {$R *.dfm} procedure Tfrm_SetCompany.GetCompanyInfo(str:string); var _s,block:string; aa:DsWebServiceSoap; Companycount,_i,_j,p1,p2:integer; begin //获取往来单位信息XML getwebservice_ds; XML:=mServiceSoap_Ds.LoadAllCompany(frm_data_share.AnsiStringToWideString(str,936)); //XML:=aa.ReceiveBookingCargoSpace(_s); Companycount:= frm_data_share.countString('Company',xml); //result:= Opseaecount; MT1.Close; //MT1.EmptyTable; //MT1.Open; //写入MT1 for _i:=1 to Companycount do begin p1:=frm_data_share.GettimePotion(_i,'',xml); p2:=frm_data_share.GettimePotion(_i,'',xml); block:=Copy(XML,p1,p2-p1); MT1.Open; MT1.Edit; MT1.Insert; MT1['ServerCompanyName']:=frm_data_share.GetXMLValue('Name',block); MT1['SPXNO']:=frm_data_share.GetXMLValue('CompanyID',block); MT1['LocalName']:=''; MT1.Post; end; if (Companycount=0) then begin MT1.open; end; //从GetCompanyQry中逐个读取本地往来单位信息,将订舱系统序列号对应的客户简称写入MT1 MT1.First; qry1.close; qry1.OPEN; while not MT1.Eof do begin qry1.First; while not qry1.Eof do begin if (qry1.FieldByName('订舱系统序列号').AsString=MT1.FieldByName('SPXNO').AsString) then begin MT1.Edit; MT1['LocalName']:=qry1.FieldByName('客户简称').AsString; MT1.Post; //MT2.Edit; //MT2.Delete; //qry1.Post; //MT2.first; end; qry1.Next; end; MT1.Next; end; end; procedure Tfrm_SetCompany.getwebservice_ds; var URL:String; begin try URL:=get_WebseviceURL; mHttpRIO_ds:=THTTPRIO.Create(nil); mHttpRIO_ds.WSDLLocation:=URL+'?WSDL'; mHttpRIO_ds.URL:=URL; // mHttpRIO_ds.WSDLLocation:='http://192.168.1.5:8086/webservice/DsWebService.asmx?WSDL'; // mHttpRIO_ds.URL:='http://192.168.1.5:8086/webservice/DsWebService.asmx'; mHttpRIO_ds.Port:='DsWebServiceSoap'; mHttpRIO_ds.Service:='DsWebService'; mHttpRIO_ds.HTTPWebNode.UseUTF8InHeader:=true; InvRegistry.RegisterInvokeOptions(TypeInfo(DsWebServiceSoap),ioDocument );//就是这一行 mServiceSoap_Ds:=mHttpRIO_ds as DsWebServiceSoap; except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; procedure Tfrm_SetCompany.bsSkinButton10Click(Sender: TObject); begin GetCompanyInfo(edt1.text); end; procedure Tfrm_SetCompany.bsSkinButton2Click(Sender: TObject); begin //保存 //循环MT1,如果'本地客户简称'有值 则执行setCompanyQry设置订舱序列号 MT1.First; while not MT1.Eof do begin if (MT1.FieldByName('LocalName').AsString<>'') then begin SetCompany.SQL.Clear; SetCompany.sql.Add(' update t_crm_client set 订舱系统序列号='''' where 订舱系统序列号=:订舱系统序列号2'); SetCompany.sql.Add(' update t_crm_client set 订舱系统序列号=:订舱系统序列号 where 客户简称=:客户简称'); SetCompany.Close; SetCompany.Parameters.ParamByName('订舱系统序列号').Value:=MT1.fieldbyname('SPXNO').asstring; SetCompany.Parameters.ParamByName('订舱系统序列号2').Value:=MT1.fieldbyname('SPXNO').asstring; SetCompany.Parameters.ParamByName('客户简称').Value:=MT1.fieldbyname('LocalName').asstring; SetCompany.ExecSQL; end; MT1.Next; end; end; procedure Tfrm_SetCompany.FormShow(Sender: TObject); begin frm_data_share.t_crm_client.close; frm_data_share.t_crm_client.open; end; end.