unit u_op_ctn; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, BusinessSkinForm, Grids, Wwdbigrd, Wwdbgrid, StdCtrls, wwdblook, DB, ADODB, Mask, wwdbedit, Wwdotdot, Wwdbcomb, DBGridEh, ExtCtrls, DBCtrls, Menus,DateUtils, inifiles, Rio, SOAPHTTPClient,InvokeRegistry,DyxtService,Service,jfczService,myService,CaragtQuery_Cxwl,servicezh, DBClient,XMLIntf,XMLDoc, xmldom, Xmlxform, kbmMemTable,IdHTTP,my_sys_function, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient ,ComObj,superobject; type Tfrm_op_ctn = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; wwDBGrid1: TwwDBGrid; wwDBLookupCombo1: TwwDBLookupCombo; wwDBLookupCombo2: TwwDBLookupCombo; t_op_ctn: TADOQuery; t_op_ctn1: TDataSource; Memo1: TMemo; Memo2: TMemo; Memo3: TMemo; Memo4: TMemo; bsSkinPanel1: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton5: TbsSkinButton; wwDBLookupCombo4: TwwDBLookupCombo; bsSkinPanel2: TbsSkinPanel; Splitter1: TSplitter; t_op_ctndetail1: TDataSource; wwDBLookupCombo5: TwwDBLookupCombo; wwDBLookupCombo3: TwwDBLookupCombo; t_op_ctndetail: TADOQuery; DBGridEh1: TDBGridEh; bsSkinButton9: TbsSkinButton; t_ch_client: TADOQuery; t_ch_client1: TDataSource; t_op_ctnsum1: TDataSource; t_op_ctnsum: TADOQuery; bsSkinPanel3: TbsSkinPanel; Label1: TLabel; DBText1: TDBText; Label2: TLabel; DBText2: TDBText; DBText3: TDBText; Label3: TLabel; DBText4: TDBText; Label4: TLabel; Label5: TLabel; DBText5: TDBText; PopupMenu1: TPopupMenu; N2: TMenuItem; N3: TMenuItem; N7: TMenuItem; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton10: TbsSkinButton; Panel1: TPanel; DBNavigator1: TDBNavigator; bsSkinButton11: TbsSkinButton; Button1: TButton; t_op_ctndetailid: TAutoIncField; t_op_ctndetailctn_id: TIntegerField; t_op_ctndetailDSDesigner: TStringField; t_op_ctndetailDSDesigner2: TStringField; t_op_ctndetailDSDesigner3: TSmallintField; t_op_ctndetailDSDesigner4: TStringField; t_op_ctndetailDSDesigner5: TIntegerField; t_op_ctndetailHTS: TStringField; t_op_ctndetailDSDesigner6: TBCDField; t_op_ctndetailDSDesigner7: TStringField; t_op_ctndetailDSDesigner8: TStringField; t_op_ctndetailDSDesigner9: TBCDField; t_op_ctndetailPACKAGE: TStringField; t_op_ctndetailTRADETYPE: TStringField; bsSkinButton12: TbsSkinButton; t_ch_fee: TADOQuery; kbmMemTable1: TkbmMemTable; kbmMemTable1StringField: TStringField; kbmMemTable1StringField2: TStringField; kbmMemTable1IntegerField: TIntegerField; kbmMemTable1StringField3: TStringField; kbmMemTable1FloatField: TFloatField; kbmMemTable1FloatField2: TFloatField; kbmMemTable1StringField4: TStringField; kbmMemTable1StringField5: TStringField; kbmMemTable1StringField6: TStringField; IdHTTP2: TIdHTTP; bsSkinButton14: TbsSkinButton; DBMemo1: TDBMemo; Label6: TLabel; bsSkinButton13: TbsSkinButton; OpenDialog1: TOpenDialog; wwDBComboBox1: TwwDBComboBox; bsSkinButton15: TbsSkinButton; procedure t_op_ctnAfterInsert(DataSet: TDataSet); procedure t_op_ctnBeforePost(DataSet: TDataSet); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure wwDBLookupCombo1Change(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure bsSkinButton6Click(Sender: TObject); procedure t_op_ctnBeforeDelete(DataSet: TDataSet); procedure t_op_ctnBeforeEdit(DataSet: TDataSet); procedure t_op_ctnAfterPost(DataSet: TDataSet); procedure t_op_ctndetailBeforeInsert(DataSet: TDataSet); procedure t_op_ctndetailNewRecord(DataSet: TDataSet); procedure bsSkinButton9Click(Sender: TObject); procedure t_op_ctnAfterOpen(DataSet: TDataSet); procedure N2Click(Sender: TObject); procedure N7Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinPanel1Resize(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); private { Private declarations } mServiceSoap_dy:DyxtServiceSoap; mServiceSoap_yzh:ServiceSoap; mServiceSoap_zh:ServiceSoapzh; mServiceSoap_zc:CaragtQuery_CxwlSoap; mHttpRIO_dy,mHttpRIO_yzh,mHttpRIO_zc,mHttpRIO_zh:THTTPRIO; procedure getwebservice_dy; //获取 procedure getwebservice_yzh; //获取 procedure getwebservice_zc; //获取 procedure getwebservice_zc_lw; //获取 procedure getwebservice_zc_la; procedure dewebservice; //关闭 procedure getwebservice_zh; //获取 procedure GetdyczInfo_dy(s_caragt,s_key,s_billno,bsno:String); procedure GetdyczInfo_yzh(s_caragt,s_key,s_billno,bsno:String); procedure GetdyczInfo_jfcz(s_caragt,s_key,s_billno,bsno:String); procedure GetdyczInfo_lhcz(s_caragt,s_key,s_billno,bsno:String); procedure GetdyczInfo_zc(s_caragt,s_key,s_billno,bsno:String); procedure getssczinfor(mblno:string); procedure getmjczinfor(mblno:string); procedure GetdyczInfo_zh(s_caragt,s_key,s_billno,bsno:String); function getYardCode(yard:string):string; //20140923 dengyu 抓取并存储集装箱信息相关方法 function SaveCTNINFO(s_caragt,s_key,s_billno,bsno:String;_CTNINFO:TContainerINFO):boolean; //procedure DOSAVE_CTNINFO(_HEAD:TStringList;_BODY:TList); public { Public declarations } dbserver:string; end; var frm_op_ctn: Tfrm_op_ctn; frm_op_ctn_type:boolean; op_ctn_limited:string; implementation uses u_data_share, u_op_seae, u_op_seai,u_op_seai_sf, u_main, u_op_seae_ctn; {$R *.dfm} procedure Tfrm_op_ctn.GetdyczInfo_jfcz(s_caragt,s_key,s_billno,bsno:String); var b:Boolean; s_web: WideString; xmldoc:IXMLDocument; cds:TClientDataSet; XMLTransformProvider1:TXMLTransformProvider; s_ctnno,s_ctnType:string; smartWS:jfczServiceSoap; begin try t_op_ctn.DisableControls; cds:=TClientDataSet.Create(nil); XMLTransformProvider1:=TXMLTransformProvider.Create(NIL); cds.Active:=false; xmldoc:=NewXMLDocument; xmldoc.Encoding:='UTF-8'; smartWS:=GetjfczServiceSoap(True,''); s_web:=smartWS.GetBLNoInfo(s_billno,'18315FA0-8E5A-4935-8369-91BE89BC6B6A'); xmldoc.LoadFromXML(s_web); xmldoc.SaveToFile('c:\JFCZ.xml'); // ShowMessage('\\'+dbserver+'\jfcz\jfcz.xtr'); XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\jfcz\jfcz.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; kbmMemTable1.EmptyTable; kbmMemTable1.Open; with cds do begin First; while not Eof do begin if kbmMemTable1.Locate('箱号',Trim(FieldByName('CNTRNO').AsString),[]) then begin kbmMemTable1.Edit; s_ctnno:=Trim(FieldByName('CNTRSIZE').AsString); s_ctnType:=Trim(FieldByName('CNTRTYPE').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin kbmMemTable1.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; kbmMemTable1.FieldByName('尺寸').AsString:=FieldByName('CNTRSIZE').AsString; kbmMemTable1.FieldByName('箱型').AsString:=FieldByName('CNTRTYPE').AsString; kbmMemTable1.FieldByName('封号').AsString:=FieldByName('SEALNO').AsString; kbmMemTable1.FieldByName('件数').AsInteger:=kbmMemTable1.FieldByName('件数').AsInteger+FieldByName('CARGOQTY').AsInteger; kbmMemTable1.FieldByName('包装').AsString:=FieldByName('CO_PKGCODE').AsString; kbmMemTable1.FieldByName('重量').AsFloat:=kbmMemTable1.FieldByName('重量').AsFloat+FieldByName('CARGOWEIGHT').AsFloat; kbmMemTable1.FieldByName('尺码').AsFloat:=kbmMemTable1.FieldByName('尺码').AsFloat+FieldByName('CARGOVOLUME').AsFloat; kbmMemTable1.Post; end else begin kbmMemTable1.append; s_ctnno:=Trim(FieldByName('CNTRSIZE').AsString); s_ctnType:=Trim(FieldByName('CNTRTYPE').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin kbmMemTable1.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; kbmMemTable1.FieldByName('尺寸').AsString:=FieldByName('CNTRSIZE').AsString; kbmMemTable1.FieldByName('箱型').AsString:=FieldByName('CNTRTYPE').AsString; kbmMemTable1.FieldByName('箱号').AsString:=FieldByName('CNTRNO').AsString; kbmMemTable1.FieldByName('封号').AsString:=FieldByName('SEALNO').AsString; kbmMemTable1.FieldByName('件数').AsInteger:=FieldByName('CARGOQTY').AsInteger; kbmMemTable1.FieldByName('包装').AsString:=FieldByName('CO_PKGCODE').AsString; kbmMemTable1.FieldByName('重量').AsFloat:=FieldByName('CARGOWEIGHT').AsFloat; kbmMemTable1.FieldByName('尺码').AsFloat:=FieldByName('CARGOVOLUME').AsFloat; kbmMemTable1.Post; end; Next; end; end; with kbmMemTable1 do begin First; while not Eof do begin if t_op_ctn.Locate('箱号',Trim(FieldByName('箱号').AsString),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(FieldByName('尺寸').AsString); s_ctnType:=Trim(FieldByName('箱型').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('封号').AsString:=FieldByName('封号').AsString; t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('件数').AsInteger; t_op_ctn.FieldByName('包装').AsString:=FieldByName('包装').AsString; t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('重量').AsFloat; t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('尺码').AsFloat; t_op_ctn.Post; end else begin t_op_ctn.append; s_ctnno:=Trim(FieldByName('尺寸').AsString); s_ctnType:=Trim(FieldByName('箱型').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=FieldByName('箱号').AsString; t_op_ctn.FieldByName('封号').AsString:=FieldByName('封号').AsString; t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('件数').AsInteger; t_op_ctn.FieldByName('包装').AsString:=FieldByName('包装').AsString; t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('重量').AsFloat; t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('尺码').AsFloat; t_op_ctn.Post; end; Next; end; end; finally t_op_ctn.EnableControls; cds.Free; end; end; procedure Tfrm_op_ctn.getwebservice_dy; begin try mHttpRIO_dy:=THTTPRIO.Create(nil); mHttpRIO_dy.WSDLLocation:='http://www.yydy.com/GacoWebService/DyxtService.asmx?WSDL'; mHttpRIO_dy.URL:='http://www.yydy.com/GacoWebService/DyxtService.asmx'; mHttpRIO_dy.Port:='DyxtServiceSoap'; mHttpRIO_dy.Service:='DyxtWebService'; mHttpRIO_dy.HTTPWebNode.UseUTF8InHeader:=true; mServiceSoap_dy:=mHttpRIO_dy as DyxtServiceSoap; InvRegistry.RegisterInvokeOptions(TypeInfo(DyxtServiceSoap),ioDocument );//就是这一行 except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; procedure Tfrm_op_ctn.getwebservice_zc; begin try mHttpRIO_zc:=THTTPRIO.Create(nil); mHttpRIO_zc.WSDLLocation:='http://www.cmlog.com.cn:8003/cmlwebservice/CaragtQuery_Cxwl.asmx?WSDL'; mHttpRIO_zc.URL:='http://www.cmlog.com.cn:8003/cmlwebservice/CaragtQuery_Cxwl.asmx'; mHttpRIO_zc.Port:='CaragtQuery_CxwlSoap'; mHttpRIO_zc.Service:='CaragtQuery_Cxwl'; mHttpRIO_zc.HTTPWebNode.UseUTF8InHeader:=true; mServiceSoap_zc:=mHttpRIO_zc as CaragtQuery_CxwlSoap; InvRegistry.RegisterInvokeOptions(TypeInfo(CaragtQuery_CxwlSoap),ioDocument );//就是这一行 except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; procedure Tfrm_op_ctn.getwebservice_zc_lw; begin try mHttpRIO_zc:=THTTPRIO.Create(nil); mHttpRIO_zc.WSDLLocation:='http://www.cmlog.com.cn:8003/cmlwebservice/CaragtQuery_Qlwwl.asmx?WSDL'; mHttpRIO_zc.URL:='http://www.cmlog.com.cn:8003/cmlwebservice/CaragtQuery_Qlwwl.asmx'; mHttpRIO_zc.Port:='CaragtQuery_QlwwlSoap'; mHttpRIO_zc.Service:='CaragtQuery_Qlwwl'; mHttpRIO_zc.HTTPWebNode.UseUTF8InHeader:=true; mServiceSoap_zc:=mHttpRIO_zc as CaragtQuery_CxwlSoap; InvRegistry.RegisterInvokeOptions(TypeInfo(CaragtQuery_CxwlSoap),ioDocument );//就是这一行 except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; procedure Tfrm_op_ctn.getwebservice_zc_la; begin try mHttpRIO_zc:=THTTPRIO.Create(nil); mHttpRIO_zc.WSDLLocation:='http://www.cmlog.com.cn:8003/cmlwebservice/CaragtQuery_QDLA.asmx?WSDL'; mHttpRIO_zc.URL:='http://www.cmlog.com.cn:8003/cmlwebservice/CaragtQuery_QDLA.asmx'; mHttpRIO_zc.Port:='CaragtQuery_QDLASoap'; mHttpRIO_zc.Service:='CaragtQuery_QDLA'; mHttpRIO_zc.HTTPWebNode.UseUTF8InHeader:=true; mServiceSoap_zc:=mHttpRIO_zc as CaragtQuery_CxwlSoap; InvRegistry.RegisterInvokeOptions(TypeInfo(CaragtQuery_CxwlSoap),ioDocument );//就是这一行 except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; procedure Tfrm_op_ctn.getwebservice_yzh; begin try mHttpRIO_yzh:=THTTPRIO.Create(nil); mHttpRIO_yzh.WSDLLocation:='http://222.173.95.186:78/selectservice/Service.asmx?WSDL'; mHttpRIO_yzh.URL:='http://222.173.95.186:78/selectservice/Service.asmx'; mHttpRIO_yzh.Port:='ServiceSoap'; mHttpRIO_yzh.Service:='WebService'; mHttpRIO_yzh.HTTPWebNode.UseUTF8InHeader:=true; mServiceSoap_yzh:=mHttpRIO_yzh as ServiceSoap; InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap),ioDocument );//就是这一行 { mHttpRIO_yzh:=THTTPRIO.Create(nil); mHttpRIO_yzh.WSDLLocation:='http://www.eimskipdepot.com:78/Service.asmx?WSDL'; mHttpRIO_yzh.URL:='http://www.eimskipdepot.com:78/Service.asmx'; mHttpRIO_yzh.Port:='ServiceSoap'; mHttpRIO_yzh.Service:='WebService'; mHttpRIO_yzh.HTTPWebNode.UseUTF8InHeader:=true; mServiceSoap_yzh:=mHttpRIO_yzh as ServiceSoap; InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap),ioDocument );//就是这一行 } except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; procedure Tfrm_op_ctn.getwebservice_zh; begin try mHttpRIO_zh:=THTTPRIO.Create(nil); mHttpRIO_zh.WSDLLocation:='http://221.215.94.251:8002/service.asmx?WSDL'; mHttpRIO_zh.URL:='http://221.215.94.251:8002/service.asmx'; mHttpRIO_zh.Port:='ServiceSoapzh'; mHttpRIO_zh.Service:='WebServicezh'; mHttpRIO_zh.HTTPWebNode.UseUTF8InHeader:=true; mServiceSoap_zh:=mHttpRIO_zh as ServiceSoapzh; InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoapzh),ioDocument );//就是这一行 except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; procedure Tfrm_op_ctn.dewebservice; begin mHttpRIO_dy.Free; end; procedure Tfrm_op_ctn.GetdyczInfo_dy(s_caragt,s_key,s_billno,bsno:String); var b:Boolean; s_web: WideString; xmldoc:IXMLDocument; cds:TClientDataSet; XMLTransformProvider1:TXMLTransformProvider; s_ctnno,s_ctnType:string; begin try t_op_ctn.DisableControls; getwebservice_dy; cds:=TClientDataSet.Create(nil); XMLTransformProvider1:=TXMLTransformProvider.Create(NIL); // s_billno:='HLCUTA1130371756'; //QDJY000476 cds.Active:=false; xmldoc:=NewXMLDocument; xmldoc.Encoding:='UTF-8'; s_web:=mServiceSoap_dy.GetCtnChargeXml(s_caragt,s_key,s_billno,'','1'); xmldoc.LoadFromXML(s_web); xmldoc.SaveToFile('c:\提箱.xml'); XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\大亚场站\提箱.xtr'; // XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'\大亚场站\提箱.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; with cds do begin First; while not Eof do begin if t_op_ctn.Locate('箱号',Trim(FieldByName('CTNNO').AsString),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(FieldByName('CTNSZ').AsString); s_ctnType:=Trim(FieldByName('CTNTP').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('发箱日期').AsString:=StringReplace(Copy(FieldByName('EMFUEDT').AsString,1,Pos('.',FieldByName('EMFUEDT').AsString)-1),'T',' ',[]); if FindField('SEALNO')<>nil then t_op_ctn.FieldByName('封号').AsString:=FieldByName('SEALNO').AsString; t_op_ctn.Post; end else begin t_op_ctn.append; s_ctnno:=Trim(FieldByName('CTNSZ').AsString); s_ctnType:=Trim(FieldByName('CTNTP').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=Trim(FieldByName('CTNNO').AsString); t_op_ctn.FieldByName('发箱日期').AsString:=StringReplace(Copy(FieldByName('EMFUEDT').AsString,1,Pos('.',FieldByName('EMFUEDT').AsString)-1),'T',' ',[]); if FindField('SEALNO')<>nil then t_op_ctn.FieldByName('封号').AsString:=FieldByName('SEALNO').AsString; { t_op_ctn.FieldByName('封号').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value); t_op_ctn.FieldByName('件数').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,6].Value); t_op_ctn.FieldByName('包装').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,7].Value); t_op_ctn.FieldByName('重量').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,8].Value); t_op_ctn.FieldByName('尺码').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,9].Value); } t_op_ctn.Post; end; Next; end; end; s_web:=mServiceSoap_dy.GetBackFCtnInfoXml(s_caragt,s_key,s_billno,'','1'); xmldoc.LoadFromXML(s_web); xmldoc.SaveToFile('c:\重箱返场.xml'); XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\大亚场站\重箱返场.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; with cds do begin First; while not Eof do begin if t_op_ctn.Locate('箱号',Trim(FieldByName('CTNNO').AsString),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(FieldByName('CTNSZ').AsString); s_ctnType:=Trim(FieldByName('CTNTP').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('封号').AsString:=FieldByName('SEALNO').AsString; t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('PKGS').AsInteger; t_op_ctn.FieldByName('包装').AsString:=''; t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('ALKWGT').AsFloat; t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('ALCUBAGE').AsFloat; t_op_ctn.Post; end else begin t_op_ctn.append; s_ctnno:=Trim(FieldByName('CTNSZ').AsString); s_ctnType:=Trim(FieldByName('CTNTP').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('封号').AsString:=FieldByName('SEALNO').AsString; t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('PKGS').AsInteger; t_op_ctn.FieldByName('包装').AsString:=''; t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('ALKWGT').AsFloat; t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('ALCUBAGE').AsFloat; t_op_ctn.Post; end; Next; end; end; // 包装 s_web:=mServiceSoap_dy.GetLoadCargoInfoXml(s_caragt,s_key,s_billno,'','1'); xmldoc.LoadFromXML(s_web); xmldoc.SaveToFile('c:\包装.xml'); XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\大亚场站\包装.xtr'; // XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'\大亚场站\包装.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; if not cds.IsEmpty then begin try with t_op_ctn do begin First; while not Eof do begin Edit; FieldByName('包装').AsString:=cds.FieldByName('PKTP').AsString; Post; Next; end; end; finally end; end; { s_web:=mServiceSoap_dy.GetEnterPortInfoXml(s_caragt,s_key,s_billno,'','1'); xmldoc.LoadFromXML(s_web); /// xmldoc.SaveToFile('c:\集港.xml'); XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'\大亚场站\集港.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; cds.Close; cds.ProviderName:='XMLTransformProvider1'; cds.Data:=XMLTransformProvider1.Data; cds.Active:=True; // ShowMessage(IntToStr(cds.RecordCount)); s_web:=mServiceSoap_dy.GetCusediInfoXml(s_caragt,s_key,s_billno); xmldoc.LoadFromXML(s_web); /// xmldoc.SaveToFile('c:\放行.xml'); XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'\大亚场站\放行.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; BoolToStr(mServiceSoap_dy.GetBillInfo(s_caragt,s_key,s_billno),True); } finally // dewebservice; t_op_ctn.EnableControls; // ShowMessage('导入完成,请仔细核对箱数,手工录入的集装箱可以删除'); end; end; procedure Tfrm_op_ctn.getmjczinfor(mblno:string);//qqctu获取运抵报告和报关信息 var sl,sl_data:tstringlist; IdHTTP1:TidHTTP; i,j,k,m,n:integer; istrue,QQCT,inmsg:boolean; sldata:Array [1..13] of string[50]; s,s_ctnno,s_ctnType:widestring; ss: TStringStream; begin sl:=tstringlist.Create; sl_data:=tstringlist.Create; IdHTTP1 := TidHTTP.Create(nil); QQCT:=false; istrue:=true; for i:=1 to 13 do begin sldata[i]:=''; end; n:=0; try istrue:=true; inmsg:=false; ss := TStringStream.Create(''); try IdHTTP1.Get('http://www.gfqd.com.cn/qdmj.asp?bl='+mblno, ss); sl_data.text := ss.DataString; finally ss.Free; end; j:=0; for i:=0 to sl_data.Count-1 do begin // s:=Trim(UTF8Decode(sl_data[i])); s:=Trim(sl_data[i]); if Trim(sl_data[i])<>'' then if pos('',sl_data[i])>0 then begin s:=Copy(s,Pos('',s)+16,Length(s)-1); s:=StringReplace(s,'/tr>','/tr>'+#13#10,[rfReplaceAll]); n:=1; sl.text:=s; end; end; // ShowMessage(sl.text); for i:=0 to sl.Count-1 do begin if pos('',sl[i])>0 then begin istrue:=false; Exit; end; if pos('箱号',sl[i])>0 then begin j:=i; end; if istrue and (i=j) then begin sldata[1]:=twsou('<箱号>','',sl[i]); end; if istrue and (i=j+1) then begin sldata[2]:=twsou('<尺寸>','',sl[i]); end; if istrue and (i=j+2) then begin sldata[3]:=twsou('<箱型>','',sl[i]); end; if istrue and (i=j+3) then begin sldata[4]:=twsou('<车号>','',sl[i]); end; if istrue and (i=j+4) then begin sldata[5]:=twsou('<背箱时间>','',sl[i]); end; if istrue and (i=j+5) then begin sldata[6]:=twsou('<皮重>','',sl[i]); end; if istrue and (i=j+6) then begin sldata[7]:=twsou('<件数>','',sl[i]); end; if istrue and (i=j+7) then begin sldata[8]:=twsou('<重量>','',sl[i]); end; if istrue and (i=j+8) then begin sldata[9]:=twsou('<尺码>','',sl[i]); end; if istrue and (i=j+9) then begin sldata[10]:=twsou('<铅封号>','',sl[i]); end; if istrue and (i=j+10) then begin sldata[11]:=twsou('<集港时间>','',sl[i]); if t_op_ctn.Locate('箱号',Trim(sldata[1]),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(sldata[2]); s_ctnType:=Trim(sldata[3]); if s_ctnType='HQ' then s_ctnType:='HC'; //ShowMessage(s_ctnType); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=sldata[1]; t_op_ctn.FieldByName('封号').AsString:=sldata[10]; if sldata[7]<>'' then t_op_ctn.FieldByName('件数').AsInteger:=StrToInt(sldata[7]); t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; if sldata[8]<>'' then t_op_ctn.FieldByName('重量').AsFloat:=StrToFloat(sldata[8]); if sldata[9]<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloat(sldata[9]); t_op_ctn.Post; end else begin t_op_ctn.Append; s_ctnno:=Trim(sldata[2]); s_ctnType:=Trim(sldata[3]); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=sldata[1]; t_op_ctn.FieldByName('封号').AsString:=sldata[10]; if sldata[7]<>'' then t_op_ctn.FieldByName('件数').AsInteger:=StrToInt(sldata[7]); t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; if sldata[8]<>'' then t_op_ctn.FieldByName('重量').AsFloat:=StrToFloat(sldata[8]); if sldata[9]<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloat(sldata[9]); t_op_ctn.Post; end; end; end; finally freeandnil(sl); end; end; procedure Tfrm_op_ctn.getssczinfor(mblno:string);//qqctu获取运抵报告和报关信息 var sl,sl_data:tstringlist; IdHTTP1:TidHTTP; i,j,k,m,n:integer; istrue,QQCT,inmsg:boolean; sldata:Array [1..13] of string[50]; s,s_ctnno,s_ctnType:widestring; ss: TStringStream; begin sl:=tstringlist.Create; sl_data:=tstringlist.Create; IdHTTP1 := TidHTTP.Create(nil); // ContentType:='us-ascii'; // CharSet:='GB2312'; { IdHTTP1.HandleRedirects:=true; IDHTTP1.Request.ContentType:='us-ascii'; IDHTTP1.Request.Charset:='UTF-8'; } { IdHTTP1.ProtocolVersion:=pv1_1; //IdHTTP.HTTPOptions:=IdHTTP1.HTTPOptions+[hoTreat302Like303]; IdHTTP1.Request.Accept:='text/html, application/xhtml+xml, */*'; IdHTTP1.Request.UserAgent:='Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko'; IdHTTP1.Request.AcceptEncoding:='gzip, deflate'; IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded'; IdHTTP1.HTTPOptions:= [hoInProcessAuth,hoKeepOrigProtocol,hoForceEncodeParams]; IDHTTP1.Request.Charset:='UTF-8'; } QQCT:=false; istrue:=true; for i:=1 to 13 do begin sldata[i]:=''; end; n:=0; try istrue:=true; inmsg:=false; ss := TStringStream.Create(''); try IdHTTP1.Get('http://www.ssqd.cn/agentui.aspx?bl='+mblno, ss); sl_data.text := ss.DataString; finally ss.Free; end; // sl_data.text:=Trim(idhttp1.get('http://www.ssqd.cn/agentui.aspx?bl='+mblno)); j:=0; for i:=0 to sl_data.Count-1 do begin // s:=Trim(sl_data[i]); // s:=Trim(Utf8ToAnsi(sl_data[i])); s:=Trim(UTF8Decode(sl_data[i])); if Trim(sl_data[i])<>'' then if pos('',sl_data[i])>0 then begin s:=Copy(s,Pos('',s)+16,Length(s)-1); s:=StringReplace(s,'/tr>','/tr>'+#13#10,[rfReplaceAll]); n:=1; sl.text:=s; end; end; // ShowMessage(sl.text); for i:=0 to sl.Count-1 do begin if pos('',sl[i])>0 then begin istrue:=false; Exit; end; if pos('箱号',sl[i])>0 then begin j:=i; end; if istrue and (i=j) then begin sldata[1]:=twsou('<箱号>','',sl[i]); end; if istrue and (i=j+1) then begin sldata[2]:=twsou('<尺寸>','',sl[i]); end; if istrue and (i=j+2) then begin sldata[3]:=twsou('<箱型>','',sl[i]); end; if istrue and (i=j+3) then begin sldata[4]:=twsou('<车号>','',sl[i]); end; if istrue and (i=j+4) then begin sldata[5]:=twsou('<背箱时间>','',sl[i]); end; if istrue and (i=j+5) then begin sldata[6]:=twsou('<皮重>','',sl[i]); end; if istrue and (i=j+6) then begin sldata[7]:=twsou('<总件数>','',sl[i]); end; if istrue and (i=j+7) then begin sldata[8]:=twsou('<重量>','',sl[i]); end; if istrue and (i=j+8) then begin sldata[9]:=twsou('<总尺码>','',sl[i]); end; if istrue and (i=j+9) then begin sldata[10]:=twsou('<铅封号>','',sl[i]); end; if istrue and (i=j+10) then begin sldata[11]:=twsou('<集港时间>','',sl[i]); if t_op_ctn.Locate('箱号',Trim(sldata[1]),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(sldata[2]); s_ctnType:=Trim(sldata[3]); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=sldata[1]; t_op_ctn.FieldByName('封号').AsString:=sldata[10]; if sldata[7]<>'' then t_op_ctn.FieldByName('件数').AsInteger:=StrToInt(sldata[7]); t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; if sldata[8]<>'' then t_op_ctn.FieldByName('重量').AsFloat:=StrToFloat(sldata[8]); if sldata[9]<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloat(sldata[9]); t_op_ctn.Post; end else begin t_op_ctn.Append; s_ctnno:=Trim(sldata[2]); s_ctnType:=Trim(sldata[3]); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=sldata[1]; t_op_ctn.FieldByName('封号').AsString:=sldata[10]; if sldata[7]<>'' then t_op_ctn.FieldByName('件数').AsInteger:=StrToInt(sldata[7]); t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; if sldata[8]<>'' then t_op_ctn.FieldByName('重量').AsFloat:=StrToFloat(sldata[8]); if sldata[9]<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloat(sldata[9]); t_op_ctn.Post; end; end; end; finally freeandnil(sl); end; end; /////20140923 dengyu function Tfrm_op_ctn.SaveCTNINFO(s_caragt, s_key, s_billno, bsno: String; _CTNINFO: TContainerINFO):boolean; var _i,j,k,m,n:integer; _Body:TStringList; ctn_no,ctn_Type,ctn_Size:string; GoodWeight:double; begin Result:=false; with t_op_ctn do try DisableControls; First; while not eof do begin t_op_ctn.Edit; t_op_ctn.FieldByName('件数').AsInteger:=0; t_op_ctn.FieldByName('重量').AsFloat:=0; t_op_ctn.FieldByName('尺码').AsFloat:=0; t_op_ctn.Post; Next; end; finally EnableControls; First; end; _Body:=TStringList.create(); for _i:=0 to _Ctninfo.body.count-1 do begin _Body:=TStringList.create(); _Body.clear; _Body.Assign(_CTNINFO.Body[_i]); ctn_no:=_Body[_CTNINFO.ctn_no]; ctn_Type:=_CTNINFO.GetINFO('箱型',_i); ctn_Size:=_CTNINFO.GetINFO('尺寸',_i); if t_op_ctn.Locate('箱号',trim(ctn_no),[]) then begin t_op_ctn.Edit; if _CTNINFO.GetINFO('件数',_i)<>'' then t_op_ctn.FieldByName('件数').AsInteger:=t_op_ctn.FieldByName('件数').AsInteger+StrToInt(_CTNINFO.GetINFO('件数',_i)); t_op_ctn.FieldByName('包装').AsString:=_CTNINFO.GetINFO('包装',_i); if (_CTNINFO.GetINFO('封号',_i)<>'') then t_op_ctn.FieldByName('封号').AsString:=_CTNINFO.GetINFO('封号',_i); if (_CTNINFO.GetINFO('货重',_i)<>'') or (_CTNINFO.GetINFO('实装重量',_i)<>'') then begin if (_CTNINFO.GetINFO('货重',_i)<>'') then GoodWeight:=StrToFloat(_CTNINFO.GetINFO('货重',_i)); if (_CTNINFO.GetINFO('实装重量',_i)<>'') then GoodWeight:=StrToFloat(_CTNINFO.GetINFO('实装重量',_i)); t_op_ctn.FieldByName('重量').AsFloat:=t_op_ctn.FieldByName('重量').AsFloat+GoodWeight; end; if _CTNINFO.GetINFO('体积',_i)<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=t_op_ctn.FieldByName('尺码').AsFloat+StrToFloat(_CTNINFO.GetINFO('体积',_i)) else if _CTNINFO.GetINFO('尺码',_i)<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=t_op_ctn.FieldByName('尺码').AsFloat+StrToFloat(_CTNINFO.GetINFO('尺码',_i)); t_op_ctn.Post; end else begin t_op_ctn.Append; if (_CTNINFO.GetINFO('尺寸箱型',_i)<>'') then begin end else begin t_op_ctn.FieldByName('尺寸').AsString:=ctn_Size; t_op_ctn.FieldByName('箱型').AsString:=ctn_Type; end; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(ctn_Size),trim(ctn_Type)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=ctn_no; if (_CTNINFO.GetINFO('封号',_i)<>'') then t_op_ctn.FieldByName('封号').AsString:=_CTNINFO.GetINFO('封号',_i) else if (_CTNINFO.GetINFO('铅封',_i)<>'') then t_op_ctn.FieldByName('封号').AsString:=_CTNINFO.GetINFO('铅封',_i); if _CTNINFO.GetINFO('件数',_i)<>'' then t_op_ctn.FieldByName('件数').AsInteger:=StrToInt(_CTNINFO.GetINFO('件数',_i)); t_op_ctn.FieldByName('包装').AsString:=_CTNINFO.GetINFO('包装',_i); if (_CTNINFO.GetINFO('货重',_i)<>'') or (_CTNINFO.GetINFO('实装重量',_i)<>'') then begin if (_CTNINFO.GetINFO('货重',_i)<>'') then GoodWeight:=StrToFloat(_CTNINFO.GetINFO('货重',_i)); if (_CTNINFO.GetINFO('实装重量',_i)<>'') then GoodWeight:=StrToFloat(_CTNINFO.GetINFO('实装重量',_i)); t_op_ctn.FieldByName('重量').AsFloat:=t_op_ctn.FieldByName('重量').AsFloat+GoodWeight; end; if _CTNINFO.GetINFO('体积',_i)<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloat(_CTNINFO.GetINFO('体积',_i)) else if _CTNINFO.GetINFO('尺码',_i)<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloat(_CTNINFO.GetINFO('尺码',_i)); t_op_ctn.Post; end; if trim(ctn_no)<>'' then begin Result:=true; end; end; end; { procedure Tfrm_op_ctn.getssczinfor(mblno:string);//qqctu获取运抵报告和报关信息 var sl:tstringlist; IdHTTP1:TidHTTP; i,j,k,m,n:integer; istrue,QQCT,inmsg:boolean; sldata:Array [1..13] of string[50]; s,s_ctnno,s_ctnType:widestring; begin sl:=tstringlist.Create; IdHTTP1 := TidHTTP.Create(nil); IdHTTP1.HandleRedirects:=true; QQCT:=false; istrue:=true; for i:=1 to 13 do begin sldata[i]:=''; end; n:=0; try istrue:=true; inmsg:=false; sl.text:=idhttp1.get('http://www.ssqd.cn/agentui.aspx?bl='+mblno); j:=0; for i:=0 to sl.Count-1 do begin s:=Utf8ToAnsi(sl[i]); if pos('',sl[i])>0 then begin s:=Copy(s,Pos('',s)+16,Length(s)-1); s:=StringReplace(s,'/tr>','/tr>'+#13#10,[rfReplaceAll]); n:=1; sl.text:=s; end; end; for i:=0 to sl.Count-1 do begin if pos('',sl[i])>0 then begin istrue:=false; Exit; end; if pos('箱号',sl[i])>0 then begin j:=i; end; if istrue and (i=j) then begin sldata[1]:=twsou('<箱号>','',sl[i]); end; if istrue and (i=j+1) then begin sldata[2]:=twsou('<尺寸>','',sl[i]); end; if istrue and (i=j+2) then begin sldata[3]:=twsou('<箱型>','',sl[i]); end; if istrue and (i=j+3) then begin sldata[4]:=twsou('<车号>','',sl[i]); end; if istrue and (i=j+4) then begin sldata[5]:=twsou('<背箱时间>','',sl[i]); end; if istrue and (i=j+5) then begin sldata[6]:=twsou('<皮重>','',sl[i]); end; if istrue and (i=j+6) then begin sldata[7]:=twsou('<总件数>','',sl[i]); end; if istrue and (i=j+7) then begin sldata[8]:=twsou('<重量>','',sl[i]); end; if istrue and (i=j+8) then begin sldata[9]:=twsou('<总尺码>','',sl[i]); end; if istrue and (i=j+9) then begin sldata[10]:=twsou('<铅封号>','',sl[i]); end; if istrue and (i=j+10) then begin sldata[11]:=twsou('<集港时间>','',sl[i]); if t_op_ctn.Locate('箱号',Trim(sldata[1]),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(sldata[2]); s_ctnType:=Trim(sldata[3]); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=sldata[1]; t_op_ctn.FieldByName('封号').AsString:=sldata[10]; if sldata[7]<>'' then t_op_ctn.FieldByName('件数').AsInteger:=StrToInt(sldata[7]); t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; if sldata[8]<>'' then t_op_ctn.FieldByName('重量').AsFloat:=StrToFloat(sldata[8]); if sldata[9]<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloat(sldata[9]); t_op_ctn.Post; end else begin t_op_ctn.Append; s_ctnno:=Trim(sldata[2]); s_ctnType:=Trim(sldata[3]); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=sldata[1]; t_op_ctn.FieldByName('封号').AsString:=sldata[10]; if sldata[7]<>'' then t_op_ctn.FieldByName('件数').AsInteger:=StrToInt(sldata[7]); t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; if sldata[8]<>'' then t_op_ctn.FieldByName('重量').AsFloat:=StrToFloat(sldata[8]); if sldata[9]<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloat(sldata[9]); t_op_ctn.Post; end; end; end; finally freeandnil(sl); end; end; } procedure Tfrm_op_ctn.GetdyczInfo_zc(s_caragt,s_key,s_billno,bsno:String); var b:Boolean; s_web: WideString; xmldoc:IXMLDocument; cds:TClientDataSet; XMLTransformProvider1:TXMLTransformProvider; s_ctnno,s_ctnType:string; begin try t_op_ctn.DisableControls; if trim(s_caragt)='' then getwebservice_zc else if trim(s_caragt)='利昂' then getwebservice_zc_la else getwebservice_zc_lw; cds:=TClientDataSet.Create(nil); XMLTransformProvider1:=TXMLTransformProvider.Create(NIL); // s_billno:='HLCUTA1130371756'; //QDJY000476 cds.Active:=false; xmldoc:=NewXMLDocument; xmldoc.Encoding:='UTF-8'; s_web:=mServiceSoap_zc.GetInfo(s_billno,s_key); //83891620 薄帅 xmldoc.LoadFromXML(s_web); xmldoc.SaveToFile('c:\提箱.xml'); //ShowMessage('\\'+dbserver+'\中创场站\集装箱信息.xtr'); XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\中创场站\集装箱信息.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; with cds do begin First; while not Eof do begin if t_op_ctn.Locate('箱号',Trim(FieldByName('箱号').AsString),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(FieldByName('尺寸').AsString); s_ctnType:=Trim(FieldByName('箱型').AsString); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('封号').AsString:=FieldByName('铅封号').AsString; t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('总件数').AsInteger; t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('重量').AsFloat; t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('总尺码').AsFloat; t_op_ctn.Post; end else begin t_op_ctn.append; s_ctnno:=Trim(FieldByName('尺寸').AsString); s_ctnType:=Trim(FieldByName('箱型').AsString); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=FieldByName('箱号').AsString; t_op_ctn.FieldByName('封号').AsString:=FieldByName('铅封号').AsString; t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('总件数').AsInteger; t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('重量').AsFloat; t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('总尺码').AsFloat; t_op_ctn.Post; end; Next; end; end; { s_web:=mServiceSoap_yzh.P_GETDATA(s_billno,'FX');; xmldoc.LoadFromXML(s_web); // xmldoc.SaveToFile('c:\集装箱信息.xml'); XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'\怡之航场站\放行.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; } finally // dewebservice; t_op_ctn.EnableControls; end; end; procedure Tfrm_op_ctn.GetdyczInfo_zh(s_caragt,s_key,s_billno,bsno:String); //振华 var b:Boolean; s_web: WideString; xmldoc:IXMLDocument; cds:TClientDataSet; XMLTransformProvider1:TXMLTransformProvider; s_ctnno,s_ctnType:string; sl:tstringlist; i:integer; begin try t_op_ctn.DisableControls; getwebservice_zh; cds:=TClientDataSet.Create(nil); XMLTransformProvider1:=TXMLTransformProvider.Create(NIL); // s_billno:='HLCUTA1130371756'; //QDJY000476 cds.Active:=false; xmldoc:=NewXMLDocument; xmldoc.Encoding:='UTF-8'; s_web:=mServiceSoap_zh.GetReturnDataXml(s_caragt,s_key,s_billno); xmldoc.LoadFromXML(s_web); xmldoc.SaveToFile('c:\集装箱信息.xml'); if FileExists(ExtractFilePath(Application.ExeName)+'振华场站\振华集装箱信息.xtr') then begin XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'振华场站\振华集装箱信息.xtr'; end else begin CreateDirectory(pChar(ExtractFilePath(Application.ExeName)+'振华场站'),nil); CopyFile(pChar('\\'+dbserver+'\振华场站\振华集装箱信息.xtr'),pChar(ExtractFilePath(Application.ExeName)+'振华场站\振华集装箱信息.xtr'),True); XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'振华场站\振华集装箱信息.xtr'; end; // XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\振华场站\振华集装箱信息.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; with cds do begin First; while not Eof do begin if t_op_ctn.Locate('箱号',Trim(FieldByName('箱号').AsString),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(FieldByName('箱尺寸').AsString); s_ctnType:=Trim(FieldByName('箱型').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('封号').AsString:=FieldByName('铅封号').AsString; if FieldByName('总件数').AsString<>'' then t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('总件数').AsInteger; t_op_ctn.FieldByName('包装').AsString:=''; if FieldByName('总重量').AsString<>'' then t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('总重量').AsFloat; if FieldByName('总尺码').AsString<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('总尺码').AsFloat; t_op_ctn.Post; end else begin t_op_ctn.append; s_ctnno:=Trim(FieldByName('箱尺寸').AsString); s_ctnType:=Trim(FieldByName('箱型').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=FieldByName('箱号').AsString; t_op_ctn.FieldByName('封号').AsString:=FieldByName('铅封号').AsString; if FieldByName('总件数').AsString<>'' then t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('总件数').AsInteger; t_op_ctn.FieldByName('包装').AsString:=''; if FieldByName('总重量').AsString<>'' then t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('总重量').AsFloat; if FieldByName('总尺码').AsString<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('总尺码').AsFloat; t_op_ctn.Post; end; Next; end; end; finally t_op_ctn.EnableControls; end; end; procedure Tfrm_op_ctn.GetdyczInfo_yzh(s_caragt,s_key,s_billno,bsno:String); var b:Boolean; s_web: WideString; xmldoc:IXMLDocument; cds:TClientDataSet; XMLTransformProvider1:TXMLTransformProvider; s_ctnno,s_ctnType:string; begin try t_op_ctn.DisableControls; getwebservice_yzh; cds:=TClientDataSet.Create(nil); XMLTransformProvider1:=TXMLTransformProvider.Create(NIL); // s_billno:='HLCUTA1130371756'; //QDJY000476 cds.Active:=false; xmldoc:=NewXMLDocument; xmldoc.Encoding:='UTF-8'; s_web:=mServiceSoap_yzh.P_GETDATA(s_billno,'YT'); // ShowMessage(s_web); xmldoc.LoadFromXML(s_web); xmldoc.SaveToFile('c:\集装箱信息.xml'); XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\怡之航场站\集装箱信息.xtr'; // XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'\怡之航场站\集装箱信息.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; with cds do begin First; while not Eof do begin if t_op_ctn.Locate('箱号',Trim(FieldByName('箱号').AsString),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(FieldByName('尺寸').AsString); s_ctnType:=Trim(FieldByName('箱型').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('封号').AsString:=FieldByName('铅封号').AsString; if FieldByName('总件数').AsString<>'' then t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('总件数').AsInteger; t_op_ctn.FieldByName('包装').AsString:=''; if FieldByName('重量').AsString<>'' then t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('重量').AsFloat; if FieldByName('总尺码').AsString<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('总尺码').AsFloat; t_op_ctn.Post; end else begin t_op_ctn.append; s_ctnno:=Trim(FieldByName('尺寸').AsString); s_ctnType:=Trim(FieldByName('箱型').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=FieldByName('箱号').AsString; t_op_ctn.FieldByName('封号').AsString:=FieldByName('铅封号').AsString; if FieldByName('总件数').AsString<>'' then t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('总件数').AsInteger; t_op_ctn.FieldByName('包装').AsString:=''; if FieldByName('重量').AsString<>'' then t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('重量').AsFloat; if FieldByName('总尺码').AsString<>'' then t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('总尺码').AsFloat; t_op_ctn.Post; end; Next; end; end; { s_web:=mServiceSoap_yzh.P_GETDATA(s_billno,'FX');; xmldoc.LoadFromXML(s_web); // xmldoc.SaveToFile('c:\集装箱信息.xml'); XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'\怡之航场站\放行.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; } finally // dewebservice; t_op_ctn.EnableControls; end; end; procedure Tfrm_op_ctn.GetdyczInfo_lhcz(s_caragt,s_key,s_billno,bsno:String); var testService:myServicePortType; strmsg:string; s_web: WideString; xmldoc:IXMLDocument; cds:TClientDataSet; XMLTransformProvider1:TXMLTransformProvider; s_ctnno,s_ctnType:string; begin testService:=GetmyServicePortType(false,'http://221.215.96.158:8190/WebServiceTest/services/myService?wsdl',nil); // testService:=GetmyServicePortType(false,'http://www.lhl.cn:8190/WebServiceTest/services/myService?wsdl',nil); try t_op_ctn.DisableControls; cds:=TClientDataSet.Create(nil); XMLTransformProvider1:=TXMLTransformProvider.Create(NIL); cds.Active:=false; xmldoc:=NewXMLDocument; xmldoc.Encoding:='UTF-8'; s_web:=testService.CntrMess(s_billno) ; // ShowMessage(s_web); xmldoc.LoadFromXML(s_web); xmldoc.SaveToFile('c:\集装箱信息.xml'); //ShowMessage('1'); if FileExists(ExtractFilePath(Application.ExeName)+'陆海场站\集装箱信息.xtr') then begin XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'陆海场站\集装箱信息.xtr'; end else begin CreateDirectory(pChar(ExtractFilePath(Application.ExeName)+'陆海场站'),nil); CopyFile(pChar('\\'+dbserver+'\陆海场站\集装箱信息.xtr'),pChar(ExtractFilePath(Application.ExeName)+'陆海场站\集装箱信息.xtr'),True); XMLTransformProvider1.TransformRead.TransformationFile:=ExtractFilePath(Application.ExeName)+'陆海场站\集装箱信息.xtr'; end; // XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\陆海场站\集装箱信息.xtr'; //ShowMessage('\\'+dbserver+'\陆海场站\重箱返场.xtr'); XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; // ShowMessage('3'); cds.Data:=XMLTransformProvider1.Data; // ShowMessage('4'); cds.Active:=true; with cds do begin First; while not Eof do begin if t_op_ctn.Locate('箱号',Trim(FieldByName('CTNNO').AsString),[]) then begin t_op_ctn.Edit; s_ctnno:=Trim(FieldByName('CTNSZ').AsString); s_ctnType:=Trim(FieldByName('CTNTP').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('封号').AsString:=FieldByName('SEALNO').AsString; if FieldByName('PKGS').Value<>'null' then t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('PKGS').AsInteger; t_op_ctn.FieldByName('包装').AsString:=FieldByName('PKTP').AsString; if FieldByName('ALKWGT').Value<>'null' then t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('ALKWGT').AsFloat; if FieldByName('ALCUBAGE').Value<>'null' then t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('ALCUBAGE').AsFloat; t_op_ctn.Post; end else begin t_op_ctn.append; s_ctnno:=Trim(FieldByName('CTNSZ').AsString); s_ctnType:=Trim(FieldByName('CTNTP').AsString); if s_ctnType='HQ' then s_ctnType:='HC'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=Trim(FieldByName('CTNNO').AsString); t_op_ctn.FieldByName('封号').AsString:=FieldByName('SEALNO').AsString; if FieldByName('PKGS').Value<>'null' then t_op_ctn.FieldByName('件数').AsInteger:=FieldByName('PKGS').AsInteger; t_op_ctn.FieldByName('包装').AsString:=FieldByName('PKTP').AsString; if FieldByName('ALKWGT').Value<>'null' then t_op_ctn.FieldByName('重量').AsFloat:=FieldByName('ALKWGT').AsFloat; if FieldByName('ALCUBAGE').Value<>'null' then t_op_ctn.FieldByName('尺码').AsFloat:=FieldByName('ALCUBAGE').AsFloat; t_op_ctn.Post; end; Next; end; end; finally t_op_ctn.EnableControls; end; end; procedure Tfrm_op_ctn.t_op_ctnAfterInsert(DataSet: TDataSet); begin t_op_ctn['编号']:=t_op_ctn.DataSource.DataSet['编号']; t_op_ctn['数量']:=1; t_op_ctn['代码']:='01'; t_op_ctn['称重方式']:='累加'; end; procedure Tfrm_op_ctn.t_op_ctnBeforePost(DataSet: TDataSet); var cntrs:string; begin if frm_data_share.t_code_ctn.Locate('代码',t_op_ctn.fieldbyname('代码').asstring,[]) then begin t_op_ctn['表现形式']:=frm_data_share.t_code_ctn['表现形式']; t_op_ctn['箱型']:=frm_data_share.t_code_ctn['箱型']; t_op_ctn['尺寸']:=frm_data_share.t_code_ctn['尺寸']; if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='10'then t_op_ctn['TEU']:=0.5*t_op_ctn.FieldByName('数量').asFloat; if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn['TEU']:=1*t_op_ctn.FieldByName('数量').asinteger; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45')then t_op_ctn['TEU']:=2*t_op_ctn.FieldByName('数量').asinteger; end else begin t_op_ctn['代码']:=''; t_op_ctn['表现形式']:=''; t_op_ctn['箱型']:=''; t_op_ctn['尺寸']:=''; end; cntrs:=t_op_ctn.fieldbyname('箱号').asstring; if cntrs<>'' then if ((GetStrNum(cntrs))<>7) or ((GetcharNum(cntrs))<>4) then begin MessageDlg('集装箱箱号不正确!:格式为:ABCU1234567',mtWarning,[mbOk],0); abort; end; if op_ctn_limited='0002'then begin if (not t_op_ctn.FieldByName('发箱日期').IsNull) and (not t_op_ctn.FieldByName('卸箱时间').IsNull) then begin if (daysBetween(t_op_ctn.FieldByName('发箱日期').Value,t_op_ctn.FieldByName('卸箱时间').Value)-t_op_ctn.FieldByName('免堆天数').Value)>0 then t_op_ctn.FieldByName('实际堆存天数').Value:=daysBetween(t_op_ctn.FieldByName('发箱日期').Value,t_op_ctn.FieldByName('卸箱时间').Value)+1-t_op_ctn.FieldByName('免堆天数').Value else t_op_ctn.FieldByName('实际堆存天数').Value:=0; t_op_ctn.FieldByName('实际堆存费').Value:=t_op_ctn.FieldByName('实际堆存天数').Value*t_op_ctn.FieldByName('堆存费标准').Value; end; if (not t_op_ctn.DataSource.DataSet.FieldByName('进口日期').IsNull) and (not t_op_ctn.FieldByName('回箱日期').IsNull) then begin if (daysBetween(t_op_ctn.DataSource.DataSet.FieldByName('进口日期').Value,t_op_ctn.FieldByName('回箱日期').Value)-t_op_ctn.FieldByName('免箱使天数').Value)>0 then t_op_ctn.FieldByName('实际箱使天数').Value:=daysBetween(t_op_ctn.DataSource.DataSet.FieldByName('进口日期').Value,t_op_ctn.FieldByName('回箱日期').Value)+1-t_op_ctn.FieldByName('免箱使天数').Value else t_op_ctn.FieldByName('实际箱使天数').Value:=0; t_op_ctn.FieldByName('实际箱使费').Value:=t_op_ctn.FieldByName('实际箱使天数').Value*t_op_ctn.FieldByName('箱使费').Value; end; end; table_before_post(t_op_ctn,'代码'); table_before_post(t_op_ctn,'数量'); end; procedure Tfrm_op_ctn.bsSkinButton2Click(Sender: TObject); begin table_post(t_op_ctn); table_post(t_op_ctndetail); end; procedure Tfrm_op_ctn.bsSkinButton4Click(Sender: TObject); var i:integer; str_list:Tstringlist; begin if t_op_ctn.isempty then exit; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)<>IDOK then exit; if wwDBGrid1.SelectedList.Count>=1 then begin try t_op_ctn.DisableControls; str_list:=Tstringlist.create; for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_op_ctn.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); str_list.Add(t_op_ctn.fieldbyname('ctn_ID').asstring); end; for i:=0 to str_list.Count-1 do begin if t_op_ctn.locate('ctn_ID',str_list[i],[]) then begin while not t_op_ctndetail.eof do t_op_ctndetail.delete; t_op_ctn.Delete; end; end; finally str_list.free; t_op_ctn.EnableControls; end; end else begin t_op_ctn.delete; end; t_op_ctn.Refresh; end; procedure Tfrm_op_ctn.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_ctn); end; procedure Tfrm_op_ctn.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_ctn.FormShow(Sender: TObject); var inifile1:Tinifile; FromFileName,ToFileName:string; begin loadwwgrid(frm_op_ctn.wwDBGrid1,'集装箱'); t_op_ctn.open; t_op_ctndetail.Open; { frm_data_share.t_code_tradetype.requery; frm_data_share.t_code_ctn.requery; frm_data_share.t_code_package.requery; frm_data_share.t_crm_client_truck.requery; frm_data_share.t_crm_client_changzhan.requery; } inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); dbserver:=inifile1.ReadString('database','Data Source',''); if pos(';',dbserver)>0 then begin dbserver:=Copy(dbserver,1,Length(dbserver)-1); if pos('\',dbserver)>0 then begin dbserver:=Copy(dbserver,1,pos('\',dbserver)-1); end; end else begin if pos('\',dbserver)>0 then begin dbserver:=Copy(dbserver,1,pos('\',dbserver)-1); end; end; if if_reg(2601) then // jfcz 捷丰场站通信 begin FromFileName:='\\'+dbserver+'\jfcz\midas.dll'; ToFileName:=ExtractFilePath(application.ExeName)+'midas.dll'; if not FileExists(ExtractFilePath(application.ExeName)+'midas.dll') then CopyFile(pChar(FromFileName),pChar(ToFileName),False); end; if if_reg(2602) then // 大亚场站 begin FromFileName:='\\'+dbserver+'\大亚场站\midas.dll'; ToFileName:=ExtractFilePath(application.ExeName)+'midas.dll'; if not FileExists(ExtractFilePath(application.ExeName)+'midas.dll') then CopyFile(pChar(FromFileName),pChar(ToFileName),False); end; if if_reg(2603) then // 怡之航场站 begin FromFileName:='\\'+dbserver+'\怡之航场站\midas.dll'; ToFileName:=ExtractFilePath(application.ExeName)+'midas.dll'; if not FileExists(ExtractFilePath(application.ExeName)+'midas.dll') then CopyFile(pChar(FromFileName),pChar(ToFileName),False); end; bsSkinButton15.Visible:=if_reg(2612); inifile1.free; end; procedure Tfrm_op_ctn.wwDBLookupCombo1Change(Sender: TObject); begin if (t_op_ctn.State=dsedit)or(t_op_ctn.State=dsinsert) then begin if frm_data_share.t_code_ctn.Locate('代码',wwDBLookupCombo1.text,[]) then begin t_op_ctn['表现形式']:=frm_data_share.t_code_ctn['表现形式']; t_op_ctn['箱型']:=frm_data_share.t_code_ctn['箱型']; t_op_ctn['尺寸']:=frm_data_share.t_code_ctn['尺寸']; end else begin t_op_ctn['表现形式']:=''; t_op_ctn['箱型']:=''; t_op_ctn['尺寸']:=''; end; end; end; procedure Tfrm_op_ctn.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin CanClose:=frm_close_query(t_op_ctn); CanClose:=frm_close_query(t_op_ctndetail); end; procedure Tfrm_op_ctn.bsSkinButton6Click(Sender: TObject); var bok:Tbookmark; if_first:boolean; pkgs,as_id:integer; kgs,cbm:double; s,package:string; aQuery,aQueryEmp:TAdoQuery; begin if t_op_ctn.IsEmpty then exit; { if op_ctn_limited='0001'then begin op_befor_post(frm_op_seae.t_op_seae,op_ctn_limited); end else if op_ctn_limited='0003'then begin op_befor_post(frm_op_seai_sf.t_op_seai,op_ctn_limited); end else begin op_befor_post(frm_op_seai.t_op_seai,op_ctn_limited); end; } t_op_ctn.First; if_first:=true; pkgs:=0; kgs:=0.00; cbm:=0.00; bok:=t_op_ctn.GetBookmark; try t_op_ctn.DisableControls; t_op_ctn.DataSource.DataSet.DisableControls; while not t_op_ctn.Eof do begin if strtobool(get_parameters_value(139,'true')) then begin if if_first then begin if (Trim(t_op_ctn.fieldbyname('箱号').asstring)<>'') then // if (Trim(t_op_ctn.fieldbyname('箱号').asstring)<>'') and (Trim(t_op_ctn.fieldbyname('封号').asstring)<>'') then memo1.Lines.Text:=t_op_ctn.fieldbyname('箱号').asstring+'/'+t_op_ctn.fieldbyname('封号').asstring; memo2.Lines.Text:=t_op_ctn.fieldbyname('件数').asstring+t_op_ctn.fieldbyname('包装').asstring; memo3.Lines.Text:=t_op_ctn.fieldbyname('重量').asstring+'KGS'; memo4.Lines.Text:=t_op_ctn.fieldbyname('尺码').asstring+'CBM'; pkgs:=t_op_ctn.fieldbyname('件数').asinteger; kgs:=t_op_ctn.fieldbyname('重量').asfloat; cbm:=t_op_ctn.fieldbyname('尺码').asfloat; package:=t_op_ctn.fieldbyname('包装').asstring; if_first:=false; end else begin if (Trim(t_op_ctn.fieldbyname('箱号').asstring)<>'') then // if (Trim(t_op_ctn.fieldbyname('箱号').asstring)<>'') and (Trim(t_op_ctn.fieldbyname('封号').asstring)<>'') then memo1.Lines.Add(t_op_ctn.fieldbyname('箱号').asstring+'/'+t_op_ctn.fieldbyname('封号').asstring); memo2.Lines.Add(t_op_ctn.fieldbyname('件数').asstring+t_op_ctn.fieldbyname('包装').asstring); memo3.Lines.Add(t_op_ctn.fieldbyname('重量').asstring+'KGS'); memo4.Lines.Add(t_op_ctn.fieldbyname('尺码').asstring+'CBM'); pkgs:=pkgs+t_op_ctn.fieldbyname('件数').asinteger; kgs:=kgs+t_op_ctn.fieldbyname('重量').asfloat; cbm:=cbm+t_op_ctn.fieldbyname('尺码').asfloat; package:=t_op_ctn.fieldbyname('包装').asstring; end; end else begin if if_first then begin memo1.Lines.Text:=t_op_ctn.fieldbyname('箱号').asstring+'/'+t_op_ctn.fieldbyname('封号').asstring+'/'+t_op_ctn.fieldbyname('表现形式').asstring+'/' +t_op_ctn.fieldbyname('件数').asstring+t_op_ctn.fieldbyname('包装').asstring+'/'+t_op_ctn.fieldbyname('重量').asstring+'KGS'+'/'+t_op_ctn.fieldbyname('尺码').asstring+'CBM'; memo2.Lines.Text:=t_op_ctn.fieldbyname('件数').asstring+t_op_ctn.fieldbyname('包装').asstring; memo3.Lines.Text:=t_op_ctn.fieldbyname('重量').asstring+'KGS'; memo4.Lines.Text:=t_op_ctn.fieldbyname('尺码').asstring+'CBM'; pkgs:=t_op_ctn.fieldbyname('件数').asinteger; kgs:=t_op_ctn.fieldbyname('重量').asfloat; cbm:=t_op_ctn.fieldbyname('尺码').asfloat; package:=t_op_ctn.fieldbyname('包装').asstring; if_first:=false; end else begin memo1.Lines.Add(t_op_ctn.fieldbyname('箱号').asstring+'/'+t_op_ctn.fieldbyname('封号').asstring+'/'+t_op_ctn.fieldbyname('表现形式').asstring+'/' +t_op_ctn.fieldbyname('件数').asstring+t_op_ctn.fieldbyname('包装').asstring+'/'+t_op_ctn.fieldbyname('重量').asstring+'KGS'+'/'+t_op_ctn.fieldbyname('尺码').asstring+'CBM' ); memo2.Lines.Add(t_op_ctn.fieldbyname('件数').asstring+t_op_ctn.fieldbyname('包装').asstring); memo3.Lines.Add(t_op_ctn.fieldbyname('重量').asstring+'KGS'); memo4.Lines.Add(t_op_ctn.fieldbyname('尺码').asstring+'CBM'); pkgs:=pkgs+t_op_ctn.fieldbyname('件数').asinteger; kgs:=kgs+t_op_ctn.fieldbyname('重量').asfloat; cbm:=cbm+t_op_ctn.fieldbyname('尺码').asfloat; package:=t_op_ctn.fieldbyname('包装').asstring; end; end; t_op_ctn.next; end; if (FormatFloat('0.0000;-0.0000;0',pkgs)<>FormatFloat('0.0000;-0.0000;0',t_op_ctn.DataSource.DataSet.FieldByName('件数').AsInteger)) or (FormatFloat('0.0000;-0.0000;0',kgs)<>FormatFloat('0.0000;-0.0000;0',t_op_ctn.DataSource.DataSet.FieldByName('重量').AsFloat)) or (FormatFloat('0.0000;-0.0000;0',cbm)<>FormatFloat('0.0000;-0.0000;0',t_op_ctn.DataSource.DataSet.FieldByName('尺码').AsFloat)) or ((Trim(package)<>'') and (Trim(package)<>Trim(t_op_ctn.DataSource.DataSet.fieldbyname('包装').asstring))) then begin if MessageDlg('基本信息的件,重,尺,包装和集装箱信息的件,重,尺,包装不同,是否更新',mtWarning,[mbyes,mbno],0)=mrYes then begin //showmessage(op_ctn_limited+' '+memo3.Lines.Text); if op_ctn_limited='0001'then begin aQuery:=CreateAdoQuery; aQueryEmp:=CreateAdoQuery; try if op_ctn_limited='0001'then begin if assigned(frm_op_seae) then begin frm_op_seae.t_op_seae.BeforePost:=nil; frm_op_seae.t_op_seae.BeforeEdit:=nil; end; end; t_op_ctn.DataSource.DataSet.edit; t_op_ctn.DataSource.DataSet['箱号封号']:=memo1.Lines.Text; t_op_ctn.DataSource.DataSet['件数包装']:=memo2.Lines.Text; t_op_ctn.DataSource.DataSet['货物重量']:=memo3.Lines.Text; t_op_ctn.DataSource.DataSet['货物尺码']:=memo4.Lines.Text; t_op_ctn.DataSource.DataSet['件数']:=pkgs; t_op_ctn.DataSource.DataSet['重量']:=kgs; t_op_ctn.DataSource.DataSet['尺码']:=cbm; t_op_ctn.DataSource.DataSet['包装']:=t_op_ctn.fieldbyname('包装').asstring; t_op_ctn.DataSource.DataSet['件数大写']:='SAY:'+ntoc(pkgs,true)+t_op_ctn.fieldbyname('包装').asstring+' ONLY.'; t_op_ctn.DataSource.DataSet.post; aQuery.close;aQuery.sql.clear; aQuery.sql.Add('select AS_ID from t_op_seae_assistant where 编号='''+t_op_ctn.DataSource.DataSet['编号']+''''); aQuery.open; as_id:=aQuery.fieldbyname('AS_ID').AsInteger; aQuery.Close;aQuery.sql.Clear; aQuery.sql.Add('select * from t_op_ctn_fendan'); aQuery.sql.Add('where as_id=:as_id'); aQuery.Parameters.ParamByName('as_id').Value:=as_id; aQuery.open;aQuery.First; aQuery.close;aQuery.sql.clear; aQuery.sql.Add('select count(AS_ID) as count from t_op_seae_assistant where 编号='''+t_op_ctn.DataSource.DataSet['编号']+''''); aQuery.open; if aQuery.fieldbyname('count').AsInteger=1 then begin aQuery.close;aQuery.sql.clear; aQuery.sql.Add('select * from t_op_seae_assistant where 编号='''+t_op_ctn.DataSource.DataSet['编号']+''''); aQuery.open; aQuery.edit; aQuery['箱号封号']:=memo1.Lines.Text; aQuery['件数包装']:=memo2.Lines.Text; aQuery['货物重量']:=memo3.Lines.Text; aQuery['货物尺码']:=memo4.Lines.Text; aQuery['件数']:=pkgs; aQuery['重量']:=kgs; aQuery['尺码']:=cbm; aQuery['包装']:=t_op_ctn.fieldbyname('包装').asstring; aQuery['件数大写']:='SAY:'+ntoc(pkgs,true)+t_op_ctn.fieldbyname('包装').asstring+' ONLY.'; aQuery.post; aQuery.Close;aQuery.sql.Clear; aQuery.sql.Add('select * from t_op_ctn_fendan'); aQuery.sql.Add('where as_id=:as_id'); aQuery.Parameters.ParamByName('as_id').Value:=as_id; aQuery.open;aQuery.First; with aQueryEmp do begin close;sql.clear; sql.Add('select * from t_op_ctn where 编号='''+t_op_ctn.DataSource.DataSet['编号']+''''); Open;First; while not eof do begin if aQuery.Locate('箱号', FieldByName('箱号').AsString,[]) then begin aQuery.Edit; if FieldByName('件数').AsInteger<>0 then aQuery.FieldByName('件数').AsInteger:=FieldByName('件数').AsInteger; if FieldByName('重量').AsFloat<>0 then aQuery.FieldByName('重量').AsFloat:=FieldByName('重量').AsFloat; if FieldByName('尺码').AsFloat<>0 then aQuery.FieldByName('尺码').AsFloat:=FieldByName('尺码').AsFloat; if trim(FieldByName('包装').AsString)<>'' then aQuery.FieldByName('包装').AsString:=FieldByName('包装').AsString; aQuery.Post; end; Next; end; end; end; finally if op_ctn_limited='0001'then begin if assigned(frm_op_seae) then begin frm_op_seae.t_op_seae.Beforepost:=frm_op_seae.t_op_seaeBeforepost; frm_op_seae.t_op_seae.BeforeEdit:=frm_op_seae.t_op_seaeBeforeEdit; end; aQueryEmp.Free; aQuery.Free; end; end; end; if op_ctn_limited='0002'then begin t_op_ctn.DataSource.DataSet.edit; t_op_ctn.DataSource.DataSet['箱号封号']:=memo1.Lines.Text; t_op_ctn.DataSource.DataSet['件数']:=pkgs; t_op_ctn.DataSource.DataSet['重量']:=kgs; t_op_ctn.DataSource.DataSet['尺码']:=cbm; t_op_ctn.DataSource.DataSet['件数大写']:='SAY:'+ntoc(pkgs,true)+t_op_ctn.DataSource.DataSet.fieldbyname('包装').asstring+' ONLY.'; t_op_ctn.DataSource.DataSet.post; end; if op_ctn_limited='0003'then begin t_op_ctn.DataSource.DataSet.edit; t_op_ctn.DataSource.DataSet['箱号封号']:=memo1.Lines.Text; t_op_ctn.DataSource.DataSet['件数']:=pkgs; t_op_ctn.DataSource.DataSet['重量']:=kgs; t_op_ctn.DataSource.DataSet['尺码']:=cbm; t_op_ctn.DataSource.DataSet.post; end; end; end; if memo1.Lines.Count>=1 then begin try if op_ctn_limited='0001'then begin if assigned(frm_op_seae) then begin frm_op_seae.t_op_seae.BeforePost:=nil; frm_op_seae.t_op_seae.BeforeEdit:=nil; end; end; t_op_ctn.DataSource.DataSet.edit; t_op_ctn.DataSource.DataSet['箱号封号']:=memo1.Lines.Text; t_op_ctn.DataSource.DataSet.post; finally if op_ctn_limited='0001'then begin if assigned(frm_op_seae) then begin frm_op_seae.t_op_seae.Beforepost:=frm_op_seae.t_op_seaeBeforepost; frm_op_seae.t_op_seae.BeforeEdit:=frm_op_seae.t_op_seaeBeforeEdit; end; end; end; end; finally t_op_ctn.EnableControls; t_op_ctn.DataSource.DataSet.EnableControls; t_op_ctn.GotoBookmark(bok); end; end; procedure Tfrm_op_ctn.t_op_ctnBeforeDelete(DataSet: TDataSet); begin if t_op_ctn.RecordCount=1 then begin if t_op_ctn.DataSource.DataSet.FieldByName('装运方式').asstring='整箱' then begin showmessage('业务集装箱不能为空,不能删除!!'); abort; end; end; if t_op_ctndetail.RecordCount>=1 then begin showmessage('集装箱存在装箱货物明细,不能删除,请先删除该集装箱下的货物明细'); abort; end; if op_ctn_limited='0001'then begin op_befor_post(TADOQuery(t_op_ctn.DataSource.DataSet),op_ctn_limited); end else if op_ctn_limited='0002'then begin op_befor_post(TADOQuery(t_op_ctn.DataSource.DataSet),op_ctn_limited); end else begin op_befor_post(TADOQuery(t_op_ctn.DataSource.DataSet),op_ctn_limited); end; end; procedure Tfrm_op_ctn.t_op_ctnBeforeEdit(DataSet: TDataSet); begin if op_ctn_limited='0001'then begin op_befor_post(TADOQuery(t_op_ctn.DataSource.DataSet),op_ctn_limited); end else if op_ctn_limited='0002'then begin op_befor_post(TADOQuery(t_op_ctn.DataSource.DataSet),op_ctn_limited); end else begin op_befor_post(TADOQuery(t_op_ctn.DataSource.DataSet),op_ctn_limited); end; end; procedure Tfrm_op_ctn.t_op_ctnAfterPost(DataSet: TDataSet); begin { update_ctn(t_op_ctn); if t_op_ctnsum.Active then t_op_ctnsum.Requery; t_op_ctn.Refresh; } end; procedure Tfrm_op_ctn.t_op_ctndetailBeforeInsert(DataSet: TDataSet); begin if t_op_ctn.IsEmpty then begin ShowMessage('集装箱信息为空不能增加集装箱明细'); Abort; end; { if Trim(t_op_ctndetail['hts'])='' then begin ShowMessage('HS NO 必须填写!'); Abort; end; if Trim(t_op_ctndetail['包装'])='' then begin ShowMessage('包装 必须填写!'); Abort; end; } if t_op_ctn.State in [dsedit,dsinsert] then t_op_ctn.Post; t_op_ctn.Refresh; end; procedure Tfrm_op_ctn.t_op_ctndetailNewRecord(DataSet: TDataSet); begin t_op_ctndetail['ctn_id']:=t_op_ctn.FieldByName('ctn_id').AsInteger; t_op_ctndetail['件数']:=t_op_ctn.FieldByName('件数').AsInteger; t_op_ctndetail['包装']:=t_op_ctn.FieldByName('包装').AsString; t_op_ctndetail['重量']:=t_op_ctn.FieldByName('重量').AsFloat; t_op_ctndetail['尺码']:=t_op_ctn.FieldByName('尺码').AsFloat; t_op_ctndetail['货物描述']:=t_op_ctn.FieldByName('品名').AsString; t_op_ctndetail['hts']:=t_op_ctn.DataSource.DataSet.FieldByName('运输方式').AsString; end; procedure Tfrm_op_ctn.bsSkinButton9Click(Sender: TObject); var i :integer; str:string; begin if t_op_ctn.IsEmpty then exit; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_op_ctn.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); if i=0 then str:='('+t_op_ctn.fieldbyname('ctn_id').asstring else str:=str+','+t_op_ctn.fieldbyname('ctn_id').asstring; end; end else begin str:='('+t_op_ctn.fieldbyname('ctn_id').asstring; end; str:=str+')'; t_ch_client.close; t_ch_client.sql.clear; t_ch_client.sql.add('select * from t_op_ctn ' +'where ctn_id in '+str +' order by ctn_id'); t_ch_client.open; try sys_print('海运出口装箱单',2,t_op_ctn.DataSource,nil,nil,nil,nil,t_ch_client1,t_op_ctn1,nil,nil,nil,nil); except end; end; procedure Tfrm_op_ctn.t_op_ctnAfterOpen(DataSet: TDataSet); begin if not t_op_ctnsum.Active then t_op_ctnsum.open; end; procedure Tfrm_op_ctn.N2Click(Sender: TObject); begin t_op_ctn.Append; end; procedure Tfrm_op_ctn.N7Click(Sender: TObject); var afield : variant; i: Integer; begin if t_op_ctn.IsEmpty then exit; afield := vararraycreate([0,t_op_ctn.fieldcount-1],varvariant); for i := 0 to (t_op_ctn.fieldcount-1) do begin afield[i] :=t_op_ctn.fields[i].value ; end; t_op_ctn.append; for i := 0 to (t_op_ctn.fieldcount-1) do begin if (t_op_ctn.fields[i].FieldName<>'ctn_id') and (t_op_ctn.fields[i].FieldName<>'箱号') and (t_op_ctn.fields[i].FieldName<>'封号') then t_op_ctn.fields[i].value := afield[i] ; end; end; procedure Tfrm_op_ctn.bsSkinButton1Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton1.ClientToScreen(Point(0,bsSkinButton1.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_ctn.bsSkinButton7Click(Sender: TObject); var afield : variant; i,j,m: Integer; book1:TBookmark; begin if t_op_ctn.IsEmpty then exit; try t_op_ctn.DisableControls; book1:=t_op_ctn.GetBookmark; m:=t_op_ctn.fieldByName('数量').AsInteger; for j:=0 to m-2 do begin afield := vararraycreate([0,t_op_ctn.fieldcount-1],varvariant); for i := 0 to (t_op_ctn.fieldcount-1) do begin afield[i] :=t_op_ctn.fields[i].value ; end; t_op_ctn.append; for i := 0 to (t_op_ctn.fieldcount-1) do begin if (t_op_ctn.fields[i].FieldName<>'ctn_id') and (t_op_ctn.fields[i].FieldName<>'数量') then t_op_ctn.fields[i].value := afield[i] ; end; end; finally t_op_ctn.GotoBookmark(book1); t_op_ctn.EnableControls; t_op_ctn.Edit; t_op_ctn.fieldByName('数量').AsInteger:=1; t_op_ctn.Post; end; end; procedure Tfrm_op_ctn.FormClose(Sender: TObject; var Action: TCloseAction); var Days,holidays:integer; begin if t_op_ctn.DataSource.DataSet.FieldByName('业务状态').AsString='业务封帐' then exit; if strtobool(get_parameters_value(320,'false'))then if op_ctn_limited='0001'then begin if t_op_ctn.DataSource.DataSet.State=dsinsert then else if not t_op_ctn.DataSource.DataSet.fieldbyname('是否解锁').asboolean then begin if trim(t_op_ctn.DataSource.DataSet.FieldByName('业务类型').AsString)='普通货' then begin if not t_op_ctn.DataSource.DataSet.fieldbyname('开船日期').IsNull then begin holidays:=GetHoliday(t_op_ctn.DataSource.DataSet.fieldbyname('开船日期').asstring); if frm_data_share.t_crm_client_ship.Locate('客户简称',t_op_ctn.DataSource.DataSet.fieldbyname('船公司').asstring,[]) then begin Days:=frm_data_share.t_crm_client_ship.fieldbyname('船公司出帐天数').AsInteger; end; if (date-t_op_ctn.DataSource.DataSet.fieldbyname('开船日期').asdatetime)>Days+holidays then begin showmessage('业务已经开船,超过了最后期限 超期天数:'+FloatToStr((date-t_op_ctn.DataSource.DataSet.fieldbyname('开船日期').asdatetime))+' 允许天数:'+FloatToStr(Days+holidays)+' ,不能修改!!'); //exit; end else; end; end; end; end; if strtobool(get_parameters_value(317,'true')) then begin if not do_data(op_ctn_limited,t_op_ctn.DataSource.DataSet.FieldByName('录入人').asstring ,t_op_ctn.DataSource.DataSet.FieldByName('操作员').asstring ,t_op_ctn.DataSource.DataSet.FieldByName('揽货人').asstring ,t_op_ctn.DataSource.DataSet.FieldByName('客服员').asstring ,t_op_ctn.DataSource.DataSet.FieldByName('报关操作').asstring ,t_op_ctn.DataSource.DataSet.FieldByName('报检操作').asstring) then begin Exit; end; if t_op_ctn.DataSource.DataSet.FieldByName('业务状态').AsString<>'业务封帐' then begin if not t_op_ctn.IsEmpty then begin try if op_ctn_limited='0001'then begin frm_op_seae.t_op_seae.BeforePost:=nil; frm_op_seae.t_op_seae.BeforeEdit:=nil; end; update_ctn(t_op_ctn); bsSkinButton6.OnClick(bsSkinButton6); finally if op_ctn_limited='0001'then begin frm_op_seae.t_op_seae.Beforepost:=frm_op_seae.t_op_seaeBeforepost; frm_op_seae.t_op_seae.BeforeEdit:=frm_op_seae.t_op_seaeBeforeEdit; end; end; end; end; // savewwgrid(frm_op_ctn.wwDBGrid1,'集装箱'); end else begin if t_op_ctn.DataSource.DataSet.FieldByName('业务状态').AsString<>'业务封帐' then begin if not t_op_ctn.IsEmpty then begin try if op_ctn_limited='0001'then begin frm_op_seae.t_op_seae.BeforePost:=nil; frm_op_seae.t_op_seae.BeforeEdit:=nil; end; update_ctn(t_op_ctn); finally if op_ctn_limited='0001'then begin frm_op_seae.t_op_seae.Beforepost:=frm_op_seae.t_op_seaeBeforepost; frm_op_seae.t_op_seae.BeforeEdit:=frm_op_seae.t_op_seaeBeforeEdit; end; end; end; end; end; end; procedure Tfrm_op_ctn.bsSkinButton8Click(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'货物描述'); end; procedure Tfrm_op_ctn.bsSkinButton10Click(Sender: TObject); var s_czmc,s_user,s_key,s_yzh,s_yzhuser,s_yzhkey,s_lh,s_zc,s_zcuser,s_zckey,s_sscz:string; s_CRCZ,MBLNO,BSNO,s_GL,s_STKY,MJCZ,userzh,passwordzh,zhcz:string; CTNINFO:TContainerInfo; i:integer; begin try s_user:=get_parameters_value(2101,'false'); s_key:=get_parameters_value(2102,'false'); s_czmc:=get_parameters_value(2103,'false'); s_yzhuser:=get_parameters_value(2104,'false'); s_yzhkey:=get_parameters_value(2105,'false'); s_yzh:=get_parameters_value(2106,'false'); s_lh:=get_parameters_value(2109,'false'); s_zc:=get_parameters_value(2113,'false'); s_zcuser:=get_parameters_value(2111,''); s_zckey:=get_parameters_value(2112,'false'); s_sscz:=get_parameters_value(2114,'false'); s_CRCZ:=get_parameters_value(2115,'false'); s_GL:=get_parameters_value(2116,'false'); s_STKY:=get_parameters_value(2116,'false'); MJCZ:=get_parameters_value(2118,'false'); userzh:=get_parameters_value(2119,'false'); passwordzh:=get_parameters_value(2120,'false'); zhcz:=get_parameters_value(2121,'false'); if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_czmc then if if_reg(2602) then GetdyczInfo_dy(s_user,s_key,Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString) else begin ShowMessage('没有注册大亚场站通信,请联系东胜注册'); end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_yzh then if if_reg(2603) then GetdyczInfo_yzh(s_user,s_key,Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString) else begin ShowMessage('没有注册怡之航场站通信,请联系东胜注册'); end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_lh then if if_reg(2604) then GetdyczInfo_lhcz(s_user,s_key,Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString) else begin ShowMessage('没有注册陆海场站通信,请联系东胜注册'); end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=zhcz then if if_reg(2611) then GetdyczInfo_zh(userzh,passwordzh,Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),'') //NSSLTACQB4264902 else begin ShowMessage('没有注册振华场站通信,请联系东胜注册'); end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_CRCZ then begin if 1=1 then begin MBLNO:=Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString); BSNO:=Trim(t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString); for i:=1 to 10 do begin ctninfo:=TCR.Create('长荣场站'); CTNINFO.Search('tdh='+MBLNO); if SaveCTNINFO(s_user,s_zckey,MBLNO,BSNO,CTNINFO) then begin break; end; end; end else begin ShowMessage('没有注册长荣场站通信,请联系东胜注册'); end; end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_GL then begin if 1=1 then begin MBLNO:=Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString); BSNO:=Trim(t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString); ctninfo:=TGL.Create('港陆场站'); CTNINFO.Search(MBLNO); SaveCTNINFO(s_user,s_zckey,MBLNO,BSNO,CTNINFO); end else begin ShowMessage('没有注册港陆场站通信,请联系东胜注册'); end; end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_STKY then begin if 1=1 then begin MBLNO:=Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString); BSNO:=Trim(t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString); ctninfo:=TSTKY.Create('世腾克运场站'); CTNINFO.Search(MBLNO); SaveCTNINFO(s_user,s_zckey,MBLNO,BSNO,CTNINFO); end else begin ShowMessage('没有注册世腾克运场站通信,请联系东胜注册'); end; end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_GL then begin if 1=1 then begin MBLNO:=Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString); BSNO:=Trim(t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString); ctninfo:=TCR.Create('港陆场站'); CTNINFO.Search('tdh='+MBLNO); SaveCTNINFO(s_user,s_zckey,MBLNO,BSNO,CTNINFO); end else begin ShowMessage('没有注册港陆场站,请联系东胜注册'); end; end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_zc then begin if if_reg(2610) then GetdyczInfo_zc(s_zcuser,s_zckey,Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString) else begin ShowMessage('没有注册中创场站通信,请联系东胜注册'); end; end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_sscz then begin if if_reg(2605) then getssczinfor(Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString)) else begin ShowMessage('没有注册胜狮场站通信,请联系东胜注册'); end; end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=MJCZ then begin if if_reg(2606) then getmjczinfor(Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString)) else begin ShowMessage('没有注册珉钧场站通信,请联系东胜注册'); end; end else if if_reg(2601) then GetdyczInfo_jfcz('','',Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),'') else begin ShowMessage('没有注册捷丰场站通信,请联系东胜注册'); end; finally t_op_ctn.Requery; end; end; //getssczinfor procedure Tfrm_op_ctn.bsSkinButton11Click(Sender: TObject); begin frm_main.view_momo(t_op_ctndetail1,'货物描述'); end; procedure Tfrm_op_ctn.Button1Click(Sender: TObject); var qty:integer; pkg,cbm:Double; begin qty:=0; pkg:=0; cbm:=0; if t_op_ctndetail.IsEmpty then Exit; with t_op_ctndetail do try DisableControls; First; while not eof do begin qty:=qty+FieldByName('件数').AsInteger; pkg:=pkg+FieldByName('重量').AsFloat; cbm:=cbm+FieldByName('尺码').AsFloat; next; end; showmessage('分箱合计 件数:'+IntToStr(qty)+' 重量:'+FormatFloat('0.0000;0.0000;0',pkg)+' 尺码:'+FormatFloat('0.0000;0.0000;0',cbm)); finally EnableControls; end; end; procedure Tfrm_op_ctn.bsSkinButton12Click(Sender: TObject); var i,k:integer; begin if t_op_ctn.DataSource.DataSet.FieldByName('费用状态').asstring='费用封帐' then begin ShowMessage('业务已经费用封帐,不能添加费用'); Exit; end; try k:=0; t_ch_fee.Close; t_ch_fee.Open; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_op_ctn.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); if (t_op_ctn.fieldbyname('金额').asfloat<>0) and (trim(t_op_ctn.fieldbyname('车队').asString)<>'') and (trim(t_op_ctn.fieldbyname('箱号').asString)<>'') // and (trim(t_op_ctn.fieldbyname('厂址').asString)<>'') then begin t_ch_fee.Append; t_ch_fee['类型']:='付'; t_ch_fee['金额']:=t_op_ctn.fieldbyname('金额').asfloat; t_ch_fee['单价']:=t_op_ctn.fieldbyname('金额').asfloat; t_ch_fee['费用状态']:='录入状态'; t_ch_fee['编号']:=t_op_ctn['编号']; t_ch_fee['费用名称']:='陆运费'; t_ch_fee['费用英文名称']:=''; t_ch_fee['客户名称']:=t_op_ctn.fieldbyname('车队').asString; t_ch_fee['结算单位']:='车队'; t_ch_fee['标准']:=t_op_ctn.fieldbyname('表现形式').asString; t_ch_fee['数量']:=1; t_ch_fee['币别']:='RMB'; t_ch_fee['汇率']:=1; t_ch_fee['结算金额']:=0; t_ch_fee['开票金额']:=0; t_ch_fee['申请开票']:=0; t_ch_fee['冲抵金额']:=0; t_ch_fee['申请金额']:=0; t_ch_fee['是否对帐']:=0; t_ch_fee['是否垫付']:=0; t_ch_fee['不开发票']:=0; t_ch_fee['录入人']:=employee; t_ch_fee['录入日期']:=date; t_ch_fee['是否对帐']:=0; t_ch_fee['机密']:=0; t_ch_fee['备注']:=t_op_ctn.fieldbyname('箱号').asString+','+t_op_ctn.fieldbyname('厂址').asString+','+t_op_ctn.fieldbyname('备注').asString; t_ch_fee.post; k:=k+1; end else begin ShowMessage('箱号,金额,车队 必须有值'); end; end; end else begin ShowMessage('请选择数据'); end; finally if k>0 then ShowMessage('共生成'+IntToStr(k)+'条费用'); end; end; { try if not ASSIGNED(frm_op_seae_ctn) then frm_op_seae_ctn:=Tfrm_op_seae_ctn.Create(application); frm_op_seae_ctn.t_op_ctn1:=t_op_ctn1; frm_op_seae_ctn.bsNo:=t_op_ctn.DataSource.DataSet.FieldByName('编号').asstring; frm_op_seae_ctn.CorpName:=t_op_ctn.DataSource.DataSet.FieldByName('委托单位').asstring; frm_op_seae_ctn.Vsl:=t_op_ctn.DataSource.DataSet.FieldByName('船名').asstring; frm_op_seae_ctn.Voy:=t_op_ctn.DataSource.DataSet.FieldByName('航次').asstring; frm_op_seae_ctn.ShowModal; finally frm_op_seae_ctn.Free; frm_op_seae_ctn:=nil; end; } procedure Tfrm_op_ctn.bsSkinPanel1Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel1.Width/14); bsSkinButton1.Width:=i; bsSkinButton2.Width:=i; bsSkinButton3.Width:=i; bsSkinButton4.Width:=i; bsSkinButton6.Width:=i; bsSkinButton7.Width:=i; bsSkinButton8.Width:=i; bsSkinButton9.Width:=i; bsSkinButton10.Width:=i; bsSkinButton12.Width:=i; bsSkinButton13.Width:=i; bsSkinButton14.Width:=i; bsSkinButton15.Width:=i; end; procedure Tfrm_op_ctn.bsSkinButton14Click(Sender: TObject); begin savewwgrid(frm_op_ctn.wwDBGrid1,'集装箱'); end; procedure Tfrm_op_ctn.bsSkinButton13Click(Sender: TObject); var Ext,ctnno,ctnType,cnts:string; ExcelTemplet:Variant; i:integer; begin if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); try ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); I:=2; t_op_ctn.First; // ShowMessage(trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value))); // if t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)) then while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value)<>'' do //件数 begin begin if VartoStr(ExcelTemplet.ActiveSheet.Cells[I,10].Value)<>'' then //箱号 begin t_op_ctn.append; cnts:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,12].Value); cnts:=copy(cnts,pos('*',cnts)+1,4); ctnno:=copy(cnts,1,2);; ctnType:=copy(cnts,3,2); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(ctnno),trim(ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,10].Value); t_op_ctn.FieldByName('封号').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,11].Value); t_op_ctn.FieldByName('唛头').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value); t_op_ctn.FieldByName('包装').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value); t_op_ctn.FieldByName('件数').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value); t_op_ctn.FieldByName('重量').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,5].Value); t_op_ctn.FieldByName('尺码').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,6].Value); t_op_ctn.Post; t_op_ctndetail.Append; t_op_ctndetail.FieldByName('ctn_id').AsInteger:=t_op_ctn.FieldByName('ctn_id').AsInteger; t_op_ctndetail.FieldByName('包装').AsString:=Vartostr(ExcelTemplet.ActiveSheet.Cells[I,3].Value); t_op_ctndetail.FieldByName('件数').AsInteger:=StrToInt(Vartostr(ExcelTemplet.ActiveSheet.Cells[I,4].Value)); t_op_ctndetail.FieldByName('重量').AsFloat:=StrToFloat(Vartostr(ExcelTemplet.ActiveSheet.Cells[I,5].Value)); t_op_ctndetail.FieldByName('尺码').AsFloat:=StrToFloat(Vartostr(ExcelTemplet.ActiveSheet.Cells[I,6].Value)); t_op_ctndetail.FieldByName('货物描述').AsString:=Vartostr(ExcelTemplet.ActiveSheet.Cells[I,8].Value); t_op_ctndetail.FieldByName('hts').AsString:=Vartostr(ExcelTemplet.ActiveSheet.Cells[I,7].Value); t_op_ctndetail.Post; end else begin t_op_ctn.Edit; t_op_ctn.FieldByName('件数').AsInteger:=t_op_ctn.FieldByName('件数').AsInteger+StrToInt(Vartostr(ExcelTemplet.ActiveSheet.Cells[I,4].Value)); t_op_ctn.FieldByName('重量').AsFloat:=t_op_ctn.FieldByName('重量').AsFloat+StrToFloat(Vartostr(ExcelTemplet.ActiveSheet.Cells[I,5].Value)); t_op_ctn.FieldByName('尺码').AsFloat:=t_op_ctn.FieldByName('尺码').AsFloat+StrToFloat(Vartostr(ExcelTemplet.ActiveSheet.Cells[I,6].Value)); t_op_ctn.Post; t_op_ctndetail.Append; t_op_ctndetail.FieldByName('ctn_id').AsInteger:=t_op_ctn.FieldByName('ctn_id').AsInteger; t_op_ctndetail.FieldByName('包装').AsString:=Vartostr(ExcelTemplet.ActiveSheet.Cells[I,3].Value); t_op_ctndetail.FieldByName('件数').AsInteger:=StrToInt(Vartostr(ExcelTemplet.ActiveSheet.Cells[I,4].Value)); t_op_ctndetail.FieldByName('重量').AsFloat:=StrToFloat(Vartostr(ExcelTemplet.ActiveSheet.Cells[I,5].Value)); t_op_ctndetail.FieldByName('尺码').AsFloat:=StrToFloat(Vartostr(ExcelTemplet.ActiveSheet.Cells[I,6].Value)); t_op_ctndetail.FieldByName('货物描述').AsString:=Vartostr(ExcelTemplet.ActiveSheet.Cells[I,8].Value); t_op_ctndetail.FieldByName('hts').AsString:=Vartostr(ExcelTemplet.ActiveSheet.Cells[I,7].Value); t_op_ctndetail.Post; end; i:=i+1; end; end; finally showmessage('导入完成'); ExcelTemplet.DisplayAlerts := false;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 end; end; end; end; procedure Tfrm_op_ctn.bsSkinButton15Click(Sender: TObject); var yardcode:string; IdHTTP1:TIdHTTP; strmsg,company:string; Url : string;//请求地址 ResponseStream : TStringStream; //返回信息 ResponseStr: string; RequestStr : string; //请求信息 RequestStream : TStringStream; jo:ISuperobject; tt:TSuperArray; i:Integer; CTNALL,s_ctnno,s_ctnType,pkgs,kgs,cbm:string; begin if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)='' then begin ShowMessage('场站不能为空!'); exit; end; if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString)='' then begin ShowMessage('主提单号不能为空!'); exit; end; yardcode:=getYardCode(Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)); if (yardcode='') then begin ShowMessage('场站东胜代码不能为空!'); exit; end; company:=frm_data_share.t_sys_company.fieldbyname('简称').AsString; ResponseStream := TStringStream.Create(''); RequestStream := TStringStream.Create(''); IdHTTP1:=TIdHTTP.Create(Application); try IdHttp1.Request.Accept := '*/*'; IdHttp1.Request.AcceptLanguage:='zh-CN'; IdHttp1.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)'; IdHttp1.Request.ContentType:='application/x-www-form-urlencoded'; Url:='http://47.104.90.170:5000/query'; try RequestStr:='webusername=&webuserpass=&mblno='+Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString)+'&yardid='+yardcode+'&isweb=0&custname='+company+'&psw='; //孙小华 RequestStream.WriteString(RequestStr); IdHttp1.post(Url,RequestStream,ResponseStream); except on e : Exception do begin end; end; ResponseStr := ResponseStream.DataString; //获取网页返回的信息 ResponseStr := UTF8Decode(ResponseStr); //网页中的存在中文时,需要进行UTF8解码 jo:=so(ResponseStr); if (jo.O['status'].AsString='0') then begin showmessage('无法提取,'+jo.O['message'].AsString); end else begin tt:=jo.O['message'].AsArray; for i:=0 to tt.Length-1 do begin CTNALL:=tt.O[i].S['CTNALL']; if t_op_ctn.Locate('箱号',Trim(tt.O[i].S['CNTRNO']),[]) then begin t_op_ctn.Edit; s_ctnno:=Copy(CTNALL,1,2); s_ctnType:=Copy(CTNALL,3,2); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; pkgs:=tt.O[i].S['PKGS']; kgs:=tt.O[i].S['KGS']; cbm:=tt.O[i].S['CBM']; if pkgs='' then pkgs:='0'; if kgs='' then kgs:='0'; if cbm='' then cbm:='0'; t_op_ctn.FieldByName('封号').AsString:=tt.O[i].S['SEALNO']; t_op_ctn.FieldByName('件数').AsInteger:=StrToInt(pkgs); t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; t_op_ctn.FieldByName('重量').AsFloat:=StrToFloatDef(kgs,0); t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloatDef(cbm,0); t_op_ctn.Post; end else begin t_op_ctn.append; s_ctnno:=Copy(CTNALL,1,2); s_ctnType:=Copy(CTNALL,3,2); pkgs:=tt.O[i].S['PKGS']; kgs:=tt.O[i].S['KGS']; cbm:=tt.O[i].S['CBM']; if pkgs='' then pkgs:='0'; if kgs='' then kgs:='0'; if cbm='' then cbm:='0'; if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([trim(s_ctnno),trim(s_ctnType)]), []) then begin t_op_ctn.FieldByName('代码').AsString:=frm_data_share.t_code_ctn.FieldByName('代码').AsString; end; t_op_ctn.FieldByName('箱号').AsString:=tt.O[i].S['CNTRNO']; t_op_ctn.FieldByName('封号').AsString:=tt.O[i].S['SEALNO']; t_op_ctn.FieldByName('件数').AsInteger:=StrToInt(pkgs); t_op_ctn.FieldByName('包装').AsString:=t_op_ctn.DataSource.DataSet.fieldbyname('包装').AsString; t_op_ctn.FieldByName('重量').AsFloat:=StrToFloatDef(kgs,0); t_op_ctn.FieldByName('尺码').AsFloat:=StrToFloatDef(cbm,0); t_op_ctn.Post; end; end; end; finally FreeAndNil(IdHTTP1); end; end; function Tfrm_op_ctn.getYardCode(yard: string): string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 东胜代码 from t_crm_client where 客户简称='''+yard+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('东胜代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; end.