unit u_op_seae_edi_data; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,IdFTP,IdFTPCommon,DateUtils, Dialogs, bsSkinCtrls, ExtCtrls, DB, ADODB, dxExEdtr, dxCntner, dxTL, ActiveX, dxDBCtrl, dxDBGrid, ComCtrls, bsSkinTabs, RxLookup, StdCtrls, Mask,inifiles, DBCtrls, wwdbdatetimepicker, wwdblook, u_op_sate, u_fee, u_op_card, Menus, dxDBTLCl, dxGrClms, bsdbctrls, XPMenu, wwdbedit, Wwdotdot, Wwdbcomb, Grids, Wwdbigrd, Wwdbgrid, FtpCli, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdIntercept, IdLogBase, IdLogEvent,DBClient, IdAntiFreezeBase, IdAntiFreeze, dxEditor, dxEdLib, dxDBELib, DBCtrlsEh ,ComObj,DsWebService,SoapHTTPClient,InvokeRegistry,XMLIntf,XMLDoc, xmldom, Xmlxform, msxmldom, bsSkinBoxCtrls,DyxtService,Service,jfczService,myService,CaragtQuery_Cxwl,IdHTTP, kbmMemTable, cxControls, cxContainer, cxCheckListBox, cxDBCheckListBox,Clipbrd, OleCtrls, SHDocVw, IdExplicitTLSClientServerBase, cxTreeView, Excel,IdMultipartFormData,IdGlobalProtocols,superobject; type TMyThread = class(TThread) protected filename:string; filetype:string; ediname:string; edipassword:string; mblno:string; editype:string; procedure Execute; override; public constructor create(mfilename:string;mfiletype:string;mediname:string;medipassword:string;mmblno:string;meditype:string);virtual; destructor destroy; override; end; TSendDGData = Record //消息客户端消息结构 dgConPerson :String; dgTel :String; dgClass :widestring; temperature :String; temUnit :String; humidity :String; vent :String; dgNo:String; end; TDsThread = class(TThread) protected filename:string; carrierid:string; ScriptPath:string; webusername:string; webpassword:string; webcustname:string; senddgdata:TSendDGData; procedure Execute; override; public constructor create(mfilename:string;mcarrierid:string;mScriptPath:string;mwebusername:string;mwebpassword:string;msenddgdata:TSendDGData;mwebcustname:string='');virtual; destructor destroy; override; end; Tfrm_op_seae_edi_data = class(TForm) Panel2: TPanel; bsSkinButton7: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton38: TbsSkinButton; Notebook1: TNotebook; t_op_seae: TADOQuery; t_op_seae1: TDataSource; dxDBGrid1: TdxDBGrid; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinPanel1: TbsSkinPanel; Label1: TLabel; Label2: TLabel; Label38: TLabel; DBEdit1: TDBEdit; DBEdit9: TDBEdit; PopupMenu3: TPopupMenu; N37: TMenuItem; N38: TMenuItem; N62: TMenuItem; N25: TMenuItem; N64: TMenuItem; N63: TMenuItem; N17: TMenuItem; N18: TMenuItem; N34: TMenuItem; N35: TMenuItem; N36: TMenuItem; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridDateColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column18: TdxDBGridMaskColumn; dxDBGrid1Column19: TdxDBGridDateColumn; dxDBGrid1Column17: TdxDBGridColumn; XPMenu1: TXPMenu; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; bsSkinPanel2: TbsSkinPanel; Label47: TLabel; Label49: TLabel; Label51: TLabel; wwDBDateTimePicker9: TwwDBDateTimePicker; wwDBDateTimePicker11: TwwDBDateTimePicker; Edit3: TEdit; wwDBDateTimePicker12: TwwDBDateTimePicker; Label52: TLabel; wwDBDateTimePicker13: TwwDBDateTimePicker; Label53: TLabel; bsSkinButton8: TbsSkinButton; bsSkinButton12: TbsSkinButton; Label60: TLabel; DBEdit10: TDBEdit; bsSkinButton14: TbsSkinButton; PopupMenu1: TPopupMenu; N1: TMenuItem; dxDBGrid1Column65: TdxDBGridColumn; dxDBGrid1Column67: TdxDBGridColumn; Label45: TLabel; Label48: TLabel; wwDBComboBox2: TwwDBComboBox; bsSkinGroupBox4: TbsSkinGroupBox; Label54: TLabel; DBEdit46: TDBEdit; Label55: TLabel; DBEdit48: TDBEdit; Label56: TLabel; DBEdit50: TDBEdit; Label59: TLabel; t_op_ctn1: TDataSource; t_op_ctn: TADOQuery; wwDBComboBox3: TwwDBComboBox; bsSkinPanel5: TbsSkinPanel; bsSkinGroupBox1: TbsSkinGroupBox; Label6: TLabel; Label7: TLabel; Label8: TLabel; bsSkinSpeedButton1: TbsSkinSpeedButton; DBEdit5: TDBEdit; DBEdit6: TDBEdit; DBEdit7: TDBEdit; bsSkinGroupBox2: TbsSkinGroupBox; Label16: TLabel; Label17: TLabel; Label18: TLabel; bsSkinSpeedButton2: TbsSkinSpeedButton; DBEdit17: TDBEdit; DBEdit19: TDBEdit; DBEdit20: TDBEdit; bsSkinGroupBox3: TbsSkinGroupBox; Label26: TLabel; Label27: TLabel; Label28: TLabel; bsSkinSpeedButton3: TbsSkinSpeedButton; DBEdit28: TDBEdit; DBEdit29: TDBEdit; DBEdit30: TDBEdit; bsSkinGroupBox5: TbsSkinGroupBox; DBMemo3: TDBMemo; bsSkinGroupBox7: TbsSkinGroupBox; DBMemo1: TDBMemo; bsSkinGroupBox8: TbsSkinGroupBox; DBMemo2: TDBMemo; SaveDialog1: TSaveDialog; t_op_ctn_detail: TADOQuery; IntegerField1: TIntegerField; StringField8: TStringField; BCDField1: TBCDField; BCDField2: TBCDField; StringField12: TStringField; StringField13: TStringField; BCDField3: TBCDField; t_op_ctn_detail1: TDataSource; t_op_ctn_detailctn_id: TIntegerField; bsSkinButton19: TbsSkinButton; Label73: TLabel; bsSkinButton20: TbsSkinButton; Label74: TLabel; bsSkinButton21: TbsSkinButton; Label75: TLabel; RxDBLookupCombo16: TRxDBLookupCombo; RxDBLookupCombo1: TRxDBLookupCombo; RxDBLookupCombo2: TRxDBLookupCombo; t_code_shiper: TADOQuery; t_code_shiper1: TDataSource; t_code_consignee: TADOQuery; t_code_consignee1: TDataSource; t_code_notifyparty: TADOQuery; t_code_notifyparty1: TDataSource; bsSkinGroupBox11: TbsSkinGroupBox; Label61: TLabel; Label62: TLabel; Label70: TLabel; Label71: TLabel; Label72: TLabel; Edit4: TEdit; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; EditType: TEdit; bsSkinButton16: TbsSkinButton; bsSkinButton17: TbsSkinButton; bsSkinButton18: TbsSkinButton; FtpClient1: TFtpClient; lblstatus: TLabel; IdFTP1: TIdFTP; IdLogEvent1: TIdLogEvent; DebugListBox: TListBox; StatusBar1: TStatusBar; ProgressBar1: TProgressBar; Label76: TLabel; bsSkinButton22: TbsSkinButton; PopupMenu4: TPopupMenu; wwDBDateTimePicker3: TwwDBDateTimePicker; Label77: TLabel; Label78: TLabel; bsSkinButton23: TbsSkinButton; N4: TMenuItem; NWD2101: TMenuItem; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; Label80: TLabel; Edit1: TEdit; Label217: TLabel; wwDBLookupCombo26: TwwDBLookupCombo; Label218: TLabel; Edit8: TEdit; Label81: TLabel; Edit2: TEdit; N9: TMenuItem; N19: TMenuItem; NWY: TMenuItem; NLD: TMenuItem; NYD: TMenuItem; wwDBLookupCombo21: TwwDBLookupCombo; wwDBLookupCombo20: TwwDBLookupCombo; NHF: TMenuItem; Label58: TLabel; NZH: TMenuItem; bsSkinButton25: TbsSkinButton; wwDBLookupCombo3: TwwDBLookupCombo; wwDBLookupCombo52: TwwDBLookupCombo; wwDBLookupCombo17: TwwDBLookupCombo; N6: TMenuItem; NHGYDT: TMenuItem; OpenDialog1: TOpenDialog; t_op_state1: TDataSource; t_op_state: TADOQuery; N20: TMenuItem; Panel1: TPanel; bsSkinGroupBox9: TbsSkinGroupBox; Label68: TLabel; Label169: TLabel; Label63: TLabel; Label64: TLabel; Label65: TLabel; Label66: TLabel; Label67: TLabel; Label106: TLabel; Label105: TLabel; Label109: TLabel; Label108: TLabel; Label69: TLabel; Label83: TLabel; wwDBComboBox15: TwwDBComboBox; DBEdit81: TDBEdit; wwDBLookupCombo61: TwwDBLookupCombo; DBEdit82: TDBEdit; DBEdit83: TDBEdit; DBMemo38: TDBMemo; DBMemo39: TDBMemo; DBEdit55: TDBEdit; wwDBComboBox6: TwwDBComboBox; DBEdit56: TDBEdit; DBEdit57: TDBEdit; bsSkinButton47: TbsSkinButton; bsSkinButton24: TbsSkinButton; bsSkinButton26: TbsSkinButton; DBEdit2: TDBEdit; bsSkinGroupBox6: TbsSkinGroupBox; bsSkinPanel9: TbsSkinPanel; bsSkinButton56: TbsSkinButton; bsSkinButton57: TbsSkinButton; bsSkinButton58: TbsSkinButton; bsSkinButton59: TbsSkinButton; btnMarks: TbsSkinButton; btnDesc: TbsSkinButton; btnSeal: TbsSkinButton; bsSkinButton15: TbsSkinButton; bsSkinButton28: TbsSkinButton; bsSkinExPanel1: TbsSkinExPanel; bsSkinPanel6: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton13: TbsSkinButton; wwDBGrid2: TwwDBGrid; N22: TMenuItem; bsSkinComboBox1: TbsSkinComboBox; Label3: TLabel; N2: TMenuItem; N21: TMenuItem; N23: TMenuItem; bsSkinLabel1: TbsSkinLabel; bsSkinLabel2: TbsSkinLabel; bsSkinLabel3: TbsSkinLabel; bsSkinLabel4: TbsSkinLabel; bsSkinLabel5: TbsSkinLabel; DBEdit3: TDBEdit; PopupMenu5: TPopupMenu; ABC1: TMenuItem; bsSkinButton27: TbsSkinButton; dxDBGrid1Column23: TdxDBGridColumn; bsSkinLabel6: TbsSkinLabel; kbmMemTable1: TkbmMemTable; kbmMemTable1StringField: TStringField; kbmMemTable1StringField2: TStringField; kbmMemTable1IntegerField: TIntegerField; kbmMemTable1StringField3: TStringField; kbmMemTable1FloatField: TFloatField; kbmMemTable1FloatField2: TFloatField; kbmMemTable1StringField4: TStringField; kbmMemTable1StringField5: TStringField; kbmMemTable1StringField6: TStringField; cxDBCheckListBox1: TcxDBCheckListBox; Label36: TLabel; Label37: TLabel; Label39: TLabel; Label44: TLabel; Label46: TLabel; DBEdit38: TDBEdit; DBEdit39: TDBEdit; DBEdit40: TDBEdit; DBEdit43: TDBEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; bsSkinButton32: TbsSkinButton; bsSkinButton31: TbsSkinButton; bsSkinExPanel2: TbsSkinExPanel; lbl1: TLabel; dbedt1: TDBEdit; N24: TMenuItem; N26: TMenuItem; N27: TMenuItem; CL: TMenuItem; Label10: TLabel; DBMemo4: TDBMemo; dxDBGrid1Column22: TdxDBGridColumn; dxDBGrid1Column24: TdxDBGridColumn; dxDBGrid1Column25: TdxDBGridColumn; dxDBGrid1Column26: TdxDBGridColumn; Label12: TLabel; RxDBLookupCombo9: TRxDBLookupCombo; Label4: TLabel; DBEdit4: TDBEdit; Label9: TLabel; DBEdit11: TDBEdit; Label5: TLabel; DBEdit8: TDBEdit; DBEdit12: TDBEdit; Label11: TLabel; Label13: TLabel; DBEdit13: TDBEdit; dxDBGrid1Column27: TdxDBGridColumn; bsSkinButton34: TbsSkinButton; dxDBGrid1Column28: TdxDBGridColumn; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; Label14: TLabel; Edit9: TEdit; Label15: TLabel; Edit10: TEdit; Label19: TLabel; Edit11: TEdit; Label42: TLabel; wwDBComboBox8: TwwDBComboBox; idhttp1: TIdHTTP; bsSkinButton35: TbsSkinButton; Memo1: TMemo; cxTreeView1: TcxTreeView; dxDBGrid1Column29: TdxDBGridColumn; dxDBGrid1Column30: TdxDBGridColumn; dxDBGrid1Column31: TdxDBGridColumn; dxDBGrid1Column33: TdxDBGridColumn; Label20: TLabel; Edit12: TEdit; mmo1: TMemo; bsSkinButton36: TbsSkinButton; bsSkinButton37: TbsSkinButton; t_code_cangdan1: TDataSource; t_code_cangdan: TADOQuery; Label21: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; Label22: TLabel; DBEdit14: TDBEdit; Label23: TLabel; DBEdit15: TDBEdit; dxDBGrid1Column32: TdxDBGridColumn; dxDBGrid1Column34: TdxDBGridColumn; dxDBGrid1Column35: TdxDBGridColumn; DBMemo5: TDBMemo; Label24: TLabel; Label25: TLabel; DBEdit16: TDBEdit; DBEdit18: TDBEdit; Label439: TLabel; DBEdit242: TDBEdit; Label438: TLabel; DBEdit244: TDBEdit; Label447: TLabel; DBEdit251: TDBEdit; Label29: TLabel; DBEdit21: TDBEdit; Label30: TLabel; DBEdit22: TDBEdit; DBEdit23: TDBEdit; Label31: TLabel; Label32: TLabel; DBEdit24: TDBEdit; Label33: TLabel; DBEdit25: TDBEdit; DBEdit26: TDBEdit; Label34: TLabel; Label35: TLabel; DBEdit27: TDBEdit; Label40: TLabel; DBEdit31: TDBEdit; Label41: TLabel; DBEdit32: TDBEdit; bsSkinSpeedButton4: TbsSkinSpeedButton; bsSkinButton39: TbsSkinButton; bsSkinButton41: TbsSkinButton; bsSkinButton40: TbsSkinButton; wwDBComboBoxOwner: TwwDBComboBox; wwDBComboBox1: TwwDBComboBox; wwDBLookupCombo16: TwwDBLookupCombo; wwDBLookupComboctn: TwwDBLookupCombo; t_op_seaeDSDesigner: TStringField; t_op_seaeDSDesigner2: TStringField; t_op_seaeEDI: TStringField; t_op_seaeEDI2: TStringField; t_op_seaeDSDesigner3: TStringField; t_op_seaeDSDesigner4: TDateTimeField; t_op_seaeDSDesigner5: TStringField; t_op_seaeDSDesigner6: TStringField; t_op_seaeDSDesigner7: TStringField; t_op_seaeDSDesigner8: TStringField; t_op_seaeDSDesigner1: TStringField; t_op_seaeDSDesigner22: TStringField; t_op_seaeDSDesigner9: TStringField; t_op_seaeDSDesigner10: TStringField; t_op_seaeDSDesigner11: TStringField; t_op_seaeDSDesigner12: TStringField; t_op_seaeDSDesigner13: TStringField; t_op_seaeDSDesigner14: TStringField; t_op_seaeDSDesigner15: TStringField; t_op_seaeDSDesigner23: TStringField; t_op_seaeDSDesigner16: TStringField; t_op_seaeDSDesigner17: TStringField; t_op_seaeDSDesigner18: TStringField; t_op_seaeDSDesigner19: TStringField; t_op_seaeDSDesigner20: TStringField; t_op_seaeDSDesigner21: TStringField; t_op_seaeDSDesigner110: TStringField; t_op_seaeDSDesigner24: TStringField; t_op_seaeDSDesigner25: TStringField; t_op_seaeDSDesigner26: TStringField; t_op_seaeDSDesigner27: TStringField; t_op_seaeDSDesigner28: TStringField; t_op_seaeDSDesigner29: TStringField; t_op_seaeDSDesigner210: TStringField; t_op_seaeDSDesigner212: TStringField; t_op_seaeDSDesigner222: TStringField; t_op_seaeDSDesigner211: TStringField; t_op_seaeDSDesigner213: TStringField; t_op_seaeDSDesigner214: TStringField; t_op_seaeDSDesigner215: TStringField; t_op_seaeDSDesigner216: TStringField; t_op_seaeDSDesigner30: TStringField; t_op_seaeDSDesigner31: TStringField; t_op_seaeDSDesigner32: TStringField; t_op_seaeDSDesigner33: TStringField; t_op_seaeDSDesigner34: TStringField; t_op_seaeDSDesigner35: TDateTimeField; t_op_seaeDSDesigner36: TStringField; t_op_seaeDSDesigner37: TStringField; t_op_seaeDSDesigner38: TStringField; t_op_seaeDSDesigner39: TStringField; t_op_seaeDSDesigner40: TStringField; t_op_seaeDSDesigner41: TStringField; t_op_seaeDSDesigner42: TStringField; t_op_seaeDSDesigner43: TStringField; t_op_seaeDSDesigner44: TStringField; t_op_seaeDSDesigner45: TStringField; t_op_seaeDSDesigner46: TStringField; t_op_seaeDSDesigner47: TIntegerField; t_op_seaeDSDesigner48: TStringField; t_op_seaeDSDesigner49: TBCDField; t_op_seaeDSDesigner50: TBCDField; t_op_seaeDSDesigner51: TStringField; t_op_seaeDSDesigner52: TStringField; t_op_seaeDSDesigner53: TStringField; t_op_seaeDSDesigner54: TStringField; t_op_seaeDSDesigner55: TStringField; t_op_seaeDSDesigner56: TStringField; t_op_seaeDSDesigner57: TStringField; t_op_seaeDSDesigner58: TStringField; t_op_seaeDSDesigner59: TStringField; t_op_seaeDSDesigner60: TStringField; t_op_seaeDSDesigner61: TStringField; t_op_seaeDSDesigner62: TStringField; t_op_seaeDSDesigner63: TStringField; t_op_seaeDSDesigner217: TStringField; t_op_seaeDSDesigner310: TStringField; t_op_seaeDSDesigner311: TStringField; t_op_seaeDSDesigner312: TStringField; t_op_seaeDSDesigner232: TStringField; t_op_seaeIMO: TStringField; t_op_seaeDSDesigner64: TStringField; t_op_seaeDSDesigner65: TStringField; t_op_seaeDSDesigner66: TStringField; t_op_seaeDSDesigner67: TStringField; t_op_seaeDSDesigner68: TStringField; t_op_seaeDSDesigner69: TStringField; t_op_seaeDSDesigner70: TStringField; t_op_seaeDSDesigner71: TBooleanField; t_op_seaeDSDesigner72: TBooleanField; t_op_seaeDSDesigner73: TStringField; t_op_seaeDSDesigner74: TStringField; t_op_seaeDSDesigner75: TStringField; t_op_seaeDSDesigner76: TDateTimeField; t_op_seaeDSDesigner77: TStringField; t_op_seaeDSDesigner78: TStringField; t_op_seaeDSDesigner79: TStringField; t_op_seaeDSDesigner80: TStringField; t_op_seaeDSDesigner81: TStringField; t_op_seaeDSDesigner82: TDateTimeField; t_op_seaeDSDesigner83: TStringField; t_op_seaeDSDesigner84: TStringField; t_op_seaeDSDesigner85: TStringField; t_op_seaeDSDesigner86: TStringField; t_op_seaeDSDesigner87: TStringField; t_op_seaeDSDesigner88: TStringField; t_op_seaeDSDesigner90: TStringField; t_op_seaeDSDesigner91: TIntegerField; t_op_seaeDSDesigner92: TBooleanField; t_op_seaeDSDesigner93: TStringField; t_op_seaeDSDesigner94: TDateTimeField; t_op_seaeDSDesigner95: TStringField; t_op_seaeDSDesigner96: TStringField; t_op_seaeDSDesigner97: TBCDField; t_op_seaeDSDesigner98: TStringField; t_op_seaeDSDesigner99: TStringField; t_op_seaeDSDesigner100: TBCDField; t_op_seaeDSDesigner101: TBCDField; t_op_seaeDSDesigner102: TBCDField; t_op_seaeDSDesigner103: TWordField; t_op_seaeDSDesigner104: TStringField; t_op_seaeDSDesigner105: TStringField; t_op_seaeDSDesigner106: TStringField; t_op_seaeDSDesigner107: TStringField; t_op_seaeDSDesigner108: TStringField; t_op_seaeDSDesigner109: TStringField; wwDBComboBox4: TwwDBComboBox; wwDBGrid1: TwwDBGrid; DBEdit33: TDBEdit; EXCEL1: TMenuItem; Excel2: TExcel; SaveDialog: TSaveDialog; N28: TMenuItem; wwDBComboBoxOP: TComboBox; wwDBComboBoxType: TComboBox; lblmarklength: TLabel; Label43: TLabel; bsSkinButton291: TbsSkinButton; N30: TMenuItem; N31: TMenuItem; t_code_carrier1: TDataSource; t_code_carrier: TADOQuery; wwDBLookupCombo1: TwwDBLookupCombo; t_op_seaeDSDesigner89: TStringField; t_op_seaeDSDesigner111: TStringField; NZHZF: TMenuItem; op: TbsSkinButton; adopingtai: TADOQuery; t_op_seaeDSDesigner112: TStringField; dxDBGrid1Column36: TdxDBGridColumn; Label50: TLabel; wwDBComboBox5: TwwDBComboBox; N5: TMenuItem; N7: TMenuItem; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; Label57: TLabel; DBEdit34: TDBEdit; Label79: TLabel; DBEdit35: TDBEdit; t_op_seaeDSDesigner113: TStringField; t_op_seaeDSDesigner114: TStringField; t_op_seaeDSDesigner115: TBooleanField; bsSkinButton29: TbsSkinButton; DBMemo6: TDBMemo; Label82: TLabel; t_op_seaeDSDesigner116: TStringField; N8: TMenuItem; Memo2: TMemo; Button1: TButton; dxDBGrid1Column37: TdxDBGridColumn; dxDBGrid1Column38: TdxDBGridColumn; dxDBGrid1Column39: TdxDBGridColumn; t_code_cdstatus: TADOQuery; t_code_cdstatus1: TDataSource; bsSkinPanel3: TbsSkinPanel; Label84: TLabel; wwDBLookupCombo2: TwwDBLookupCombo; bsSkinButton30: TbsSkinButton; t_op_seaeDSDesigner117: TStringField; t_op_seaeDSDesigner118: TStringField; t_op_seaeDSDesigner119: TDateTimeField; t_code_goods_not: TADOQuery; dxDBGrid1Column40: TdxDBGridColumn; t_op_seaestatus_detai: TStringField; code_e_carrier: TADOQuery; dxDBGrid1Column41: TdxDBGridColumn; lblTSGOOD: TLabel; N29: TMenuItem; N32: TMenuItem; t_code_zy_client: TADOQuery; t_code_zy_client1: TDataSource; DBEdit36: TDBEdit; N33: TMenuItem; N39: TMenuItem; RxDBLookupCombo4: TRxDBLookupCombo; code_cdkehuchuand: TADOQuery; code_cdkehuchuand1: TDataSource; CheckBox1: TCheckBox; dxDBGrid1Column42: TdxDBGridColumn; N3: TMenuItem; N40: TMenuItem; bsSkinButton33: TbsSkinButton; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Panel2Resize(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure bsSkinSpeedButton1Click(Sender: TObject); procedure bsSkinSpeedButton2Click(Sender: TObject); procedure bsSkinSpeedButton3Click(Sender: TObject); procedure bsSkinButton56Click(Sender: TObject); procedure bsSkinButton57Click(Sender: TObject); procedure bsSkinButton58Click(Sender: TObject); procedure bsSkinButton59Click(Sender: TObject); procedure wwDBLookupComboctnChange(Sender: TObject); procedure btnMarksClick(Sender: TObject); procedure btnDescClick(Sender: TObject); procedure t_op_ctnAfterInsert(DataSet: TDataSet); procedure wwDBGrid1ColEnter(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure t_op_ctn_detailAfterInsert(DataSet: TDataSet); procedure t_op_ctn_detailBeforePost(DataSet: TDataSet); procedure t_op_ctn_detailBeforeInsert(DataSet: TDataSet); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinButton19Click(Sender: TObject); procedure bsSkinButton20Click(Sender: TObject); procedure bsSkinButton21Click(Sender: TObject); procedure RxDBLookupCombo16Enter(Sender: TObject); procedure RxDBLookupCombo16Exit(Sender: TObject); procedure RxDBLookupCombo1Enter(Sender: TObject); procedure RxDBLookupCombo1Exit(Sender: TObject); procedure RxDBLookupCombo2Enter(Sender: TObject); procedure RxDBLookupCombo2Exit(Sender: TObject); procedure RxDBLookupCombo16Change(Sender: TObject); procedure RxDBLookupCombo1Change(Sender: TObject); procedure RxDBLookupCombo2Change(Sender: TObject); procedure IdFTP1Status(ASender: TObject; const AStatus: TIdStatus; const AStatusText: String); procedure IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); procedure IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); procedure IdFTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode); procedure bsSkinButton22Click(Sender: TObject); procedure NZYClick(Sender: TObject); procedure bsSkinButton23Click(Sender: TObject); procedure NZTClick(Sender: TObject); procedure NWD2101Click(Sender: TObject); procedure t_op_ctnBeforePost(DataSet: TDataSet); procedure NWD1101Click(Sender: TObject); procedure NYDClick(Sender: TObject); procedure NLDClick(Sender: TObject); procedure NWYClick(Sender: TObject); procedure NHGClick(Sender: TObject); procedure btnSealClick(Sender: TObject); procedure NHFClick(Sender: TObject); procedure wwDBComboBoxOPDropDown(Sender: TObject); procedure NZHClick(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure bsSkinButton47Click(Sender: TObject); procedure bsSkinButton24Click(Sender: TObject); procedure bsSkinButton25Click(Sender: TObject); procedure bsSkinButton26Click(Sender: TObject); procedure wwDBLookupCombo3Change(Sender: TObject); procedure wwDBLookupCombo3Exit(Sender: TObject); procedure wwDBLookupCombo52Change(Sender: TObject); procedure wwDBLookupCombo52Exit(Sender: TObject); procedure wwDBLookupCombo17Change(Sender: TObject); procedure wwDBLookupCombo17Exit(Sender: TObject); procedure N1Click(Sender: TObject); procedure bsSkinButton28Click(Sender: TObject); procedure NHGYDTClick(Sender: TObject); procedure bsSkinButton29Click(Sender: TObject); procedure t_op_seaeBeforeEdit(DataSet: TDataSet); procedure t_op_ctnBeforeEdit(DataSet: TDataSet); procedure N20Click(Sender: TObject); procedure bsSkinButton30Click(Sender: TObject); procedure bsSkinComboBox1Change(Sender: TObject); procedure bsSkinButton31Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure bsSkinButton32Click(Sender: TObject); procedure t_op_seaeBeforeDelete(DataSet: TDataSet); procedure DBEdit3Change(Sender: TObject); procedure bsSkinLabel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure bsSkinLabel2MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure bsSkinLabel3MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure bsSkinLabel4MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure bsSkinLabel5MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure bsSkinButton27Click(Sender: TObject); procedure bsSkinLabel6MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure t_op_seaeAfterInsert(DataSet: TDataSet); procedure bsSkinButton33Click(Sender: TObject); procedure RxDBLookupCombo9Enter(Sender: TObject); procedure RxDBLookupCombo9KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo9Exit(Sender: TObject); procedure t_op_ctnNewRecord(DataSet: TDataSet); procedure CLClick(Sender: TObject); procedure dxDBGrid1CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure DBEdit1Change(Sender: TObject); procedure bsSkinButton35Click(Sender: TObject); procedure t_op_ctnAfterPost(DataSet: TDataSet); procedure bsSkinButton36Click(Sender: TObject); procedure bsSkinButton37Click(Sender: TObject); procedure RxDBLookupCombo3Change(Sender: TObject); procedure DBEdit11Change(Sender: TObject); procedure bsSkinSpeedButton4Click(Sender: TObject); procedure bsSkinButton39Click(Sender: TObject); procedure bsSkinButton40Click(Sender: TObject); procedure Notebook1PageChanged(Sender: TObject); procedure bsSkinButton41Click(Sender: TObject); procedure DBEdit11Exit(Sender: TObject); procedure t_op_seaeAfterScroll(DataSet: TDataSet); procedure EXCEL1Click(Sender: TObject); procedure N29Click(Sender: TObject); procedure DBMemo38Change(Sender: TObject); procedure DBMemo39Change(Sender: TObject); procedure bsSkinButton291Click(Sender: TObject); procedure N31Click(Sender: TObject); procedure wwDBGrid1CalcCellColors(Sender: TObject; Field: TField; State: TGridDrawState; Highlight: Boolean; AFont: TFont; ABrush: TBrush); procedure DBEdit4Change(Sender: TObject); procedure N3Click(Sender: TObject); procedure opClick(Sender: TObject); procedure N7Click(Sender: TObject); procedure N30Click(Sender: TObject); procedure widClick(Sender: TObject); procedure N8Click(Sender: TObject); procedure t_op_seaeAfterPost(DataSet: TDataSet); procedure Button1Click(Sender: TObject); procedure e1Click(Sender: TObject); procedure N32Click(Sender: TObject); procedure N39Click(Sender: TObject); procedure NZHZFClick(Sender: TObject); procedure N40Click(Sender: TObject); private { Private declarations } AbortTransfer: Boolean; TransferrignData: Boolean; BytesToTransfer: LongWord; STime: TDateTime; mServiceSoap_Ds:DsWebServiceSoap; mHttpRIO_ds:THTTPRIO; mServiceSoap_dy:DyxtServiceSoap; mServiceSoap_yzh:ServiceSoap; mServiceSoap_zc:CaragtQuery_CxwlSoap; mHttpRIO_dy,mHttpRIO_yzh,mHttpRIO_zc:THTTPRIO; function DoPost(_URL:string;_Referer:string;_Order:TStringList):String; //向网页发送请求 procedure SetState(response:string) ; procedure updatelr; procedure getwebservice_dy; //获取 procedure getwebservice_yzh; //获取 procedure getwebservice_zc; //获取 procedure dewebservice; //关闭 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 setconcolor; //设置控件的颜色 function getCtnAfr(code:string):string; function getPkgAfr(code:string):string; function formatAfrstr(str:string):string; procedure PutToDebugLog(Operation, S1: String); function isEditrue(DataSet:TDataSet): boolean; procedure Delay(dwMilliseconds:DWORD); function get_edi_id:string; //获取全局唯一变量 public { Public declarations } dbserver:string; edi_addseai:boolean; function GetStrChar(str:String):string; function GetStrChar_1(str:String):string; function GetpkgsEdi(pkgs: String): String; function GetwypkgsEdi(pkgs: String): String; function GetpkgsEdi2(pkgs: String): String; function GetpkgsMscEdi(pkgs: String): String; procedure UpdateCTN(BSNO:STRING); procedure getwebservice_ds; function IsZhongwen(Str: String): Boolean; function CreateSIEdiFile_XML:TStrings; function GetCtnCode(ctnkind,ctnsize:String): String; function GetCtnWYCode(ctnkind,ctnsize:String): String; function GetCtnMSCCode(ctn:String): String; function GetCtnMSCCodeCode(ctn:String): String; procedure UpdateInfor; procedure SelectReciveData(bsno,mblno:string); function CreateIgengzongxml(SOI:string):TStringlist; function IgzEdi(EdiStrings:TStrings):Boolean; function formattel(str:string):string; function createzhjson(UserName,userpsw:string):string; procedure Sendzyzf(); procedure Sendzhzf(); procedure Sendqgzf(lhcd:string); procedure GetDuiBiStr; procedure Sendzczf(); end; var frm_op_seae_edi_data: Tfrm_op_seae_edi_data; AverageSpeed: Double = 0; STATE,EVENT,_S:String; hThread: THandle; {线程句柄} implementation uses u_main,u_data_share, my_sys_function, u_sys_progress, u_code_edicode, u_op_seae_edi_custom_cosco, u_op_seae_edi_custom_zt, u_op_seae_edi_custom_WaiDai, u_op_seae_edi_custom_WaiDai_1101, u_op_seae_edi_custom_yd, u_op_seae_edi_custom_LD, u_op_seae_edi_custom_wy, u_op_seae_edi_custom_hg, u_op_seae_edi_custom_zh, u_op_seae_edi_custom_hgydt, u_op_seae_zhedi, u_op_seae_edi_custom_qgzf, u_op_seae_edi_custom_zyzf, u_op_seae_edi_custom_lhcd, u_sys_messagedlg, u_code_zy_cust, u_op_seae_edi_custom_zhzf, u_op_seae_edi_custom_zczf; {$R *.dfm} procedure Tfrm_op_seae_edi_data.SetState(response: string); var _eventstart,_eventend,_statestart,_stateend:integer; _temp:string; begin _eventstart:=pos('name="__VIEWSTATE" id="',response); _temp:=copy(response,_eventstart+43,3000); _eventend:=pos('" />',_temp); _temp:=copy(_temp,0,_eventend-1); STATE:=_temp; //edit1.text:=_eventstart.Tostring(); _statestart:=pos('id="__EVENTVALIDATION" value="',response); _temp:=copy(response,_statestart+30,3000); _stateend:=pos('" />',_temp); _temp:=copy(_temp,0,_stateend-1); EVENT:=_temp; end; function Tfrm_op_seae_edi_data.DoPost(_URL:string;_Referer:string;_order:TStringList):String; var Param:TStringList; RStream:TStringStream; post:AnsiString; begin Param:=TStringList.Create; RStream:=TStringStream.Create(''); Param:=_order; IdHTTP1.ProtocolVersion:=pv1_1; IdHTTP1.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.Host:='56.qdcdc.com'; IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded'; IdHTTP1.Request.CustomHeaders.Text:='Cookie:'+mmo1.Text; IdHTTP1.Request.Referer:=_Referer; try IdHTTP1.Post(_URL,Param,RStream); except on e:Exception do//抛出所有异常 begin //doing something raise; end; end; result:=UTF8Decode(RStream.DataString); end; procedure Tfrm_op_seae_edi_data.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_seae_edi_data.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_seae_edi_data.getwebservice_yzh; begin try mHttpRIO_yzh:=THTTPRIO.Create(nil); mHttpRIO_yzh.WSDLLocation:='http://222.173.95.170:78/Service.asmx?WSDL'; mHttpRIO_yzh.URL:='http://222.173.95.170: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 );//就是这一行 { 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_seae_edi_data.dewebservice; begin mHttpRIO_dy.Free; end; procedure Tfrm_op_seae_edi_data.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 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 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 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; // t_op_ctn['表现形式']:=frm_data_share.t_code_ctn['表现形式']; 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 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; // t_op_ctn['表现形式']:=frm_data_share.t_code_ctn['表现形式']; 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_seae_edi_data.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 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',' ',[]); t_op_ctn.Post; end else begin t_op_ctn.append; s_ctnno:=Trim(FieldByName('CTNSZ').AsString); s_ctnType:=Trim(FieldByName('CTNTP').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:=Trim(FieldByName('CTNNO').AsString); // t_op_ctn.FieldByName('发箱日期').AsString:=StringReplace(Copy(FieldByName('EMFUEDT').AsString,1,Pos('.',FieldByName('EMFUEDT').AsString)-1),'T',' ',[]); { 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.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 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 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_seae_edi_data.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; begin sl:=tstringlist.Create; sl_data:=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_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(Utf8ToAnsi(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; 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_seae_edi_data.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; getwebservice_zc; 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); 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('箱号').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_seae_edi_data.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 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.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.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_seae_edi_data.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); 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'); 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 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 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_seae_edi_data.setconcolor; procedure consetcolor(fielname:String); var i:integer; scolor:string; begin scolor:=get_parameters_value(144,'clInfoBk'); with bsSkinGroupBox1 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; with bsSkinGroupBox2 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; with bsSkinGroupBox3 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; with bsSkinGroupBox4 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; with bsSkinGroupBox5 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; with bsSkinGroupBox7 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; with bsSkinGroupBox8 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; with bsSkinGroupBox9 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; with Panel1 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; with bsSkinPanel1 do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TwwDBComboBox then begin if TwwDBComboBox(Controls[i]).DataField=fielname then begin TwwDBComboBox(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBLookupCombo then begin if TwwDBLookupCombo(Controls[i]).DataField=fielname then begin TwwDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBEdit then begin if TDBEdit(Controls[i]).DataField=fielname then begin TDBEdit(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TwwDBDateTimePicker then begin if TwwDBDateTimePicker(Controls[i]).DataField=fielname then begin TwwDBDateTimePicker(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBMemo then begin if TDBMemo(Controls[i]).DataField=fielname then begin TDBMemo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TRxDBLookupCombo then begin if TRxDBLookupCombo(Controls[i]).DataField=fielname then begin TRxDBLookupCombo(Controls[i]).Color:=StringToColor(scolor); exit; end; end else if Controls[i] is TDBComboBoxEh then begin if TDBComboBoxEh(Controls[i]).DataField=fielname then begin TDBComboBoxEh(Controls[i]).Color:=StringToColor(scolor); exit; end; end; end; end; end; begin //必填项目不同颜色显示 frm_data_share.t_code_empty.Filtered:=false; frm_data_share.t_code_empty.Filter:='表=''t_op_seae_edi'''; frm_data_share.t_code_empty.Filtered:=true; frm_data_share.t_code_empty.First; while not frm_data_share.t_code_empty.Eof do begin consetcolor(frm_data_share.t_code_empty.fieldbyname('字段名称').asstring); frm_data_share.t_code_empty.next; end; end; procedure Tfrm_op_seae_edi_data.UpdateInfor; var aAdoQuery:TAdoQuery; begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('Update t_code_vessel set 船舶呼号=:船舶呼号'); sql.add('where 英文船名=:英文船名'); Parameters.ParamByName('英文船名').Value:=t_op_seae.fieldbyname('船名').asstring; Parameters.ParamByName('船舶呼号').Value:=t_op_seae.fieldbyname('船舶IMO').asstring; ExecSQL; finally Free; end; end; function Tfrm_op_seae_edi_data.GetStrChar_1(str:String):string; var i:integer; begin result:=''; if str='' then exit; for i:=1 to length(Str) do begin if str[i] in ['0','1','2','3','4','5','6','7','8','9','.'] then else result:=result+str[i]; end; end; function Tfrm_op_seae_edi_data.GetStrChar(str:String):string; var i:integer; begin result:=''; if str='' then exit; for i:=1 to length(Str) do begin if str[i] in ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] then else result:=result+str[i]; end; end; function Tfrm_op_seae_edi_data.IsZhongwen(Str: String): Boolean; var i:Integer; begin Result:=false; if Str='' then Exit; for i:=1 to Length(Str) do begin // if Str[i]>Chr(127) then begin if bytetype(Str[i],1)<>mbsinglebyte then begin Result:=True; Exit; end; end; end; function Tfrm_op_seae_edi_data.GetCtnCode(ctnkind,ctnsize:String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; ctnsize:=StringReplace(ctnsize,'''','''''',[rfReplaceAll]); try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 海关EDI代码 EDI代码 from t_code_ctn where 箱型='''+ctnkind+''' and 尺寸='''+ctnsize+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_data.GetpkgsEdi(pkgs: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select Edi代码 from t_code_package where 代码='''+pkgs+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_data.GetwypkgsEdi(pkgs: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 外运代码 from t_code_package where 代码='''+pkgs+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('外运代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_data.isEditrue(DataSet:TDataSet): boolean; var error:String; i,c : Integer; begin result:=true; if trim(get_parameters_value(301,''))='' then begin result:=false; if trim(error)='' then error:='用户代码' else error:=error+#13#10+'用户代码'; end; if trim(get_parameters_value(302,''))='' then begin result:=false; if trim(error)='' then error:='用户代码' else error:=error+#13#10+'发送方代码'; end; if trim(get_parameters_value(303,''))='' then begin result:=false; if trim(error)='' then error:='用户代码' else error:=error+#13#10+'接受方代码'; end; c:=0; if bsSkinComboBox1.ItemIndex=3 then begin for i:=0 to cxDBCheckListBox1.Count-1 do begin if cxDBCheckListBox1.Items[i].Checked then begin c:=c+1; end; end; if c<=0 then begin if trim(error)='' then error:='修改原因' else error:=error+#13#10+'修改原因'; end else if c>4 then begin if trim(error)='' then error:='最多只能选择3个原因' else error:=error+#13#10+'最多只能选择3个原因'; result:=false; end; end; if GetStrChar(DataSet.fieldbyname('主提单号').asstring)<>'' then begin result:=false; if trim(error)='' then error:='主提单号中存在非法字符' else error:=error+#13#10+'主提单号中存在非法字符'; end; if GetStrChar(DataSet.fieldbyname('分提单号').asstring)<>'' then begin result:=false; if trim(error)='' then error:='分提单号中存在非法字符' else error:=error+#13#10+'分提单号中存在非法字符'; end; if GetStrChar_1(DataSet.fieldbyname('运输方式').asstring)<>'' then begin result:=false; if trim(error)='' then error:='HS CODE 中存在非法字符' else error:=error+#13#10+'HS CODE 中存在非法字符'; end; if DataSet.fieldbyname('船舶IMO').AsString='' then begin result:=false; if trim(error)='' then error:='船舶IMO' else error:=error+#13#10+'船舶IMO'; end; if DataSet.fieldbyname('船公司代码').AsString='' then begin result:=false; if trim(error)='' then error:='船公司海关代码' else error:=error+#13#10+'船公司海关代码'; end; if trim(DataSet.fieldbyname('主提单号').asstring)='' then begin result:=false; if trim(error)='' then error:='主提单号' else error:=error+#13#10+'主提单号'; end; if trim(DataSet.fieldbyname('发货人名称').asstring)='' then begin result:=false; if trim(error)='' then error:='发货人名称' else error:=error+#13#10+'发货人名称'; end; if trim(DataSet.fieldbyname('发货人地址1').asstring)='' then begin result:=false; if trim(error)='' then error:='发货人地址1' else error:=error+#13#10+'发货人地址1'; end; if trim(DataSet.fieldbyname('收货人名称').asstring)='' then begin result:=false; if trim(error)='' then error:='收货人名称' else error:=error+#13#10+'收货人名称'; end; if trim(DataSet.fieldbyname('收货人地址1').asstring)='' then begin result:=false; if trim(error)='' then error:='收货人地址1' else error:=error+#13#10+'收货人地址1'; end; if trim(DataSet.fieldbyname('通知人名称').asstring)='' then begin result:=false; if trim(error)='' then error:='通知人名称' else error:=error+#13#10+'通知人名称'; end; if trim(DataSet.fieldbyname('通知人地址1').asstring)='' then begin result:=false; if trim(error)='' then error:='通知人地址1' else error:=error+#13#10+'通知人地址1'; end; if trim(DataSet.fieldbyname('付费方式').asstring)='' then begin result:=false; if trim(error)='' then error:='付费方式' else error:=error+#13#10+'付费方式'; end; if pos(' ', trim(DataSet.fieldbyname('船名').asstring))>0 then begin result:=false; if trim(error)='' then error:='船名存在两个空格' else error:=error+#13#10+'船名存在两个空格'; end; if trim(DataSet.fieldbyname('船名').asstring)='' then begin result:=false; if trim(error)='' then error:='船名' else error:=error+#13#10+'船名'; end; if trim(DataSet.fieldbyname('航次').asstring)='' then begin result:=false; if trim(error)='' then error:='航次' else error:=error+#13#10+'航次'; end; if Length(trim(DataSet.fieldbyname('船舶IMO').asstring))<7 then begin result:=false; if trim(error)='' then error:='船舶呼号不能小于7位' else error:=error+#13#10+'船舶呼号不能小于7位'; end; if trim(DataSet.fieldbyname('装港代码').asstring)='' then begin result:=false; if trim(error)='' then error:='装港代码' else error:=error+#13#10+'装港代码'; end; if trim(DataSet.fieldbyname('装货港').asstring)='' then begin result:=false; if trim(error)='' then error:='装货港' else error:=error+#13#10+'装货港'; end; if pos('/',trim(DataSet.fieldbyname('装港代码').asstring))<=0 then begin result:=false; if trim(error)='' then error:='装港代码代码中必须有 "/" ' else error:=error+#13#10+'装港代码代码中必须有 "/" '; end; if trim(DataSet.fieldbyname('开船日期').asstring)='' then begin result:=false; if trim(error)='' then error:='开船日期' else error:=error+#13#10+'开船日期'; end; if trim(DataSet.fieldbyname('预抵日期').asstring)='' then begin result:=false; if trim(error)='' then error:='预抵日期' else error:=error+#13#10+'预抵日期'; end; if trim(DataSet.fieldbyname('卸货代码').asstring)='' then begin result:=false; if trim(error)='' then error:='卸货代码' else error:=error+#13#10+'卸货代码'; end; if trim(DataSet.fieldbyname('目的代码').asstring)='' then begin result:=false; if trim(error)='' then error:='目的代码' else error:=error+#13#10+'目的代码'; end; if trim(DataSet.fieldbyname('目的地').asstring)='' then begin result:=false; if trim(error)='' then error:='目的地' else error:=error+#13#10+'目的地'; end; if trim(DataSet.fieldbyname('签单地点').asstring)='' then begin result:=false; if trim(error)='' then error:='签单地点' else error:=error+#13#10+'签单地点'; end; if trim(GetpkgsEdi(DataSet.fieldbyname('包装').asstring))='' then begin result:=false; if trim(error)='' then error:='包装代码' else error:=error+#13#10+'包装代码'; end; if Length(trim(GetpkgsEdi(DataSet.fieldbyname('包装').asstring)))<>2 then begin result:=false; if trim(error)='' then error:='包装代码只能是两位代码' else error:=error+#13#10+'包装代码只能是两位代码'; end; if trim(DataSet.fieldbyname('货物描述').asstring)='' then begin result:=false; if trim(error)='' then error:='货物描述' else error:=error+#13#10+'货物描述'; end; if trim(DataSet.fieldbyname('唛头').asstring)='' then begin result:=false; if trim(error)='' then error:='唛头' else error:=error+#13#10+'唛头'; end; if DataSet.fieldbyname('件数').asinteger=0 then begin result:=false; if trim(error)='' then error:='件数' else error:=error+#13#10+'件数'; end; if DataSet.fieldbyname('重量').asFloat=0 then begin result:=false; if trim(error)='' then error:='重量' else error:=error+#13#10+'重量'; end; if DataSet.fieldbyname('尺码').asFloat=0 then begin result:=false; if trim(error)='' then error:='尺码' else error:=error+#13#10+'尺码'; end; if trim(DataSet.fieldbyname('货物标识').asstring)='' then begin result:=false; if trim(error)='' then error:='货物标识' else error:=error+#13#10+'货物标识'; end; if trim(DataSet.FieldByName('货物标识').asstring)='D' then begin if Trim(DataSet.fieldbyname('危险品分类').asstring)='' then begin result:=false; if trim(error)='' then error:='危险品分类' else error:=error+#13#10+'危险品分类'; end; if Trim(DataSet.fieldbyname('危险品编号').asstring)='' then begin result:=false; if trim(error)='' then error:='危险品编号' else error:=error+#13#10+'危险品编号'; end; if GetStrNum(Trim(DataSet.fieldbyname('危险品编号').asstring))<>4 then begin result:=false; MessageDlg('危险品编号必须是4位数字',mtWarning,[mbOk],0); if trim(error)='' then error:='危险品编号必须是4位数字' else error:=error+#13#10+'危险品编号必须是4位数字'; end; end; if trim(DataSet.FieldByName('货物标识').asstring)='R' then begin if Trim(DataSet.fieldbyname('设置温度').asstring)='' then begin result:=false; if trim(error)='' then error:='设置温度' else error:=error+#13#10+'设置温度'; end; end; t_op_ctn.close; t_op_ctn.Parameters.ParamByName('编号').Value:=DataSet.fieldbyname('编号').asstring; t_op_ctn.open; if t_op_ctn.IsEmpty then begin result:=false; MessageDlg('集装箱不能为空',mtWarning,[mbOk],0); end; t_op_ctn.First; while not t_op_ctn.Eof do begin if Trim(t_op_ctn.fieldbyname('箱号').asstring)='' then begin result:=false; if trim(error)='' then error:='箱号' else error:=error+#13#10+'箱号'; end; if Trim(t_op_ctn.fieldbyname('封号').asstring)='' then begin result:=false; if trim(error)='' then error:='封号' else error:=error+#13#10+'封号'; end; if trim(GetpkgsEdi(t_op_ctn.fieldbyname('包装').asstring))='' then begin result:=false; if trim(error)='' then error:='包装代码' else error:=error+#13#10+'包装代码'; end; if Length(trim(GetpkgsEdi(t_op_ctn.fieldbyname('包装').asstring)))<>2 then begin result:=false; if trim(error)='' then error:='包装代码只能是两位代码' else error:=error+#13#10+'包装代码只能是两位代码'; end; if t_op_ctn.fieldbyname('件数').asinteger=0 then begin result:=false; if trim(error)='' then error:='件数' else error:=error+#13#10+'件数'; end; if t_op_ctn.fieldbyname('重量').asFloat=0 then begin result:=false; if trim(error)='' then error:='重量' else error:=error+#13#10+'重量'; end; if t_op_ctn.fieldbyname('尺码').asFloat=0 then begin result:=false; if trim(error)='' then error:='尺码' else error:=error+#13#10+'尺码'; end; if GetCtnCode(t_op_ctn.fieldbyname('箱型').asstring,t_op_ctn.fieldbyname('尺寸').asstring)='' then begin result:=false; if trim(error)='' then error:='集装箱Edi代码' else error:=error+#13#10+'集装箱Edi代码'; end; t_op_ctn.Next; end; if iszhongwen(dataset.fieldbyname('唛头').AsString) then begin result:=false; MessageDlg('唛头不能有中文字符!',mtWarning,[mbOk],0); end; if iszhongwen(dataset.fieldbyname('货物描述').AsString) then begin result:=false; MessageDlg('货物描述不能有中文字符!',mtWarning,[mbOk],0); end; if trim(error)<>'' then ShowMessage(error+#13#10+'不能为空'); end; function Tfrm_op_seae_edi_data.CreateSIEdiFile_XML:TStrings; var str:Tstringlist; i,j,k,l,Count:integer; strsql,strRmain:string; rs:Tadoquery; wide_str:widestring; inifile1:Tinifile; strType,XType,TransType:string; strDatetime,IMO:string; SenderCode,ReciverCode:string; alist,alisttemp:TStringList; begin if not isEditrue(frm_op_seae_edi_data.t_op_seae) then begin Exit; end; SenderCode:=trim(get_parameters_value(302,'')) ; ReciverCode:=trim(get_parameters_value(303,'')) ; if bsSkinComboBox1.ItemIndex=0 then strType:='9' else if bsSkinComboBox1.ItemIndex=1 then strType:='2' else if bsSkinComboBox1.ItemIndex=2 then strType:='3' else if bsSkinComboBox1.ItemIndex=3 then strType:='5' else if bsSkinComboBox1.ItemIndex=4 then strType:='0' else if bsSkinComboBox1.ItemIndex=5 then strType:='11' else strType:='9'; if bsSkinComboBox1.ItemIndex<>2 then begin if frm_op_seae_edi_data.dxdbgrid1.SelectedCount<=1 then begin str:=Tstringlist.Create; str.Clear; str.Add(''); // str.Add(''); str.Add(''); str.Add(''); // str.Add(''+SenderCode+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring)+GetDatetime(datetimetostr(now),3)+IntToStr(GetTickCount)+''); // str.Add(''+strType+''); // str.Add('MT2101'); // str.Add(''+SenderCode+''); // str.Add(''+ReciverCode+''); // str.Add(''+GetDatetime(datetimetostr(now),4)+''); // str.Add('1.0'); str.Add(''); // str.Add(''); // str.Add(''); // str.Add(''+SenderCode+''); str.Add(''); // str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('装港代码').asstring)+''); str.Add(''); // str.Add(''); // str.Add(''+SenderCode+''); str.Add(''); // str.Add(''); // str.Add(''+frm_op_seae_edi_data.t_op_seae.fieldbyname('船公司代码').AsString+''); str.Add(''); // str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('航次').asstring)+''); // str.Add('1'); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('船舶IMO').asstring)+''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('船名').AsString)+''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('卸货代码').asstring)+''); // str.Add(''+GetDatetime(frm_op_seae_edi_data.t_op_seae.fieldbyname('开船日期').asstring,1)+'086'+''); // str.Add(''+GetDatetime(frm_op_seae_edi_data.t_op_seae.fieldbyname('预抵日期').asstring,1)+'086'+''); str.Add(''); // str.Add(''); // str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring)+''); // if bsSkinComboBox1.ItemIndex=3 then begin for i:=0 to cxDBCheckListBox1.Count-1 do begin if cxDBCheckListBox1.Items[i].Checked then begin str.Add(''+COPY(cxDBCheckListBox1.Items[i].Text,1,Pos(':',cxDBCheckListBox1.Items[i].Text)-1)+''); end; end; end; if pos('FREIGHT PREPAID',trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('付费方式').asstring)) >0 then xtype := 'PP' else if pos('FREIGHT COLLECT',trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('付费方式').asstring)) >0 then xtype := 'CC' else xtype := 'PP'; if uppercase(frm_op_seae_edi_data.t_op_seae.fieldbyname('运输条款').asstring)='CY-CY' then TransType:='10' else if uppercase(frm_op_seae_edi_data.t_op_seae.fieldbyname('运输条款').asstring)='DOOR-DOOR' then TransType:='27' else if uppercase(frm_op_seae_edi_data.t_op_seae.fieldbyname('运输条款').asstring)='DOOR-PIER' then TransType:='28' else if uppercase(frm_op_seae_edi_data.t_op_seae.fieldbyname('运输条款').asstring)='PIER-DOOR' then TransType:='29' else TransType:='10'; // PIER TO PIER // str.Add(''+TransType+''); // { str.Add(''); // str.Add(''); str.Add(''); } str.Add(''); // { if trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('分提单号').asstring)<>'' then begin str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('分提单号').asstring)+''); str.Add(''); end else begin end; } // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('尺码').asstring)+''); // // str.Add(''); // str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('装港代码').asstring)+''); // str.Add(''+GetDatetime(frm_op_seae_edi_data.t_op_seae.fieldbyname('开船日期').asstring,1)+'086'+''); str.Add(''); // str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('卸货代码').asstring)+''); // str.Add(''+GetDatetime(frm_op_seae_edi_data.t_op_seae.fieldbyname('预抵日期').asstring,0)+''); str.Add(''); // str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('目的代码').asstring)+''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('目的地').asstring)+''); str.Add(''); { // str.Add(''); // str.Add('); str.Add('') } // str.Add(''); // str.Add(''+xtype+''); str.Add(''); // str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('件数').asstring)+''); // str.Add(''+trim(GetpkgsEdi(frm_op_seae_edi_data.t_op_seae.fieldbyname('包装').asstring))+''); str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('重量').asstring)+''); { } // str.Add(''); // str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('收货人企业代码').AsString))+''); // str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('收货人名称').AsString))+''); // str.Add('
'); // str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('收货人地址1').AsString))+''); { } str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('收货人国家代码').AsString))+''); str.Add('
'); if (frm_op_seae_edi_data.t_op_seae.fieldbyname('收货人电话').AsString<>'') or (frm_op_seae_edi_data.t_op_seae.fieldbyname('收货人邮箱').AsString<>'') then begin // str.Add(''); // if (frm_op_seae_edi_data.t_op_seae.fieldbyname('收货人电话').AsString<>'') then begin str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('收货人电话').AsString))+''); // str.Add('TE'); end else begin str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('收货人邮箱').AsString))+''); // str.Add('FX'); end; str.Add(''); end; { } str.Add('
'); // str.Add(''); // str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('发货人企业代码').AsString))+''); // str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('发货人名称').AsString))+''); // str.Add('
'); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('发货人地址1').AsString)+''); { } str.Add('
'); { } if (frm_op_seae_edi_data.t_op_seae.fieldbyname('发货人电话').AsString<>'') or (frm_op_seae_edi_data.t_op_seae.fieldbyname('发货人邮箱').AsString<>'') then begin // str.Add(''); // if (frm_op_seae_edi_data.t_op_seae.fieldbyname('发货人电话').AsString<>'') then begin str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('发货人电话').AsString))+''); // str.Add('TE'); end else begin str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('发货人邮箱').AsString))+''); // str.Add('FX'); end; str.Add(''); end; str.Add('
'); // str.Add(''); // str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('通知人企业代码').AsString))+''); // str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('通知人名称').AsString))+''); // str.Add('
'); // str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('通知人地址1').AsString))+''); { } str.Add(''+formatAfrstr(trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('通知人国家代码').AsString))+''); str.Add('
'); { } str.Add('
'); { } strsql:='select * from t_op_ctn_edi ' +'WHERE 编号=' +#39+frm_op_seae_edi_data.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=CreateAdoQuery; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; if not rs.IsEmpty then begin rs.First; while not rs.Eof do begin // str.Add(''); // str.Add(''); // str.Add(''+rs.fieldbyname('箱号').asstring+''); str.Add(''); // str.Add(''+GetCtnCode(rs.fieldbyname('箱型').asstring,rs.fieldbyname('尺寸').asstring)+''); // str.Add('2'); // str.Add('5'); // str.Add('M/'+trim(rs.fieldbyname('封号').asstring)+''); str.Add(''); rs.Next; end; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; k:=1; alist:=TStringList.Create; alisttemp:=TStringList.Create; strsql:='select * from t_op_ctn_edi ' +'WHERE 编号=' +#39+frm_op_seae_edi_data.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=CreateAdoQuery; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; if not rs.IsEmpty then begin rs.First; while not rs.Eof do begin // str.Add(''); // str.Add(''+inttostr(k)+''); // str.Add(''); // str.Add(''+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+''); // str.Add(''+trim(GetpkgsEdi(rs.fieldbyname('包装').asstring)) +''); alist.text:=''; if trim(rs.fieldbyname('唛头').asstring)<>'' then alist.text:=trim(rs.fieldbyname('唛头').asstring) else alist.text:=trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('唛头').asstring); alisttemp.Clear; for l:=0 to alist.Count-1 do begin alisttemp.Add(formatAfrstr(alist[l])); end; // str.Add(''+alisttemp.text+''); str.Add(''); alist.text:=''; if trim(rs.fieldbyname('货描').asstring)<>'' then alist.text:=trim(rs.fieldbyname('货描').asstring) else alist.text:=trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('货物描述').asstring); alisttemp.Clear; for l:=0 to alist.Count-1 do begin alisttemp.Add(formatAfrstr(alist[l])); end; // str.Add(''); // str.Add(''+alisttemp.text+''); // if trim(frm_op_seae_edi_data.t_op_seae.FieldByName('货物标识').asstring)='D' then begin str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品编号').asstring)+''); end; // if trim(rs.fieldbyname('HTS号').asstring)<>'' then str.Add(''+rs.fieldbyname('HTS号').asstring+'') else begin if trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('运输方式').asstring)<>'' then str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('运输方式').asstring)+''); end; str.Add(''); // { str.Add(''); // str.Add(''); str.Add(''); } // str.Add(''); // str.Add(''+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+''); str.Add(''); // str.Add(''); // str.Add(''+trim(rs.fieldbyname('箱号').asstring)+''); str.Add(''); // { str.Add(''); // str.Add(''); str.Add(''); } { // str.Add(''); // str.Add(''); str.Add(''); } // { str.Add(''); // str.Add(''); str.Add(''); } str.Add(''); k:=k+1; rs.Next; end; end; rs.Close; rs.Destroy; alist.Free; alisttemp.Free; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; str.Add('
'); // { str.Add(''); // str.Add(''); str.Add(''); } str.Add('
'); str.Add('
'); frm_op_seae_edi_data.t_op_seae.Edit; frm_op_seae_edi_data.t_op_seae.FieldByName('EDI状态').AsString:='已发送'; frm_op_seae_edi_data.t_op_seae.Post; end end else begin if frm_op_seae_edi_data.dxdbgrid1.SelectedCount<=1 then begin str:=Tstringlist.Create; str.Clear; str.Add(''); // str.Add(''); str.Add(''); str.Add(''); // str.Add(''+SenderCode+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring)+GetDatetime(datetimetostr(now),3)+IntToStr(GetTickCount)+''); // str.Add(''+strType+''); // str.Add('MT2101'); // str.Add(''+SenderCode+''); // str.Add(''+ReciverCode+''); // str.Add(''+GetDatetime(datetimetostr(now),4)+''); // str.Add('1.0'); str.Add(''); // str.Add(''); // str.Add(''); // str.Add(''+SenderCode+''); str.Add(''); // str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('航次').asstring)+''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('船舶IMO').asstring)+''); str.Add(''); // str.Add(''); // str.Add(''); // str.Add(''+trim(frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring)+''); // if (bsSkinComboBox1.ItemIndex=2) then begin for i:=0 to cxDBCheckListBox1.Count-1 do begin if cxDBCheckListBox1.Items[i].Checked then begin str.Add(''+COPY(cxDBCheckListBox1.Items[i].Text,1,Pos(':',cxDBCheckListBox1.Items[i].Text)-1)+''); end; end; end; str.Add(''); str.Add(''); str.Add(''); str.Add(''); frm_op_seae_edi_data.t_op_seae.Edit; frm_op_seae_edi_data.t_op_seae.FieldByName('EDI状态').AsString:='已发送'; frm_op_seae_edi_data.t_op_seae.Post; end; end; Result:=str; end; procedure Tfrm_op_seae_edi_data.getwebservice_ds; begin try mHttpRIO_ds:=THTTPRIO.Create(nil); mHttpRIO_ds.WSDLLocation:='http://122.4.79.84:8090/webservice/DsWebService.asmx?WSDL'; mHttpRIO_ds.URL:='http://122.4.79.84:8090/webservice/DsWebService.asmx'; mHttpRIO_ds.Port:='DsWebServiceSoap'; mHttpRIO_ds.Service:='DsWebService'; mHttpRIO_ds.HTTPWebNode.UseUTF8InHeader:=true; mServiceSoap_Ds:=mHttpRIO_ds as DsWebServiceSoap; InvRegistry.RegisterInvokeOptions(TypeInfo(DsWebServiceSoap),ioDocument );//就是这一行 { mHttpRIO_ds:=THTTPRIO.Create(nil); mHttpRIO_ds.WSDLLocation:='http://221.3.83.5:8090/webservice/DsWebService.asmx?WSDL'; mHttpRIO_ds.URL:='http://221.3.83.5:8090/webservice/DsWebService.asmx'; mHttpRIO_ds.Port:='DsWebServiceSoap'; mHttpRIO_ds.Service:='DsWebService'; mHttpRIO_ds.HTTPWebNode.UseUTF8InHeader:=true; mServiceSoap_Ds:=mHttpRIO_ds as DsWebServiceSoap; InvRegistry.RegisterInvokeOptions(TypeInfo(DsWebServiceSoap),ioDocument );//就是这一行 } except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; procedure Tfrm_op_seae_edi_data.UpdateCTN(BSNO:STRING); var aAdoQuery:TAdoQuery; p:Integer; w,c:Double; begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select sum(件数) 件数, sum(重量) 重量,sum(尺码) 尺码 from t_op_ctn_edi'); sql.add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=BSNO; open;First; if not IsEmpty then begin t_op_seae.Edit; p:=FieldByName('件数').AsInteger; w:=FieldByName('重量').AsFloat; c:=FieldByName('尺码').AsFloat; t_op_seae.Post; close; sql.clear; sql.add('Update t_op_seae_edi set 件数=:件数, 重量=:重量,尺码=:尺码'); sql.add('where 编号=:编号'); Parameters.ParamByName('件数').Value:=p; Parameters.ParamByName('重量').Value:=w; Parameters.ParamByName('尺码').Value:=c; Parameters.ParamByName('编号').Value:=BSNO; ExecSQL; end; finally Free; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_edi_data.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); if hThread>0 then TerminateThread(hThread,0); frm_op_seae_edi_data.Hide; frm_op_seae_edi_data.ManualFloat(frm_op_seae_edi_data.BoundsRect ); frm_main.freeTabs('frm_op_seae_edi_data'); action:=cafree; frm_op_seae_edi_data:=nil; end; procedure Tfrm_op_seae_edi_data.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/16); bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton11.Width:=i; bsSkinButton14.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; bsSkinButton38.Width:=i; bsSkinButton22.Width:=i; bsSkinButton25.Width:=i; bsSkinButton27.Width:=i; bsSkinButton29.Width:=i; end; procedure Tfrm_op_seae_edi_data.bsSkinButton7Click(Sender: TObject); begin table_Prior(t_op_seae); end; procedure Tfrm_op_seae_edi_data.bsSkinButton6Click(Sender: TObject); begin table_next(t_op_seae); end; procedure Tfrm_op_seae_edi_data.bsSkinButton2Click(Sender: TObject); begin t_op_seae.fieldbyname('预抵日期').AsDateTime:=t_op_seae.fieldbyname('开船日期').AsDateTime+3; table_post(t_op_seae); end; procedure Tfrm_op_seae_edi_data.bsSkinButton11Click(Sender: TObject); var answer:TModalResult; begin if bsSkinButton11.Caption='编辑修改' then begin Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; // GetDuiBiStr; //DBEdit3.OnChange(Sender); end else begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then BEGIN answer:=messagedlg( '数据已经修改,是否保存?',mtWarning,mbYesNoCancel,0); if answer=mrYes then begin t_op_seae.post; end; if answer=mrNo then begin t_op_seae.cancel; end; if answer=mrCancel then begin exit; end; END; Notebook1.PageIndex:=0; bsSkinButton11.Caption:='编辑修改'; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton4Click(Sender: TObject); var i,j:Integer; strno:string; aQuery:TADOQuery; begin if t_op_seae.FieldByName('EDI状态').AsString='已发送' then begin showmessage('已发送不能修改,删除!'); Exit; end; j:=dxDBGrid1.SelectedCount; strno:=' where 1=2 '; for i:=0 to j-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); strno:=strno+' or 编号='''+t_op_seae.fieldbyname('编号').asstring+''''; end; if MessageDlg('确定要删除选中的'+inttostr(j)+'票业务数据吗?',mtWarning,[mbyes,mbno],0)=mryes then begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add(' delete from t_op_ctn_detail_edi where ctn_id in (select ctn_id from t_op_ctn_edi '+strno+')'); ExecSQL; Close;SQL.Clear; SQL.Add(' delete from t_op_ctn_edi '+strno); ExecSQL; Close;SQL.Clear; SQL.Add(' delete from t_op_seae_edi '+strno); ExecSQL; end; finally FreeAndNil(aQuery); end; t_op_seae.Refresh; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_seae); end; procedure Tfrm_op_seae_edi_data.bsSkinButton38Click(Sender: TObject); var book1:Tbookmark; begin book1:=t_op_seae.GetBookmark; t_op_seae.Refresh; t_op_seae.GotoBookmark(book1); end; procedure Tfrm_op_seae_edi_data.FormShow(Sender: TObject); var inifile1:Tinifile; s:string; FromFileName,ToFileName:string; begin Notebook1.PageIndex:=0; inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); s:=inifile1.ReadString('database','Data Source',''); if Pos('\',s)>0 then begin dbserver:=Copy(s,1,Pos('\',s)-1); end else if Pos(';',s)>0 then begin dbserver:=Copy(s,1,Pos(';',s)-1); end else dbserver:=s; 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); if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.bsSkinGauge1.ProgressText:='加载数据请等候。。。'; frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=28; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; //委托编号处理 t_op_seae.Close; t_op_seae.SQL.clear; t_op_seae.SQL.Add('select top 100 * from t_op_seae_edi where EDI类型=''CN'' AND ' +'(录入人='+''''+employee+''''+') order by 录入日期 desc '); t_op_seae.open; t_op_ctn.Open; t_op_ctn_detail.Open; t_op_state.Open; t_code_cangdan.Open; t_code_cdstatus.open; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; loadreggrid(dxdbgrid1,false,caption); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; {with t_code_shiper do begin Close; SQL.Clear; SQL.Add('select * from t_code_edicode where 发货人=1 and 操作员='+QuotedStr(employee)+' order by 代码'); Open; end; } t_code_shiper.Open; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; {with t_code_consignee do begin Close; SQL.Clear; SQL.Add('select * from t_code_edicode where 收货人=1 and 操作员='+QuotedStr(employee)+' order by 代码'); Open; end;} t_code_goods_not.Open; t_code_consignee.Open; code_e_carrier.Open; code_cdkehuchuand.Open; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; {with t_code_notifyparty do begin Close; SQL.Clear; SQL.Add('select * from t_code_edicode where 通知人=1 and 操作员='+QuotedStr(employee)+' order by 代码'); Open; end;} t_code_notifyparty.Open; t_code_carrier.Open; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; if if_reg(20301) then //外代 begin NWD2101.Visible:=True; // NWD1101.Visible:=True; end else begin NWD2101.Visible:=False; // NWD1101.Visible:=False; end; if if_reg(20302) then //外运 begin NWY.Visible:=True; end else begin NWY.Visible:=False; end; if if_reg(20303) then //联代 begin NLD.Visible:=True; end else begin NLD.Visible:=False; end; if if_reg(20304) then //华港 begin // NHG.Visible:=True; end else begin // NHG.Visible:=False; end; if if_reg(20305) then //远大 begin NYD.Visible:=True; end else begin NYD.Visible:=False; end; if if_reg(20306) then //中远 begin // NZY.Visible:=True; end else begin // NZY.Visible:=False; end; if if_reg(20307) then //中通 begin // NZT.Visible:=True; end else begin // NZT.Visible:=False; end; if if_reg(20309) then //海丰 begin NHF.Visible:=True; end else begin NHF.Visible:=False; end; if if_reg(20310) then //振华 begin NZH.Visible:=True; // ShowMessage('ok'); end else begin NZH.Visible:=False; end; if if_reg(20311) then //海关一点通 begin NHGYDT.Visible:=True; end else begin NHGYDT.Visible:=False; end; end; procedure Tfrm_op_seae_edi_data.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_seae_edi_data.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_seae_edi_data.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,213); end; procedure Tfrm_op_seae_edi_data.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_seae_edi_data.bsSkinButton8Click(Sender: TObject); VAR str:widestring; adate:TDate; begin str:='where EDI类型=''CN'' AND '+open_data('0001','录入人','no','no','no','no'); if (not CheckBox1.Checked) then begin adate:=IncMonth(Now,-3); str:=str+' and 录入日期>='+''''+formatdatetime('yyyy-mm-dd',adate)+''''; adate:=IncMonth(Now,1); str:=str+' and 录入日期<='+''''+formatdatetime('yyyy-mm-dd',adate)+''''; end; if Edit3.text<>''then str:=str+' and 主提单号 like '+''''+'%'+Edit3.text+'%'+''''; if Edit1.text<>''then str:=str+' and 分提单号 like '+''''+'%'+Edit1.text+'%'+''''; if wwDBComboBoxType.text<>''then str:=str+' and EDI类型 like '+''''+wwDBComboBoxType.text+''''; if wwDBComboBox2.text<>''then str:=str+' and EDI状态 like '+''''+wwDBComboBox2.text+''''; if wwDBDateTimePicker9.text<>''then str:=str+' and 录入日期>='+''''+wwDBDateTimePicker9.text+''''; if wwDBDateTimePicker12.text<>''then str:=str+' and 录入日期<='+''''+wwDBDateTimePicker12.text+' 23:59:59'''; if wwDBDateTimePicker11.text<>''then str:=str+' and 开船日期>='+''''+wwDBDateTimePicker11.text+''''; if wwDBDateTimePicker13.text<>''then str:=str+' and 开船日期<='+''''+wwDBDateTimePicker13.text+''''; if wwDBComboBoxOP.text<>''then str:=str+' and 录入人='+''''+wwDBComboBoxOP.text+''''; if wwDBComboBox5.text<>''then str:=str+' and 转发类型='+''''+wwDBComboBox5.text+''''; str:=query_tiaojian(1,str,'船名','模糊',wwDBLookupCombo26.text); str:=query_tiaojian(1,str,'航次','模糊',Edit8.text); str:=query_tiaojian(1,str,'船公司','模糊',Edit9.text); str:=query_tiaojian(1,str,'船代','模糊',Edit10.text); str:=query_tiaojian(1,str,'卸货港','模糊',Edit11.text); str:=query_tiaojian(1,str,'委托发送方','模糊',Edit12.text); if Edit2.text<>''then str:=str+' and 编号 in ( select 编号 from t_op_ctn_edi where 箱号 like '+''''+'%'+Edit2.text+'%'+''')'; t_op_ctn.close; t_op_ctn_detail.close; t_op_state.close; t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add('select * from t_op_seae_edi '+str+' order by 主提单号'); t_op_seae.open; t_op_ctn.open; t_op_ctn_detail.open; t_op_state.open; end; procedure Tfrm_op_seae_edi_data.bsSkinButton12Click(Sender: TObject); begin Edit3.text:=''; Edit8.text:=''; Edit2.text:=''; Edit1.text:=''; Edit11.text:=''; Edit12.text:=''; wwDBDateTimePicker9.text:=''; wwDBDateTimePicker12.text:=''; wwDBDateTimePicker11.text:=''; wwDBDateTimePicker13.text:=''; wwDBComboBoxType.Text:=''; wwDBComboBox2.Text:=''; wwDBLookupCombo26.Clear; end; procedure Tfrm_op_seae_edi_data.bsSkinButton14Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton14.ClientToScreen(Point(0,bsSkinButton14.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_edi_data.bsSkinSpeedButton1Click(Sender: TObject); begin if bsSkinGroupBox5.Visible then begin bsSkinGroupBox5.Visible:=false; bsSkinGroupBox2.Visible:=true; end else begin bsSkinGroupBox5.left:=bsSkinGroupBox2.Left; bsSkinGroupBox5.Top:=bsSkinGroupBox2.Top; bsSkinGroupBox5.Height:=bsSkinGroupBox2.Height; bsSkinGroupBox5.Width:=bsSkinGroupBox2.Width; bsSkinGroupBox2.Visible:=False; bsSkinGroupBox5.Visible:=True; end; end; procedure Tfrm_op_seae_edi_data.bsSkinSpeedButton2Click(Sender: TObject); begin if bsSkinGroupBox7.Visible then begin bsSkinGroupBox7.Visible:=false; bsSkinGroupBox3.Visible:=true; end else begin bsSkinGroupBox7.left:=bsSkinGroupBox3.Left; bsSkinGroupBox7.Top:=bsSkinGroupBox3.Top; bsSkinGroupBox7.Height:=bsSkinGroupBox3.Height; bsSkinGroupBox7.Width:=bsSkinGroupBox3.Width; bsSkinGroupBox3.Visible:=False; bsSkinGroupBox7.Visible:=True; end; end; procedure Tfrm_op_seae_edi_data.bsSkinSpeedButton3Click(Sender: TObject); begin if bsSkinGroupBox8.Visible then begin bsSkinGroupBox8.Visible:=false; bsSkinGroupBox2.Visible:=true; end else begin bsSkinGroupBox8.left:=bsSkinGroupBox2.Left; bsSkinGroupBox8.Top:=bsSkinGroupBox2.Top; bsSkinGroupBox8.Height:=bsSkinGroupBox2.Height; bsSkinGroupBox8.Width:=bsSkinGroupBox2.Width; bsSkinGroupBox2.Visible:=False; bsSkinGroupBox8.Visible:=True; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton56Click(Sender: TObject); begin t_op_ctn.insert; end; procedure Tfrm_op_seae_edi_data.bsSkinButton57Click(Sender: TObject); begin table_post(t_op_ctn); end; procedure Tfrm_op_seae_edi_data.bsSkinButton58Click(Sender: TObject); begin table_delete(t_op_ctn); end; procedure Tfrm_op_seae_edi_data.bsSkinButton59Click(Sender: TObject); begin table_cancel(t_op_ctn); end; procedure Tfrm_op_seae_edi_data.wwDBLookupComboctnChange(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('代码',wwDBLookupComboctn.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_seae_edi_data.btnMarksClick(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'唛头'); end; procedure Tfrm_op_seae_edi_data.btnDescClick(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'货描'); end; procedure Tfrm_op_seae_edi_data.t_op_ctnAfterInsert(DataSet: TDataSet); begin t_op_ctn['编号']:=t_op_seae1.DataSet['编号']; t_op_ctn['数量']:=1; t_op_ctn['TEU']:=0; end; procedure Tfrm_op_seae_edi_data.wwDBGrid1ColEnter(Sender: TObject); begin if (wwDBGrid1.GetActiveField.FieldName='唛头') then begin // bsSkinPanel4.Visible:=true; // Label62.Visible:=True; // Label61.Visible:=false; // DBMemo5.Visible:=true; // DBMemo4.Visible:=false; end else if (wwDBGrid1.GetActiveField.FieldName='货描') then begin // bsSkinPanel4.Visible:=true; // Label62.Visible:=false; // Label61.Visible:=True; // DBMemo5.Visible:=false; // DBMemo4.Visible:=true; end else begin // bsSkinPanel4.Visible:=False; end; end; function Tfrm_op_seae_edi_data.getCtnAfr(code: string): string; var aQuery:TADOQuery; begin result:=''; aQuery:=CreateAdoQuery; try with aQuery do begin Close; SQL.Text:='select AFR代码 from t_code_ctn where 代码='''+code+''''; Open; Result:=aQuery.fieldbyname('AFR代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_data.getPkgAfr(code: string): string; var aQuery:TADOQuery; begin result:=''; aQuery:=CreateAdoQuery; try with aQuery do begin Close; SQL.Text:='select AFR代码 from t_code_package where 代码='''+code+''''; Open; if not IsEmpty then Result:=aQuery.fieldbyname('AFR代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_data.formatAfrstr(str: string): string; begin Result:=Trim(str); Result:=StringReplace(Result,'&','&',[rfReplaceAll]); Result:=StringReplace(Result,'<','<',[rfReplaceAll]); Result:=StringReplace(Result,'"','"',[rfReplaceAll]); Result:=StringReplace(Result,'>','>',[rfReplaceAll]); Result:=StringReplace(Result,'''',''',[rfReplaceAll]); end; procedure Tfrm_op_seae_edi_data.bsSkinButton1Click(Sender: TObject); begin t_op_ctn_detail.insert; end; procedure Tfrm_op_seae_edi_data.bsSkinButton9Click(Sender: TObject); begin table_post(t_op_ctn_detail); end; procedure Tfrm_op_seae_edi_data.bsSkinButton10Click(Sender: TObject); begin table_delete(t_op_ctn_detail); end; procedure Tfrm_op_seae_edi_data.bsSkinButton13Click(Sender: TObject); begin table_cancel(t_op_ctn_detail); end; procedure Tfrm_op_seae_edi_data.t_op_ctn_detailAfterInsert(DataSet: TDataSet); begin t_op_ctn_detail['ctn_id']:=t_op_ctn['ctn_id']; end; procedure Tfrm_op_seae_edi_data.t_op_ctn_detailBeforePost(DataSet: TDataSet); begin t_op_ctn_detail['ctn_id']:=t_op_ctn['ctn_id']; end; procedure Tfrm_op_seae_edi_data.t_op_ctn_detailBeforeInsert(DataSet: TDataSet); begin if t_op_ctn.State in [dsedit,dsinsert] then t_op_ctn.Post; end; procedure Tfrm_op_seae_edi_data.bsSkinButton17Click(Sender: TObject); begin try if IdFTP1.Connected then begin IdFTP1.Abort; IdFTP1.Quit; end; finally bsSkinGroupBox11.Visible:=false; bsSkinButton16.Enabled:=True; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton19Click(Sender: TObject); begin frm_code_edicode:=Tfrm_code_edicode.Create(self); try frm_code_edicode.t_code_edicode.Open; if not frm_code_edicode.t_code_edicode.Locate('简称',RxDBLookupCombo16.DisplayValue,[]) then begin frm_code_edicode.t_code_edicode.Insert; frm_code_edicode.t_code_edicode.FieldByName('客户简称').AsString:=t_op_seae.fieldbyname('发货人').AsString; frm_code_edicode.t_code_edicode.FieldByName('发货人').AsBoolean:=true; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('发货人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('发货人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('发货人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('发货人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('发货人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('发货人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('发货人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('发货人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('发货人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('发货人州').AsString; end else begin frm_code_edicode.t_code_edicode.Edit; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('发货人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('发货人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('发货人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('发货人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('发货人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('发货人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('发货人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('发货人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('发货人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('发货人州').AsString; end; frm_code_edicode.ShowModal; finally t_code_shiper.Requery(); FreeAndNil(frm_code_edicode); end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton20Click(Sender: TObject); begin frm_code_edicode:=Tfrm_code_edicode.Create(self); try frm_code_edicode.t_code_edicode.Open; if not frm_code_edicode.t_code_edicode.Locate('简称',RxDBLookupCombo1.DisplayValue,[]) then begin frm_code_edicode.t_code_edicode.Insert; frm_code_edicode.t_code_edicode.FieldByName('客户简称').AsString:=t_op_seae.fieldbyname('收货人').AsString; frm_code_edicode.t_code_edicode.FieldByName('收货人').AsBoolean:=true; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('收货人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('收货人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('收货人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('收货人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('收货人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('收货人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('收货人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('收货人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('收货人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('收货人州').AsString; end else begin frm_code_edicode.t_code_edicode.Edit; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('收货人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('收货人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('收货人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('收货人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('收货人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('收货人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('收货人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('收货人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('收货人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('收货人州').AsString; end; frm_code_edicode.ShowModal; finally t_code_consignee.Requery(); FreeAndNil(frm_code_edicode); end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton21Click(Sender: TObject); begin frm_code_edicode:=Tfrm_code_edicode.Create(self); try frm_code_edicode.t_code_edicode.Open; if not frm_code_edicode.t_code_edicode.Locate('简称',RxDBLookupCombo2.DisplayValue,[]) then begin frm_code_edicode.t_code_edicode.Insert; frm_code_edicode.t_code_edicode.FieldByName('客户简称').AsString:=t_op_seae.fieldbyname('通知人').AsString; frm_code_edicode.t_code_edicode.FieldByName('通知人').AsBoolean:=true; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('通知人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('通知人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('通知人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('通知人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('通知人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('通知人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('通知人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('通知人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('通知人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('通知人州').AsString; end else begin frm_code_edicode.t_code_edicode.Edit; frm_code_edicode.t_code_edicode.FieldByName('名称').AsString:=t_op_seae.fieldbyname('通知人名称').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址1').AsString:=t_op_seae.fieldbyname('通知人地址1').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址2').AsString:=t_op_seae.fieldbyname('通知人地址2').AsString; frm_code_edicode.t_code_edicode.FieldByName('地址3').AsString:=t_op_seae.fieldbyname('通知人地址3').AsString; frm_code_edicode.t_code_edicode.FieldByName('城市').AsString:=t_op_seae.fieldbyname('通知人城市').AsString; frm_code_edicode.t_code_edicode.FieldByName('邮编').AsString:=t_op_seae.fieldbyname('通知人邮编').AsString; frm_code_edicode.t_code_edicode.FieldByName('国家代码').AsString:=t_op_seae.fieldbyname('通知人国家代码').AsString; frm_code_edicode.t_code_edicode.FieldByName('联系人').AsString:=t_op_seae.fieldbyname('通知人联系人').AsString; frm_code_edicode.t_code_edicode.FieldByName('电话').AsString:=t_op_seae.fieldbyname('通知人电话').AsString; frm_code_edicode.t_code_edicode.FieldByName('州').AsString:=t_op_seae.fieldbyname('通知人州').AsString; end; frm_code_edicode.ShowModal; finally t_code_notifyparty.Requery(); FreeAndNil(frm_code_edicode); end; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo16Enter(Sender: TObject); begin RxDBLookupCombo16.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo16Exit(Sender: TObject); begin RxDBLookupCombo16.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo1Enter(Sender: TObject); begin RxDBLookupCombo1.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo1Exit(Sender: TObject); begin RxDBLookupCombo1.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo2Enter(Sender: TObject); begin RxDBLookupCombo2.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo2Exit(Sender: TObject); begin RxDBLookupCombo2.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo16Change(Sender: TObject); begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit)then begin if RxDBLookupCombo16.DisplayValue<>'' then begin t_op_seae.fieldbyname('发货人名称').AsString:=t_code_shiper.FieldByName('名称').AsString; t_op_seae.fieldbyname('发货人地址1').AsString:=t_code_shiper.FieldByName('地址1').AsString; t_op_seae.fieldbyname('发货人地址2').AsString:=t_code_shiper.FieldByName('地址2').AsString; t_op_seae.fieldbyname('发货人地址3').AsString:=t_code_shiper.FieldByName('地址3').AsString; t_op_seae.fieldbyname('发货人城市').AsString:=t_code_shiper.FieldByName('城市').AsString; t_op_seae.fieldbyname('发货人邮编').AsString:=t_code_shiper.FieldByName('邮编').AsString; t_op_seae.fieldbyname('发货人国家代码').AsString:=t_code_shiper.FieldByName('国家代码').AsString; t_op_seae.fieldbyname('发货人联系人').AsString:=t_code_shiper.FieldByName('联系人').AsString; t_op_seae.fieldbyname('发货人电话').AsString:=t_code_shiper.FieldByName('电话').AsString; t_op_seae.fieldbyname('发货人州').AsString:=t_code_shiper.FieldByName('州').AsString; end; end; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo1Change(Sender: TObject); begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit)then begin if RxDBLookupCombo1.DisplayValue<>'' then begin t_op_seae.fieldbyname('收货人名称').AsString:=t_code_consignee.FieldByName('名称').AsString; t_op_seae.fieldbyname('收货人地址1').AsString:=t_code_consignee.FieldByName('地址1').AsString; t_op_seae.fieldbyname('收货人地址2').AsString:=t_code_consignee.FieldByName('地址2').AsString; t_op_seae.fieldbyname('收货人地址3').AsString:=t_code_consignee.FieldByName('地址3').AsString; t_op_seae.fieldbyname('收货人城市').AsString:=t_code_consignee.FieldByName('城市').AsString; t_op_seae.fieldbyname('收货人邮编').AsString:=t_code_consignee.FieldByName('邮编').AsString; t_op_seae.fieldbyname('收货人国家代码').AsString:=t_code_consignee.FieldByName('国家代码').AsString; t_op_seae.fieldbyname('收货人联系人').AsString:=t_code_consignee.FieldByName('联系人').AsString; t_op_seae.fieldbyname('收货人电话').AsString:=t_code_consignee.FieldByName('电话').AsString; t_op_seae.fieldbyname('收货人州').AsString:=t_code_consignee.FieldByName('州').AsString; end; end; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo2Change(Sender: TObject); begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit)then begin if RxDBLookupCombo2.DisplayValue<>'' then begin t_op_seae.fieldbyname('通知人名称').AsString:=t_code_notifyparty.FieldByName('名称').AsString; t_op_seae.fieldbyname('通知人地址1').AsString:=t_code_notifyparty.FieldByName('地址1').AsString; t_op_seae.fieldbyname('通知人地址2').AsString:=t_code_notifyparty.FieldByName('地址2').AsString; t_op_seae.fieldbyname('通知人地址3').AsString:=t_code_notifyparty.FieldByName('地址3').AsString; t_op_seae.fieldbyname('通知人城市').AsString:=t_code_notifyparty.FieldByName('城市').AsString; t_op_seae.fieldbyname('通知人邮编').AsString:=t_code_notifyparty.FieldByName('邮编').AsString; t_op_seae.fieldbyname('通知人国家代码').AsString:=t_code_notifyparty.FieldByName('国家代码').AsString; t_op_seae.fieldbyname('通知人联系人').AsString:=t_code_notifyparty.FieldByName('联系人').AsString; t_op_seae.fieldbyname('通知人电话').AsString:=t_code_notifyparty.FieldByName('电话').AsString; t_op_seae.fieldbyname('通知人州').AsString:=t_code_notifyparty.FieldByName('州').AsString; end; end; end; procedure Tfrm_op_seae_edi_data.PutToDebugLog(Operation, S1: String); Var S: String; begin while Length(S1) > 0 do begin if Pos(#13, S1) > 0 then begin S := Copy(S1, 1, Pos(#13, S1) - 1); Delete(S1, 1, Pos(#13, S1)); if S1[1] = #10 then Delete(S1, 1, 1); end else S := S1; DebugListBox.ItemIndex := DebugListBox.Items.Add(Operation + S); end; end; procedure Tfrm_op_seae_edi_data.IdFTP1Status(ASender: TObject; const AStatus: TIdStatus; const AStatusText: String); begin DebugListBox.ItemIndex := DebugListBox.Items.Add(AStatusText); end; procedure Tfrm_op_seae_edi_data.IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); Var S: String; TotalTime: TDateTime; H, M, Sec, MS: Word; DLTime: Double; begin TotalTime := Now - STime; DecodeTime(TotalTime, H, M, Sec, MS); Sec := Sec + M * 60 + H * 3600; DLTime := Sec + MS / 1000; if DLTime > 0 then AverageSpeed := {(AverageSpeed + }(AWorkCount / 1024) / DLTime{) / 2}; if AverageSpeed > 0 then begin Sec := Trunc(((ProgressBar1.Max - AWorkCount) / 1024) / AverageSpeed); S := Format('%2d:%2d:%2d', [Sec div 3600, (Sec div 60) mod 60, Sec mod 60]); S := '剩余时间 ' + S; end else S := ''; S := FormatFloat('0.00 KB/s', AverageSpeed) + '; ' + S; case AWorkMode of wmRead: StatusBar1.Panels[1].Text := '下载速度 ' + S; wmWrite: StatusBar1.Panels[1].Text := '上传速度 ' + S; end; if AbortTransfer then IdFTP1.Abort; ProgressBar1.Position := AWorkCount; AbortTransfer := false; end; procedure Tfrm_op_seae_edi_data.IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); begin TransferrignData := true; AbortTransfer := false; STime := Now; if AWorkCountMax > 0 then ProgressBar1.Max := AWorkCountMax else ProgressBar1.Max := BytesToTransfer; AverageSpeed := 0; end; procedure Tfrm_op_seae_edi_data.IdFTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode); begin StatusBar1.Panels[1].Text := '传输完毕.'; BytesToTransfer := 0; TransferrignData := false; ProgressBar1.Position := 0; AverageSpeed := 0; end; procedure Tfrm_op_seae_edi_data.bsSkinButton22Click(Sender: TObject); var Pnt:Tpoint; aAdoQuery,aAdoQuery2:TAdoQuery; s:string; LengthQ, PosQ,i:Integer; iscon:Boolean; begin if wwDBDateTimePicker1.Date900) then begin if MessageDlg('此票货货物描述超长,确实要发送吗?',mtWarning,[mbYes,mbNo],0)=mrNo then exit; end; if (t_op_seae1.DataSet.FieldByName('货物标识').AsString='O') then begin if MessageDlg('此票为超限箱,是否继续操作?',mtWarning,[mbYes,mbNo],0)=mrNo then exit; end; s:=''; aAdoQuery:=createAdoQuery; aAdoQuery2:=createAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('select isnull(object_id(''CANGDAN_CUSTOMER''),''0'') as tbl'); Open; if (FieldByName('tbl').AsString<>'0') then begin Close;sql.Clear; sql.Add('select COUNT(*) CT FROM CANGDAN_CUSTOMER WHERE CUSTOMERNAME='''+t_op_seae.fieldbyname('委托发送方').asstring+''''); Open; if (FieldByName('CT').AsInteger=0) then begin MessageDlg('不能发送该客户尚未开通舱单申报业务,请与对应业务同事联系!',mtError,[mbOk],0); Exit; end; end; if (t_op_seae.FieldByName('分提单号').AsString='') then begin Close;sql.Clear; sql.Add('select distinct b.主提单号,c.箱号 from t_op_seae_edi b left join t_op_ctn_edi c on (c.编号=b.编号) where b.船名='''+t_op_seae.fieldbyname('船名').AsString+''' '); sql.Add(' and b.录入日期>=GETDATE()-20 '); sql.Add(' and b.航次='''+t_op_seae.fieldbyname('航次').AsString+''' and b.主提单号<>'''+t_op_seae.fieldbyname('主提单号').AsString+''' '); sql.Add(' and c.箱号 in (select 箱号 from t_op_ctn_edi where 编号='''+t_op_seae.fieldbyname('编号').AsString+''') '); Open;First; while not Eof do begin if s='' then s:='该航次'+FieldByName('主提单号').AsString+'下存在相同箱号'+FieldByName('箱号').AsString+'' else s:=s+#13#10+FieldByName('箱号').AsString; Next; end; Close;sql.Clear; sql.Add('select c.箱号,sum(c.件数) 件数,sum(c.重量) 重量,sum(c.尺码) 尺码 from t_op_seae_edi b left join t_op_ctn_edi c on (c.编号=b.编号) where ISNULL(b.分提单号,'''')<>'''' '); sql.Add(' AND b.主提单号='''+t_op_seae.fieldbyname('主提单号').AsString+''' and b.船名='''+t_op_seae.fieldbyname('船名').AsString+''' and b.航次='''+t_op_seae.fieldbyname('航次').AsString+''' '); sql.Add(' GROUP BY C.箱号 '); Open; if (not IsEmpty) then begin First; while not eof do begin if t_op_ctn.Locate('箱号',fieldbyname('箱号').AsString,[]) then begin if t_op_ctn.FieldByName('件数').AsInteger<>FieldByName('件数').AsInteger then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+' 件数:'+FieldByName('件数').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'件数:'+FieldByName('件数').AsString; if t_op_ctn.FieldByName('重量').AsFloat<>FieldByName('重量').AsFloat then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+'重量:'+FieldByName('重量').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'重量:'+FieldByName('重量').AsString; if t_op_ctn.FieldByName('尺码').AsFloat<>FieldByName('尺码').AsFloat then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+'尺码:'+FieldByName('尺码').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'尺码:'+FieldByName('尺码').AsString; end else begin if s='' then s:='主单不存在箱号:'+FieldByName('箱号').AsString else s:=s+#13#10+'主单不存在箱号:'+FieldByName('箱号').AsString; end; Next; end; t_op_ctn.First; while not t_op_ctn.Eof do begin if aAdoQuery.Locate('箱号',t_op_ctn.fieldbyname('箱号').AsString,[]) then begin end else begin if s='' then s:='分单不存在箱号:'+FieldByName('箱号').AsString else s:=s+#13#10+'分单不存在箱号:'+FieldByName('箱号').AsString; end; t_op_ctn.Next; end; end; end else begin aAdoQuery2.Close; aAdoQuery2.SQL.Clear; aAdoQuery2.SQL.add('SELECT * from t_op_ctn_edi where 编号 in (select top 1 编号 from t_op_seae_edi where ISNULL(分提单号,'''')='''' and 主提单号='''+t_op_seae.fieldbyname('主提单号').AsString+''' '); aAdoQuery2.SQL.add(' and 船名='''+t_op_seae.fieldbyname('船名').AsString+''' and 航次='''+t_op_seae.fieldbyname('航次').AsString+''' )'); aAdoQuery2.Open; Close;sql.Clear; sql.Add('select c.箱号,sum(c.件数) 件数,sum(c.重量) 重量,sum(c.尺码) 尺码 from t_op_seae_edi b left join t_op_ctn_edi c on (c.编号=b.编号) where ISNULL(b.分提单号,'''')<>'''' '); sql.Add(' AND b.主提单号='''+t_op_seae.fieldbyname('主提单号').AsString+''' and b.船名='''+t_op_seae.fieldbyname('船名').AsString+''' and b.航次='''+t_op_seae.fieldbyname('航次').AsString+''' '); sql.Add(' GROUP BY C.箱号 '); Open; if (not IsEmpty) then begin First; while not eof do begin if aAdoQuery2.Locate('箱号',fieldbyname('箱号').AsString,[]) then begin if aAdoQuery2.FieldByName('件数').AsInteger<>FieldByName('件数').AsInteger then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+' 件数:'+FieldByName('件数').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'件数:'+FieldByName('件数').AsString; if aAdoQuery2.FieldByName('重量').AsFloat<>FieldByName('重量').AsFloat then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+'重量:'+FieldByName('重量').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'重量:'+FieldByName('重量').AsString; if aAdoQuery2.FieldByName('尺码').AsFloat<>FieldByName('尺码').AsFloat then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+'尺码:'+FieldByName('尺码').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'尺码:'+FieldByName('尺码').AsString; end else begin if s='' then s:='主单不存在箱号:'+FieldByName('箱号').AsString else s:=s+#13#10+'主单不存在箱号:'+FieldByName('箱号').AsString; end; Next; end; end; aAdoQuery2.First; while not aAdoQuery2.Eof do begin if aAdoQuery.Locate('箱号',aAdoQuery2.fieldbyname('箱号').AsString,[]) then begin end else begin if s='' then s:='分单不存在箱号:'+FieldByName('箱号').AsString else s:=s+#13#10+'分单不存在箱号:'+FieldByName('箱号').AsString; end; aAdoQuery2.Next; end; Close;sql.Clear; sql.Add('select b.分提单号,b.件数 总件数,b.重量 总重量,b.尺码 总尺码,sum(c.件数) 件数,sum(c.重量) 重量,sum(c.尺码) 尺码 from t_op_seae_edi b left join t_op_ctn_edi c on (c.编号=b.编号) where ISNULL(b.分提单号,'''')<>'''' '); sql.Add(' AND b.主提单号='''+t_op_seae.fieldbyname('主提单号').AsString+''' and b.船名='''+t_op_seae.fieldbyname('船名').AsString+''' and b.航次='''+t_op_seae.fieldbyname('航次').AsString+''' '); sql.Add(' GROUP BY b.分提单号,b.件数,b.重量,b.尺码 '); Open; First; while not eof do begin if (FieldByName('总件数').AsInteger<>FieldByName('件数').AsInteger) then begin if s='' then s:='分单:'+FieldByName('分提单号').AsString+' 总件数和集装箱明细件数合计不一致!' else s:=s+#13#10+'分单:'+FieldByName('分提单号').AsString+' 总件数和集装箱明细件数合计不一致!' end; if (FieldByName('总重量').AsFloat<>FieldByName('重量').AsFloat) then begin if s='' then s:='分单:'+FieldByName('分提单号').AsString+' 总重量和集装箱明细重量合计不一致!' else s:=s+#13#10+'分单:'+FieldByName('分提单号').AsString+' 总重量和集装箱明细重量合计不一致!' end; if (FieldByName('总尺码').AsFloat<>FieldByName('尺码').AsFloat) then begin if s='' then s:='分单:'+FieldByName('分提单号').AsString+' 总尺码和集装箱明细尺码合计不一致!' else s:=s+#13#10+'分单:'+FieldByName('分提单号').AsString+' 总尺码和集装箱明细尺码合计不一致!' end; Next; end; end; iscon:=true; if (s<>'') then begin iscon:=False; try frm_sys_messagedlg:=tfrm_sys_messagedlg.Create (application); frm_sys_messagedlg.msg:=s; iscon:=frm_sys_messagedlg.ShowModal=mrOk; finally frm_sys_messagedlg.Free; frm_sys_messagedlg:=nil; end; // if MessageDlg(s+',是否继续?',mtWarning,mbOKCancel,0)<>mrok then exit; end; if (not iscon) then exit; s:=''; Close;sql.Clear; sql.Add('select 箱号,count(*)'); sql.Add('from t_op_ctn_edi'); sql.Add('where 编号=:编号'); sql.Add('group by 箱号'); sql.Add('having count(*)>1'); Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').AsString; Open;First; while not Eof do begin if s='' then s:=FieldByName('箱号').AsString else s:=s+#13#10+FieldByName('箱号').AsString; Next; end; if s<>'' then begin ShowMessage('重复的箱号如下:'+#13#10+s); Exit; end; s:=''; Close;sql.Clear; sql.Add('select sum(件数) 件数,sum(重量) 重量,sum(尺码) 尺码'); sql.Add('from t_op_ctn_edi'); sql.Add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').AsString; Open;First; if t_op_seae.FieldByName('件数').AsInteger<>FieldByName('件数').AsInteger then if s='' then s:='件数:'+FieldByName('件数').AsString else s:=s+#13#10+'件数:'+FieldByName('件数').AsString; if t_op_seae.FieldByName('重量').AsFloat<>FieldByName('重量').AsFloat then if s='' then s:='重量:'+FieldByName('重量').AsString else s:=s+#13#10+'重量:'+FieldByName('重量').AsString; if t_op_seae.FieldByName('尺码').AsFloat<>FieldByName('尺码').AsFloat then if s='' then s:='尺码:'+FieldByName('尺码').AsString else s:=s+#13#10+'尺码:'+FieldByName('尺码').AsString; if s<>'' then begin ShowMessage('存在差异'+#13#10+s); end; { if (t_op_seae.FieldByName('发货人国家代码').AsString='CN') then begin if not ((pos('USCI+',t_op_seae.FieldByName('发货人企业代码').AsString)>0) or (pos('OC+',t_op_seae.FieldByName('发货人企业代码').AsString)>0)) then begin ShowMessage('发货人企业代码不符合规范,请检查'); exit; end; if (pos('USCI+',t_op_seae.FieldByName('发货人企业代码').AsString)>0) then begin if (Length(t_op_seae.FieldByName('发货人企业代码').AsString)<>23) then begin ShowMessage('发货人企业代码不符合规范,请检查'); exit; end; end; if (pos('OC+',t_op_seae.FieldByName('发货人企业代码').AsString)>0) then begin if (Length(t_op_seae.FieldByName('发货人企业代码').AsString)<>12) then begin ShowMessage('发货人企业代码不符合规范,请检查'); exit; end; end; LengthQ := Length(t_op_seae.FieldByName('发货人企业代码').AsString); PosQ := Pos('+',t_op_seae.FieldByName('发货人企业代码').AsString); s := Copy(t_op_seae.FieldByName('发货人企业代码').AsString, PosQ + 1, LengthQ - PosQ + 1); for i := 1 to Length(s) do begin if not (s[i] in ['0'..'9', 'A'..'Z','-',#32]) then begin ShowMessage('企业代码必须为数字和大写字母'); Exit; end; end; end; } if (Trim(t_op_seae.FieldByName('船名').AsString)<>t_op_seae.FieldByName('船名').AsString) then begin ShowMessage('船名前后有空格,请检查!'); Exit; end; if (Trim(t_op_seae.FieldByName('航次').AsString)<>t_op_seae.FieldByName('航次').AsString) then begin ShowMessage('航次前后有空格,请检查!'); Exit; end; if (Pos('DESCRIPTION',t_op_seae.FieldByName('货物描述').AsString)>0) then begin if MessageDlg('货物描述中包含特殊单词[DESCRIPTION],请与客户确认品名是否正确,确实继续发送吗?',mtWarning,[mbyes,mbno],0)<>mryes then exit; end; if (Pos('LIST',t_op_seae.FieldByName('货物描述').AsString)>0) then begin if MessageDlg('货物描述中包含特殊单词[LIST],请与客户确认品名是否正确,确实继续发送吗?',mtWarning,[mbyes,mbno],0)<>mryes then exit; end; if (Pos('N/M',t_op_seae.FieldByName('货物描述').AsString)>0) then begin if MessageDlg('货物描述中包含特殊单词[N/M],请与客户确认品名是否正确,确实继续发送吗?',mtWarning,[mbyes,mbno],0)<>mryes then exit; end; t_code_goods_not.First; while not t_code_goods_not.Eof do begin if (Pos(t_code_goods_not.fieldbyname('货物名称').AsString,t_op_seae.FieldByName('货物描述').AsString)>0) then begin if MessageDlg('货物描述中包含特殊单词'+t_code_goods_not.fieldbyname('货物名称').AsString+',请与客户确认品名是否正确,确实继续发送吗?',mtWarning,[mbyes,mbno],0)<>mryes then exit; end; t_code_goods_not.Next; end; { if IsZhongwen(Trim(t_op_seae.FieldByName('发货人企业代码').AsString)) then begin ShowMessage('发货人企业代码有特殊字符,请检查!'); Exit; end; } if IsZhongwen(Trim(t_op_seae.FieldByName('发货人名称').AsString)) then begin ShowMessage('发货人名称有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('发货人地址1').AsString)) then begin ShowMessage('发货人地址1有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('发货人电话').AsString)) then begin ShowMessage('发货人电话有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('收货人名称').AsString)) then begin ShowMessage('收货人名称有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('收货人地址1').AsString)) then begin ShowMessage('收货人地址1有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('收货人电话').AsString)) then begin ShowMessage('收货人电话有特殊字符,请检查!'); Exit; end; { if IsZhongwen(Trim(t_op_seae.FieldByName('收货人企业代码').AsString)) then begin ShowMessage('收货人企业代码有特殊字符,请检查!'); Exit; end; } if IsZhongwen(Trim(t_op_seae.FieldByName('通知人名称').AsString)) then begin ShowMessage('通知人名称有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('通知人地址1').AsString)) then begin ShowMessage('通知人地址1有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('通知人电话').AsString)) then begin ShowMessage('通知人电话有特殊字符,请检查!'); Exit; end; { if IsZhongwen(Trim(t_op_seae.FieldByName('通知人企业代码').AsString)) then begin ShowMessage('通知人企业代码有特殊字符,请检查!'); Exit; end; } if IsZhongwen(Trim(t_op_seae.FieldByName('装货港').AsString)) then begin ShowMessage('装货港有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('卸货港').AsString)) then begin ShowMessage('卸货港有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('目的地').AsString)) then begin ShowMessage('目的地有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('唛头').AsString)) then begin ShowMessage('唛头有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(t_op_seae.FieldByName('货物描述').AsString)) then begin ShowMessage('货物描述有特殊字符,请检查!'); Exit; end; Close;sql.Clear; sql.Add('select * '); sql.Add('from t_op_ctn_edi'); sql.Add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').AsString; Open;First; while not Eof do begin if (Trim(FieldByName('箱号').AsString)<>FieldByName('箱号').AsString) then begin ShowMessage('箱号'+FieldByName('箱号').AsString+'前后有空格,请检查!'); Exit; end; if (Trim(FieldByName('封号').AsString)<>FieldByName('封号').AsString) then begin ShowMessage('封号'+FieldByName('封号').AsString+'前后有空格,请检查!'); Exit; end; if (FieldByName('箱号').AsString=FieldByName('封号').AsString) then begin ShowMessage('箱号封号相同,请检查!'); Exit; end; if IsZhongwen(Trim(FieldByName('箱号').AsString)) then begin ShowMessage('箱号'+FieldByName('箱号').AsString+'有特殊字符,请检查!'); Exit; end; if IsZhongwen(Trim(FieldByName('封号').AsString)) then begin ShowMessage('封号'+FieldByName('封号').AsString+'有特殊字符,请检查!'); Exit; end; if (not frm_data_share.t_code_ctn.Locate('表现形式',FieldByName('表现形式').AsString,[])) then begin ShowMessage('箱号'+FieldByName('箱号').AsString+',箱型在系统中不存在,请检查!'); Exit; end; Next; end; finally FreeAndNil(aAdoQuery); FreeAndNil(aAdoQuery2); end; Pnt:=bsSkinButton22.ClientToScreen(Point(0,bsSkinButton22.Height)); PopupMenu4.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_edi_data.NZYClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; updatelr; try if not assigned(frm_op_seae_edi_custom_cosco) then frm_op_seae_edi_custom_cosco:=tfrm_op_seae_edi_custom_cosco.Create(application); frm_op_seae_edi_custom_cosco.ShowModal; finally frm_op_seae_edi_custom_cosco.free; frm_op_seae_edi_custom_cosco:=nil; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton23Click(Sender: TObject); begin t_op_seae.Edit; t_op_seae.fieldbyname('通知人名称').AsString:=t_op_seae.fieldbyname('收货人名称').AsString;; t_op_seae.fieldbyname('通知人地址1').AsString:=t_op_seae.fieldbyname('收货人地址1').AsString; t_op_seae.fieldbyname('通知人地址2').AsString:=t_op_seae.fieldbyname('收货人地址2').AsString; t_op_seae.fieldbyname('通知人地址3').AsString:=t_op_seae.fieldbyname('收货人地址3').AsString; t_op_seae.fieldbyname('通知人城市').AsString:=t_op_seae.fieldbyname('收货人城市').AsString; t_op_seae.fieldbyname('通知人邮编').AsString:=t_op_seae.fieldbyname('收货人邮编').AsString; t_op_seae.fieldbyname('通知人国家代码').AsString:=t_op_seae.fieldbyname('收货人国家代码').AsString; t_op_seae.fieldbyname('通知人联系人').AsString:=t_op_seae.fieldbyname('收货人联系人').AsString; t_op_seae.fieldbyname('通知人电话').AsString:=t_op_seae.fieldbyname('收货人电话').AsString; t_op_seae.fieldbyname('通知人州').AsString:=t_op_seae.fieldbyname('收货人州').AsString; t_op_seae.fieldbyname('通知人企业代码').AsString:=t_op_seae.fieldbyname('收货人企业代码').AsString; t_op_seae.Post; end; procedure Tfrm_op_seae_edi_data.NZTClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; updatelr; try if not assigned(frm_op_seae_custom_edi_zt) then frm_op_seae_custom_edi_zt:=tfrm_op_seae_custom_edi_zt.Create(application); frm_op_seae_custom_edi_zt.ShowModal; finally frm_op_seae_custom_edi_zt.free; frm_op_seae_custom_edi_zt:=nil; end; end; procedure Tfrm_op_seae_edi_data.updatelr; var aQuery:TADOQuery; i:Integer; str:WideString; begin aQuery:=CreateAdoQuery; if dxDBGrid1.SelectedCount=0 then begin ShowMessage('没有数据!不能同步录入人!'); Exit; end; str:=''; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; end; str:=str+')'; with aQuery do begin Close; SQL.Clear; SQL.Add('update t_op_seae_edi set 录入人='+QuotedStr(employee)+' where 编号 in '+ str); ExecSQL; end; FreeAndNil(aQuery); end; procedure Tfrm_op_seae_edi_data.NWD2101Click(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; updatelr; try if not assigned(frm_op_seae_edi_custom_waidai) then frm_op_seae_edi_custom_waidai:=tfrm_op_seae_edi_custom_waidai.Create(application); frm_op_seae_edi_custom_waidai.ShowModal; finally frm_op_seae_edi_custom_waidai.free; frm_op_seae_edi_custom_waidai:=nil; end; end; procedure Tfrm_op_seae_edi_data.t_op_ctnBeforePost(DataSet: TDataSet); begin if length(t_op_ctn.FieldByName('唛头').AsString)>180 then begin MessageDlg('唛头长度不能超过180个字符',mtWarning,[mbOk],0); Abort; end; if length(t_op_ctn.FieldByName('货描').AsString)>180 then begin MessageDlg('货描长度不能超过180个字符',mtWarning,[mbOk],0); Abort; end; 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['尺寸']; end else begin t_op_ctn['代码']:=''; t_op_ctn['表现形式']:=''; t_op_ctn['箱型']:=''; t_op_ctn['尺寸']:=''; end; end; procedure Tfrm_op_seae_edi_data.NWD1101Click(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; updatelr; try if not assigned(frm_op_seae_edi_custom_waidai_1101) then frm_op_seae_edi_custom_waidai_1101:=tfrm_op_seae_edi_custom_waidai_1101.Create(application); frm_op_seae_edi_custom_waidai_1101.ShowModal; finally frm_op_seae_edi_custom_waidai_1101.free; frm_op_seae_edi_custom_waidai_1101:=nil; end; end; procedure Tfrm_op_seae_edi_data.NYDClick(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; updatelr; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; sys_print('远大舱单',2,aDataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); finally aDataSource.Free; Free; end; end; { if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_yd) then frm_op_seae_edi_custom_yd:=tfrm_op_seae_edi_custom_yd.Create(application); frm_op_seae_edi_custom_yd.ShowModal; finally frm_op_seae_edi_custom_yd.free; frm_op_seae_edi_custom_yd:=nil; end; } procedure Tfrm_op_seae_edi_data.NLDClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有托单信息,不能生成EDI文件!'); exit; end; updatelr; try if not assigned(frm_op_seae_edi_custom_ld) then frm_op_seae_edi_custom_ld:=tfrm_op_seae_edi_custom_ld.Create(application); frm_op_seae_edi_custom_ld.ShowModal; finally frm_op_seae_edi_custom_ld.free; frm_op_seae_edi_custom_ld:=nil; end; end; procedure Tfrm_op_seae_edi_data.NWYClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; updatelr; try if not assigned(frm_op_seae_edi_custom_wy) then frm_op_seae_edi_custom_wy:=tfrm_op_seae_edi_custom_wy.Create(application); frm_op_seae_edi_custom_wy.ShowModal; finally frm_op_seae_edi_custom_wy.free; frm_op_seae_edi_custom_wy:=nil; end; end; procedure Tfrm_op_seae_edi_data.NHGClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; updatelr; try if not assigned(frm_op_seae_edi_custom_hg) then frm_op_seae_edi_custom_hg:=tfrm_op_seae_edi_custom_hg.Create(application); frm_op_seae_edi_custom_hg.ShowModal; finally frm_op_seae_edi_custom_hg.free; frm_op_seae_edi_custom_hg:=nil; end; end; procedure Tfrm_op_seae_edi_data.btnSealClick(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'封号'); end; procedure Tfrm_op_seae_edi_data.NHFClick(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); updatelr; aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; sys_print('海丰舱单',2,aDataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.wwDBComboBoxOPDropDown(Sender: TObject); var AdoQuery1:TAdoQuery; begin wwDBComboBoxOP.items.clear; AdoQuery1:=CreateAdoQuery; with AdoQuery1 do try Close;sql.Clear; SQL.Add('select * from t_sys_employee where 状态=''在职'''); SQL.Add('Order by 姓名'); Open;first; while not Eof do begin wwDBComboBoxOP.Items.Add(AdoQuery1.fieldbyname('姓名').AsString); Next; end; finally Free; end; end; procedure Tfrm_op_seae_edi_data.NZHClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; updatelr; try if not assigned(frm_op_seae_edi_custom_zh) then frm_op_seae_edi_custom_zh:=tfrm_op_seae_edi_custom_zh.Create(application); frm_op_seae_edi_custom_zh.ShowModal; finally frm_op_seae_edi_custom_zh.free; frm_op_seae_edi_custom_zh:=nil; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton15Click(Sender: TObject); var aAdoQuery:TAdoQuery; begin if (t_op_ctn.State=dsinsert)or(t_op_ctn.State=dsedit) then t_op_ctn.post; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select sum(件数) 件数, sum(重量) 重量,sum(尺码) 尺码 from t_op_ctn_edi'); sql.add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=t_op_seae.fieldbyname('编号').asstring; open;First; if not IsEmpty then begin if t_op_seae=nil then exit; if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then t_op_seae.post; t_op_seae.Edit; t_op_seae.FieldByName('件数').AsInteger:=FieldByName('件数').AsInteger; t_op_seae.FieldByName('重量').AsFloat:=FieldByName('重量').AsFloat; t_op_seae.FieldByName('尺码').AsFloat:=FieldByName('尺码').AsFloat; t_op_seae.Post; end; finally Free; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton47Click(Sender: TObject); begin frm_main.view_momo(t_op_seae1,'唛头'); end; procedure Tfrm_op_seae_edi_data.bsSkinButton24Click(Sender: TObject); begin frm_main.view_momo(t_op_seae1,'货物描述'); end; procedure Tfrm_op_seae_edi_data.bsSkinButton25Click(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.State=dsinsert)or(t_op_seae1.DataSet.State=dsedit) then t_op_seae1.DataSet.post; sys_print('舱单申报',2,t_op_seae1,t_op_ctn1,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_edi_data.bsSkinButton26Click(Sender: TObject); begin frm_main.view_momo(t_op_seae1,'箱号封号'); end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo3Change(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_loaport.Locate('英文名',wwDBLookupCombo3.text,[]) then begin t_op_seae1.DataSet['装港代码']:=frm_data_share.t_code_loaport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo3Exit(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_loaport.Locate('英文名',wwDBLookupCombo3.text,[]) then begin t_op_seae1.DataSet['装港代码']:=frm_data_share.t_code_loaport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo52Change(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_disport.Locate('英文名',wwDBLookupCombo52.text,[]) then begin t_op_seae1.DataSet['卸货代码']:=frm_data_share.t_code_disport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo52Exit(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_disport.Locate('英文名',wwDBLookupCombo52.text,[]) then begin t_op_seae1.DataSet['卸货代码']:=frm_data_share.t_code_disport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo17Change(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_disport.Locate('英文名',wwDBLookupCombo17.text,[]) then begin t_op_seae1.DataSet['目的代码']:=frm_data_share.t_code_disport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.wwDBLookupCombo17Exit(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.state=dsedit)or(t_op_seae1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_disport.Locate('英文名',wwDBLookupCombo17.text,[]) then begin t_op_seae1.DataSet['目的代码']:=frm_data_share.t_code_disport['EDI代码']; end; end; end; procedure Tfrm_op_seae_edi_data.N1Click(Sender: TObject); var Ext,adate,bsno,corp,vslvoy,mblno,id,cntNo,ctnName,s:String; ExcelTemplet:Variant; i,j,k:integer; M,D,Y:Word; imp,seae_apply_add_total:boolean; aAdoQuery,t_op_ctn_edi:TAdoQuery; alist:TStringList; function getcustedi(cust:string):string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; result:=''; try aQuery.Close; aQuery.SQL.Text:='select EDI代码 from t_crm_client where 客户简称='''+cust+''''; aQuery.Open; if not aQuery.IsEmpty then result:=aQuery.fieldbyname('EDI代码').AsString; finally FreeAndNil(aQuery); end; end; function GetvesselEdi(avessel: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 船舶呼号 from t_code_vessel where 英文船名='''+avessel+''''); Open; if IsEmpty then Result:='a' else Result:=FieldByName('船舶呼号').AsString; end; finally FreeAndNil(aQuery); end; end; function getETD(VSL,VOY:string):string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; result:=''; try aQuery.Close; aQuery.SQL.Text:='select * from v_vessel_voyage where 英文船名='''+VSL+''' and 航次='''+VOY+''''; aQuery.Open; if not aQuery.IsEmpty then result:=aQuery.fieldbyname('开船日期').AsString; finally FreeAndNil(aQuery); end; end; begin // id:=get_id; j:=1; aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin close;SQL.Clear; SQL.Add('select * from t_op_seae_edi'); SQL.Add('where 主提单号=:主提单号'); Parameters.ParamByName('主提单号').Value:=''; end; alist:=TStringList.Create; t_op_ctn_edi:=CreateAdoQuery; t_op_ctn_edi.close; t_op_ctn_edi.sql.Text:='select * from t_op_ctn_edi where 编号=:编号'; if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); try frm_main.db.BeginTrans; t_op_seae.DisableControls; t_op_ctn.DisableControls; I:=2; while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value)<>'' do begin mblno:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value); aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('主提单号').Value:=mblno; aAdoQuery.Open; if aAdoQuery.IsEmpty then begin j:=j+1; id:=get_edi_id; t_op_seae.Insert; t_op_seae['编号']:=id; t_op_seae['业务编号']:=mblno; t_op_seae['主编号']:=''; t_op_seae['EDI类型']:='CN'; t_op_seae['EDI状态']:='未发送'; t_op_seae['录入人']:=employee; t_op_seae['录入日期']:=now; t_op_seae['主提单号']:=mblno; t_op_seae['付费方式']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,5].Value); t_op_seae['签单地点']:='QINGDAO,CHINA'; t_op_seae['发货人代码']:=''; // t_op_seae['船公司']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value); t_op_seae['船公司代码']:=getcustedi(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value)); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,13].Value; s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; t_op_seae['发货人名称']:=Trim(s); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,14].Value; s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; t_op_seae['发货人地址1']:=Trim(s); t_op_seae['发货人地址2']:=''; t_op_seae['发货人地址3']:=''; t_op_seae['发货人']:=''; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,15].Value; s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; t_op_seae['收货人名称']:=Trim(s); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,16].Value; s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; t_op_seae['收货人地址1']:=Trim(s); t_op_seae['收货人地址2']:=''; t_op_seae['收货人地址3']:=''; t_op_seae['收货人代码']:=''; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,17].Value; s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; t_op_seae['通知人名称']:=Trim(s); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,18].Value; s:=''; for k:=0 to alist.Count-1 do begin s:=Trim(alist[k])+s; end; t_op_seae['通知人地址1']:=Trim(s); t_op_seae['通知人地址2']:=''; t_op_seae['通知人地址3']:=''; t_op_seae['船名']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value); t_op_seae['航次']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value); t_op_seae['船舶IMO']:=GetvesselEdi(t_op_seae['船名']); if getETD(t_op_seae['船名'],t_op_seae['航次'])<>'' then begin t_op_seae['开船日期']:=getETD(t_op_seae['船名'],t_op_seae['航次']); t_op_seae.FieldByName('预抵日期').AsDateTime:=t_op_seae.FieldByName('开船日期').AsDateTime+3; end; t_op_seae['装货港']:='QINGDAO,CHINA';//VartoStr(ExcelTemplet.ActiveSheet.Cells[I,7].Value); t_op_seae['装港代码']:='CNTAO'; {if frm_data_share.t_code_loaport.Locate('英文名',t_op_seae['装货港'],[]) then begin t_op_seae['装港代码']:=frm_data_share.t_code_loaport['EDI代码']; end else t_op_seae['装港代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,8].Value); } t_op_seae['卸货港']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,9].Value); if frm_data_share.t_code_disport.Locate('英文名',t_op_seae['卸货港'],[]) then begin t_op_seae['卸货代码']:=frm_data_share.t_code_disport['EDI代码']; end else t_op_seae['卸货代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,10].Value); t_op_seae['目的地']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,11].Value); if frm_data_share.t_code_disport.Locate('英文名',t_op_seae['卸货港'],[]) then begin t_op_seae['目的代码']:=frm_data_share.t_code_disport['EDI代码']; end else t_op_seae['目的代码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,12].Value); t_op_seae['运输条款']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,6].Value); t_op_seae['运输方式']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,28].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,27].Value; t_op_seae['唛头']:=alist.Text; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,26].Value; t_op_seae['货物描述']:=alist.Text; t_op_seae['件数']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,23].Value); t_op_seae['包装']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,22].Value); t_op_seae['重量']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,24].Value); t_op_seae['尺码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,25].Value); t_op_seae['危险品分类']:=''; t_op_seae['危险品编号']:=''; t_op_seae['冷藏通风量']:=''; t_op_seae['温度单位']:=''; t_op_seae['设置温度']:=''; t_op_seae['最低温度']:=''; t_op_seae['最高温度']:=''; t_op_seae['货物标识']:=''; t_op_seae['运费协议号']:=''; t_op_seae['湿度']:=''; t_op_seae['订舱号码']:=''; t_op_seae['运输方式']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,28].Value); if pos('冻',VartoStr(ExcelTemplet.ActiveSheet.Cells[I,29].Value))>0 then begin t_op_seae['货物标识']:='R'; t_op_seae['温度单位']:='C'; t_op_seae['设置温度']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,30].Value); t_op_seae['最低温度']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,30].Value); t_op_seae['最高温度']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,30].Value); end else if pos('危',VartoStr(ExcelTemplet.ActiveSheet.Cells[I,29].Value))>0 then begin t_op_seae['货物标识']:='D'; t_op_seae['危险品分类']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,31].Value); t_op_seae['危险品编号']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,32].Value); end else t_op_seae['货物标识']:='S'; t_op_seae['文件类型']:='Master'; t_op_seae.Post; t_op_ctn_edi.Close; t_op_ctn_edi.Parameters.ParamByName('编号').Value:=id; t_op_ctn_edi.Open; t_op_ctn_edi.Insert; t_op_ctn_edi['编号']:=id; cntNo:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,19].Value),1,2); ctnName:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,19].Value),3,2); // showmessage(mblno+' '+cntNo+'--'+ctnName); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([cntNo,ctnName]),[]) then begin t_op_ctn_edi['代码']:=frm_data_share.t_code_ctn.fieldbyname('代码').asstring; end else begin t_op_ctn_edi['代码']:='无'; end; t_op_ctn_edi['尺寸']:=cntNo; t_op_ctn_edi['箱型']:=ctnName; t_op_ctn_edi['数量']:=1; t_op_ctn_edi['表现形式']:=cntNo+''''+ctnName; t_op_ctn_edi['箱号']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,20].Value); t_op_ctn_edi['封号']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,21].Value); t_op_ctn_edi['件数']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,23].Value); t_op_ctn_edi['包装']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,22].Value); t_op_ctn_edi['重量']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,24].Value); t_op_ctn_edi['尺码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,25].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,27].Value; t_op_ctn_edi['唛头']:=alist.Text; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,26].Value; t_op_ctn_edi['货描']:=alist.Text; if frm_data_share.t_code_ctn.Locate('代码',t_op_ctn_edi.fieldbyname('代码').asstring,[]) then begin if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn_edi['TEU']:=1; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45')then t_op_ctn_edi['TEU']:=2; end; t_op_ctn_edi.Post; end else begin t_op_ctn_edi.Close; t_op_ctn_edi.Parameters.ParamByName('编号').Value:=aAdoQuery.fieldbyname('编号').asstring; t_op_ctn_edi.Open; if not t_op_ctn_edi.Locate('箱号;封号',VarArrayOf([VartoStr(ExcelTemplet.ActiveSheet.Cells[I,20].Value),VartoStr(ExcelTemplet.ActiveSheet.Cells[I,21].Value)]),[]) then begin t_op_ctn_edi.Insert; t_op_ctn_edi['编号']:=aAdoQuery.fieldbyname('编号').asstring; cntNo:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,19].Value),1,2); ctnName:=Copy(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,19].Value),3,2); if frm_data_share.t_code_ctn.Locate('尺寸;箱型',VarArrayOf([cntNo,ctnName]),[]) then begin t_op_ctn_edi['代码']:=frm_data_share.t_code_ctn.fieldbyname('代码').asstring; end else begin t_op_ctn_edi['代码']:='无'; end; t_op_ctn_edi['尺寸']:=cntNo; t_op_ctn_edi['箱型']:=ctnName; t_op_ctn_edi['数量']:=1; t_op_ctn_edi['表现形式']:=cntNo+''''+ctnName; t_op_ctn_edi['箱号']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,20].Value); t_op_ctn_edi['封号']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,21].Value); t_op_ctn_edi['件数']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,23].Value); t_op_ctn_edi['包装']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,22].Value); t_op_ctn_edi['重量']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,24].Value); t_op_ctn_edi['尺码']:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,25].Value); alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,27].Value; t_op_ctn_edi['唛头']:=alist.Text; alist.Text:=''; alist.Text:=ExcelTemplet.ActiveSheet.Cells[I,26].Value; t_op_ctn_edi['货描']:=alist.Text; if frm_data_share.t_code_ctn.Locate('代码',t_op_ctn_edi.fieldbyname('代码').asstring,[]) then begin if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn_edi['TEU']:=1; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45')then t_op_ctn_edi['TEU']:=2; end; t_op_ctn_edi.Post; end; UpdateCTN(aAdoQuery.fieldbyname('编号').asstring); end; i:=i+1; end; frm_main.db.CommitTrans; finally t_op_seae.EnableControls; t_op_ctn.EnableControls; ExcelTemplet.DisplayAlerts := false;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 MessageDlg('导入:'+IntTostr(i-2)+'行 '+'票数:'+IntTostr(j-1)+'票 ', mtConfirmation, [mbYes],0); if frm_main.db.InTransaction then begin ShowMessage('导入时出错,请刷新重试!'); frm_main.db.RollbackTrans; end; end; end; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton28Click(Sender: TObject); var i :Integer; begin with t_op_ctn do begin First; while not eof do begin Edit; FieldByName('尺码').AsFloat:=s_w(0,FieldByName('尺码').AsFloat); post; Next; end; end; end; procedure Tfrm_op_seae_edi_data.NHGYDTClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; updatelr; try if not assigned(frm_op_seae_edi_custom_hgYDT) then frm_op_seae_edi_custom_hgYDT:=tfrm_op_seae_edi_custom_hgYDT.Create(application); frm_op_seae_edi_custom_hgYDT.ShowModal; finally frm_op_seae_edi_custom_hgYDT.free; frm_op_seae_edi_custom_hgYDT:=nil; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton29Click(Sender: TObject); { var xmldoc:IXMLDocument; cds:TClientDataSet; XMLTransformProvider1:TXMLTransformProvider; s_web: WideString; i :Integer; aAdoQuery,bAdoQuery:TAdoQuery; AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond:Word; STATUS:string; } begin { getwebservice_ds; cds:=TClientDataSet.Create(nil); XMLTransformProvider1:=TXMLTransformProvider.Create(NIL); aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin Close;Sql.Clear; SQL.Add('Insert Into t_op_state (编号 ,业务状态 ,是否完成,完成时间,完成人,录入人 ,录入日期,系统加入,备注)'); SQL.Add('values (:编号,:业务状态 ,:是否完成,:完成时间,:完成人,:录入人,:录入日期,:系统加入,:备注)'); Close; end; bAdoQuery:=CreateAdoQuery; with bAdoQuery do begin Close;Sql.Clear; SQL.Add('select 业务状态,完成时间 from t_op_state'); SQL.Add('where 编号=:编号'); SQL.Add('order by 完成时间 desc'); end; try cds.Active:=false; xmldoc:=NewXMLDocument; xmldoc.Encoding:='UTF-8'; xmldoc.Options:=[doNamespaceDecl]; s_web:=mServiceSoap_Ds.LoadCustomMainfastStatus(t_op_seae.FieldByName('主提单号').AsString); xmldoc.LoadFromXML(s_web); XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\青岛海关\dscustom.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; if cds.RecordCount<=0 then begin ShowMessage('海关没有返回数据'); exit; end; with cds do begin First; while not Eof do begin aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('主编号').AsString; if Copy(FieldByName('STATUS').AsString,1,5)='11104' then STATUS:='舱单运输工具无预报动态' else if Copy(FieldByName('STATUS').AsString,1,5)='11124' then STATUS:='单已放行不能再拼箱' else if Copy(FieldByName('STATUS').AsString,1,5)='15302' then STATUS:='理货报告传输成功理货异常' else if Copy(FieldByName('STATUS').AsString,1,5)='21102' then STATUS:='舱单运输工具未备案' else if Copy(FieldByName('STATUS').AsString,1,5)='21106' then STATUS:='提(运)单号重复' else if Copy(FieldByName('STATUS').AsString,1,5)='21107' then STATUS:='总提(运)单未向海关传输' else if Copy(FieldByName('STATUS').AsString,1,5)='21301' then STATUS:='预配舱单主要数据传输成功' else if Copy(FieldByName('STATUS').AsString,1,5)='22103' then STATUS:=' 未找到对应提(运)单' else if Copy(FieldByName('STATUS').AsString,1,5)='22201' then STATUS:='预配舱单其他数据申报审核通过' else if Copy(FieldByName('STATUS').AsString,1,5)='23105' then STATUS:='该提(运)单已核注' else if Copy(FieldByName('STATUS').AsString,1,5)='23301' then STATUS:='预配舱单修改申请审核通过' else if Copy(FieldByName('STATUS').AsString,1,5)='24103' then STATUS:='申请删除的提(运)单不存在' else if Copy(FieldByName('STATUS').AsString,1,5)='24301' then STATUS:='预配舱单删除申请审核通过' else if Copy(FieldByName('STATUS').AsString,1,5)='25201' then STATUS:='海运运抵报告传输成功' else if Copy(FieldByName('STATUS').AsString,1,5)='99001' then STATUS:=' 报文不符合填制规范' else STATUS:=FieldByName('STATUS').AsString; aAdoQuery.Parameters.ParamByName('业务状态').Value:=STATUS; aAdoQuery.Parameters.ParamByName('是否完成').Value:=true; aAdoQuery.Parameters.ParamByName('完成人').Value:=employee; AYear:=StrToInt(Copy(FieldByName('DATESTR').AsString,1,4)); AMonth:=StrToInt(Copy(FieldByName('DATESTR').AsString,5,2)); ADay:=StrToInt(Copy(FieldByName('DATESTR').AsString,7,2)); AHour:=StrToInt(Copy(FieldByName('DATESTR').AsString,9,2)); AMinute:=StrToInt(Copy(FieldByName('DATESTR').AsString,11,2)); aAdoQuery.Parameters.ParamByName('完成时间').Value:=EncodeDatetime(AYear,AMonth,ADay,AHour,AMinute,ASecond, AMilliSecond); //DATASTR aAdoQuery.Parameters.ParamByName('录入人').Value:=employee; aAdoQuery.Parameters.ParamByName('录入日期').Value:=FormatDateTime('YYYY-MM-DD',Now); aAdoQuery.Parameters.ParamByName('系统加入').Value:=True; aAdoQuery.Parameters.ParamByName('备注').Value:=FieldByName('STATUS').AsString; aAdoQuery.ExecSQL; Next; end; end; finally bAdoQuery.Close; bAdoQuery.Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('主编号').AsString; bAdoQuery.Open; bAdoQuery.First; modify_all:=True; if bAdoQuery.FieldByName('业务状态').AsString<>'' then begin t_op_seae.Edit; if bAdoQuery.FieldByName('业务状态').AsString='预配舱单主要数据传输成功' then t_op_seae.FieldByName('当前状态').AsString:='主要数据传输成功' else if bAdoQuery.FieldByName('业务状态').AsString='预配舱单其他数据申报审核通过' then t_op_seae.FieldByName('当前状态').AsString:='其他数据审核通过' else if bAdoQuery.FieldByName('业务状态').AsString='运抵比对结果为:运抵正常' then t_op_seae.FieldByName('当前状态').AsString:='已运抵' else if bAdoQuery.FieldByName('业务状态').AsString='提运单放行' then t_op_seae.FieldByName('当前状态').AsString:='已放行' else if bAdoQuery.FieldByName('业务状态').AsString='预配舱单修改申请审核通过' then t_op_seae.FieldByName('当前状态').AsString:='修改通过'; t_op_seae.Post; end; modify_all:=False; aAdoQuery.Free; bAdoQuery.Free; cds.Free; t_op_state.Requery(); DBEdit3.OnChange(Sender); end; } end; procedure Tfrm_op_seae_edi_data.SelectReciveData(bsno,mblno:string); var xmldoc:IXMLDocument; cds:TClientDataSet; XMLTransformProvider1:TXMLTransformProvider; s_web: WideString; i :Integer; aAdoQuery,bAdoQuery:TAdoQuery; AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond:Word; STATUS:string; begin cds:=TClientDataSet.Create(nil); XMLTransformProvider1:=TXMLTransformProvider.Create(NIL); aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin Close;Sql.Clear; SQL.Add('Insert Into t_op_state (编号 ,业务状态 ,是否完成,完成时间,完成人,录入人 ,录入日期,系统加入,备注)'); SQL.Add('values (:编号,:业务状态 ,:是否完成,:完成时间,:完成人,:录入人,:录入日期,:系统加入,:备注)'); Close; end; bAdoQuery:=CreateAdoQuery; with bAdoQuery do begin Close;Sql.Clear; SQL.Add('select 业务状态,完成时间 from t_op_state'); SQL.Add('where 编号=:编号'); SQL.Add('order by 完成时间 desc'); end; try cds.Active:=false; xmldoc:=NewXMLDocument; xmldoc.Encoding:='UTF-8'; xmldoc.Options:=[doNamespaceDecl]; s_web:=mServiceSoap_Ds.LoadCustomMainfastStatus(mblno); xmldoc.LoadFromXML(s_web); XMLTransformProvider1.TransformRead.TransformationFile:='\\'+dbserver+'\青岛海关\dscustom.xtr'; XMLTransformProvider1.TransformRead.SourceXmlDocument:=xmldoc.GetDOMDocument; cds.Data:=XMLTransformProvider1.Data; cds.Active:=true; with cds do begin First; while not Eof do begin aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('编号').Value:=bsno; if Copy(FieldByName('STATUS').AsString,1,5)='11104' then STATUS:='舱单运输工具无预报动态' else if Copy(FieldByName('STATUS').AsString,1,5)='11124' then STATUS:='单已放行不能再拼箱' else if Copy(FieldByName('STATUS').AsString,1,5)='15302' then STATUS:='理货报告传输成功理货异常' else if Copy(FieldByName('STATUS').AsString,1,5)='21102' then STATUS:='舱单运输工具未备案' else if Copy(FieldByName('STATUS').AsString,1,5)='21106' then STATUS:='提(运)单号重复' else if Copy(FieldByName('STATUS').AsString,1,5)='21107' then STATUS:='总提(运)单未向海关传输' else if Copy(FieldByName('STATUS').AsString,1,5)='21301' then STATUS:='预配舱单主要数据传输成功' else if Copy(FieldByName('STATUS').AsString,1,5)='22103' then STATUS:=' 未找到对应提(运)单' else if Copy(FieldByName('STATUS').AsString,1,5)='22201' then STATUS:='预配舱单其他数据申报审核通过' else if Copy(FieldByName('STATUS').AsString,1,5)='23105' then STATUS:='该提(运)单已核注' else if Copy(FieldByName('STATUS').AsString,1,5)='23301' then STATUS:='预配舱单修改申请审核通过' else if Copy(FieldByName('STATUS').AsString,1,5)='24103' then STATUS:='申请删除的提(运)单不存在' else if Copy(FieldByName('STATUS').AsString,1,5)='24301' then STATUS:='预配舱单删除申请审核通过' else if Copy(FieldByName('STATUS').AsString,1,5)='25201' then STATUS:='海运运抵报告传输成功' else if Copy(FieldByName('STATUS').AsString,1,5)='99001' then STATUS:=' 报文不符合填制规范' else STATUS:=FieldByName('STATUS').AsString; aAdoQuery.Parameters.ParamByName('业务状态').Value:=STATUS; aAdoQuery.Parameters.ParamByName('是否完成').Value:=true; aAdoQuery.Parameters.ParamByName('完成人').Value:=employee; AYear:=StrToInt(Copy(FieldByName('DATESTR').AsString,1,4)); AMonth:=StrToInt(Copy(FieldByName('DATESTR').AsString,5,2)); ADay:=StrToInt(Copy(FieldByName('DATESTR').AsString,7,2)); AHour:=StrToInt(Copy(FieldByName('DATESTR').AsString,9,2)); AMinute:=StrToInt(Copy(FieldByName('DATESTR').AsString,11,2)); aAdoQuery.Parameters.ParamByName('完成时间').Value:=EncodeDatetime(AYear,AMonth,ADay,AHour,AMinute,ASecond, AMilliSecond); //DATASTR aAdoQuery.Parameters.ParamByName('录入人').Value:=employee; aAdoQuery.Parameters.ParamByName('录入日期').Value:=FormatDateTime('YYYY-MM-DD',Now); aAdoQuery.Parameters.ParamByName('系统加入').Value:=True; aAdoQuery.Parameters.ParamByName('备注').Value:=FieldByName('STATUS').AsString; aAdoQuery.ExecSQL; Next; end; end; finally bAdoQuery.Close; bAdoQuery.Parameters.ParamByName('编号').Value:=bsno; bAdoQuery.Open; bAdoQuery.First; modify_all:=True; t_op_seae.Edit; if bAdoQuery.FieldByName('业务状态').AsString<>'' then begin if bAdoQuery.FieldByName('业务状态').AsString='预配舱单主要数据传输成功' then t_op_seae.FieldByName('当前状态').AsString:='主要数据传输成功' else if bAdoQuery.FieldByName('业务状态').AsString='预配舱单其他数据申报审核通过' then t_op_seae.FieldByName('当前状态').AsString:='其他数据审核通过' else if bAdoQuery.FieldByName('业务状态').AsString='运抵比对结果为:运抵正常' then t_op_seae.FieldByName('当前状态').AsString:='已运抵' else if bAdoQuery.FieldByName('业务状态').AsString='提运单放行' then t_op_seae.FieldByName('当前状态').AsString:='已放行' else if bAdoQuery.FieldByName('业务状态').AsString='预配舱单修改申请审核通过' then t_op_seae.FieldByName('当前状态').AsString:='修改通过' end; t_op_seae.Post; aAdoQuery.Free; XMLTransformProvider1.Free; cds.Free; bAdoQuery.Free; modify_all:=False; end; end; procedure Tfrm_op_seae_edi_data.t_op_seaeBeforeEdit(DataSet: TDataSet); begin if not modify_all then begin if t_op_seae.FieldByName('EDI状态').AsString='已发送' then begin showmessage('已发送不能修改,删除!'); abort; end; end; end; procedure Tfrm_op_seae_edi_data.t_op_ctnBeforeEdit(DataSet: TDataSet); begin if not modify_all then begin if t_op_seae.FieldByName('EDI状态').AsString='已发送' then begin showmessage('已发送不能修改!'); abort; end; end; end; procedure Tfrm_op_seae_edi_data.N20Click(Sender: TObject); begin if t_op_seae.fieldbyname('录入人').AsString<>employee then begin if (not if_open('422')) then begin ShowMessage('你没有权限修改他们录入的业务!'); exit; end; end; try modify_all:=true; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='未发送'; t_op_seae.Post; finally modify_all:=false; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton30Click(Sender: TObject); var Str:string; i:integer; numunzipped:integer; fileType,SenderHandphone,SenderEmail,SenderFax:string; s0,s5:string; aQuery:TADOQuery; begin if (t_op_seae1.DataSet.State=dsinsert)or(t_op_seae1.DataSet.State=dsedit) then t_op_seae1.DataSet.post; if (wwDBLookupCombo2.Text='') then begin showmessage('状态不能为空!'); abort; end; if t_op_seae.IsEmpty then Exit; aQuery:=CreateAdoQuery; try if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aQuery.SQL.Text:='update t_op_seae_edi set 异常业务状态='''+wwDBLookupCombo2.Text+''',状态更新人='''+employee+''',状态更新时间=GETDATE() WHERE 编号 in '+str; aQuery.ExecSQL; t_op_seae.Requery(); if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); adopingtai.Close; adopingtai.SQL.Clear; adopingtai.SQL.Add('insert into op_seae_edi_status(gid,mfno,mblno,statustext,statustime,createtime,ShenBaoXiangShu) '); adopingtai.SQL.Add(' select top 1 newid(),MFNO,MBLNO,'''+wwDBLookupCombo2.Text+''',GETDATE(),GETDATE(),''0'' from op_seae_edi WHERE '); if (t_op_seae.FieldByName('分提单号').AsString<>'') then adopingtai.SQL.Add(' HBLNO='''+t_op_seae.fieldbyname('分提单号').asstring+''' ') else adopingtai.SQL.Add(' ISNULL(HBLNO,'''')='''' AND MBLNO='''+t_op_seae.fieldbyname('主提单号').asstring+''' '); adopingtai.ExecSQL; end; end else begin adopingtai.Close; adopingtai.SQL.Clear; adopingtai.SQL.Add('insert into op_seae_edi_status(gid,mfno,mblno,statustext,statustime,createtime,ShenBaoXiangShu) '); adopingtai.SQL.Add(' select top 1 newid(),MFNO,MBLNO,'''+wwDBLookupCombo2.Text+''',GETDATE(),GETDATE(),''0'' from op_seae_edi WHERE '); if (t_op_seae.FieldByName('分提单号').AsString<>'') then adopingtai.SQL.Add(' HBLNO='''+t_op_seae.fieldbyname('分提单号').asstring+''' ') else adopingtai.SQL.Add(' ISNULL(HBLNO,'''')='''' AND MBLNO='''+t_op_seae.fieldbyname('主提单号').asstring+''' '); adopingtai.ExecSQL; end; ShowMessage('已更新!'); finally FreeAndNil(aQuery); end; { if t_op_seae.FieldByName('EDI状态').AsString='已发送' then begin showmessage('已发送不能发送,请修改为未发送!'); abort; end; if MessageDlg('确定要发送吗?',mtWarning,[mbyes,mbno],0)=mrNo then Exit; bsSkinButton28Click(Sender); bsSkinButton15Click(Sender); s0:=''; s5:=''; str:=Tstringlist.Create; try modify_all:=True; if bsSkinComboBox1.ItemIndex=0 then begin Str:=CreateSIEdiFile_xml; s0:=Str.Text; for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin ShowMessage('此票业务可能含有中文字符或其他不规范字符'+Str[i]); exit; end; end; s5:='1'; end else begin Str:=CreateSIEdiFile_xml; s0:=Str.Text; for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin ShowMessage('此票业务可能含有中文字符或其他不规范字符'+Str[i]); exit; end; end; end; finally modify_all:=False; FreeAndNil(Str) end; try modify_all:=True; getwebservice_ds; if frm_data_share.t_sys_employee.locate('姓名',employee,[]) then begin SenderHandphone:=frm_data_share.t_sys_employee.fieldbyname('移动电话').asstring; SenderEmail:=frm_data_share.t_sys_employee.fieldbyname('邮箱').asstring; SenderFax:=frm_data_share.t_sys_employee.fieldbyname('传真').asstring; end; mServiceSoap_Ds.UpdateCustomMainfast(s0,s5,trim(get_parameters_value(301,'')),employee,SenderHandphone,SenderEmail,SenderFax,frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring); frm_op_seae_edi_data.t_op_seae.Edit; frm_op_seae_edi_data.t_op_seae.FieldByName('发送时间').Value:=Now; frm_op_seae_edi_data.t_op_seae.FieldByName('当前状态').Value:='已发送'; frm_op_seae_edi_data.t_op_seae.Post; showmessage('发送成功!'); modify_all:=False; except showmessage('发送错误!'); end; } end; procedure Tfrm_op_seae_edi_data.bsSkinComboBox1Change(Sender: TObject); begin if (bsSkinComboBox1.ItemIndex=3) or (bsSkinComboBox1.ItemIndex=2) then begin cxDBCheckListBox1.Visible:=true; end else begin cxDBCheckListBox1.Visible:=False; end; end; { procedure Tfrm_op_seae_edi_data.bsSkinButton31Click(Sender: TObject); var Str:TStrings; i:integer; fileType:string; begin if bsSkinComboBox1.ItemIndex=0 then fileType:='-9' else if bsSkinComboBox1.ItemIndex=1 then fileType:='-2' else if bsSkinComboBox1.ItemIndex=2 then fileType:='-3' else if bsSkinComboBox1.ItemIndex=3 then fileType:='-5' else if bsSkinComboBox1.ItemIndex=4 then fileType:='-0' else if bsSkinComboBox1.ItemIndex=5 then fileType:='-11' else fileType:='-9'; str:=Tstringlist.Create; try Str:=CreateSIEdiFile_xml; for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin if MessageDlg('此票业务可能含有中文字符或其他不规范字符,确实要继续上传吗!',mtWarning,[mbYes,mbNo],0)=mrNo then exit; end; end; SaveDialog1.FileName:=frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring; SaveDialog1.Filter:='*.xml|*.xml'; if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+fileType+'.xml'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; finally FreeAndNil(Str) end; end; } procedure Tfrm_op_seae_edi_data.N2Click(Sender: TObject); var afield,afieldfee : variant; aOR_ID:integer; aQuery:TAdoQuery; i:integer; bsno,id:string; Boolean_Ctn:Boolean; begin if t_op_seae.IsEmpty then begin exit; MessageDlg('没有复制的信息,不能复制添加!',mtWarning,[mbok],0); end; afield := vararraycreate([0,t_op_seae.fieldcount-1],varvariant); for i := 0 to (t_op_seae.fieldcount-1) do begin afield[i] :=t_op_seae.fields[i].value ; end; bsno:=t_op_seae.fieldbyname('编号').AsString; t_op_seae.append; for i := 0 to (t_op_seae.fieldcount-1) do begin if t_op_seae.fields[i].FieldName<>'编号' then t_op_seae.fields[i].value := afield[i] ; end; id:=get_edi_id; t_op_seae.fieldbyname('录入人').Value:=employee; t_op_seae.fieldbyname('录入日期').Value:=date; t_op_seae.fieldbyname('EDI状态').Value:='未发送'; t_op_seae.fieldbyname('当前状态').Value:='未发送'; t_op_seae.fieldbyname('编号').Value:=id; t_op_seae.fieldbyname('主编号').Value:=id; t_op_seae.fieldbyname('修改原因').Value:=''; t_op_seae.Post; aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.Add('select * from t_op_ctn_edi where 编号=:编号'); Parameters.ParamByName('编号').Value:=bsno; open; if not t_op_ctn.active then t_op_ctn.Open; first; while not eof do begin t_op_ctn.Insert; t_op_ctn['编号']:=id; t_op_ctn['代码']:=aQuery['代码']; t_op_ctn['尺寸']:=aQuery['尺寸']; t_op_ctn['箱型']:=aQuery['箱型']; t_op_ctn['数量']:=1; t_op_ctn['表现形式']:=aQuery['表现形式']; t_op_ctn['箱号']:=aQuery['箱号']; t_op_ctn['封号']:=aQuery['封号']; t_op_ctn['件数']:=aQuery['件数']; t_op_ctn['包装']:=aQuery['包装']; t_op_ctn['重量']:=aQuery['重量']; t_op_ctn['尺码']:=aQuery['尺码']; t_op_ctn['货描']:=aQuery['货描']; t_op_ctn['唛头']:=aQuery['唛头']; if frm_data_share.t_code_ctn.Locate('代码',t_op_ctn.fieldbyname('代码').asstring,[]) then begin if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn['TEU']:=1; 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; end; t_op_ctn.Post; next; end; end; finally freeandnil(aQuery); showmessage('复制完成'); end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton32Click(Sender: TObject); begin UpdateInfor; end; procedure Tfrm_op_seae_edi_data.t_op_seaeBeforeDelete(DataSet: TDataSet); begin if t_op_seae.FieldByName('EDI状态').AsString='已发送' then begin showmessage('已发送不能修改,删除!'); abort; end; end; procedure Tfrm_op_seae_edi_data.DBEdit3Change(Sender: TObject); begin if t_op_seae.FieldByName('EDI状态').AsString='已发送' then begin bsSkinLabel1.DefaultFont.Color:=clGreen; end else begin bsSkinLabel1.DefaultFont.Color:=clRed; end; if not t_op_state.Active then t_op_state.OPEN; if t_op_state.Locate('业务状态','预配舱单主要数据传输成功',[]) then begin bsSkinLabel2.DefaultFont.Color:=clGreen; end else begin bsSkinLabel2.DefaultFont.Color:=clRed; end; if t_op_state.Locate('业务状态','预配舱单其他数据申报审核通过',[]) then begin bsSkinLabel3.DefaultFont.Color:=clGreen; end else begin bsSkinLabel3.DefaultFont.Color:=clRed; end; if t_op_state.Locate('业务状态','运抵比对结果为:运抵正常',[]) then begin bsSkinLabel4.DefaultFont.Color:=clGreen; end else begin bsSkinLabel4.DefaultFont.Color:=clRed; end; if t_op_state.Locate('业务状态','提运单放行',[]) then begin bsSkinLabel5.DefaultFont.Color:=clGreen; end else begin bsSkinLabel5.DefaultFont.Color:=clRed; end; if t_op_state.Locate('业务状态','预配舱单修改申请审核通过',[]) then begin bsSkinLabel6.DefaultFont.Color:=clGreen; end else begin bsSkinLabel6.DefaultFont.Color:=clRed; end; end; procedure Tfrm_op_seae_edi_data.bsSkinLabel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var Pnt:Tpoint; begin exit; Pnt:=bsSkinLabel1.ClientToScreen(Point(0,bsSkinLabel1.Height)); if not t_op_seae.FieldByName('发送时间').IsNull then begin ABC1.Caption:=t_op_seae.FieldByName('发送时间').Asstring; PopupMenu5.Popup(Pnt.x,Pnt.y); end else begin ABC1.Caption:='无'; PopupMenu5.Popup(Pnt.x,Pnt.y); end; end; procedure Tfrm_op_seae_edi_data.bsSkinLabel2MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var Pnt:Tpoint; begin exit; Pnt:=bsSkinLabel2.ClientToScreen(Point(0,bsSkinLabel2.Height)); if t_op_state.Locate('业务状态','预配舱单主要数据传输成功',[]) then begin ABC1.Caption:=t_op_state.FieldByName('完成时间').Asstring; PopupMenu5.Popup(Pnt.x,Pnt.y); end else begin ABC1.Caption:='无'; PopupMenu5.Popup(Pnt.x,Pnt.y); end; end; procedure Tfrm_op_seae_edi_data.bsSkinLabel3MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var Pnt:Tpoint; begin exit; Pnt:=bsSkinLabel3.ClientToScreen(Point(0,bsSkinLabel3.Height)); if t_op_state.Locate('业务状态','预配舱单其他数据申报审核通过',[]) then begin ABC1.Caption:=t_op_state.FieldByName('完成时间').Asstring; PopupMenu5.Popup(Pnt.x,Pnt.y); end else begin ABC1.Caption:='无'; PopupMenu5.Popup(Pnt.x,Pnt.y); end; end; procedure Tfrm_op_seae_edi_data.bsSkinLabel4MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var Pnt:Tpoint; begin exit; Pnt:=bsSkinLabel4.ClientToScreen(Point(0,bsSkinLabel4.Height)); if t_op_state.Locate('业务状态','运抵比对结果为:运抵正常',[]) then begin ABC1.Caption:=t_op_state.FieldByName('完成时间').Asstring; PopupMenu5.Popup(Pnt.x,Pnt.y); end else begin ABC1.Caption:='无'; PopupMenu5.Popup(Pnt.x,Pnt.y); end; end; procedure Tfrm_op_seae_edi_data.bsSkinLabel5MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var Pnt:Tpoint; begin exit; Pnt:=bsSkinLabel5.ClientToScreen(Point(0,bsSkinLabel5.Height)); if t_op_state.Locate('业务状态','提运单放行',[]) then begin ABC1.Caption:=t_op_state.FieldByName('完成时间').Asstring; PopupMenu5.Popup(Pnt.x,Pnt.y); end else begin ABC1.Caption:='无'; PopupMenu5.Popup(Pnt.x,Pnt.y); end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton27Click(Sender: TObject); var Param:TStringList; response,MBLNO,s,s_val:string; RStream:TStringStream; SHSJ,SHHZ,YDSJ,YDHZ,BGZT,TDFX,TDSJ,CKZZ,ZZSJ:string; str_memo:Tmemo; Str:TStrings; SenderHandphone,SenderEmail, SenderFax:string; basecnt,i,beginpos,endpos,baseid:Integer; alist:TStringList; QYT,WEIGHT,ctncount:Double; aAdoQuery:TAdoQuery; k:integer; begin if dxDBGrid1.SelectedCount>=1 then begin if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); try frm_sys_progress.bsSkinGauge1.ProgressText:='正在提取请稍后。。。'; frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=dxDBGrid1.SelectedCount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; for k:=0 to dxDBGrid1.SelectedCount-1 do begin frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_op_seae.GotoBookmark(Pointer(dxDBGrid1.selectedrows[k])); baseid:=-1; if t_op_seae.fieldbyname('分提单号').asstring<>'' then //打开登录页面 MBLNO:=t_op_seae.fieldbyname('分提单号').asstring else MBLNO:=t_op_seae.fieldbyname('主提单号').asstring; if Trim(MBLNO)='' then begin ShowMessage('主提单号不能为空'); exit; end; Param:=TStringList.Create; // response:=DoPost('http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx','',Param) ; response:=DoPost('http://56.qdcdc.com/cnm/MftQuery/BillExportQuery.aspx','',Param) ; // showmessage('6'); SetState(response); ///////////////////// Param.Clear; Param.Add('__VIEWSTATE='+state ); Param.Add('__EVENTVALIDATION=' + EVENT); Param.Add('txtIMO=' ); Param.Add('txtTransportName=' ); Param.Add('txtVoyageNo=' ); Param.Add('txtBillNo='+MBLNO ); Param.Add('LinkButtonQuery=%E6%9F%A5%E8%AF%A2' ); Param.Add('hdSelectRow=' ); Param.Add('hdData=' ); Param.Add('hdCols=%E5%BA%8F%E5%8F%B7%2C%E5%87%BA%E5%8F%A3%E6%8F%90%E5%8D%95%E5%8F%B7%2C%E9%A2%84%E9%85%8D%E8%88%B1%E5%8D%95%2C%E5%87%BA%E5%8F%A3%E8%BF%90%E6%8A%B5%E6%8A'); Param[Param.Count-1]:=Param[Param.Count-1]+'%A5%E5%91%8A%2C%E5%87%BA%E5%8F%A3%E8%A3%85%E8%BD%BD%2C%E5%87%BA%E5%8F%A3%E7%90%86%E8%B4%A7%2C%E5%87%BA%E5%8F%A3%E6%8A%A5%E5%85%B3%E7%8A%B6%E6%80%81%2C%E7%A9%BA%E7%AE%B1%E9%AA%8C%E6%94%BE%2C%E6%8F%90%E5%8D%95%E6%94%BE%E8%A1%8C'; Param.Add('hdChildHide=' ); Param.Add('hdColsHide=' ); Param.Add('hdColSpan=%E6%8F%90%E5%8D%95%E5%8F%B7' ); Param.Add('hdMutiQuery=' ); Param.Add('hdReturnResult=' ); Param.Add('hdLoadMarkText=' ); Param.Add('hdArrivalMarkText=' ); Param.Add('hdEmptyResult=' ); Param.Add('hdTalMarkText=' ); //showmessage('7'); // response:=DoPost('http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx' // ,'http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx',Param); response:=DoPost('http://56.qdcdc.com/cnm/MftQuery/BillExportQuery.aspx' ,'http://56.qdcdc.com/cnm/MftQuery/BillExportQuery.aspx',Param); idhttp1.Disconnect; _s:=response; //处理查询结果 //ShowMessage(GetPosition(edt1.Text,Memo1.Text,8).ToString()); if (Pos('没有查到结果',_s)>0) then begin // ShowMessage('没有查到结果'); end else begin //1 审核时间 basecnt:=10; beginpos:=Pos('',_s); _s:=Copy(_s,beginpos,endpos-beginpos); // showmessage('8'); alist:=TStringList.Create; for i:=0 to 25 do begin if _s<>'' then begin beginpos:=Pos('',_s); endpos:=Pos('',_s); s:=Copy(_s,beginpos+4,endpos-beginpos-4); _s:=Trim(Copy(_s,endpos+5,Length(_s))); alist.Add(StringReplace(Trim(s), #13#10, '', [rfReplaceAll])); end; end; SHSJ:=alist[11+baseid]; //预配舱单 时间 SHHZ:=alist[12+baseid]; // YDSJ:=alist[13+baseid]; // 运抵状态 时间 YDHZ:=alist[14+baseid]; if alist[15+baseid]<>'-' then BGZT:=alist[15+baseid]; //单证放行 TDFX:=alist[17+baseid]; //装船放行 TDSJ:=alist[16+baseid]; CKZZ:=alist[20+baseid]; //装载 ZZSJ:=alist[19+baseid]; IF Trim(alist[9+baseid])<>'' THEN QYT:=strtofloat(alist[9+baseid]); IF Trim(alist[10+baseid])<>'' THEN WEIGHT:=strtofloat(alist[10+baseid]); IF Trim(alist[8+baseid])<>'' THEN ctncount:=strtofloat(alist[8+baseid]); cxTreeView1.Items.Clear; cxTreeView1.Items.Add(nil,'预配申报:'+alist[12+baseid]+' '+alist[11+baseid]); cxTreeView1.Items.Add(nil,'出口运抵:'+alist[14+baseid]+' '+alist[13+baseid]); cxTreeView1.Items.Add(nil,'出口报关状态:'+alist[15+baseid]); cxTreeView1.Items.Add(nil,'提单放行:'+alist[17+baseid]+' '+alist[16+baseid]); cxTreeView1.Items.Add(nil,'出口装载 :'+alist[20+baseid]+' '+alist[19+baseid]); try modify_all:=true; t_op_seae.Edit; t_op_seae.FieldByName('申报状态').AsString:=alist[12+baseid]; t_op_seae.FieldByName('状态日期').AsString:=StringReplace(alist[11+baseid],'/','-',[rfReplaceAll]) ; t_op_seae.Post; finally modify_all:=false; end; aAdoQuery:=createAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('select sum(数量) 数量'); sql.Add('from t_op_ctn_edi'); sql.Add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').AsString; Open;First; if ctncount<>FieldByName('数量').AsFloat then s_val:=' 箱量 '; finally free; end; if QYT<>t_op_seae1.DataSet.FieldByName('件数').AsFloat then s_val:=s_val+' 件数'; if WEIGHT<>t_op_seae1.DataSet.FieldByName('重量').AsFloat then s_val:=s_val+' 重量'; if s_val<>'' then showmessage('申报箱量为:'+alist[8+baseid]+' 申报件数为:'+alist[9+baseid]+' 申报重量为:'+alist[10+baseid]+#13#10+ '对比结果:'+s_val+'不相等'); end; sleep(6000); end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; finally frm_sys_progress.Close; frm_sys_progress.Free; frm_sys_progress:=nil; end; end; end; { procedure Tfrm_op_seae_edi_data.bsSkinButton27Click(Sender: TObject); var i:integer; begin if dxDBGrid1.SelectedCount>1 then begin if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); try frm_sys_progress.bsSkinGauge1.ProgressText:='正在生成凭证请稍后。。。'; frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=dxDBGrid1.SelectedCount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; getwebservice_ds; for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(Pointer(dxDBGrid1.selectedrows[I])); SelectReciveData(t_op_seae.FieldByName('主编号').AsString,t_op_seae.FieldByName('主提单号').AsString); end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; finally freeAndNil(frm_sys_progress); end; end else begin if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); try frm_sys_progress.bsSkinGauge1.ProgressText:='正在生成凭证请稍后。。。'; frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=t_op_seae.RecordCount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; getwebservice_ds; with t_op_seae do begin First; while not eof do begin if t_op_seae.FieldByName('当前状态').AsString<>'已放行' then SelectReciveData(t_op_seae.FieldByName('主编号').AsString,t_op_seae.FieldByName('主提单号').AsString); Next; end; end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; finally freeAndNil(frm_sys_progress); t_op_seae.First; end; end; end; } procedure Tfrm_op_seae_edi_data.bsSkinLabel6MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var Pnt:Tpoint; begin Pnt:=bsSkinLabel6.ClientToScreen(Point(0,bsSkinLabel6.Height)); if t_op_state.Locate('业务状态','预配舱单修改申请审核通过',[]) then begin ABC1.Caption:=t_op_state.FieldByName('完成时间').Asstring; PopupMenu5.Popup(Pnt.x,Pnt.y); end else begin ABC1.Caption:='无'; PopupMenu5.Popup(Pnt.x,Pnt.y); end; end; procedure Tfrm_op_seae_edi_data.t_op_seaeAfterInsert(DataSet: TDataSet); begin t_op_seae.FieldByName('当前状态').Asstring:='未发送'; t_op_seae.FieldByName('签单地点').Asstring:='QINGDAO,CHINA'; end; procedure Tfrm_op_seae_edi_data.bsSkinButton33Click(Sender: TObject); var strtmp:string; begin strtmp:=''; t_op_ctn.First; while not t_op_ctn.eof do begin strtmp:=strtmp+t_op_ctn.fieldbyname('箱号').AsString+' '+t_op_ctn.fieldbyname('封号').AsString+' ' +StringReplace(t_op_ctn.fieldbyname('表现形式').AsString,'''','',[])+' '+t_op_ctn.fieldbyname('件数').AsString+' ' +t_op_ctn.fieldbyname('重量').AsString+' '+t_op_ctn.fieldbyname('尺码').AsString+#13#10; t_op_ctn.Next; end; Clipboard.AsText :=strtmp; { if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)='' then begin showmessage('场站不能为空'); exit; end; 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_zckey:=get_parameters_value(2112,'false'); s_sscz:=get_parameters_value(2114,'false'); if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_czmc then GetdyczInfo_dy(s_user,s_key,Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString) else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_yzh then GetdyczInfo_yzh(s_user,s_key,Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString) else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_lh then GetdyczInfo_lhcz(s_user,s_key,Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString) else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_zc then begin GetdyczInfo_zc(s_user,s_zckey,Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),t_op_ctn.DataSource.DataSet.fieldbyname('编号').AsString) end else if Trim(t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)=s_sscz then begin getssczinfor(Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString)) end else if pos('捷',t_op_ctn.DataSource.DataSet.fieldbyname('场站').AsString)>0 then begin GetdyczInfo_jfcz('','',Trim(t_op_ctn.DataSource.DataSet.fieldbyname('主提单号').AsString),'') end else begin showmessage('请指定场站'); end; finally t_op_ctn.Requery; end; } end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo9Enter(Sender: TObject); begin RxLookupComboEnter(RxDBLookupCombo9); end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo9KeyPress(Sender: TObject; var Key: Char); begin RxLookupComboExit(RxDBLookupCombo9); end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo9Exit(Sender: TObject); begin RxLookupComboExit(RxDBLookupCombo9); end; procedure Tfrm_op_seae_edi_data.t_op_ctnNewRecord(DataSet: TDataSet); begin t_op_ctn['包装']:=t_op_seae.FieldByName('包装').AsString; end; procedure Tfrm_op_seae_edi_data.CLClick(Sender: TObject); var EdiStrings:TStrings; FileNames,repeatCtnNo,ctntype:String; ctncount,i:integer; S,ctns,dddd,Heads,oldHeads,VslID,Vessel,VoyNo,eta,etd,Carrier,s2,CarrierAgent,cz,CarrierName,shipper,tmp,bsno:String; tempStr:TStrings; aQuery,aQuery2,aQueryCount,aQueryUpdate,aQuery3,aQuerytmp:TAdoQuery; isstr:Boolean; SendOp,SendTel:string; L:Integer; RL:TStringList; filename:string; function GetPosString(S1:string;m:integer):String; var z:integer; begin Result:=''; if pos(':',S1)=0 then exit; s1:=StringReplace(s1,'??','?',[rfReplaceAll]); s1:=StringReplace(s1,'?:','し',[rfReplaceAll]); s1:=StringReplace(s1,'?''','''',[rfReplaceAll]); s1:=StringReplace(s1,'?+','+',[rfReplaceAll]); for z:=1 to m-1 do begin if Pos(':',S1)=0 then exit; if Pos(':',S1)=1 then S1:=Copy(S1,Pos(':',S1)+1,(length(s1)-Pos(':',S1))) else S1:=Copy(S1,Pos(':',S1)+1,(length(s1)-Pos(':',S1))); end; if pos(':',S1)=1 then exit; if Pos(':',S1)=0 then begin if (Pos('''',S1)=0) then Result:=Copy(S1,1,length(S1)) else Result:=Copy(S1,1,length(S1)-1); end else Result:=Copy(S1,1,Pos(':',S1)-1); Result:=StringReplace(Result,'し',':',[rfReplaceAll]); end; function GetPosString2(S1:string):String; var z:integer; begin Result:=''; // if pos(':',S1)=0 then exit; s1:=StringReplace(s1,'??','?',[rfReplaceAll]); s1:=StringReplace(s1,'?:','し',[rfReplaceAll]); s1:=StringReplace(s1,'?''','''',[rfReplaceAll]); s1:=StringReplace(s1,'?+','+',[rfReplaceAll]); if Pos('''',S1)<>0 then Result:=Copy(S1,1,length(S1)-1) else Result:=S1; Result:=StringReplace(Result,'し',':',[rfReplaceAll]); end; function FormatDateStr(ADate:String):String; begin Result:=''; if length(ADate)<>8 then exit; Result:=Copy(ADate,1,4)+'-'+Copy(ADate,5,2)+'-'+Copy(ADate,7,2); end; function FormatNumStr(ANum:String):String; var i:integer; begin Result:='0'; if length(ANum)=0 then exit; for i:=1 to length(ANum) do begin if Copy(ANum,1,1)='0' then system.Delete(ANum,1,1) else Break; end; Result:=ANum; end; function CheckctnNoRepeat(ctnNo:string):string; var aQuery:TAdoQuery; begin Result:=''; if trim(ctnNo)='' then exit; aQuery:=CreateAdoQuery; with aQuery do try close;sql.Clear; sql.Add('select 主提单号 from t_op_ctn_edi'); sql.Add('left join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号'); sql.Add('where 箱号=:箱号'); sql.Add(' and 开船日期>=GetDate()-30 and 开船日期<=GetDate()+30'); Parameters.ParamByName('箱号').Value:=ctnNo; open;First; while not eof do begin if result='' then result:=FieldByName('主提单号').AsString else result:=result+#13#10+FieldByName('主提单号').AsString; Next; end; finally free; end; end; begin repeatCtnNo:=''; aQueryCount:=CreateAdoQuery; with aQueryCount do begin Close;sql.Clear; SQL.Add('select Count(*) C from t_op_seae_edi'); SQL.Add('where 主提单号=:主提单号 and 分提单号=:分提单号 and EDI类型=''CN''') ; end; aQueryUpdate:=CreateAdoQuery; with aQueryUpdate do begin Close;sql.Clear; SQL.Add('update t_op_seae_edi set 数据重复=1'); SQL.Add('where 主提单号=:主提单号 and 分提单号=:分提单号 and EDI类型=''CN''') ; end; EdiStrings:=TStringList.Create; try if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.bsSkinGauge1.ProgressText:='导入数据请等候。。。'; edi_addseai:=true; OpenDialog1.Execute; RL := TStringList.Create; RL := TStringList(OpenDialog1.Files); frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=RL.Count; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; for L := 0 to RL.Count - 1 do begin FileNames:=RL.Strings[L]; if FileNames<>'' then begin EdiStrings.LoadFromFile(FileNames); end; if EdiStrings.Count=0 then exit; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_main.db.BeginTrans; try for i:=0 to EdiStrings.Count-1 do begin S:=EdiStrings.Strings[i]; OldHeads:=Heads; tmp:=Copy(S,3,1); if tmp=':' then begin Heads:=Copy(S,1,2); isstr:=False; end else begin Heads:=oldHeads; isstr:=true; end; //showmessage(Heads); if Heads='00' then begin CarrierAgent:=GetPosString(S,3); // showmessage(CarrierAgent); shipper:=GetPosString(S,5); SendOp:=GetPosString(S,9); SendTel:=GetPosString(S,10); end; if Heads='10' then begin VslID:=GetPosString(S,2); Vessel:=GetPosString(S,3); CarrierName:=GetPosString(S,4); VoyNo:=GetPosString(S,5); //eta:=GetPosString(S,8); //etd:=GetPosString(S,9); end; if Heads='11' then begin Carrier:=GetPosString(S,4); cz:=GetPosString(S,5); end; if Heads='12' then begin if t_op_seae1.DataSet.State in [dsinsert,dsEdit] then t_op_seae1.DataSet.Post; frm_main.t_sum_ctn.close; frm_main.t_sum_ctn.open; bsno:=get_edi_id; aQuerytmp:=CreateAdoQuery; try with aQuerytmp do begin Close;sql.Clear; SQL.Add(' delete from t_op_ctn where 编号='''+bsno+''''); ExecSQL; end; finally FreeAndNil(aQuerytmp); end; t_op_seae1.DataSet.Insert; t_op_seae.fieldbyname('编号').Value:=bsno; t_op_seae.fieldbyname('主编号').Value:=get_edi_id; t_op_seae.fieldbyname('业务编号').Value:=get_edi_id; t_op_seae.fieldbyname('装运类型').Value:='FCL'; t_op_seae.fieldbyname('船代').Value:=CarrierAgent; t_op_seae.fieldbyname('场站').Value:=cz; t_op_seae1.DataSet.FieldByName('货物标识').AsString:='S'; t_op_seae.fieldbyname('委托发送方').Value:=shipper; t_op_seae.fieldbyname('发送方人员').Value:=SendOp; t_op_seae.fieldbyname('发送方电话').Value:=SendTel; { aQuery3:=CreateAdoQuery; try with aQuery3 do begin close;SQL.Clear; SQL.Add('select a.* from code_price_edi a inner join code_emf_type b on a.舱单发送类型=b.舱单发送类型 ' +' where a.EDI类型=''舱单'' and 客户简称='''+shipper+''''); Open; if not IsEmpty then begin t_op_seae.fieldbyname('揽货人').Value:=fieldbyname('揽货人').AsString; t_op_seae.fieldbyname('单价').Value:=fieldbyname('单价').AsString; t_op_seae.fieldbyname('备注').Value:=fieldbyname('舱单发送类型').AsString; end; end; finally FreeAndNil(aQuery3); end; } t_op_seae['EDI类型']:='CN'; t_op_seae['EDI状态']:='未发送'; t_op_seae['当前状态']:='未发送'; t_op_seae['录入人']:=employee; t_op_seae['录入日期']:=now; t_op_seae1.DataSet['卸货港']:=''; t_op_seae1.DataSet['付费方式']:=''; t_op_seae1.DataSet['货物描述']:=''; t_op_seae1.DataSet.FieldByName('船名').AsString:=Vessel; t_op_seae1.DataSet.FieldByName('航次').AsString:=VoyNo; t_op_seae1.DataSet.FieldByName('主提单号').AsString:=GetPosString(S,2); t_op_seae1.DataSet.FieldByName('分提单号').AsString:=GetPosString(S,17); aQueryCount.Close; aQueryCount.Parameters.ParamByName('主提单号').Value:=GetPosString(S,2); aQueryCount.Parameters.ParamByName('分提单号').Value:=GetPosString(S,17); aQueryCount.Open; IF aQueryCount.FieldByName('c').AsInteger>=1 then begin t_op_seae1.DataSet.FieldByName('数据重复').AsBoolean:=True; aQueryUpdate.Close; aQueryUpdate.Parameters.ParamByName('主提单号').Value:=GetPosString(S,2); aQueryUpdate.Parameters.ParamByName('分提单号').Value:=GetPosString(S,17); aQueryUpdate.ExecSQL; showmessage(GetPosString(S,2)+'数据重复'); end else t_op_seae1.DataSet.FieldByName('数据重复').AsBoolean:=false; t_op_seae1.DataSet.FieldByName('船公司').AsString:=CarrierName; {t_op_seae1.DataSet.FieldByName('装港代码').AsString:=GetPosString(S,8); t_op_seae1.DataSet.FieldByName('装货港').AsString:=GetPosString(S,9); } t_op_seae1.DataSet.FieldByName('装港代码').AsString:='CNTAO'; t_op_seae1.DataSet.FieldByName('装货港').AsString:='QINGDAO,CHINA'; t_op_seae1.DataSet.FieldByName('运输条款').AsString:=GetPosString(S,10); t_op_seae1.DataSet.FieldByName('付费方式').AsString:=GetPosString(S,11); s2:=copy(GetPosString(S,12),1,8); if trim(s2)<>'' then begin t_op_seae1.DataSet.FieldByName('开船日期').AsDateTime:=StrToDate(FormatDateStr(s2)); t_op_seae1.DataSet.FieldByName('预抵日期').AsDateTime:=StrToDate(FormatDateStr(s2))+3; end; t_op_seae1.DataSet.FieldByName('唛头').AsString:=''; t_op_seae1.DataSet.FieldByName('货物描述').AsString:=''; end; if Heads='13' then begin t_op_seae1.DataSet.FieldByName('卸货代码').AsString:=GetPosString(S,2); t_op_seae1.DataSet.FieldByName('卸货港').AsString:=GetPosString(S,3); t_op_seae1.DataSet.FieldByName('目的代码').AsString:=GetPosString(S,4); t_op_seae1.DataSet.FieldByName('目的地').AsString:=GetPosString(S,5); end; if Heads='14' then begin end; if Heads='15' then begin end; if Heads='16' then begin t_op_seae1.DataSet.FieldByName('发货人名称').AsString:=GetPosString(S,3); t_op_seae1.DataSet.FieldByName('发货人地址1').AsString:=GetPosString(S,4); //20180526 孙小华添加 t_op_seae1.DataSet.FieldByName('发货人企业代码').AsString:= GetPosString(S,2); t_op_seae1.DataSet.FieldByName('发货人国家代码').AsString:= GetPosString(S,9); t_op_seae1.DataSet.FieldByName('发货人电话').AsString:= GetPosString(S,11); t_op_seae1.DataSet.FieldByName('发货人邮箱').AsString:= GetPosString(S,12); end; if Heads='17' then begin t_op_seae1.DataSet.FieldByName('收货人名称').AsString:=GetPosString(S,3); t_op_seae1.DataSet.FieldByName('收货人地址1').AsString:=GetPosString(S,4); //20180526 孙小华添加 t_op_seae1.DataSet.FieldByName('收货人企业代码').AsString:= GetPosString(S,2); t_op_seae1.DataSet.FieldByName('收货人国家代码').AsString:= GetPosString(S,9); t_op_seae1.DataSet.FieldByName('收货人电话').AsString:= GetPosString(S,11); t_op_seae1.DataSet.FieldByName('收货人邮箱').AsString:= GetPosString(S,12); end; if Heads='18' then begin t_op_seae1.DataSet.FieldByName('通知人名称').AsString:=GetPosString(S,3); t_op_seae1.DataSet.FieldByName('通知人地址1').AsString:=GetPosString(S,4); //20180526 孙小华添加 t_op_seae1.DataSet.FieldByName('通知人企业代码').AsString:= GetPosString(S,2); t_op_seae1.DataSet.FieldByName('通知人国家代码').AsString:= GetPosString(S,9); t_op_seae1.DataSet.FieldByName('通知人电话').AsString:= GetPosString(S,11); t_op_seae1.DataSet.FieldByName('通知人邮箱').AsString:= GetPosString(S,12); end; if Heads='19' then begin end; if Heads='20' then begin end; if Heads='41' then begin t_op_seae1.DataSet.FieldByName('件数').AsString:=FormatNumStr(GetPosString(S,4)); t_op_seae1.DataSet.FieldByName('包装').AsString:=GetPosString(S,6); t_op_seae1.DataSet.FieldByName('重量').AsString:=FormatNumStr(GetPosString(S,7)); t_op_seae1.DataSet.FieldByName('尺码').AsString:=FormatNumStr(GetPosString(S,9)); end; if Heads='43' then begin t_op_seae1.DataSet.FieldByName('货物标识').AsString:='S'; IF Trim(GetPosString(S,11))<>'' then begin t_op_seae1.DataSet.FieldByName('货物标识').AsString:='R'; t_op_seae1.DataSet.FieldByName('设置温度').AsString:=GetPosString(S,11); end else IF Trim(GetPosString(S,2))<>'' then begin t_op_seae1.DataSet.FieldByName('货物标识').AsString:='D'; t_op_seae1.DataSet.FieldByName('危险品分类').AsString:=GetPosString(S,2); t_op_seae1.DataSet.FieldByName('危险品编号').AsString:=GetPosString(S,4); end; end; if Heads='44' then begin if (isstr) then begin if t_op_seae1.DataSet.FieldByName('唛头').AsString<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString2(S) else t_op_seae1.DataSet.FieldByName('唛头').AsString:=GetPosString2(S); end else begin if t_op_seae1.DataSet.FieldByName('唛头').AsString<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString(S,2) else t_op_seae1.DataSet.FieldByName('唛头').AsString:=GetPosString(S,2); if GetPosString(S,3)<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString(S,3); if GetPosString(S,4)<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString(S,4); if GetPosString(S,5)<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString(S,5); if GetPosString(S,6)<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString(S,6); if GetPosString(S,7)<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString(S,7); if GetPosString(S,8)<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString(S,8); if GetPosString(S,9)<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString(S,9); if GetPosString(S,10)<>'' then t_op_seae1.DataSet.FieldByName('唛头').AsString:=t_op_seae1.DataSet.FieldByName('唛头').AsString+#13#10+GetPosString(S,10); end; end; if Heads='47' then begin if (isstr) then begin if (t_op_seae1.DataSet.FieldByName('货物描述').AsString<>'') then t_op_seae1.DataSet.FieldByName('货物描述').AsString:=t_op_seae1.DataSet.FieldByName('货物描述').AsString+#13#10+GetPosString2(S) else t_op_seae1.DataSet.FieldByName('货物描述').AsString:=GetPosString2(S); end else begin if (t_op_seae1.DataSet.FieldByName('货物描述').AsString<>'') then t_op_seae1.DataSet.FieldByName('货物描述').AsString:=t_op_seae1.DataSet.FieldByName('货物描述').AsString+#13#10+GetPosString(S,2) else t_op_seae1.DataSet.FieldByName('货物描述').AsString:=GetPosString(S,2); if GetPosString(S,3)<>'' then t_op_seae1.DataSet.FieldByName('货物描述').AsString:=t_op_seae1.DataSet.FieldByName('货物描述').AsString+#13#10+GetPosString(S,3); if GetPosString(S,4)<>'' then t_op_seae1.DataSet.FieldByName('货物描述').AsString:=t_op_seae1.DataSet.FieldByName('货物描述').AsString+#13#10+GetPosString(S,4); if GetPosString(S,5)<>'' then t_op_seae1.DataSet.FieldByName('货物描述').AsString:=t_op_seae1.DataSet.FieldByName('货物描述').AsString+#13#10+GetPosString(S,5); if GetPosString(S,6)<>'' then t_op_seae1.DataSet.FieldByName('货物描述').AsString:=t_op_seae1.DataSet.FieldByName('货物描述').AsString+#13#10+GetPosString(S,6); end; end; if Heads='51' then begin repeatctnno:=CheckctnNoRepeat(GetPosString(S,3)); if repeatctnno<>'' then begin showmessage(repeatctnno+#13#10+'以上提单号存在该箱号:'+GetPosString(S,3)); end; if (not t_op_seae1.DataSet.FieldByName('编号').IsNull) and (t_op_seae1.DataSet.FieldByName('编号').AsString<>'') then begin aQuery:=createAdoQuery; aQuery2:=createAdoQuery; try with aQuery do begin Close;sql.clear; sql.Add('select * from t_op_ctn_edi where 编号=:编号'); DataSource:=t_op_seae1; open; aQuery2.close;aQuery2.sql.Clear; aQuery2.SQL.Add('select * from t_code_ctn where 尺寸+箱型='''+GetPosString(S,5)+''''); aQuery2.Open; if not aQuery2.IsEmpty then begin ctntype:= aQuery2.fieldbyname('表现形式').AsString; Insert; FieldByName('代码').AsString:=aQuery2.fieldbyname('代码').AsString; FieldByName('箱型').AsString:=aQuery2.fieldbyname('箱型').AsString; FieldByName('尺寸').AsString:=aQuery2.fieldbyname('尺寸').AsString; FieldByName('表现形式').AsString:=aQuery2.fieldbyname('表现形式').AsString; FieldByName('数量').AsInteger:=1; if aQuery2.fieldbyname('尺寸').AsString='20'then FieldByName('TEU').AsInteger:=1; if (aQuery2.fieldbyname('尺寸').AsString='40') OR (aQuery2.fieldbyname('尺寸').AsString='45') then FieldByName('TEU').AsInteger:=2; //FieldByName('包装').AsString:=GetPosString(S,3); FieldByName('箱号').AsString:=GetPosString(S,3); FieldByName('封号').AsString:=GetPosString(S,4); FieldByName('件数').AsString:=FormatNumStr(GetPosString(S,7)); FieldByName('重量').AsString:=FormatNumStr(GetPosString(S,8)); FieldByName('尺码').AsString:=FormatNumStr(GetPosString(S,10)); FieldByName('包装').AsString:=FormatNumStr(GetPosString(S,11)); Post; end else begin ctntype:=GetPosString(S,5); Insert; FieldByName('代码').AsString:='XX'; // showmessage(GetPosString(S,5)+Copy(GetPosString(S,5),1,2)+Copy(GetPosString(S,5),3,2)); FieldByName('箱型').AsString:=Copy(GetPosString(S,5),1,2); FieldByName('尺寸').AsString:=Copy(GetPosString(S,5),3,2); FieldByName('表现形式').AsString:=GetPosString(S,5); FieldByName('数量').AsInteger:=1; if Copy(GetPosString(S,5),1,2)='20'then FieldByName('TEU').AsInteger:=1; if (Copy(GetPosString(S,5),1,2)='40') OR (Copy(GetPosString(S,5),1,2)='45') then FieldByName('TEU').AsInteger:=2 else FieldByName('TEU').AsInteger:=0; // FieldByName('包装').AsString:=GetPosString(S,3); FieldByName('箱号').AsString:=GetPosString(S,3); FieldByName('封号').AsString:=GetPosString(S,4); FieldByName('件数').AsString:=FormatNumStr(GetPosString(S,7)); FieldByName('重量').AsString:=FormatNumStr(GetPosString(S,8)); FieldByName('尺码').AsString:=FormatNumStr(GetPosString(S,10)); FieldByName('包装').AsString:=FormatNumStr(GetPosString(S,11)); Post; end; end; finally FreeAndNil(aQuery); FreeAndNil(aQuery2); end; end; end; if Heads='99' then begin if t_op_seae1.DataSet.State in [dsinsert,dsEdit] then t_op_seae1.DataSet.Post; t_op_ctn.Close; t_op_ctn.Open; update_edictn(t_op_ctn); end; END; frm_main.db.CommitTrans; except on e:Exception do begin showmessage('导入数据时发生错误,没有正常导入!'+e.Message+FileNames); frm_main.db.RollbackTrans; aQuery:=createAdoQuery; try with aQuery do begin Close;sql.clear; sql.Add('delete from t_op_ctn_edi where 编号='''+bsno+''''); ExecSQL; end; finally FreeAndNil(aQuery); end; end; end; END; finally frm_sys_progress.close; frm_sys_progress:=nil; edi_addseai:=true; FreeAndNil(EdiStrings); end; notebook1.pageindex:=1; end; procedure Tfrm_op_seae_edi_data.dxDBGrid1CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin if uppercase(ANode.Strings[dxDBGrid1Column28.Index])='TRUE' then begin AColor:=clRed; exit; end; end; function Tfrm_op_seae_edi_data.IgzEdi(EdiStrings:TStrings):Boolean; var i:integer; MblNo,HblNo,CtnNo,S,Heads,ctnStatusNo,ctnStatus,adate:string; function GetPosString(S1:string;m:integer):String; var z:integer; begin Result:=''; if pos(':',S1)=0 then exit; s1:=StringReplace(s1,'??','?',[rfReplaceAll]); s1:=StringReplace(s1,'?:','し',[rfReplaceAll]); s1:=StringReplace(s1,'?''','''',[rfReplaceAll]); s1:=StringReplace(s1,'?+','+',[rfReplaceAll]); for z:=1 to m-1 do begin if Pos(':',S1)=0 then exit; if Pos(':',S1)=1 then S1:=Copy(S1,Pos(':',S1)+1,(length(s1)-Pos(':',S1))) else S1:=Copy(S1,Pos(':',S1)+1,(length(s1)-Pos(':',S1))); end; if pos(':',S1)=1 then exit; if Pos(':',S1)=0 then Result:=Copy(S1,1,length(S1)-1) else Result:=Copy(S1,1,Pos(':',S1)-1); Result:=StringReplace(Result,'し',':',[rfReplaceAll]); end; function FormatDateStr(ADate:String):String; begin Result:=''; if length(ADate)<>8 then exit; Result:=Copy(ADate,1,4)+'-'+Copy(ADate,5,2)+'-'+Copy(ADate,7,2); end; function FormatNumStr(ANum:String):String; var i:integer; begin Result:='0'; if length(ANum)=0 then exit; for i:=1 to length(ANum) do begin if Copy(ANum,1,1)='0' then system.Delete(ANum,1,1) else Break; end; Result:=ANum; end; begin Memo1.Clear; Memo1.Lines.Clear; try for i:=0 to EdiStrings.Count-1 do begin S:=EdiStrings.Strings[i]; if Pos('RFF+BN:',S)>0 then begin HblNo:=Copy(s,Pos(':',S)+1,length(S)-Pos(':',S)-1); Memo1.Lines.Add('分提单号:'+HblNo); end; if Pos('RFF+BM:',S)>0 then begin MblNo:=Copy(s,Pos(':',S)+1,length(S)-Pos(':',S)-1); Memo1.Lines.Add('主提单号:'+MblNo); end; if Pos('STS+1+',S)>0 then begin ctnStatusNo:=Copy(s,7,Pos('::',S)-7); if ctnStatusNo='EE' then ctnStatus:='空箱出场' else if ctnStatusNo='I' then ctnStatus:='重箱回场' else if ctnStatusNo='TR' then ctnStatus:='运抵报告' else if ctnStatusNo='CT' then ctnStatus:='海关放行' else if ctnStatusNo='AE' then ctnStatus:='装船' else if ctnStatusNo='AF' then ctnStatus:='始发港离港' else if ctnStatusNo='UV' then ctnStatus:='卸船' else if ctnStatusNo='VA' then ctnStatus:='到港' else if ctnStatusNo='VD' then ctnStatus:='离港' else if ctnStatusNo='OA' then ctnStatus:='重箱出场' else if ctnStatusNo='MT' then ctnStatus:='空箱回场' else if ctnStatusNo='RD' then ctnStatus:='Return Container' else ctnStatus:='未识别为标准代码的状态'; Memo1.Lines.Add('状态:'+ctnStatus); end; adate:=''; if Pos('DTM+334:',S)>0 then begin adate:=Copy(s,Pos(':',S)+1,12); Memo1.Lines.Add('发生日期:'+adate); end; adate:=''; if Pos('DTM+132:',S)>0 then begin adate:=Copy(s,Pos(':',S)+1,12); Memo1.Lines.Add('到港日期:'+adate); end; if Pos('EQD+CN+',S)>0 then begin CtnNo:=Copy(s,8,11); Memo1.Lines.Add('箱号:'+CtnNo); end; end; finally end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton35Click(Sender: TObject); var EdiString:TStrings; FileNames:string; begin EdiString:=TStringList.Create; try OpenDialog1.Execute; FileNames:=OpenDialog1.FileName; if FileNames<>'' then begin EdiString.LoadFromFile(FileNames); IgzEdi(EdiString); end; finally FreeAndNil(EdiString); end; end; procedure Tfrm_op_seae_edi_data.DBEdit1Change(Sender: TObject); begin cxTreeView1.Items.Clear; end; procedure Tfrm_op_seae_edi_data.bsSkinButton31Click(Sender: TObject); var Str:TStrings; begin str:=Tstringlist.Create; try Str:=CreateIgengzongxml('SO'); SaveDialog1.FileName:='YT_'+FormatDateTime('YYYYMMDD',Date)+'_N'; SaveDialog1.Filter:='*.xml|*.xml'; if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.xml'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; finally FreeAndNil(Str) end; end; function Tfrm_op_seae_edi_data.CreateIgengzongxml(SOI:string):TStringlist; var str,alist:Tstringlist; StlType:string; s:widestring; aAdoQuery:TAdoQuery; i:integer; begin i:=1; str:=Tstringlist.Create; alist:=Tstringlist.Create; str.Clear; str.Add(''); str.Add(''); str.Add('
'); str.Add('QueryCondition'); str.Add(''); str.Add(''+FormatDateTime('YYYYMMDD',Date)+'000000'); str.Add(''); str.Add('
'); str.Add(''); for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(Pointer(dxDBGrid1.selectedrows[I])); SelectReciveData(t_op_seae.FieldByName('主编号').AsString,t_op_seae.FieldByName('主提单号').AsString); str.Add(' CarrierCode="'+t_op_seae.FieldByName('船公司').AsString+'" PortCode="'+t_op_seae.FieldByName('装港代码').AsString+'" DockCode="" EndDate="">'); str.Add(''+t_op_seae.FieldByName('主提单号').AsString+''); str.Add(''); end; str.Add(''); str.Add('
'); Result:=str; end; procedure Tfrm_op_seae_edi_data.t_op_ctnAfterPost(DataSet: TDataSet); begin // update_edictn(t_op_ctn); end; procedure Tfrm_op_seae_edi_data.bsSkinButton36Click(Sender: TObject); begin { try if not assigned(frmget56Cookie) then frmget56Cookie:=tfrmget56Cookie.Create(application); frmget56Cookie.ShowModal; finally frmget56Cookie.free; frmget56Cookie:=nil; end; } end; procedure Tfrm_op_seae_edi_data.bsSkinButton37Click(Sender: TObject); var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('update t_op_ctn_edi set 包装='''+t_op_seae.fieldbyname('包装').AsString+''' where 编号='''+t_op_seae.fieldbyname('编号').AsString+''''); ExecSQL; end; finally FreeAndNil(aQuery); end; t_op_ctn.Requery; end; procedure Tfrm_op_seae_edi_data.RxDBLookupCombo3Change(Sender: TObject); var aQuery:TADOQuery; kftype,kffieldname:string; begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit)then begin if RxDBLookupCombo3.DisplayValue<>'' then begin kftype:=t_code_cangdan.FieldByName('扣费类型').AsString; if (kftype='') then exit; if (kftype='新增') then kftype:='发送'; if trim(t_op_seae.fieldbyname('分提单号').AsString)='' then begin kffieldname:='主单'+kftype; end else begin kffieldname:='分单'+kftype; end; aQuery:=CreateAdoQuery; try with aQuery do begin close;SQL.Clear; SQL.Add('SELECT D.'+kffieldname+' FROM code_price_edi_detail D'); SQL.Add(' LEFT JOIN code_price_edi P ON D.LINKGID=P.序号'); SQL.Add(' WHERE P.客户简称='''+t_op_seae.fieldbyname('委托发送方').AsString+''' and D.船代='''+t_op_seae.fieldbyname('船代').AsString+''''); open; if not IsEmpty then begin t_op_seae.fieldbyname('单价').AsString:=FieldByName(kffieldname).AsString; t_op_seae.fieldbyname('应收').AsString:=FieldByName(kffieldname).AsString; end else begin close;SQL.Clear; SQL.Add('SELECT P.'+kffieldname+' '); SQL.Add(' FROM code_price_edi P '); SQL.Add(' WHERE P.客户简称='''+t_op_seae.fieldbyname('委托发送方').AsString+''' '); open; if not IsEmpty then begin t_op_seae.fieldbyname('单价').AsString:=FieldByName(kffieldname).AsString; t_op_seae.fieldbyname('应收').AsString:=FieldByName(kffieldname).AsString; end end; end; finally FreeAndNil(aQuery); end; end; end; end; procedure Tfrm_op_seae_edi_data.DBEdit11Change(Sender: TObject); begin { t_code_cangdan.Close; t_code_cangdan.Parameters.ParamByName('委托发送方').Value:=DBEdit11.Text; // t_code_cangdan.Parameters.ParamByName('船代').Value:=DBEdit4.Text; if (Trim(DBEdit10.Text)='') then t_code_cangdan.Parameters.ParamByName('主分单类型').Value:='主单' else t_code_cangdan.Parameters.ParamByName('主分单类型').Value:='分单'; t_code_cangdan.Open; } end; procedure Tfrm_op_seae_edi_data.bsSkinSpeedButton4Click(Sender: TObject); var aQuery,bQuery,cQuery,dQuery:TADOQuery; SQLStr,CTNSQLStr:string; i:Integer; ResentBookMark:TBookmark; begin if messagedlg('您确定要同步主提单号为:'+DBEdit9.Text+' 的分提单号吗?',mtWarning,mbYesNoCancel,0)=MrYES then begin ResentBookMark:=t_op_seae.GetBookmark; aQuery:=CreateAdoQuery; with aQuery do begin Close; SQL.Clear; SQL.Add('select * from t_op_seae_edi where 主提单号='+QuotedStr(DBEdit9.Text)+' and (分提单号<>'''' and 分提单号 is not null) ' +' and 船名='+QuotedStr(DBEdit38.Text) ) ; Open; end; if aQuery.IsEmpty then begin ShowMessage('没有找到主提单号为: '+DBEdit9.Text+',船名为: '+QuotedStr(DBEdit38.Text)+', 的分提单号! 不能同步!'); FreeAndNil(aQuery); Exit; end; cQuery:=CreateAdoQuery; with cQuery do begin Close; SQL.Clear; SQL.Add('select top 1 * from t_op_ctn_edi where 编号='+QuotedStr(DBEdit33.Text) ); Open; end; if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.ProgressText:='正在同步数据 请等候。。。'; frm_sys_progress.bsSkinGauge1.MaxValue:=aQuery.RecordCount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; bQuery:=CreateAdoQuery; dQuery:=CreateAdoQuery; aQuery.First; while not aQuery.Eof do begin SQLStr:='update t_op_seae_edi set 航次=:p1,开船日期=:p2,船舶IMO=:p3,船公司代码=:p4,发货人=:p5,发货人名称=:p6,发货人地址1=:p7,' +'发货人地址2=:p8,发货人邮箱=:p9,发货人电话=:p10,发货人国家代码=:p11,发货人企业代码=:p12,收货人=:p13,收货人名称=:p14,' +'收货人地址1=:p15,收货人地址2=:p16,收货人邮箱=:p17,收货人电话=:p18,收货人国家代码=:p19,收货人企业代码=:p20,通知人=:p21,' +'通知人名称=:p22,通知人地址1=:p23,通知人地址2=:p24,通知人邮箱=:p25,通知人电话=:p26,通知人国家代码=:p27,通知人企业代码=:p28,' +'运输条款=:p29,装货港=:p30,装港代码=:p31,签单地点=:p32,卸货港=:p34,卸货代码=:p35,目的地=:p36,目的代码=:p37,' +'预抵日期=:p38,付费方式=:p39,包装=:p40,船代=:p41,委托发送方=:p42,备注=:p43,揽货人=:p44,危险品联系人=:p45,危险品电话=:p46,' +'危险品分类=:p47,危险品编号=:p48 where 编号=' +QuotedStr(aQuery.fieldbyname('编号').AsString); CTNSQLStr:='update t_op_ctn_edi set 包装=:p1 where 编号='+QuotedStr(aQuery.fieldbyname('编号').AsString); with bQuery do begin Close; SQL.Clear; SQL.Add(CTNSQLStr); Parameters.ParamByName('p1').Value:=t_op_seae.FieldByName('包装').AsString; ExecSQL; Close; SQL.Clear; SQL.Add(SQLStr); Parameters.ParamByName('p1').Value:=t_op_seae.FieldByName('航次').AsString; Parameters.ParamByName('p2').Value:=t_op_seae.FieldByName('开船日期').AsDateTime; Parameters.ParamByName('p3').Value:=t_op_seae.FieldByName('船舶IMO').AsString; Parameters.ParamByName('p4').Value:=t_op_seae.FieldByName('船公司代码').AsString; Parameters.ParamByName('p5').Value:=t_op_seae.FieldByName('发货人').AsString; Parameters.ParamByName('p6').Value:=t_op_seae.FieldByName('发货人名称').AsString; Parameters.ParamByName('p7').Value:=t_op_seae.FieldByName('发货人地址1').AsString; Parameters.ParamByName('p8').Value:=t_op_seae.FieldByName('发货人地址2').AsString; Parameters.ParamByName('p9').Value:=t_op_seae.FieldByName('发货人邮箱').AsString; Parameters.ParamByName('p10').Value:=t_op_seae.FieldByName('发货人电话').AsString; Parameters.ParamByName('p11').Value:=t_op_seae.FieldByName('发货人国家代码').AsString; Parameters.ParamByName('p12').Value:=t_op_seae.FieldByName('发货人企业代码').AsString; Parameters.ParamByName('p13').Value:=t_op_seae.FieldByName('收货人').AsString; Parameters.ParamByName('p14').Value:=t_op_seae.FieldByName('收货人名称').AsString; Parameters.ParamByName('p15').Value:=t_op_seae.FieldByName('收货人地址1').AsString; Parameters.ParamByName('p16').Value:=t_op_seae.FieldByName('收货人地址2').AsString; Parameters.ParamByName('p17').Value:=t_op_seae.FieldByName('收货人邮箱').AsString; Parameters.ParamByName('p18').Value:=t_op_seae.FieldByName('收货人电话').AsString; Parameters.ParamByName('p19').Value:=t_op_seae.FieldByName('收货人国家代码').AsString; Parameters.ParamByName('p20').Value:=t_op_seae.FieldByName('收货人企业代码').AsString; Parameters.ParamByName('p21').Value:=t_op_seae.FieldByName('通知人').AsString; Parameters.ParamByName('p22').Value:=t_op_seae.FieldByName('通知人名称').AsString; Parameters.ParamByName('p23').Value:=t_op_seae.FieldByName('通知人地址1').AsString; Parameters.ParamByName('p24').Value:=t_op_seae.FieldByName('通知人地址2').AsString; Parameters.ParamByName('p25').Value:=t_op_seae.FieldByName('通知人邮箱').AsString; Parameters.ParamByName('p26').Value:=t_op_seae.FieldByName('通知人电话').AsString; Parameters.ParamByName('p27').Value:=t_op_seae.FieldByName('通知人国家代码').AsString; Parameters.ParamByName('p28').Value:=t_op_seae.FieldByName('通知人企业代码').AsString; Parameters.ParamByName('p29').Value:=t_op_seae.FieldByName('运输条款').AsString; Parameters.ParamByName('p30').Value:=t_op_seae.FieldByName('装货港').AsString; Parameters.ParamByName('p31').Value:=t_op_seae.FieldByName('装港代码').AsString; { Parameters.ParamByName('p30').Value:='QINGDAO,CHINA'; Parameters.ParamByName('p31').Value:='CNTAO'; } Parameters.ParamByName('p32').Value:=t_op_seae.FieldByName('签单地点').AsString; Parameters.ParamByName('p34').Value:=t_op_seae.FieldByName('卸货港').AsString; Parameters.ParamByName('p35').Value:=t_op_seae.FieldByName('卸货代码').AsString; Parameters.ParamByName('p36').Value:=t_op_seae.FieldByName('目的地').AsString; Parameters.ParamByName('p37').Value:=t_op_seae.FieldByName('目的代码').AsString; Parameters.ParamByName('p38').Value:=t_op_seae.FieldByName('预抵日期').AsDateTime; Parameters.ParamByName('p39').Value:=t_op_seae.FieldByName('付费方式').AsString; Parameters.ParamByName('p40').Value:=t_op_seae.FieldByName('包装').AsString; Parameters.ParamByName('p41').Value:=t_op_seae.FieldByName('船代').AsString; Parameters.ParamByName('p42').Value:=t_op_seae.FieldByName('委托发送方').AsString; Parameters.ParamByName('p43').Value:=t_op_seae.FieldByName('备注').AsString; Parameters.ParamByName('p44').Value:=t_op_seae.FieldByName('揽货人').AsString; Parameters.ParamByName('p45').Value:=t_op_seae.FieldByName('危险品联系人').AsString; Parameters.ParamByName('p46').Value:=t_op_seae.FieldByName('危险品电话').AsString; Parameters.ParamByName('p47').Value:=t_op_seae.FieldByName('危险品分类').AsString; Parameters.ParamByName('p48').Value:=t_op_seae.FieldByName('危险品编号').AsString; ExecSQL; end; //,重箱整箱标志=:p45,施封人=:p46 if not cQuery.IsEmpty then begin with dQuery do begin Close; SQL.Clear; SQL.Add('update t_op_ctn_edi set 重箱整箱标志=:p1,施封人=:p2 where 编号='+QuotedStr(aQuery.fieldbyname('编号').AsString) ); Parameters.ParamByName('p1').Value:=cQuery.FieldByName('重箱整箱标志').AsString; Parameters.ParamByName('p2').Value:=cQuery.FieldByName('施封人').AsString; ExecSQL; end; end; aQuery.Next; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; end; FreeAndNil(aQuery); FreeAndNil(bQuery); FreeAndNil(cQuery); FreeAndNil(dQuery); t_op_seae.Requery(); t_op_seae.GotoBookmark(ResentBookMark); frm_sys_progress.close; frm_sys_progress:=nil; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton39Click(Sender: TObject); begin t_op_seae.Edit; t_op_seae.fieldbyname('收货人名称').AsString:=t_op_seae.fieldbyname('通知人名称').AsString;; t_op_seae.fieldbyname('收货人地址1').AsString:=t_op_seae.fieldbyname('通知人地址1').AsString; t_op_seae.fieldbyname('收货人地址2').AsString:=t_op_seae.fieldbyname('通知人地址2').AsString; t_op_seae.fieldbyname('收货人地址3').AsString:=t_op_seae.fieldbyname('通知人地址3').AsString; t_op_seae.fieldbyname('收货人城市').AsString:=t_op_seae.fieldbyname('通知人城市').AsString; t_op_seae.fieldbyname('收货人邮编').AsString:=t_op_seae.fieldbyname('通知人邮编').AsString; t_op_seae.fieldbyname('收货人国家代码').AsString:=t_op_seae.fieldbyname('通知人国家代码').AsString; t_op_seae.fieldbyname('收货人联系人').AsString:=t_op_seae.fieldbyname('通知人联系人').AsString; t_op_seae.fieldbyname('收货人电话').AsString:=t_op_seae.fieldbyname('通知人电话').AsString; t_op_seae.fieldbyname('收货人州').AsString:=t_op_seae.fieldbyname('通知人州').AsString; t_op_seae.fieldbyname('收货人企业代码').AsString:=t_op_seae.fieldbyname('通知人企业代码').AsString; t_op_seae.Post; end; procedure Tfrm_op_seae_edi_data.bsSkinButton40Click(Sender: TObject); var ctntype,ctnsize,ctncode:string; mybookmark:TBookmark; begin mybookmark:=t_op_ctn.GetBookmark; ctncode:=t_op_ctn.fieldbyname('代码').AsString; ctntype:=t_op_ctn.fieldbyname('箱型').AsString; ctnsize:=t_op_ctn.fieldbyname('尺寸').AsString; with t_op_ctn do begin First; while not eof do begin Edit; FieldByName('代码').AsString:=ctncode; FieldByName('箱型').AsString:=ctntype; FieldByName('尺寸').AsString:=ctnsize; FieldByName('表现形式').AsString:=ctnsize+'"'+ctntype; post; Next; end; end; t_op_ctn.Requery(); t_op_ctn.GotoBookmark(mybookmark); end; procedure Tfrm_op_seae_edi_data.Notebook1PageChanged(Sender: TObject); begin setconcolor; if (Notebook1.PageIndex=1) then begin if (t_op_seae.FieldByName('船代').AsString='中远') or (t_op_seae.FieldByName('船代').AsString='中远海运') then begin t_code_zy_client.Close; t_code_zy_client.SQL.Text:='select top 1 客户简称 from t_code_zy_client where 所属公司='''+t_op_seae.FieldByName('委托发送方').AsString+''''; t_code_zy_client.Open; end else t_code_zy_client.Close; end else begin t_code_zy_client.Close; end; end; procedure Tfrm_op_seae_edi_data.bsSkinButton41Click(Sender: TObject); var ctnsfr:string; mybookmark:TBookmark; begin mybookmark:=t_op_ctn.GetBookmark; ctnsfr:=t_op_ctn.fieldbyname('施封人').AsString; with t_op_ctn do begin First; while not eof do begin Edit; FieldByName('施封人').AsString:=ctnsfr; post; Next; end; end; t_op_ctn.Requery(); t_op_ctn.GotoBookmark(mybookmark); end; procedure Tfrm_op_seae_edi_data.DBEdit11Exit(Sender: TObject); begin { t_code_cangdan.Close; t_code_cangdan.Parameters.ParamByName('委托发送方').Value:=DBEdit11.Text; t_code_cangdan.Open; } end; procedure Tfrm_op_seae_edi_data.t_op_seaeAfterScroll(DataSet: TDataSet); begin { t_code_cangdan.Close; t_code_cangdan.Parameters.ParamByName('委托发送方').Value:=t_op_seae.fieldbyname('委托发送方').AsString; t_code_cangdan.Open; } { t_code_cangdan.Close; t_code_cangdan.Parameters.ParamByName('委托发送方').Value:=t_op_seae.fieldbyname('委托发送方').AsString; if (Trim(t_op_seae.fieldbyname('分提单号').AsString)='') then t_code_cangdan.Parameters.ParamByName('主分单类型').Value:='主单' else t_code_cangdan.Parameters.ParamByName('主分单类型').Value:='分单'; t_code_cangdan.Open; } if (Notebook1.PageIndex=1) then begin if (t_op_seae.FieldByName('船代').AsString='中远') or (t_op_seae.FieldByName('船代').AsString='中远海运') then begin t_code_zy_client.Close; t_code_zy_client.SQL.Text:='select top 1 客户简称 from t_code_zy_client where 所属公司='''+t_op_seae.FieldByName('委托发送方').AsString+''''; t_code_zy_client.Open; end else t_code_zy_client.Close; end else begin t_code_zy_client.Close; end; // GetDuiBiStr; end; procedure Tfrm_op_seae_edi_data.EXCEL1Click(Sender: TObject); var i,j:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr,zhusername,zhpassword,ScriptPath,str_file:string; inifile1:TIniFile; senddgdata:TSendDGData; begin if t_op_seae.IsEmpty then Exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; j:=6; excel2.Connect; Excel2.Exec('[open('+'"'+ExtractFilePath(Application.ExeName)+'ZHENHUA.xls'+'"'+')]'); excel2.putstr(2,1,aAdoQuery.FieldByName('主提单号').AsString); First; while not eof do begin excel2.putstr(j,1,aAdoQuery.FieldByName('船名').AsString); excel2.putstr(j,2,aAdoQuery.FieldByName('航次').AsString); excel2.putstr(j,3,aAdoQuery.FieldByName('船公司代码').AsString); excel2.putstr(j,4,''); excel2.putstr(j,5,aAdoQuery.FieldByName('主提单号').AsString); excel2.putstr(j,6,aAdoQuery.FieldByName('箱号').AsString); excel2.putstr(j,7,aAdoQuery.FieldByName('封号').AsString); poststr:=aAdoQuery.FieldByName('装货港').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); excel2.putstr(j,8,poststr); poststr:=aAdoQuery.FieldByName('卸货港').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); excel2.putstr(j,10,poststr); poststr:=aAdoQuery.FieldByName('目的地').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); excel2.putstr(j,11,poststr); excel2.putstr(j,12,aAdoQuery.FieldByName('件数').AsString); excel2.putstr(j,13,aAdoQuery.FieldByName('包装').AsString); excel2.putstr(j,14,aAdoQuery.FieldByName('重量').AsString); excel2.putstr(j,15,aAdoQuery.FieldByName('尺码').AsString); excel2.putstr(j,16,aAdoQuery.FieldByName('尺寸').AsString+aAdoQuery.FieldByName('箱型').AsString); excel2.putstr(j,17,aAdoQuery.FieldByName('货物描述').AsString); excel2.putstr(j,18,aAdoQuery.FieldByName('发货人名称').AsString); excel2.putstr(j,19,aAdoQuery.FieldByName('收货人名称').AsString); excel2.putstr(j,20,aAdoQuery.FieldByName('通知人名称').AsString); if Pos('COLLECT',aAdoQuery.FieldByName('付费方式').AsString)>0 THEN excel2.putstr(j,21,'COLLECT') else excel2.putstr(j,21,'PREPAID'); excel2.putstr(j,22,aAdoQuery.FieldByName('唛头_1').AsString); excel2.putstr(j,24,aAdoQuery.FieldByName('发货人地址1').AsString); excel2.putstr(j,25,''); excel2.putstr(j,26,aAdoQuery.FieldByName('发货人国家代码').AsString); excel2.putstr(j,27,'TE'); excel2.putstr(j,28,aAdoQuery.FieldByName('发货人电话').AsString); excel2.putstr(j,30,aAdoQuery.FieldByName('收货人地址1').AsString); excel2.putstr(j,31,''); excel2.putstr(j,32,aAdoQuery.FieldByName('收货人国家代码').AsString); excel2.putstr(j,33,'TE'); excel2.putstr(j,34,aAdoQuery.FieldByName('收货人电话').AsString); excel2.putstr(j,36,aAdoQuery.FieldByName('通知人地址1').AsString); excel2.putstr(j,37,''); excel2.putstr(j,38,aAdoQuery.FieldByName('通知人国家代码').AsString); excel2.putstr(j,39,'TE'); excel2.putstr(j,40,aAdoQuery.FieldByName('通知人电话').AsString); if (aAdoQuery.FieldByName('货物标识').AsString='D') then excel2.putstr(j,42,'是') else excel2.putstr(j,42,'否'); excel2.putstr(j,43,aAdoQuery.FieldByName('危险品编号').AsString); excel2.putstr(j,44,aAdoQuery.FieldByName('危险品分类').AsString); excel2.putstr(j,45,aAdoQuery.FieldByName('危险品联系人').AsString); excel2.putstr(j,46,aAdoQuery.FieldByName('危险品电话').AsString); j:=j+1; Next; end; SaveDialog.Filter := '(*.xls)|*.xls'; SaveDialog.FileName := aAdoQuery.fieldbyname('主提单号').asstring+'.xls'; if SaveDialog.Execute then begin excel2.Exec('[SAVE.AS("'+SaveDialog.FileName+'";1;"";false;"";false)]'); excel2.Exec('[CLOSE(false)]'); end; updatelr; finally aDataSource.Free; Free; end; end; //function PlateThreadZHFun(p: Pointer): Integer; stdcall; //procedure TMyThread.Execute; procedure Tfrm_op_seae_edi_data.N29Click(Sender: TObject); var i,j:integer; str,ScriptPath,str_file:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr:string; MultiPartFormDataStream: TIdMultiPartFormDataStream; IdHTTP1:TIdHTTP; inifile1: Tinifile; zhusername,zhpassword,mblno:string; ExcelEXP: TExcel; isfile:Boolean; xlstest, thesheet:Variant; begin if MessageDlg('确定要<<中海直发>>选中的'+inttostr(j)+'票业务数据吗?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; // FreeOnTerminate := True; inifile1 := Tinifile.Create(ExtractFilePath(application.ExeName) + 'main.ini'); zhusername:= inifile1.ReadString('customZH', 'EDIUSERNAME', ''); zhpassword:= inifile1.ReadString('customZH', 'EDIPASSOWRD', ''); if zhusername='' then begin ShowMessage('发送用户名和密码不能为空!'); Exit; end; if frm_op_seae_edi_data.t_op_seae.IsEmpty then Exit; ScriptPath:=ExtractFilePath(ParamStr(0))+'TMPEXCEL\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); CoInitialize(Nil); if frm_op_seae_edi_data.dxDBGrid1.SelectedCount>0 then begin for i:=0 to frm_op_seae_edi_data.dxDBGrid1.SelectedCount-1 do begin frm_op_seae_edi_data.t_op_seae.GotoBookmark(pointer(frm_op_seae_edi_data.dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+frm_op_seae_edi_data.t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+frm_op_seae_edi_data.t_op_seae.fieldbyname('编号').asstring+''''; frm_op_seae_edi_data.t_op_seae.Edit; frm_op_seae_edi_data.t_op_seae.FieldByName('EDI状态').AsString:='已发送'; frm_op_seae_edi_data.t_op_seae.Post; end; end else begin str:='('+''''+frm_op_seae_edi_data.t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; mblno:=frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring+'(中海)'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; ExcelEXP:=TExcel.Create(nil); with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; j:=2; try xlstest:=CreateOleObject('Excel.Application'); except Try //多用一个Try..Finally是防止在读写单元格过程中出错,退出时可能没有释放Excel,造成内存漏洞 xlstest.ActiveWorkBook.Saved := True; xlstest.Quit; Finally xlstest:=UnAssigned; End; Exit; end; xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'ZHONGHAI.xls'); thesheet:= xlstest.Workbooks[1].Worksheets['sheet1']; First; while not eof do begin thesheet.cells.item[j,1]:=aAdoQuery.FieldByName('主提单号').AsString; thesheet.cells.item[j,2]:=''; thesheet.cells.item[j,3]:=aAdoQuery.FieldByName('船名').AsString; thesheet.cells.item[j,4]:=aAdoQuery.FieldByName('航次').AsString; thesheet.cells.item[j,5]:=aAdoQuery.FieldByName('发货人名称').AsString; thesheet.cells.item[j,6]:=aAdoQuery.FieldByName('发货人地址1').AsString; thesheet.cells.item[j,7]:=aAdoQuery.FieldByName('发货人企业代码').AsString; thesheet.cells.item[j,8]:=aAdoQuery.FieldByName('发货人国家代码').AsString; thesheet.cells.item[j,9]:='TE'; thesheet.cells.item[j,10]:=aAdoQuery.FieldByName('发货人电话').AsString; thesheet.cells.item[j,12]:=aAdoQuery.FieldByName('收货人名称').AsString; thesheet.cells.item[j,13]:=aAdoQuery.FieldByName('收货人地址1').AsString; thesheet.cells.item[j,14]:=aAdoQuery.FieldByName('收货人企业代码').AsString; thesheet.cells.item[j,15]:=aAdoQuery.FieldByName('收货人国家代码').AsString; thesheet.cells.item[j,16]:='TE'; thesheet.cells.item[j,17]:=aAdoQuery.FieldByName('收货人电话').AsString; thesheet.cells.item[j,19]:=aAdoQuery.FieldByName('通知人名称').AsString; thesheet.cells.item[j,20]:=aAdoQuery.FieldByName('通知人地址1').AsString; thesheet.cells.item[j,21]:=aAdoQuery.FieldByName('通知人企业代码').AsString; thesheet.cells.item[j,22]:=aAdoQuery.FieldByName('通知人国家代码').AsString; thesheet.cells.item[j,23]:='TE'; thesheet.cells.item[j,24]:=aAdoQuery.FieldByName('通知人电话').AsString; thesheet.cells.item[j,26]:=aAdoQuery.FieldByName('装港代码').AsString; thesheet.cells.item[j,27]:=aAdoQuery.FieldByName('卸货代码').AsString; thesheet.cells.item[j,28]:=aAdoQuery.FieldByName('箱号').AsString; thesheet.cells.item[j,29]:=aAdoQuery.FieldByName('封号').AsString; thesheet.cells.item[j,30]:=aAdoQuery.FieldByName('尺寸').AsString+aAdoQuery.FieldByName('箱型').AsString; poststr:=aAdoQuery.FieldByName('重箱整箱标志').AsString; if (poststr='空箱') then thesheet.cells.item[j,31]:='E' else thesheet.cells.item[j,31]:='F'; thesheet.cells.item[j,32]:=aAdoQuery.FieldByName('货物描述').AsString; thesheet.cells.item[j,33]:=aAdoQuery.FieldByName('唛头_1').AsString; thesheet.cells.item[j,34]:=aAdoQuery.FieldByName('件数').AsString; thesheet.cells.item[j,35]:=aAdoQuery.FieldByName('重量').AsString; thesheet.cells.item[j,36]:=aAdoQuery.FieldByName('尺码').AsString; thesheet.cells.item[j,37]:=frm_op_seae_edi_data.GetpkgsEdi(aAdoQuery.FieldByName('包装').AsString); thesheet.cells.item[j,38]:=aAdoQuery.FieldByName('危险品编号').AsString; j:=j+1; Next; end; str_file:=ScriptPath +frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+FormatDateTime('ss',now)+'.xls'; xlstest.DisplayAlerts:=false; xlstest.ActiveWorkBook.SaveAs(str_file); xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'ZHONGHAI.xls'); // xlstest.Disconnect; xlstest.Quit; xlstest:=UnAssigned; frm_op_seae_edi_data.updatelr; // Delay(10000); // ShowMessage(mblno+str_file); TMyThread.create(str_file,'',zhusername,zhpassword,mblno,'zh'); finally FreeAndNil(ExcelEXP); aDataSource.Free; Free; CoUninitialize; end; end; procedure Tfrm_op_seae_edi_data.Delay(dwMilliseconds:DWORD);//Longint var iStart,iStop:DWORD; begin iStart := GetTickCount; repeat iStop := GetTickCount; Application.ProcessMessages; until (iStop - iStart) >= dwMilliseconds; end; ///procedure Tfrm_op_seae_edi_data.N29Click(Sender: TObject); // var // ID: DWORD; //begin // TMyThread.Create(False); { if hThread>0 then begin showmessage('有进程正在发送,不能发送!'); Exit; end; try hThread := CreateThread(nil, 0, @PlateThreadZHFun, nil, CREATE_SUSPENDED, ID); ResumeThread(hThread); except if hThread>0 then TerminateThread(hThread,0); end; } //end; { TMyThread } constructor TMyThread.create(mfilename, mfiletype, mediname, medipassword, mmblno: string;meditype:string); begin inherited Create(True); filename:=mfilename; filetype:=mfiletype; ediname:=mediname; edipassword:=medipassword; mblno:=mmblno; editype:=meditype; FreeOnTerminate:=True; Resume; end; destructor TMyThread.destroy; begin inherited; end; procedure TMyThread.Execute; var MultiPartFormDataStream: TIdMultiPartFormDataStream; IdHTTP1:TIdHTTP; strmsg:string; begin inherited; CoInitialize(Nil); try // if editype='zh' then Sleep(10000); // ShowMessage(filename); MultiPartFormDataStream := TIdMultiPartFormDataStream.Create; IdHTTP1:=TIdHTTP.Create(Application); try IdHttp1.Request.Accept := '*/*'; IdHttp1.Request.AcceptLanguage:='zh-CN'; IdHttp1.Request.ContentType := MultiPartFormDataStream.RequestContentType; MultiPartFormDataStream.AddFormField('username',ediname); MultiPartFormDataStream.AddFormField('password',edipassword); MultiPartFormDataStream.AddFormField('action',editype); MultiPartFormDataStream.AddFormField('encode','1'); if (filetype='') then MultiPartFormDataStream.AddFile('filename',filename,GetMIMETypeFromFile(filename)) else MultiPartFormDataStream.AddFile('filename',filename,filetype); MultiPartFormDataStream.Position := 0; strmsg:=mblno+'---'+trim(UnicodeToChinese(IdHTTP1.Post('http://47.104.73.97:8111/cdpost.ashx', MultiPartFormDataStream))); Application.MessageBox(pchar(strmsg),'提示:',mrOk); // ShowMessage(filename); finally MultiPartFormDataStream.Free; FreeAndNil(IdHTTP1); end; finally CoUninitialize; end; end; procedure Tfrm_op_seae_edi_data.DBMemo38Change(Sender: TObject); begin lblmarklength.Caption:='字符数:'+inttostr(Length (DBMemo38.Text)); end; procedure Tfrm_op_seae_edi_data.DBMemo39Change(Sender: TObject); begin Label43.Caption:='字符数:'+inttostr(Length(DBMemo39.Text)); if (Pos('?',DBMemo39.Text)>0) or (Pos('?',DBMemo39.Text)>0) then lblTSGOOD.Caption:='注意:货描存在?' else lblTSGOOD.Caption:=''; end; procedure Tfrm_op_seae_edi_data.bsSkinButton291Click(Sender: TObject); var ctnsfr:string; mybookmark:TBookmark; begin mybookmark:=t_op_ctn.GetBookmark; ctnsfr:=t_op_ctn.fieldbyname('重箱整箱标志').AsString; with t_op_ctn do begin First; while not eof do begin Edit; FieldByName('重箱整箱标志').AsString:=ctnsfr; post; Next; end; end; t_op_ctn.Requery(); t_op_ctn.GotoBookmark(mybookmark); end; function Tfrm_op_seae_edi_data.formattel(str: string): string; begin Result := Trim(str); Result := StringReplace(Result, '+', '', [rfReplaceAll]); Result := StringReplace(Result, '-', '', [rfReplaceAll]); end; procedure Tfrm_op_seae_edi_data.N31Click(Sender: TObject); begin try if not assigned(frm_op_seae_edi_custom_qgzf) then frm_op_seae_edi_custom_qgzf:=tfrm_op_seae_edi_custom_qgzf.Create(application); frm_op_seae_edi_custom_qgzf.ShowModal; finally frm_op_seae_edi_custom_qgzf.free; frm_op_seae_edi_custom_qgzf:=nil; end; end; { TDsThread } constructor TDsThread.create(mfilename, mcarrierid,mScriptPath,mwebusername,mwebpassword: string;msenddgdata:TSendDGData;mwebcustname:string=''); begin inherited Create(True); filename:=mfilename; carrierid:=mcarrierid; ScriptPath:=mScriptPath; webusername:=mwebusername; webpassword:=mwebpassword; webcustname:=mwebcustname; senddgdata:=msenddgdata; FreeOnTerminate:=True; Resume; end; destructor TDsThread.destroy; begin inherited; end; procedure TDsThread.Execute; var MultiPartFormDataStream: TIdMultiPartFormDataStream; IdHTTP1:TIdHTTP; strmsg,strfile,Url,ResponseStr:string; ResponseStream : TStringStream; //返回信息 jo:ISuperobject; begin inherited; CoInitialize(Nil); try // if editype='zh' then Sleep(10000); // ShowMessage(filename); strfile:=ScriptPath+filename; MultiPartFormDataStream := TIdMultiPartFormDataStream.Create; IdHTTP1:=TIdHTTP.Create(Application); ResponseStream := TStringStream.Create(''); try IdHttp1.Request.Accept := '*/*'; IdHttp1.Request.AcceptLanguage:='zh-CN'; IdHttp1.Request.ContentType := MultiPartFormDataStream.RequestContentType; { IdHttp1.Request.CustomHeaders.AddValue('custname','qdds'); IdHttp1.Request.CustomHeaders.AddValue('custpsw','ds20040201'); IdHttp1.Request.CustomHeaders.AddValue('yardid',carrierid); } MultiPartFormDataStream.AddFormField('custname','qdds'); MultiPartFormDataStream.AddFormField('custpsw','ds20040201'); MultiPartFormDataStream.AddFormField('yardid',carrierid); MultiPartFormDataStream.AddFormField('webusername',webusername); MultiPartFormDataStream.AddFormField('webpassword',webpassword); if (webcustname<>'') then MultiPartFormDataStream.AddFormField('webcustname',webcustname); if (senddgdata.dgConPerson<>'') then MultiPartFormDataStream.AddFormField('dgConPerson',senddgdata.dgConPerson); if (senddgdata.dgTel<>'') then MultiPartFormDataStream.AddFormField('dgTel',senddgdata.dgTel); if (senddgdata.dgClass<>'') then MultiPartFormDataStream.AddFormField('dgClass',senddgdata.dgClass); if (senddgdata.temperature<>'') then MultiPartFormDataStream.AddFormField('temperature',senddgdata.temperature); if (senddgdata.temUnit<>'') then MultiPartFormDataStream.AddFormField('temUnit',senddgdata.temUnit); if (senddgdata.humidity<>'') then MultiPartFormDataStream.AddFormField('humidity',senddgdata.humidity); if (senddgdata.vent<>'') then MultiPartFormDataStream.AddFormField('vent',senddgdata.vent); if (senddgdata.dgNo<>'') then MultiPartFormDataStream.AddFormField('dgNo',senddgdata.dgNo); // MultiPartFormDataStream.AddFormField('data','1'); // if (filetype='') then MultiPartFormDataStream.AddFile('file',strfile,GetMIMETypeFromFile(strfile)); // else MultiPartFormDataStream.AddFile('filename',filename,filetype); MultiPartFormDataStream.Position := 0; // Url:='http://47.104.90.170:8000/sub?custname=qdds&custpsw=ds20040201&yardid='+carrierid; Url:='http://47.104.90.170:8000/customer/sub'; try IdHttp1.post(Url,MultiPartFormDataStream,ResponseStream); except on e : Exception do begin end; end; ResponseStr := ResponseStream.DataString; //获取网页返回的信息 ResponseStr := UTF8Decode(ResponseStr); //网页中的存在中文时,需要进行UTF8解码 jo:=so(ResponseStr); strmsg:=jo.O['message'].AsString; if (jo.O['status'].AsString='0') then begin Application.MessageBox(pchar('上传失败,'+strmsg),'警告:',mrOk); end else begin Application.MessageBox(pchar('上传成功,'+strmsg),'提示:',mrOk); end; finally MultiPartFormDataStream.Free; FreeAndNil(IdHTTP1); FreeAndNil(ResponseStream); end; finally CoUninitialize; end; end; function Tfrm_op_seae_edi_data.GetpkgsMscEdi(pkgs: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select MSC代码 from t_code_package where 包装名称='''+pkgs+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('MSC代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_data.GetCtnMSCCode(ctn: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; ctn:=StringReplace(ctn,'''','''''',[rfReplaceAll]); try with aQuery do begin Close;SQL.Clear; SQL.Add('Select MSC箱型 EDI代码 from t_code_ctn where 表现形式='''+ctn+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_data.GetpkgsEdi2(pkgs: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select Edi代码 from t_code_package where 包装名称='''+pkgs+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_data.GetCtnMSCCodeCode(ctn: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; ctn:=StringReplace(ctn,'''','''''',[rfReplaceAll]); try with aQuery do begin Close;SQL.Clear; SQL.Add('Select MSC代码 EDI代码 from t_code_ctn where 表现形式='''+ctn+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_edi_data.wwDBGrid1CalcCellColors(Sender: TObject; Field: TField; State: TGridDrawState; Highlight: Boolean; AFont: TFont; ABrush: TBrush); begin if (Field.FieldName='封号') and (Pos('0',VarToStr(Field.Value))=1 ) then begin ABrush.Color:=clRed; end; end; procedure Tfrm_op_seae_edi_data.DBEdit4Change(Sender: TObject); begin t_code_carrier.Close; if Trim(DBEdit4.Text)='' then t_code_carrier.SQL.Text:='select * from code_cangdan_carrier ' else t_code_carrier.SQL.Text:='select * from code_cangdan_carrier where FORWARDER='''+DBEdit4.Text+''''; t_code_carrier.Open; end; function Tfrm_op_seae_edi_data.createzhjson(UserName,userpsw:string): string; var TempStr:TStringlist; str,codestr,strsql,poststr:string; aAdoQuery:TADOQuery; i:Integer; isfirst:Boolean; begin if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then strsql:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else strsql:=strsql+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; end else begin strsql:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; strsql:=strsql+')'; aAdoQuery:=CreateAdoQuery; TempStr:=TStringList.Create; try with aAdoQuery do begin close;SQL.Clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+strsql +' order by t_op_ctn_edi.编号'); open; end; str:=str+'{'; str:=str+'"username":"'+ UserName+'"'; str:=str+',"password":"'+ userpsw+'"'; str:=str+',"filename":"'+ aAdoQuery.FieldByName('主提单号').AsString+'"'; str:=str+',data:['; isfirst:=true; while not aAdoQuery.Eof do begin if (isfirst) then str:=str+'{' else str:=str+',{'; str:=str+'"vessel":"'+ aAdoQuery.FieldByName('船名').AsString+'"'; str:=str+',"voyage":"'+aAdoQuery.FieldByName('航次').AsString+'"'; str:=str+',"company":"'+ aAdoQuery.FieldByName('船公司代码').AsString+'"'; str:=str+',"subbillno":""'; str:=str+',"masterbillno":"'+aAdoQuery.FieldByName('主提单号').AsString+'"'; str:=str+',"boxno":"'+aAdoQuery.FieldByName('箱号').AsString+'"'; str:=str+',"sealno":"'+aAdoQuery.FieldByName('封号').asstring+'"'; poststr:=aAdoQuery.FieldByName('装货港').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); str:=str+',"loadingport":"'+poststr+'"'; str:=str+',"transport":""'; poststr:=aAdoQuery.FieldByName('卸货港').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); str:=str+',"dischargingport":"'+poststr+'"'; poststr:=aAdoQuery.FieldByName('目的地').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); str:=str+',"destinationport":"'+poststr+'"'; str:=str+',"unitsno":"'+aAdoQuery.FieldByName('件数').AsString+'"'; str:=str+',"pdesc":"'+aAdoQuery.FieldByName('包装').AsString+'"'; str:=str+',"roughweight":"'+aAdoQuery.FieldByName('重量').AsString+'"'; str:=str+',"volume":"'+aAdoQuery.FieldByName('尺码').AsString+'"'; str:=str+',"boxtype":"'+aAdoQuery.FieldByName('尺寸').AsString+aAdoQuery.FieldByName('箱型').AsString+'"'; str:=str+',"cargoname":"'+StringReplace(StringReplace(aAdoQuery.FieldByName('货物描述').AsString,'&','%26',[rfReplaceAll]),'"','\"',[rfReplaceAll])+'"'; str:=str+',"shipper":"'+aAdoQuery.FieldByName('发货人名称').AsString+'"'; str:=str+',"consignee":"'+aAdoQuery.FieldByName('收货人名称').AsString+'"'; str:=str+',"notify":"'+aAdoQuery.FieldByName('通知人名称').AsString+'"'; if Pos('COLLECT',aAdoQuery.FieldByName('付费方式').AsString)>0 THEN str:=str+',"paidcoll":"COLLECT"' else str:=str+',"paidcoll":"PREPAID"'; str:=str+',"mark":"'+StringReplace(StringReplace(aAdoQuery.FieldByName('唛头_1').AsString,'&','%26',[rfReplaceAll]),'"','\"',[rfReplaceAll])+'"'; str:=str+',"emptyweight":""'; str:=str+',"shipperaddress":"'+aAdoQuery.FieldByName('发货人地址1').AsString+'"'; str:=str+',"shippercode":""'; str:=str+',"shippercountry":"'+aAdoQuery.FieldByName('发货人国家代码').AsString+'"'; str:=str+',"shippercontact":"TE"'; str:=str+',"shippernumber":"'+aAdoQuery.FieldByName('发货人电话').AsString+'"'; str:=str+',"shipperAEO":""'; str:=str+',"consigneeaddress":"'+aAdoQuery.FieldByName('收货人地址1').AsString+'"'; str:=str+',"consigneecode":""'; str:=str+',"consigneecountry":"'+aAdoQuery.FieldByName('收货人国家代码').AsString+'"'; str:=str+',"consigneecontact":"TE"'; str:=str+',"consigneenumber":"'+aAdoQuery.FieldByName('收货人电话').AsString+'"'; str:=str+',"consigneeAEO":""'; str:=str+',"notifyaddress":"'+aAdoQuery.FieldByName('通知人地址1').AsString+'"'; str:=str+',"notifycode":""'; str:=str+',"notifycountry":"'+aAdoQuery.FieldByName('通知人国家代码').AsString+'"'; str:=str+',"notifycontact":"TE"'; str:=str+',"notifynumber":"'+aAdoQuery.FieldByName('通知人电话').AsString+'"'; str:=str+',"notifyAEO":""'; str:=str+',"UNno":"'+aAdoQuery.FieldByName('危险品编号').AsString+'"'; str:=str+',"Dclass":"'+aAdoQuery.FieldByName('危险品分类').AsString+'"'; if (aAdoQuery.FieldByName('货物标识').AsString='D') THEN begin str:=str+',"ISDG":"1"'; end ELSE begin str:=str+',"ISDG":"0"'; end; str:=str+',"Emergcontact":"'+aAdoQuery.FieldByName('危险品联系人').AsString+'"'; str:=str+',"Emergnumber":"'+aAdoQuery.FieldByName('危险品电话').AsString+'"'; str:=str+'}'; isfirst:=false; aAdoQuery.Next; end; str:=str+']'; str:=str+'}'; finally FreeAndNil(aAdoQuery); FreeAndNil(TempStr); end; Result:=str; end; procedure Tfrm_op_seae_edi_data.N3Click(Sender: TObject); var IdHttp : TIdHTTP; Url,StrL,JSONSTR,errmsg,UserName,userpsw : string;//请求地址 ResponseStream : TStringStream; //返回信息 ResponseStr: string; RequestStr : string; //请求信息 RequestStream : TStringStream; jo: ISuperObject; inifile1:TIniFile; i,k:Integer; begin if t_op_seae.IsEmpty then Exit; if not assigned(frm_op_seae_zhedi) then frm_op_seae_zhedi:=tfrm_op_seae_zhedi.Create (self); try IdHttp := TIdHTTP.Create(nil); IdHTTP.HTTPOptions := IdHTTP.HTTPOptions + [hoKeepOrigProtocol]; //必须有这行才使设置协议版本生效 IdHTTP.ProtocolVersion := pv1_1; IdHttp.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)'; idhttp.Request.ContentType:='application/json;charset=UTF-8'; ResponseStream := TStringStream.Create(''); RequestStream := TStringStream.Create(''); if frm_op_seae_zhedi.ShowModal = mrOK then begin UserName:=frm_op_seae_zhedi.edit2.Text; userpsw:=frm_op_seae_zhedi.edit3.Text; StrL:=createzhjson(UserName,userpsw); jo := SO(StrL); if (UserName<>'') and (userpsw<>'') then try Url:='http://47.104.90.170:9000/cloudship/upload'; try RequestStr:=jo.AsJSon(True); //孙小华 RequestStream.WriteString(RequestStr); IdHttp.post(Url,RequestStream,ResponseStream); except on e : Exception do begin errmsg:=e.Message; end; end; ResponseStr := ResponseStream.DataString; ResponseStr := UTF8Decode(ResponseStr); if Pos('"status":"0"',ResponseStr)>0 then begin i:= Pos('"Message":' ,ResponseStr); errmsg :=Copy(ResponseStr ,i+11,Length(ResponseStr)-i-11); MessageDlg('未上传成功,'+errmsg,mtWarning,[mbOk],0); end else begin if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; ShowMessage('已上传!') end; finally IdHttp.Free; RequestStream.Free; ResponseStream.Free; end; end; updatelr; finally FreeAndNil(frm_op_seae_zhedi); end; end; procedure Tfrm_op_seae_edi_data.opClick(Sender: TObject); begin if MessageDlg('确定要发送'+t_op_seae.fieldbyname('主提单号').AsString+'项下分单吗!',mtWarning,[mbYes,mbNo],0)=mrNo then exit; adopingtai.Close; adopingtai.SQL.Text:='update WLXX_MBLNO_DELAY set NEEDREAD=1,READTIME=DATEADD(n,-30,GETDATE()),ENDTIME=DATEADD(n,20,GETDATE()) where MBLNO='''+t_op_seae.fieldbyname('主提单号').AsString+''''; adopingtai.ExecSQL; ShowMessage('已设置分单自动发送!'); end; procedure Tfrm_op_seae_edi_data.N7Click(Sender: TObject); var i,j,NO:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr:string; begin if t_op_seae.IsEmpty then Exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; j:=2; excel2.Connect; Excel2.Exec('[open('+'"'+ExtractFilePath(Application.ExeName)+'OOLU.xlsx'+'"'+')]'); First; while not eof do begin excel2.putstr(j,1,inttostr(j-1)); excel2.putstr(j,2,aAdoQuery.FieldByName('主提单号').AsString); excel2.putstr(j,3,''); excel2.putstr(j,4,''); excel2.putstr(j,5,aAdoQuery.FieldByName('发货人名称').AsString); excel2.putstr(j,6,''); excel2.putstr(j,7,aAdoQuery.FieldByName('发货人地址1').AsString); excel2.putstr(j,8,'qingdao'); excel2.putstr(j,9,aAdoQuery.FieldByName('发货人国家代码').AsString); excel2.putstr(j,10,aAdoQuery.FieldByName('发货人电话').AsString); excel2.putstr(j,11,aAdoQuery.FieldByName('收货人名称').AsString); excel2.putstr(j,12,aAdoQuery.FieldByName('收货人地址1').AsString); excel2.putstr(j,13,''); excel2.putstr(j,14,aAdoQuery.FieldByName('收货人国家代码').AsString); excel2.putstr(j,15,aAdoQuery.FieldByName('收货人电话').AsString); excel2.putstr(j,16,aAdoQuery.FieldByName('通知人名称').AsString); excel2.putstr(j,17,aAdoQuery.FieldByName('通知人地址1').AsString); excel2.putstr(j,18,''); excel2.putstr(j,19,aAdoQuery.FieldByName('通知人国家代码').AsString); excel2.putstr(j,20,aAdoQuery.FieldByName('通知人电话').AsString); excel2.putstr(j,21,aAdoQuery.FieldByName('箱号').AsString); excel2.putstr(j,22,aAdoQuery.FieldByName('尺寸').AsString+aAdoQuery.FieldByName('箱型').AsString); excel2.putstr(j,23,aAdoQuery.FieldByName('封号').AsString); excel2.putstr(j,24,aAdoQuery.FieldByName('件数').AsString); excel2.putstr(j,25,GetwypkgsEdi(aAdoQuery.FieldByName('包装').AsString)); excel2.putstr(j,26,aAdoQuery.FieldByName('重量').AsString); excel2.putstr(j,27,aAdoQuery.FieldByName('尺码').AsString); excel2.putstr(j,28,aAdoQuery.FieldByName('唛头_1').AsString); excel2.putstr(j,29,aAdoQuery.FieldByName('货物描述').AsString); excel2.putstr(j,30,aAdoQuery.FieldByName('装港代码').AsString); excel2.putstr(j,31,aAdoQuery.FieldByName('卸货代码').AsString); excel2.putstr(j,32,''); excel2.putstr(j,33,aAdoQuery.FieldByName('目的代码').AsString); excel2.putstr(j,34,''); excel2.putstr(j,35,'PP - 预付'); excel2.putstr(j,36,'HH - (House to House)'); excel2.putstr(j,37,aAdoQuery.FieldByName('危险品分类').AsString); excel2.putstr(j,38,aAdoQuery.FieldByName('危险品编号').AsString); excel2.putstr(j,39,''); excel2.putstr(j,40,''); excel2.putstr(j,41,aAdoQuery.FieldByName('设置温度').AsString); excel2.putstr(j,42,aAdoQuery.FieldByName('冷藏通风量').AsString); j:=j+1; Next; end; SaveDialog.Filter := '(*.xlsx)|*.xlsx'; SaveDialog.FileName := aAdoQuery.fieldbyname('主提单号').asstring+'.xlsx'; if SaveDialog.Execute then begin excel2.Exec('[SAVE.AS("'+SaveDialog.FileName+'";1;"";false;"";false)]'); excel2.Exec('[CLOSE(false)]'); // excel2.Exec('[open("'+SaveDialog.FileName+'")]'); // excel2.Exec('[APP.maxIMIZE()]'); //最大化excel end; updatelr; finally aDataSource.Free; Free; end; end; function Tfrm_op_seae_edi_data.GetCtnWYCode(ctnkind, ctnsize: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; ctnsize:=StringReplace(ctnsize,'''','''''',[rfReplaceAll]); try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 外运EDI代码 EDI代码 from t_code_ctn where 箱型='''+ctnkind+''' and 尺寸='''+ctnsize+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_edi_data.Sendzyzf; var i,j:integer; str,pkgcode:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr,ScriptPath,str_file,strall,zhusername,zhpassword:string; stringStream: TStringStream; memory:TMemoryStream; myStream:TFileStream; buffer:PChar; ExcelEXP: TExcel; xlstest, thesheet:Variant; IdHTTP1:TIdHTTP; strmsg:string; ResponseStream : TStringStream; //返回信息 ResponseStr,Url: string; RequestStr : string; //请求信息 RequestStream : TStringStream; jo:ISuperobject; inifile1:Tinifile; senddgdata:TSendDGData; begin if MessageDlg('确定要<<中远直发>>选中的业务数据吗?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; inifile1 := Tinifile.Create(ExtractFilePath(application.ExeName) + 'main.ini'); zhusername:= inifile1.ReadString('customZYHY', 'WEBUSERNAME', ''); zhpassword:= inifile1.ReadString('customZYHY', 'WEBPASSOWRD', ''); if zhusername='' then begin ShowMessage('发送用户名和密码不能为空!'); Exit; end; if t_op_seae.IsEmpty then Exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; j:=4; try xlstest:=CreateOleObject('Excel.Application'); except Try //多用一个Try..Finally是防止在读写单元格过程中出错,退出时可能没有释放Excel,造成内存漏洞 xlstest.ActiveWorkBook.Saved := True; xlstest.Quit; Finally xlstest:=UnAssigned; End; Exit; end; xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'COSCO.xls'); thesheet:= xlstest.Workbooks[1].Worksheets['sheet1']; First; while not eof do begin thesheet.cells.item[j,1]:=Copy(aAdoQuery.FieldByName('主提单号').AsString,5,Length(aAdoQuery.FieldByName('主提单号').AsString)-4); thesheet.cells.item[j,2]:=aAdoQuery.FieldByName('发货人名称').AsString; thesheet.cells.item[j,3]:=aAdoQuery.FieldByName('发货人地址1').AsString; thesheet.cells.item[j,4]:=aAdoQuery.FieldByName('发货人国家代码').AsString; thesheet.cells.item[j,7]:='电话'; thesheet.cells.item[j,8]:=aAdoQuery.FieldByName('发货人电话').AsString; thesheet.cells.item[j,10]:='N'; thesheet.cells.item[j,11]:=aAdoQuery.FieldByName('收货人名称').AsString; thesheet.cells.item[j,12]:=aAdoQuery.FieldByName('收货人地址1').AsString; thesheet.cells.item[j,13]:=aAdoQuery.FieldByName('收货人国家代码').AsString; thesheet.cells.item[j,16]:='电话'; thesheet.cells.item[j,17]:=aAdoQuery.FieldByName('收货人电话').AsString; thesheet.cells.item[j,19]:=aAdoQuery.FieldByName('通知人名称').AsString; thesheet.cells.item[j,20]:=aAdoQuery.FieldByName('通知人地址1').AsString; thesheet.cells.item[j,21]:=aAdoQuery.FieldByName('通知人国家代码').AsString; thesheet.cells.item[j,24]:='电话'; thesheet.cells.item[j,25]:=aAdoQuery.FieldByName('通知人电话').AsString; if (aAdoQuery.FieldByName('付费方式').AsString='FREIGHT PREPAID') then thesheet.cells.item[j,26]:='P-预付' else thesheet.cells.item[j,26]:='C-到付'; thesheet.cells.item[j,27]:=aAdoQuery.FieldByName('主提单号').AsString; thesheet.cells.item[j,29]:=aAdoQuery.FieldByName('箱号').AsString; thesheet.cells.item[j,30]:=aAdoQuery.FieldByName('封号').AsString; thesheet.cells.item[j,31]:=GetCtnMSCCode(aAdoQuery.FieldByName('表现形式').AsString); thesheet.cells.item[j,32]:=aAdoQuery.FieldByName('件数').AsString; thesheet.cells.item[j,33]:=aAdoQuery.FieldByName('重量').AsString; thesheet.cells.item[j,34]:=aAdoQuery.FieldByName('尺码').AsString; thesheet.cells.item[j,35]:=aAdoQuery.FieldByName('货物描述').AsString; if (aAdoQuery.FieldByName('是否冻代干').AsBoolean) then begin thesheet.cells.item[j,36]:='GC-General' end else begin if ((aAdoQuery.FieldByName('箱型').AsString='RH') OR (aAdoQuery.FieldByName('箱型').AsString='RF') OR (aAdoQuery.FieldByName('箱型').AsString='RQ')) then begin if (aAdoQuery.FieldByName('货物标识').AsString='D') then thesheet.cells.item[j,36]:='RD-Reefer Dangerous' else thesheet.cells.item[j,36]:='RF-Reefer'; end else begin if (aAdoQuery.FieldByName('货物标识').AsString='D') then thesheet.cells.item[j,36]:='DG-Dangerous' else thesheet.cells.item[j,36]:='GC-General'; end; end; pkgcode:=GetpkgsMscEdi(aAdoQuery.FieldByName('包装').AsString); if (pkgcode='Bag') then pkgcode:='BAG(Bag)' else pkgcode:='('+pkgcode+')'; thesheet.cells.item[j,37]:=pkgcode; thesheet.cells.item[j,38]:=aAdoQuery.FieldByName('运输方式').AsString; j:=j+1; Next; end; ScriptPath:=ExtractFilePath(ParamStr(0))+'TMPEXCEL\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); str_file:=frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring +'.xls'; xlstest.DisplayAlerts:=false; xlstest.ActiveWorkBook.SaveAs(ScriptPath+str_file); xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'COSCO.xls'); xlstest.Quit; xlstest:=UnAssigned; Sleep(1000); senddgdata.dgConPerson:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品联系人').asstring; senddgdata.dgTel:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品电话').asstring; senddgdata.dgClass:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品分类').asstring; senddgdata.temperature:=frm_op_seae_edi_data.t_op_seae.fieldbyname('设置温度').asstring; senddgdata.temUnit:=frm_op_seae_edi_data.t_op_seae.fieldbyname('温度单位').asstring; senddgdata.humidity:=''; senddgdata.vent:=frm_op_seae_edi_data.t_op_seae.fieldbyname('冷藏通风量').asstring; senddgdata.dgNo:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品编号').asstring; TDsThread.create(str_file,'ZYHY',ScriptPath,zhusername,zhpassword,senddgdata); updatelr; finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.N30Click(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_zyzf) then frm_op_seae_edi_custom_zyzf:=tfrm_op_seae_edi_custom_zyzf.Create(application); frm_op_seae_edi_custom_zyzf.ShowModal; finally frm_op_seae_edi_custom_zyzf.free; frm_op_seae_edi_custom_zyzf:=nil; end; end; procedure Tfrm_op_seae_edi_data.Sendqgzf(lhcd:string); var i,j:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr,ScriptPath,str_file,strall,fileallname,zhusername,zhpassword:string; ExcelEXP: TExcel; xlstest, thesheet:Variant; IdHTTP1:TIdHTTP; strmsg:string; ResponseStream : TStringStream; //返回信息 ResponseStr,Url: string; RequestStr : string; //请求信息 RequestStream : TStringStream; jo:ISuperobject; myStream:TFileStream; buffer:PChar; inifile1:TIniFile; senddgdata:TSendDGData; begin if (lhcd='LHCD') then begin if MessageDlg('确定要<<联合船代直发>>选中的业务数据吗?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end else begin if MessageDlg('确定要<<青港直发>>选中的业务数据吗?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end; inifile1 := Tinifile.Create(ExtractFilePath(application.ExeName) + 'main.ini'); if (lhcd='LHCD') then begin zhusername:= inifile1.ReadString('customLHCD', 'WEBUSERNAME', ''); zhpassword:= inifile1.ReadString('customLHCD', 'WEBPASSOWRD', ''); end else begin zhusername:= inifile1.ReadString('customQGZF', 'WEBUSERNAME', ''); zhpassword:= inifile1.ReadString('customQGZF', 'WEBPASSOWRD', ''); end; if zhusername='' then begin ShowMessage('发送用户名和密码不能为空!'); Exit; end; if t_op_seae.IsEmpty then Exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; j:=2; try xlstest:=CreateOleObject('Excel.Application'); except Try //多用一个Try..Finally是防止在读写单元格过程中出错,退出时可能没有释放Excel,造成内存漏洞 xlstest.ActiveWorkBook.Saved := True; xlstest.Quit; Finally xlstest:=UnAssigned; End; Exit; end; xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'QINGGANG.xls'); thesheet:= xlstest.Workbooks[1].Worksheets['sheet1']; First; while not eof do begin thesheet.cells.item[j,1]:=aAdoQuery.FieldByName('主提单号').AsString; thesheet.cells.item[j,2]:=aAdoQuery.FieldByName('分提单号').AsString; thesheet.cells.item[j,3]:=aAdoQuery.FieldByName('船名').AsString; thesheet.cells.item[j,4]:=aAdoQuery.FieldByName('航次').AsString; thesheet.cells.item[j,5]:=aAdoQuery.FieldByName('发货人名称').AsString; thesheet.cells.item[j,6]:=aAdoQuery.FieldByName('发货人地址1').AsString; thesheet.cells.item[j,7]:=aAdoQuery.FieldByName('发货人国家代码').AsString; thesheet.cells.item[j,8]:='TE'; thesheet.cells.item[j,9]:=aAdoQuery.FieldByName('发货人电话').AsString; thesheet.cells.item[j,10]:=''; thesheet.cells.item[j,11]:=aAdoQuery.FieldByName('收货人名称').AsString; thesheet.cells.item[j,12]:=aAdoQuery.FieldByName('收货人地址1').AsString; thesheet.cells.item[j,13]:=aAdoQuery.FieldByName('收货人国家代码').AsString; thesheet.cells.item[j,14]:='TE'; thesheet.cells.item[j,15]:=aAdoQuery.FieldByName('收货人电话').AsString; thesheet.cells.item[j,16]:=''; thesheet.cells.item[j,17]:=aAdoQuery.FieldByName('通知人名称').AsString; thesheet.cells.item[j,18]:=aAdoQuery.FieldByName('通知人地址1').AsString; // thesheet.cells.item[j,21]:=aAdoQuery.FieldByName('通知人国家代码').AsString; thesheet.cells.item[j,19]:='TE'; thesheet.cells.item[j,20]:=aAdoQuery.FieldByName('通知人电话').AsString; thesheet.cells.item[j,21]:=''; thesheet.cells.item[j,22]:=aAdoQuery.FieldByName('装港代码').AsString; thesheet.cells.item[j,23]:=aAdoQuery.FieldByName('卸货代码').AsString; thesheet.cells.item[j,24]:=aAdoQuery.FieldByName('箱号').AsString; thesheet.cells.item[j,25]:=aAdoQuery.FieldByName('船公司代码').AsString; thesheet.cells.item[j,26]:=''''+aAdoQuery.FieldByName('封号').AsString; thesheet.cells.item[j,27]:=GetCtnMSCCodeCode(aAdoQuery.FieldByName('表现形式').AsString); poststr:=aAdoQuery.FieldByName('重箱整箱标志').AsString; if (poststr='空箱') then thesheet.cells.item[j,28]:='E' else thesheet.cells.item[j,28]:='F'; thesheet.cells.item[j,29]:=aAdoQuery.FieldByName('货物描述').AsString; thesheet.cells.item[j,30]:=aAdoQuery.FieldByName('唛头_1').AsString; thesheet.cells.item[j,31]:=aAdoQuery.FieldByName('件数').AsString; thesheet.cells.item[j,32]:=aAdoQuery.FieldByName('重量').AsString; thesheet.cells.item[j,33]:=aAdoQuery.FieldByName('尺码').AsString; thesheet.cells.item[j,34]:=GetpkgsEdi2(aAdoQuery.FieldByName('包装').AsString); thesheet.cells.item[j,35]:=aAdoQuery.FieldByName('危险品编号').AsString; thesheet.cells.item[j,36]:='CN'; j:=j+1; Next; end; ScriptPath:=ExtractFilePath(ParamStr(0))+'TMPEXCEL\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); str_file:=frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring +'.xls'; xlstest.DisplayAlerts:=false; xlstest.ActiveWorkBook.SaveAs(ScriptPath+str_file); xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'QINGGANG.xls'); xlstest.Quit; xlstest:=UnAssigned; Sleep(1000); senddgdata.dgConPerson:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品联系人').asstring; senddgdata.dgTel:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品电话').asstring; senddgdata.dgClass:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品分类').asstring; senddgdata.temperature:=frm_op_seae_edi_data.t_op_seae.fieldbyname('设置温度').asstring; senddgdata.temUnit:=frm_op_seae_edi_data.t_op_seae.fieldbyname('温度单位').asstring; senddgdata.humidity:=''; senddgdata.vent:=frm_op_seae_edi_data.t_op_seae.fieldbyname('冷藏通风量').asstring; senddgdata.dgNo:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品编号').asstring; if (lhcd='LHCD') then begin TDsThread.create(str_file,'LHCD',ScriptPath,zhusername,zhpassword,senddgdata); end else begin TDsThread.create(str_file,'CDCS',ScriptPath,zhusername,zhpassword,senddgdata); end; updatelr; finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.widClick(Sender: TObject); var i:Integer; aAdoQuery,aAdoQuery2:TAdoQuery; s:string; LengthQ, PosQ:Integer; iscon:Boolean; begin if (t_op_seae1.DataSet.FieldByName('货物标识').AsString='D') then begin if MessageDlg('此票货为危险品,确实要发送吗?',mtWarning,[mbYes,mbNo],0)=mrNo then exit; end; if (Length(Trim(t_op_seae1.DataSet.FieldByName('货物描述').AsString))>900) then begin if MessageDlg('此票货货物描述超长,确实要发送吗?',mtWarning,[mbYes,mbNo],0)=mrNo then exit; end; if (t_op_seae1.DataSet.FieldByName('货物标识').AsString='O') then begin if MessageDlg('此票为超限箱,是否继续操作?',mtWarning,[mbYes,mbNo],0)=mrNo then exit; end; s:=''; aAdoQuery:=createAdoQuery; aAdoQuery2:=createAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('select isnull(object_id(''CANGDAN_CUSTOMER''),''0'') as tbl'); Open; if (FieldByName('tbl').AsString<>'0') then begin Close;sql.Clear; sql.Add('select COUNT(*) CT FROM CANGDAN_CUSTOMER WHERE CUSTOMERNAME='''+t_op_seae.fieldbyname('委托发送方').asstring+''''); Open; if (FieldByName('CT').AsInteger=0) then begin MessageDlg('不能发送该客户尚未开通舱单申报业务,请与对应业务同事联系!',mtError,[mbOk],0); Exit; end; end; if (t_op_seae.FieldByName('分提单号').AsString='') then begin Close;sql.Clear; sql.Add('select distinct b.主提单号,c.箱号 from t_op_seae_edi b left join t_op_ctn_edi c on (c.编号=b.编号) where b.船名='''+t_op_seae.fieldbyname('船名').AsString+''' '); sql.Add(' and b.录入日期>=GETDATE()-20 '); sql.Add(' and b.航次='''+t_op_seae.fieldbyname('航次').AsString+''' and b.主提单号<>'''+t_op_seae.fieldbyname('主提单号').AsString+''' '); sql.Add(' and c.箱号 in (select 箱号 from t_op_ctn_edi where 编号='''+t_op_seae.fieldbyname('编号').AsString+''') '); Open;First; while not Eof do begin if s='' then s:='该航次'+FieldByName('主提单号').AsString+'下存在相同箱号'+FieldByName('箱号').AsString+'' else s:=s+#13#10+FieldByName('箱号').AsString; Next; end; Close;sql.Clear; sql.Add('select c.箱号,sum(c.件数) 件数,sum(c.重量) 重量,sum(c.尺码) 尺码 from t_op_seae_edi b left join t_op_ctn_edi c on (c.编号=b.编号) where ISNULL(b.分提单号,'''')<>'''' '); sql.Add(' AND b.主提单号='''+t_op_seae.fieldbyname('主提单号').AsString+''' and b.船名='''+t_op_seae.fieldbyname('船名').AsString+''' and b.航次='''+t_op_seae.fieldbyname('航次').AsString+''' '); sql.Add(' GROUP BY C.箱号 '); Open; if (not IsEmpty) then begin First; while not eof do begin if t_op_ctn.Locate('箱号',fieldbyname('箱号').AsString,[]) then begin if t_op_ctn.FieldByName('件数').AsInteger<>FieldByName('件数').AsInteger then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+' 件数:'+FieldByName('件数').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'件数:'+FieldByName('件数').AsString; if t_op_ctn.FieldByName('重量').AsFloat<>FieldByName('重量').AsFloat then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+'重量:'+FieldByName('重量').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'重量:'+FieldByName('重量').AsString; if t_op_ctn.FieldByName('尺码').AsFloat<>FieldByName('尺码').AsFloat then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+'尺码:'+FieldByName('尺码').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'尺码:'+FieldByName('尺码').AsString; end else begin if s='' then s:='主单不存在箱号:'+FieldByName('箱号').AsString else s:=s+#13#10+'主单不存在箱号:'+FieldByName('箱号').AsString; end; Next; end; t_op_ctn.First; while not t_op_ctn.Eof do begin if aAdoQuery.Locate('箱号',t_op_ctn.fieldbyname('箱号').AsString,[]) then begin end else begin if s='' then s:='分单不存在箱号:'+FieldByName('箱号').AsString else s:=s+#13#10+'分单不存在箱号:'+FieldByName('箱号').AsString; end; t_op_ctn.Next; end; end; end else begin aAdoQuery2.Close; aAdoQuery2.SQL.Clear; aAdoQuery2.SQL.add('SELECT * from t_op_ctn_edi where 编号 in (select top 1 编号 from t_op_seae_edi where ISNULL(分提单号,'''')='''' and 主提单号='''+t_op_seae.fieldbyname('主提单号').AsString+''' '); aAdoQuery2.SQL.add(' and 船名='''+t_op_seae.fieldbyname('船名').AsString+''' and 航次='''+t_op_seae.fieldbyname('航次').AsString+''' )'); aAdoQuery2.Open; Close;sql.Clear; sql.Add('select c.箱号,sum(c.件数) 件数,sum(c.重量) 重量,sum(c.尺码) 尺码 from t_op_seae_edi b left join t_op_ctn_edi c on (c.编号=b.编号) where ISNULL(b.分提单号,'''')<>'''' '); sql.Add(' AND b.主提单号='''+t_op_seae.fieldbyname('主提单号').AsString+''' and b.船名='''+t_op_seae.fieldbyname('船名').AsString+''' and b.航次='''+t_op_seae.fieldbyname('航次').AsString+''' '); sql.Add(' GROUP BY C.箱号 '); Open; if (not IsEmpty) then begin First; while not eof do begin if aAdoQuery2.Locate('箱号',fieldbyname('箱号').AsString,[]) then begin if aAdoQuery2.FieldByName('件数').AsInteger<>FieldByName('件数').AsInteger then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+' 件数:'+FieldByName('件数').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'件数:'+FieldByName('件数').AsString; if aAdoQuery2.FieldByName('重量').AsFloat<>FieldByName('重量').AsFloat then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+'重量:'+FieldByName('重量').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'重量:'+FieldByName('重量').AsString; if aAdoQuery2.FieldByName('尺码').AsFloat<>FieldByName('尺码').AsFloat then if s='' then s:='主分单不一致箱号:'+fieldbyname('箱号').AsString+'尺码:'+FieldByName('尺码').AsString else s:=s+#13#10+'主分单箱号:'+fieldbyname('箱号').AsString+'尺码:'+FieldByName('尺码').AsString; end else begin if s='' then s:='主单不存在箱号:'+FieldByName('箱号').AsString else s:=s+#13#10+'主单不存在箱号:'+FieldByName('箱号').AsString; end; Next; end; end; aAdoQuery2.First; while not aAdoQuery2.Eof do begin if aAdoQuery.Locate('箱号',aAdoQuery2.fieldbyname('箱号').AsString,[]) then begin end else begin if s='' then s:='分单不存在箱号:'+FieldByName('箱号').AsString else s:=s+#13#10+'分单不存在箱号:'+FieldByName('箱号').AsString; end; aAdoQuery2.Next; end; Close;sql.Clear; sql.Add('select b.分提单号,b.件数 总件数,b.重量 总重量,b.尺码 总尺码,sum(c.件数) 件数,sum(c.重量) 重量,sum(c.尺码) 尺码 from t_op_seae_edi b left join t_op_ctn_edi c on (c.编号=b.编号) where ISNULL(b.分提单号,'''')<>'''' '); sql.Add(' AND b.主提单号='''+t_op_seae.fieldbyname('主提单号').AsString+''' and b.船名='''+t_op_seae.fieldbyname('船名').AsString+''' and b.航次='''+t_op_seae.fieldbyname('航次').AsString+''' '); sql.Add(' GROUP BY b.分提单号,b.件数,b.重量,b.尺码 '); Open; First; while not eof do begin if (FieldByName('总件数').AsInteger<>FieldByName('件数').AsInteger) then begin if s='' then s:='分单:'+FieldByName('分提单号').AsString+' 总件数和集装箱明细件数合计不一致!' else s:=s+#13#10+'分单:'+FieldByName('分提单号').AsString+' 总件数和集装箱明细件数合计不一致!' end; if (FieldByName('总重量').AsFloat<>FieldByName('重量').AsFloat) then begin if s='' then s:='分单:'+FieldByName('分提单号').AsString+' 总重量和集装箱明细重量合计不一致!' else s:=s+#13#10+'分单:'+FieldByName('分提单号').AsString+' 总重量和集装箱明细重量合计不一致!' end; if (FieldByName('总尺码').AsFloat<>FieldByName('尺码').AsFloat) then begin if s='' then s:='分单:'+FieldByName('分提单号').AsString+' 总尺码和集装箱明细尺码合计不一致!' else s:=s+#13#10+'分单:'+FieldByName('分提单号').AsString+' 总尺码和集装箱明细尺码合计不一致!' end; Next; end; end; Close;sql.Clear; sql.Add('select * '); sql.Add('from t_op_ctn_edi'); sql.Add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').AsString; Open;First; while not Eof do begin if (not frm_data_share.t_code_ctn.Locate('表现形式',FieldByName('表现形式').AsString,[])) then begin if s='' then s:='箱号'+FieldByName('箱号').AsString+',箱型在系统中不存在,请检查!' else s:=s+#13#10+'箱号'+FieldByName('箱号').AsString+',箱型在系统中不存在,请检查!'; end; Next; end; finally FreeAndNil(aAdoQuery); FreeAndNil(aAdoQuery2); end; iscon:=true; if (s<>'') then begin iscon:=False; try frm_sys_messagedlg:=tfrm_sys_messagedlg.Create (application); frm_sys_messagedlg.msg:=s; iscon:=frm_sys_messagedlg.ShowModal=mrOk; finally frm_sys_messagedlg.Free; frm_sys_messagedlg:=nil; end; // if MessageDlg(s+',是否继续?',mtWarning,mbOKCancel,0)<>mrok then exit; end; if (not iscon) then exit; if t_op_seae.IsEmpty then exit; if (Pos('DESCRIPTION',t_op_seae.FieldByName('货物描述').AsString)>0) then begin if MessageDlg('货物描述中包含特殊单词[DESCRIPTION],请与客户确认品名是否正确,确实继续吗?',mtWarning,[mbyes,mbno],0)<>mryes then exit; end; if (Pos('LIST',t_op_seae.FieldByName('货物描述').AsString)>0) then begin if MessageDlg('货物描述中包含特殊单词[LIST],请与客户确认品名是否正确,确实继续吗?',mtWarning,[mbyes,mbno],0)<>mryes then exit; end; if (Pos('N/M',t_op_seae.FieldByName('货物描述').AsString)>0) then begin if MessageDlg('货物描述中包含特殊单词[N/M],请与客户确认品名是否正确,确实继续吗?',mtWarning,[mbyes,mbno],0)<>mryes then exit; end; t_code_goods_not.First; while not t_code_goods_not.Eof do begin if (Pos(t_code_goods_not.fieldbyname('货物名称').AsString,t_op_seae.FieldByName('货物描述').AsString)>0) then begin if MessageDlg('货物描述中包含特殊单词'+t_code_goods_not.fieldbyname('货物名称').AsString+',请与客户确认品名是否正确,确实继续发送吗?',mtWarning,[mbyes,mbno],0)<>mryes then exit; end; t_code_goods_not.Next; end; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; updatelr; end; procedure Tfrm_op_seae_edi_data.N8Click(Sender: TObject); begin try if not assigned(frm_op_seae_edi_custom_lhcd) then frm_op_seae_edi_custom_lhcd:=tfrm_op_seae_edi_custom_lhcd.Create(application); frm_op_seae_edi_custom_lhcd.ShowModal; finally frm_op_seae_edi_custom_lhcd.free; frm_op_seae_edi_custom_lhcd:=nil; end; end; procedure Tfrm_op_seae_edi_data.GetDuiBiStr; var aQuery,aQuery2:TADOQuery; cntrstr:string; begin Memo2.Lines.Clear; if (Notebook1.PageIndex=0) then Exit; aQuery:=CreateAdoQuery; aQuery2:=CreateAdoQuery; try With aQuery do begin close;sql.Clear; SQL.Add('select * from t_op_seae_edi where 主提单号='''+t_op_seae.fieldbyname('主提单号').AsString+''' '); if (t_op_seae.fieldbyname('分提单号').AsString='') then SQL.Add(' and (分提单号='''' or 分提单号 is null) ') else SQL.Add(' and 分提单号='''+t_op_seae.fieldbyname('分提单号').AsString+''''); SQL.Add(' and 编号<>'''+t_op_seae.fieldbyname('编号').AsString+''' and 录入日期<='''+t_op_seae.fieldbyname('录入日期').AsString+''' order by 录入日期 desc'); Open; if (not IsEmpty) then begin if FieldByName('船名').AsString<>t_op_seae.FieldByName('船名').AsString then Memo2.Lines.Add('船名'); if FieldByName('航次').AsString<>t_op_seae.FieldByName('航次').AsString then Memo2.Lines.Add('航次'); if FieldByName('发货人名称').AsString<>t_op_seae.FieldByName('发货人名称').AsString then Memo2.Lines.Add('发货人名称'); if FieldByName('发货人地址1').AsString<>t_op_seae.FieldByName('发货人地址1').AsString then Memo2.Lines.Add('发货人地址'); if FieldByName('发货人国家代码').AsString<>t_op_seae.FieldByName('发货人国家代码').AsString then Memo2.Lines.Add('发货人国家代码'); if FieldByName('发货人电话').AsString<>t_op_seae.FieldByName('发货人电话').AsString then Memo2.Lines.Add('发货人电话'); if FieldByName('收货人名称').AsString<>t_op_seae.FieldByName('收货人名称').AsString then Memo2.Lines.Add('收货人名称'); if FieldByName('收货人地址1').AsString<>t_op_seae.FieldByName('收货人地址1').AsString then Memo2.Lines.Add('收货人地址'); if FieldByName('收货人国家代码').AsString<>t_op_seae.FieldByName('收货人国家代码').AsString then Memo2.Lines.Add('收货人国家代码'); if FieldByName('通知人名称').AsString<>t_op_seae.FieldByName('通知人名称').AsString then Memo2.Lines.Add('通知人名称'); if FieldByName('通知人电话').AsString<>t_op_seae.FieldByName('通知人电话').AsString then Memo2.Lines.Add('通知人电话'); if FieldByName('通知人地址1').AsString<>t_op_seae.FieldByName('通知人地址1').AsString then Memo2.Lines.Add('通知人地址'); if FieldByName('通知人国家代码').AsString<>t_op_seae.FieldByName('通知人国家代码').AsString then Memo2.Lines.Add('通知人国家代码'); if FieldByName('卸货港').AsString<>t_op_seae.FieldByName('卸货港').AsString then Memo2.Lines.Add('卸货港'); if FieldByName('目的地').AsString<>t_op_seae.FieldByName('目的地').AsString then Memo2.Lines.Add('目的地'); if FieldByName('包装').AsString<>t_op_seae.FieldByName('包装').AsString then Memo2.Lines.Add('包装'); if FieldByName('唛头').AsString<>t_op_seae.FieldByName('唛头').AsString then Memo2.Lines.Add('唛头'); if FieldByName('货物描述').AsString<>t_op_seae.FieldByName('货物描述').AsString then Memo2.Lines.Add('货物描述'); if FieldByName('开船日期').AsString<>t_op_seae.FieldByName('开船日期').AsString then Memo2.Lines.Add('开船日期'); if FieldByName('集装箱').AsString<>t_op_seae.FieldByName('集装箱').AsString then Memo2.Lines.Add('集装箱'); aQuery2.Close;aQuery2.SQL.Clear; aQuery2.SQL.Add('select * from t_op_ctn_edi where 编号='''+aQuery.fieldbyname('编号').AsString+''' order by 代码'); aQuery2.Open; t_op_ctn.First; while not t_op_ctn.Eof do begin cntrstr:=''; if not (aQuery2.Locate('箱号',t_op_ctn.fieldbyname('箱号').AsString,[])) then cntrstr:='箱号:'+t_op_ctn.fieldbyname('箱号').AsString else begin if aQuery2.FieldByName('封号').AsString<>t_op_ctn.fieldbyname('封号').AsString then cntrstr:=cntrstr+',封号'; if aQuery2.FieldByName('箱型').AsString<>t_op_ctn.fieldbyname('箱型').AsString then cntrstr:=cntrstr+',箱型'; if aQuery2.FieldByName('件数').AsString<>t_op_ctn.fieldbyname('件数').AsString then cntrstr:=cntrstr+',件数'; if aQuery2.FieldByName('重量').AsString<>t_op_ctn.fieldbyname('重量').AsString then cntrstr:=cntrstr+',重量'; if aQuery2.FieldByName('尺码').AsString<>t_op_ctn.fieldbyname('尺码').AsString then cntrstr:=cntrstr+',尺码'; end; if (cntrstr<>'') then Memo2.Lines.Add('箱号:'+t_op_ctn.fieldbyname('箱号').AsString+cntrstr); t_op_ctn.Next; end; end; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_edi_data.t_op_seaeAfterPost(DataSet: TDataSet); begin // GetDuiBiStr; end; procedure Tfrm_op_seae_edi_data.Button1Click(Sender: TObject); begin GetDuiBiStr; end; function Tfrm_op_seae_edi_data.get_edi_id: string; var code:string; begin frm_data_share.p_edi_id.ExecProc; result:=frm_data_share.p_edi_id.Parameters.ParamByName('str').value; end; procedure Tfrm_op_seae_edi_data.e1Click(Sender: TObject); var i,j:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr:string; begin if t_op_seae.IsEmpty then Exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; excel2.Connect; Excel2.Exec('[open('+'"'+ExtractFilePath(Application.ExeName)+'e航无忧.xlsx'+'"'+')]'); excel2.putstr(3,2,aAdoQuery.FieldByName('主提单号').AsString); if (code_e_carrier.Locate('船公司',aAdoQuery.FieldByName('船公司代码').AsString,[])) then excel2.putstr(3,4,code_e_carrier.FieldByName('E航船公司').AsString); excel2.putstr(3,6,aAdoQuery.FieldByName('船名').AsString); excel2.putstr(4,2,aAdoQuery.FieldByName('航次').AsString); excel2.putstr(4,4,aAdoQuery.FieldByName('船代').AsString); if (aAdoQuery.FieldByName('货物标识').AsString='D') then excel2.putstr(4,6,'危险品') else if (aAdoQuery.FieldByName('货物标识').AsString='R') then excel2.putstr(4,6,'冷冻品') else excel2.putstr(4,6,'普通货物'); excel2.putstr(5,6,aAdoQuery.FieldByName('装货港').AsString); excel2.putstr(5,8,aAdoQuery.FieldByName('装港代码').AsString); excel2.putstr(6,2,aAdoQuery.FieldByName('目的地').AsString); excel2.putstr(6,4,aAdoQuery.FieldByName('目的代码').AsString); excel2.putstr(6,6,aAdoQuery.FieldByName('卸货港').AsString); excel2.putstr(6,8,aAdoQuery.FieldByName('卸货代码').AsString); excel2.putstr(3,11,aAdoQuery.FieldByName('设置温度').AsString); excel2.putstr(5,11,aAdoQuery.FieldByName('冷藏通风量').AsString); excel2.putstr(8,2,aAdoQuery.FieldByName('发货人名称').AsString); excel2.putstr(9,2,aAdoQuery.FieldByName('发货人地址1').AsString); excel2.putstr(12,2,aAdoQuery.FieldByName('发货人电话').AsString); excel2.putstr(8,6,aAdoQuery.FieldByName('收货人名称').AsString); excel2.putstr(9,6,aAdoQuery.FieldByName('收货人地址1').AsString); excel2.putstr(10,6,aAdoQuery.FieldByName('收货人国家代码').AsString); excel2.putstr(11,6,aAdoQuery.FieldByName('收货人电话').AsString); excel2.putstr(8,11,aAdoQuery.FieldByName('通知人名称').AsString); excel2.putstr(9,11,aAdoQuery.FieldByName('通知人地址1').AsString); excel2.putstr(10,11,aAdoQuery.FieldByName('通知人国家代码').AsString); excel2.putstr(11,11,aAdoQuery.FieldByName('通知人电话').AsString); j:=15; First; while not eof do begin excel2.putstr(j,1,aAdoQuery.FieldByName('主提单号').AsString); excel2.putstr(j,2,aAdoQuery.FieldByName('箱号').AsString); excel2.putstr(j,3,aAdoQuery.FieldByName('封号').AsString); excel2.putstr(j,4,aAdoQuery.FieldByName('尺寸').AsString+aAdoQuery.FieldByName('箱型').AsString); excel2.putstr(j,5,aAdoQuery.FieldByName('货物描述').AsString); excel2.putstr(j,8,aAdoQuery.FieldByName('运输方式').AsString); excel2.putstr(j,9,aAdoQuery.FieldByName('件数').AsString); excel2.putstr(j,10,aAdoQuery.FieldByName('包装').AsString); excel2.putstr(j,11,aAdoQuery.FieldByName('重量').AsString); excel2.putstr(j,12,aAdoQuery.FieldByName('尺码').AsString); excel2.putstr(j,13,aAdoQuery.FieldByName('唛头_1').AsString); if (aAdoQuery.FieldByName('货物标识').AsString='D') then begin excel2.putstr(j,14,aAdoQuery.FieldByName('危险品编号').AsString); excel2.putstr(j,15,aAdoQuery.FieldByName('危险品分类').AsString); excel2.putstr(j,16,aAdoQuery.FieldByName('危险品联系人').AsString); excel2.putstr(j,17,aAdoQuery.FieldByName('危险品电话').AsString); end; j:=j+1; Next; end; SaveDialog.Filter := '(*.xlsx)|*.xlsx'; SaveDialog.FileName := aAdoQuery.fieldbyname('主提单号').asstring+'.xlsx'; if SaveDialog.Execute then begin excel2.Exec('[SAVE.AS("'+SaveDialog.FileName+'";1;"";false;"";false)]'); excel2.Exec('[CLOSE(false)]'); // excel2.Exec('[open("'+SaveDialog.FileName+'")]'); // excel2.Exec('[APP.maxIMIZE()]'); //最大化excel end; updatelr; finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.N32Click(Sender: TObject); begin try frm_code_zy_cust:=Tfrm_code_zy_cust.Create (self); frm_code_zy_cust.ShowModal; finally frm_code_zy_cust.Free; end; end; procedure Tfrm_op_seae_edi_data.N39Click(Sender: TObject); var i,j:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr,ScriptPath,str_file,strall,fileallname,zhusername,zhpassword,zhcorpcode:string; ExcelEXP: TExcel; xlstest, thesheet:Variant; inifile1:TIniFile; senddgdata:TSendDGData; begin if MessageDlg('确定要<<中和顺德>>选中的业务数据吗?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; inifile1 := Tinifile.Create(ExtractFilePath(application.ExeName) + 'main.ini'); zhusername:= inifile1.ReadString('customZHSD', 'WEBUSERNAME', ''); zhpassword:= inifile1.ReadString('customZHSD', 'WEBPASSOWRD', ''); zhcorpcode:= inifile1.ReadString('customZHSD', 'WEBCUSTNAME', ''); if zhusername='' then begin ShowMessage('发送用户名和密码不能为空!'); Exit; end; if t_op_seae.IsEmpty then Exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if (t_op_seae.FieldByName('船公司代码').AsString='') then begin ShowMessage('船公司代码不能为空!'); Exit; end; end; end else begin if (t_op_seae.FieldByName('船公司代码').AsString='') then begin ShowMessage('船公司代码不能为空!'); Exit; end; end; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; j:=2; try xlstest:=CreateOleObject('Excel.Application'); except Try //多用一个Try..Finally是防止在读写单元格过程中出错,退出时可能没有释放Excel,造成内存漏洞 xlstest.ActiveWorkBook.Saved := True; xlstest.Quit; Finally xlstest:=UnAssigned; End; Exit; end; xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'ZHSD.xlsx'); thesheet:= xlstest.Workbooks[1].Worksheets['sheet1']; First; while not eof do begin thesheet.cells.item[j,1]:=aAdoQuery.FieldByName('发货人名称').AsString; thesheet.cells.item[j,2]:=aAdoQuery.FieldByName('发货人地址1').AsString; thesheet.cells.item[j,3]:=aAdoQuery.FieldByName('发货人国家代码').AsString; thesheet.cells.item[j,4]:=aAdoQuery.FieldByName('发货人电话').AsString; thesheet.cells.item[j,5]:=aAdoQuery.FieldByName('收货人名称').AsString; thesheet.cells.item[j,6]:=aAdoQuery.FieldByName('收货人地址1').AsString; thesheet.cells.item[j,7]:=aAdoQuery.FieldByName('收货人国家代码').AsString; thesheet.cells.item[j,8]:=aAdoQuery.FieldByName('收货人电话').AsString; thesheet.cells.item[j,9]:=aAdoQuery.FieldByName('通知人名称').AsString; thesheet.cells.item[j,10]:=aAdoQuery.FieldByName('通知人地址1').AsString; thesheet.cells.item[j,11]:=aAdoQuery.FieldByName('通知人国家代码').AsString; thesheet.cells.item[j,12]:=aAdoQuery.FieldByName('通知人电话').AsString; thesheet.cells.item[j,13]:=aAdoQuery.FieldByName('主提单号').AsString; thesheet.cells.item[j,14]:=aAdoQuery.FieldByName('分提单号').AsString; thesheet.cells.item[j,15]:=aAdoQuery.FieldByName('船公司代码').AsString; thesheet.cells.item[j,16]:=aAdoQuery.FieldByName('箱号').AsString; thesheet.cells.item[j,17]:=''''+aAdoQuery.FieldByName('封号').AsString; thesheet.cells.item[j,18]:=GetCtnMSCCodeCode(aAdoQuery.FieldByName('表现形式').AsString); thesheet.cells.item[j,19]:=aAdoQuery.FieldByName('件数').AsString; thesheet.cells.item[j,20]:=aAdoQuery.FieldByName('重量').AsString; thesheet.cells.item[j,21]:=aAdoQuery.FieldByName('尺码').AsString; thesheet.cells.item[j,22]:=aAdoQuery.FieldByName('货物描述').AsString; thesheet.cells.item[j,23]:=aAdoQuery.FieldByName('唛头_1').AsString; if (aAdoQuery.FieldByName('货物标识').AsString='D') then thesheet.cells.item[j,24]:='危险品' else if (aAdoQuery.FieldByName('货物标识').AsString='R') then thesheet.cells.item[j,24]:='冻柜' else thesheet.cells.item[j,24]:='普通货'; thesheet.cells.item[j,25]:=aAdoQuery.FieldByName('包装').AsString; thesheet.cells.item[j,26]:=aAdoQuery.FieldByName('船名').AsString; thesheet.cells.item[j,27]:=aAdoQuery.FieldByName('航次').AsString; thesheet.cells.item[j,28]:=aAdoQuery.FieldByName('卸货代码').AsString; thesheet.cells.item[j,29]:=aAdoQuery.FieldByName('目的代码').AsString; thesheet.cells.item[j,30]:=aAdoQuery.FieldByName('设置温度').AsString; thesheet.cells.item[j,31]:=aAdoQuery.FieldByName('冷藏通风量').AsString; thesheet.cells.item[j,32]:=aAdoQuery.FieldByName('危险品分类').AsString; thesheet.cells.item[j,33]:=aAdoQuery.FieldByName('危险品编号').AsString; thesheet.cells.item[j,34]:=aAdoQuery.FieldByName('危险品联系人').AsString; thesheet.cells.item[j,35]:=aAdoQuery.FieldByName('危险品电话').AsString; j:=j+1; Next; end; ScriptPath:=ExtractFilePath(ParamStr(0))+'TMPEXCEL\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); str_file:=frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring +'.xlsx'; xlstest.DisplayAlerts:=false; xlstest.ActiveWorkBook.SaveAs(ScriptPath+str_file); xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'ZHSD.xlsx'); xlstest.Quit; xlstest:=UnAssigned; Sleep(1000); senddgdata.dgConPerson:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品联系人').asstring; senddgdata.dgTel:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品电话').asstring; senddgdata.dgClass:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品分类').asstring; senddgdata.temperature:=frm_op_seae_edi_data.t_op_seae.fieldbyname('设置温度').asstring; senddgdata.temUnit:=frm_op_seae_edi_data.t_op_seae.fieldbyname('温度单位').asstring; senddgdata.humidity:=''; senddgdata.vent:=frm_op_seae_edi_data.t_op_seae.fieldbyname('冷藏通风量').asstring; senddgdata.dgNo:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品编号').asstring; TDsThread.create(str_file,'ZGL',ScriptPath,zhusername,zhpassword,senddgdata,zhcorpcode); updatelr; finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.NZHZFClick(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_zHzf) then frm_op_seae_edi_custom_zHzf:=tfrm_op_seae_edi_custom_zHzf.Create(application); frm_op_seae_edi_custom_zHzf.ShowModal; finally frm_op_seae_edi_custom_zHzf.free; frm_op_seae_edi_custom_zHzf:=nil; end; end; procedure Tfrm_op_seae_edi_data.Sendzhzf; var i,j:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr,zhusername,zhpassword,ScriptPath,str_file:string; inifile1:TIniFile; senddgdata:TSendDGData; xlstest, thesheet:Variant; begin if t_op_seae.IsEmpty then Exit; inifile1 := Tinifile.Create(ExtractFilePath(application.ExeName) + 'main.ini'); zhusername:= inifile1.ReadString('customZHZF', 'WEBUSERNAME', ''); zhpassword:= inifile1.ReadString('customZHZF', 'WEBPASSOWRD', ''); if zhusername='' then begin ShowMessage('发送用户名和密码不能为空!'); Exit; end; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; j:=6; try xlstest:=CreateOleObject('Excel.Application'); except Try //多用一个Try..Finally是防止在读写单元格过程中出错,退出时可能没有释放Excel,造成内存漏洞 xlstest.ActiveWorkBook.Saved := True; xlstest.Quit; Finally xlstest:=UnAssigned; End; Exit; end; xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'ZHENHUA.xls'); thesheet:= xlstest.Workbooks[1].Worksheets['ZHENHUA MANIFEST']; thesheet.cells.item[2,1]:=aAdoQuery.FieldByName('主提单号').AsString; { excel2.Connect; Excel2.Exec('[open('+'"'+ExtractFilePath(Application.ExeName)+'ZHENHUA.xls'+'"'+')]'); excel2.putstr(2,1,aAdoQuery.FieldByName('主提单号').AsString); } First; while not eof do begin thesheet.cells.item[j,1]:=aAdoQuery.FieldByName('船名').AsString; thesheet.cells.item[j,2]:=aAdoQuery.FieldByName('航次').AsString; thesheet.cells.item[j,3]:=aAdoQuery.FieldByName('船公司代码').AsString; thesheet.cells.item[j,4]:=''; thesheet.cells.item[j,5]:=aAdoQuery.FieldByName('主提单号').AsString; thesheet.cells.item[j,6]:=aAdoQuery.FieldByName('箱号').AsString; thesheet.cells.item[j,7]:=aAdoQuery.FieldByName('封号').AsString; poststr:=aAdoQuery.FieldByName('装货港').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); thesheet.cells.item[j,8]:=poststr; poststr:=aAdoQuery.FieldByName('卸货港').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); thesheet.cells.item[j,10]:=poststr; poststr:=aAdoQuery.FieldByName('目的地').AsString; if Pos(',',poststr)>0 then poststr:=Copy(poststr,1,Pos(',',poststr)-1); thesheet.cells.item[j,11]:=poststr; thesheet.cells.item[j,12]:=aAdoQuery.FieldByName('件数').AsString; thesheet.cells.item[j,13]:=aAdoQuery.FieldByName('包装').AsString; thesheet.cells.item[j,14]:=aAdoQuery.FieldByName('重量').AsString; thesheet.cells.item[j,15]:=aAdoQuery.FieldByName('尺码').AsString; thesheet.cells.item[j,16]:=aAdoQuery.FieldByName('尺寸').AsString+aAdoQuery.FieldByName('箱型').AsString; thesheet.cells.item[j,17]:=aAdoQuery.FieldByName('货物描述').AsStrinG; thesheet.cells.item[j,18]:=aAdoQuery.FieldByName('发货人名称').AsString; thesheet.cells.item[j,19]:=aAdoQuery.FieldByName('收货人名称').AsString; thesheet.cells.item[j,20]:=aAdoQuery.FieldByName('通知人名称').AsString; if Pos('COLLECT',aAdoQuery.FieldByName('付费方式').AsString)>0 THEN thesheet.cells.item[j,21]:='COLLECT' else thesheet.cells.item[j,21]:='PREPAID'; thesheet.cells.item[j,22]:=aAdoQuery.FieldByName('唛头_1').AsString; thesheet.cells.item[j,24]:=aAdoQuery.FieldByName('发货人地址1').AsString; thesheet.cells.item[j,25]:=''; thesheet.cells.item[j,26]:=aAdoQuery.FieldByName('发货人国家代码').AsString; thesheet.cells.item[j,27]:='TE'; thesheet.cells.item[j,28]:=aAdoQuery.FieldByName('发货人电话').AsString; thesheet.cells.item[j,30]:=aAdoQuery.FieldByName('收货人地址1').AsString; thesheet.cells.item[j,31]:=''; thesheet.cells.item[j,32]:=aAdoQuery.FieldByName('收货人国家代码').AsString; thesheet.cells.item[j,33]:='TE'; thesheet.cells.item[j,34]:=aAdoQuery.FieldByName('收货人电话').AsString; thesheet.cells.item[j,36]:=aAdoQuery.FieldByName('通知人地址1').AsString; thesheet.cells.item[j,37]:=''; thesheet.cells.item[j,38]:=aAdoQuery.FieldByName('通知人国家代码').AsString; thesheet.cells.item[j,39]:='TE'; thesheet.cells.item[j,40]:=aAdoQuery.FieldByName('通知人电话').AsString; if (aAdoQuery.FieldByName('货物标识').AsString='D') then thesheet.cells.item[j,42]:='是' else thesheet.cells.item[j,42]:='否'; thesheet.cells.item[j,43]:=aAdoQuery.FieldByName('危险品编号').AsString; thesheet.cells.item[j,44]:=aAdoQuery.FieldByName('危险品分类').AsString; thesheet.cells.item[j,45]:=aAdoQuery.FieldByName('危险品联系人').AsString; thesheet.cells.item[j,46]:=aAdoQuery.FieldByName('危险品电话').AsString; j:=j+1; Next; end; ScriptPath:=ExtractFilePath(ParamStr(0))+'TMPEXCEL\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); str_file:=frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring +'.xls'; xlstest.DisplayAlerts:=false; xlstest.ActiveWorkBook.SaveAs(ScriptPath+str_file); xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'ZHENHUA.xls'); xlstest.Quit; xlstest:=UnAssigned; Sleep(1000); senddgdata.dgConPerson:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品联系人').asstring; senddgdata.dgTel:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品电话').asstring; senddgdata.dgClass:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品分类').asstring; senddgdata.temperature:=frm_op_seae_edi_data.t_op_seae.fieldbyname('设置温度').asstring; senddgdata.temUnit:=frm_op_seae_edi_data.t_op_seae.fieldbyname('温度单位').asstring; senddgdata.humidity:=''; senddgdata.vent:=frm_op_seae_edi_data.t_op_seae.fieldbyname('冷藏通风量').asstring; senddgdata.dgNo:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品编号').asstring; TDsThread.create(str_file,'ylw',ScriptPath,zhusername,zhpassword,senddgdata); { SaveDialog.Filter := '(*.xls)|*.xls'; SaveDialog.FileName := aAdoQuery.fieldbyname('主提单号').asstring+'.xls'; if SaveDialog.Execute then begin excel2.Exec('[SAVE.AS("'+SaveDialog.FileName+'";1;"";false;"";false)]'); excel2.Exec('[CLOSE(false)]'); end; } updatelr; finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.Sendzczf; var i,j:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; poststr,zhusername,zhpassword,ScriptPath,str_file:string; inifile1:TIniFile; senddgdata:TSendDGData; xlstest, thesheet:Variant; begin if t_op_seae.IsEmpty then Exit; inifile1 := Tinifile.Create(ExtractFilePath(application.ExeName) + 'main.ini'); zhusername:= inifile1.ReadString('customZCZF', 'WEBUSERNAME', ''); zhpassword:= inifile1.ReadString('customZCZF', 'WEBPASSOWRD', ''); if zhusername='' then begin ShowMessage('发送用户名和密码不能为空!'); Exit; end; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; j:=2; try xlstest:=CreateOleObject('Excel.Application'); except Try //多用一个Try..Finally是防止在读写单元格过程中出错,退出时可能没有释放Excel,造成内存漏洞 xlstest.ActiveWorkBook.Saved := True; xlstest.Quit; Finally xlstest:=UnAssigned; End; Exit; end; xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'ZHONGCHUANG.xls'); thesheet:= xlstest.Workbooks[1].Worksheets['Sheet1']; { excel2.Connect; Excel2.Exec('[open('+'"'+ExtractFilePath(Application.ExeName)+'ZHENHUA.xls'+'"'+')]'); excel2.putstr(2,1,aAdoQuery.FieldByName('主提单号').AsString); } First; while not eof do begin thesheet.cells.item[j,2]:=aAdoQuery.FieldByName('主提单号').AsString; thesheet.cells.item[j,3]:=aAdoQuery.FieldByName('箱号').AsString; thesheet.cells.item[j,4]:=aAdoQuery.FieldByName('封号').AsString; thesheet.cells.item[j,5]:=aAdoQuery.FieldByName('尺寸').AsString; thesheet.cells.item[j,6]:=aAdoQuery.FieldByName('箱型').AsString; thesheet.cells.item[j,7]:=aAdoQuery.FieldByName('船公司代码').AsString; thesheet.cells.item[j,8]:='F'; thesheet.cells.item[j,10]:=aAdoQuery.FieldByName('件数').AsString; thesheet.cells.item[j,11]:=aAdoQuery.FieldByName('包装').AsString; thesheet.cells.item[j,12]:=aAdoQuery.FieldByName('重量').AsString; thesheet.cells.item[j,13]:=aAdoQuery.FieldByName('尺码').AsString; thesheet.cells.item[j,14]:=aAdoQuery.FieldByName('发货人名称').AsString; thesheet.cells.item[j,15]:=aAdoQuery.FieldByName('发货人地址1').AsString; thesheet.cells.item[j,16]:=aAdoQuery.FieldByName('发货人国家代码').AsString; thesheet.cells.item[j,18]:='TE'; thesheet.cells.item[j,19]:=aAdoQuery.FieldByName('发货人电话').AsString; thesheet.cells.item[j,21]:=aAdoQuery.FieldByName('收货人名称').AsString; thesheet.cells.item[j,22]:=aAdoQuery.FieldByName('收货人地址1').AsString; thesheet.cells.item[j,23]:=aAdoQuery.FieldByName('收货人国家代码').AsString; thesheet.cells.item[j,24]:=''; thesheet.cells.item[j,25]:='TE'; thesheet.cells.item[j,26]:=aAdoQuery.FieldByName('收货人电话').AsString; thesheet.cells.item[j,27]:=''; thesheet.cells.item[j,28]:=aAdoQuery.FieldByName('通知人名称').AsString; thesheet.cells.item[j,29]:=aAdoQuery.FieldByName('通知人地址1').AsString; thesheet.cells.item[j,30]:=aAdoQuery.FieldByName('通知人国家代码').AsString; thesheet.cells.item[j,31]:=''; thesheet.cells.item[j,32]:='TE'; thesheet.cells.item[j,33]:=aAdoQuery.FieldByName('通知人电话').AsString; thesheet.cells.item[j,34]:=aAdoQuery.FieldByName('装港代码').AsString; thesheet.cells.item[j,35]:=''; thesheet.cells.item[j,36]:=aAdoQuery.FieldByName('卸货代码').AsString; thesheet.cells.item[j,37]:=aAdoQuery.FieldByName('目的代码').AsString; thesheet.cells.item[j,38]:=aAdoQuery.FieldByName('付费方式').AsString; thesheet.cells.item[j,39]:=aAdoQuery.FieldByName('运输条款').AsString; thesheet.cells.item[j,40]:=aAdoQuery.FieldByName('唛头_1').AsString; thesheet.cells.item[j,41]:=aAdoQuery.FieldByName('货物描述').AsStrinG; thesheet.cells.item[j,42]:=aAdoQuery.FieldByName('危险品联系人').AsStrinG; thesheet.cells.item[j,43]:=aAdoQuery.FieldByName('危险品电话').AsStrinG; thesheet.cells.item[j,44]:=aAdoQuery.FieldByName('危险品分类').AsStrinG; thesheet.cells.item[j,45]:=aAdoQuery.FieldByName('运输方式').AsStrinG; thesheet.cells.item[j,46]:=aAdoQuery.FieldByName('船名').AsString; thesheet.cells.item[j,47]:=aAdoQuery.FieldByName('航次').AsString; j:=j+1; Next; end; ScriptPath:=ExtractFilePath(ParamStr(0))+'TMPEXCEL\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); str_file:=frm_op_seae_edi_data.t_op_seae.fieldbyname('主提单号').asstring +'.xls'; xlstest.DisplayAlerts:=false; xlstest.ActiveWorkBook.SaveAs(ScriptPath+str_file); xlstest.WorkBooks.Open(ExtractFilePath(Paramstr(0))+'ZHONGCHUANG.xls'); xlstest.Quit; xlstest:=UnAssigned; Sleep(1000); senddgdata.dgConPerson:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品联系人').asstring; senddgdata.dgTel:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品电话').asstring; senddgdata.dgClass:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品分类').asstring; senddgdata.temperature:=frm_op_seae_edi_data.t_op_seae.fieldbyname('设置温度').asstring; senddgdata.temUnit:=frm_op_seae_edi_data.t_op_seae.fieldbyname('温度单位').asstring; senddgdata.humidity:=''; senddgdata.vent:=frm_op_seae_edi_data.t_op_seae.fieldbyname('冷藏通风量').asstring; senddgdata.dgNo:=frm_op_seae_edi_data.t_op_seae.fieldbyname('危险品编号').asstring; TDsThread.create(str_file,'ZC',ScriptPath,zhusername,zhpassword,senddgdata); updatelr; finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_edi_data.N40Click(Sender: TObject); begin if t_op_seae.isempty then begin showmessage('对不起,没有数据信息,不能生成EDI文件!'); exit; end; try if not assigned(frm_op_seae_edi_custom_zczf) then frm_op_seae_edi_custom_zczf:=tfrm_op_seae_edi_custom_zczf.Create(application); frm_op_seae_edi_custom_zczf.ShowModal; finally frm_op_seae_edi_custom_zczf.free; frm_op_seae_edi_custom_zczf:=nil; end; end; end.