unit u_op_seaictn_list; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, Grids, Wwdbigrd, Wwdbgrid, StdCtrls, DB, ADODB, dxDBTLCl, dxGrClms, ComCtrls, bsSkinTabs, DBCtrls, wwdblook, wwdbdatetimepicker, RxLookup, Menus, XPMenu, Mask, wwdbedit, Wwdotdot, Wwdbcomb,inifiles; type Tfrm_op_seaictn_list = class(TForm) Panel2: TPanel; dxDBGrid1: TdxDBGrid; t_op_seae: TADOQuery; t_op_seae1: TDataSource; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; XPMenu1: TXPMenu; bsSkinPanel1: TbsSkinPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton9: TbsSkinButton; bsSkinButton5: TbsSkinButton; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridDateColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column9: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column20: TdxDBGridMaskColumn; dxDBGrid1Column23: TdxDBGridMaskColumn; dxDBGrid1Column24: TdxDBGridMaskColumn; dxDBGrid1Column25: TdxDBGridDateColumn; dxDBGrid1Column26: TdxDBGridDateColumn; dxDBGrid1Column27: TdxDBGridDateColumn; dxDBGrid1Column28: TdxDBGridMaskColumn; dxDBGrid1Column29: TdxDBGridMaskColumn; dxDBGrid1Column30: TdxDBGridMaskColumn; dxDBGrid1Column31: TdxDBGridMaskColumn; dxDBGrid1Column37: TdxDBGridMaskColumn; dxDBGrid1Column38: TdxDBGridMaskColumn; dxDBGrid1Column40: TdxDBGridMaskColumn; dxDBGrid1Column41: TdxDBGridMaskColumn; dxDBGrid1Column42: TdxDBGridMaskColumn; dxDBGrid1Column43: TdxDBGridDateColumn; dxDBGrid1Column44: TdxDBGridMaskColumn; dxDBGrid1Column45: TdxDBGridMaskColumn; dxDBGrid1Column46: TdxDBGridMaskColumn; dxDBGrid1Column47: TdxDBGridMaskColumn; dxDBGrid1Column52: TdxDBGridMaskColumn; dxDBGrid1Column76: TdxDBGridMaskColumn; dxDBGrid1Column77: TdxDBGridMaskColumn; dxDBGrid1Column78: TdxDBGridMaskColumn; dxDBGrid1Column79: TdxDBGridMaskColumn; dxDBGrid1Column80: TdxDBGridMaskColumn; dxDBGrid1Column81: TdxDBGridMaskColumn; dxDBGrid1Column82: TdxDBGridMaskColumn; dxDBGrid1Column107: TdxDBGridMaskColumn; dxDBGrid1Column108: TdxDBGridMaskColumn; dxDBGrid1Column109: TdxDBGridMaskColumn; dxDBGrid1Column110: TdxDBGridMaskColumn; dxDBGrid1Column111: TdxDBGridMaskColumn; dxDBGrid1Column112: TdxDBGridMaskColumn; dxDBGrid1Column113: TdxDBGridMaskColumn; dxDBGrid1Column114: TdxDBGridMaskColumn; dxDBGrid1Column118: TdxDBGridMaskColumn; dxDBGrid1Column193: TdxDBGridDateColumn; bsSkinPanel3: TbsSkinPanel; lblcount: TLabel; bsSkinButton2: TbsSkinButton; bsSkinButton6: TbsSkinButton; dxDBGrid1Column53: TdxDBGridColumn; dxDBGrid1Column54: TdxDBGridColumn; dxDBGrid1Column55: TdxDBGridColumn; dxDBGrid1Column56: TdxDBGridColumn; dxDBGrid1Column57: TdxDBGridColumn; dxDBGrid1Column58: TdxDBGridColumn; dxDBGrid1Column59: TdxDBGridColumn; bsSkinPanel4: TbsSkinPanel; Label10: TLabel; Label5: TLabel; Label125: TLabel; Label30: TLabel; Label1: TLabel; Label2: TLabel; Label8: TLabel; Label6: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBLookupCombo49: TwwDBLookupCombo; Edit7: TEdit; Edit2: TEdit; Edit3: TEdit; RxDBLookupCombo6: TRxDBLookupCombo; Edit1: TEdit; bsSkinGroupBox1: TbsSkinGroupBox; Label38: TLabel; DBEdit9: TDBEdit; Label36: TLabel; DBEdit7: TDBEdit; bsSkinButton1: TbsSkinButton; Label20: TLabel; Label124: TLabel; t_code_sendedi1: TDataSource; t_code_sendedi: TADOQuery; SaveDialog1: TSaveDialog; RxDBLookupCombo8: TRxDBLookupCombo; RxDBLookupCombo22: TRxDBLookupCombo; dxDBGrid1Column60: TdxDBGridCheckColumn; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton9Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure dxDBGrid2Column3CustomDrawCell(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn; ASelected, AFocused, ANewItemRow: Boolean; var AText: String; var AColor: TColor; AFont: TFont; var AAlignment: TAlignment; var ADone: Boolean); procedure bsSkinButton6Click(Sender: TObject); procedure dxDBGrid1Column4CustomDrawCell(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn; ASelected, AFocused, ANewItemRow: Boolean; var AText: String; var AColor: TColor; AFont: TFont; var AAlignment: TAlignment; var ADone: Boolean); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure t_code_sendediAfterInsert(DataSet: TDataSet); private { Private declarations } seaestr,seaedelstr:string ; function findstr:string ; procedure setFootermsg; procedure loadFindIni ; procedure writeFindIni ; function getcarrierid:string; function GetCntrEdi(cntrsize: String):String; public { Public declarations } end; var frm_op_seaictn_list: Tfrm_op_seaictn_list; implementation {$R *.dfm} uses u_main,my_sys_function,u_data_share ; procedure Tfrm_op_seaictn_list.bsSkinButton5Click(Sender: TObject); begin close ; end; procedure Tfrm_op_seaictn_list.FormClose(Sender: TObject; var Action: TCloseAction); begin writeFindIni; savereggrid(dxdbgrid1,caption+'1'); frm_op_seaictn_list.Hide; frm_op_seaictn_list.ManualFloat(frm_op_seaictn_list.BoundsRect ); frm_main.freeTabs('frm_op_seaictn_list'); action:=cafree; frm_op_seaictn_list:=nil; end; procedure Tfrm_op_seaictn_list.bsSkinButton9Click(Sender: TObject); begin sys_print('海运进口集装箱列表',2,nil,nil,nil,nil,t_op_seae1,Nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seaictn_list.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_seaictn_list.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_seaictn_list.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,210); end; procedure Tfrm_op_seaictn_list.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_seaictn_list.FormShow(Sender: TObject); var i:integer ; begin loadFindIni; loadreggrid(dxdbgrid1,true,caption+'1'); t_code_sendedi.Open; end; procedure Tfrm_op_seaictn_list.dxDBGrid2Column3CustomDrawCell(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn; ASelected, AFocused, ANewItemRow: Boolean; var AText: String; var AColor: TColor; AFont: TFont; var AAlignment: TAlignment; var ADone: Boolean); begin if frm_data_share.t_code_state.Locate('业务状态',backstate,[])then AColor:=stringtocolor(frm_data_share.t_code_state.fieldbyname('颜色').asstring) else AColor:=clwhite ; end; procedure Tfrm_op_seaictn_list.bsSkinButton6Click(Sender: TObject); begin edit1.Text:='' ; edit2.text:='' ; edit3.text:='' ; edit7.Text:='' ; wwDBDateTimePicker1.Clear ; wwDBDateTimePicker2.Clear ; RxDBLookupCombo6.ClearValue ; RxDBLookupCombo22.ClearValue ; RxDBLookupCombo8.ClearValue ; wwDBLookupCombo49.clear ; end; function Tfrm_op_seaictn_list.findstr: string; begin end; procedure Tfrm_op_seaictn_list.setFootermsg; var backteu,ggteu,thcteu:integer ; i,teu1,teu2,teu3,teu4,teu5,teu6,teu7,teu8,teu9,teu10,teuot,teuall:integer; steu:string; teu:Array [1..10] of integer; begin { lblcount.Caption:='票数 共: '+inttostr(t_op_seae.recordcount) ; ggteu:=0 ; backteu:=0 ;thcteu:=0 ; teu[1]:=0; teu[2]:=0; teu[3]:=0; teu[4]:=0; teu[5]:=0; teu[6]:=0; teu[7]:=0; teu[8]:=0; teu[9]:=0; teu[10]:=0; teuot:=0; teuall:=0; with t_op_seae do begin disablecontrols ; first ; while not eof do begin teu[1]:=teu[1]+fieldbyname('箱型1').AsInteger; teu[2]:=teu[2]+fieldbyname('箱型2').AsInteger; teu[3]:=teu[3]+fieldbyname('箱型3').AsInteger; teu[4]:=teu[4]+fieldbyname('箱型4').AsInteger; teu[5]:=teu[5]+fieldbyname('箱型5').AsInteger; teu[6]:=teu[6]+fieldbyname('箱型6').AsInteger; teu[7]:=teu[7]+fieldbyname('箱型7').AsInteger; teu[8]:=teu[8]+fieldbyname('箱型8').AsInteger; teu[9]:=teu[9]+fieldbyname('箱型9').AsInteger; teu[10]:=teu[10]+fieldbyname('箱型10').AsInteger; teuot:=teuot+fieldbyname('其他箱型').AsInteger; teuall:=teuall+fieldbyname('箱TEU').AsInteger; next ; end ; enablecontrols ; steu:='集装箱:'; for i:=1 to 10 do begin try if trim(frm_data_share.t_code_ctn_de.fieldbyname('箱型'+inttostr(i)).asstring)<>'' then begin if frm_data_share.t_code_ctn.locate('代码',trim(frm_data_share.t_code_ctn_de.fieldbyname('箱型'+inttostr(i)).asstring),[]) then begin steu:=steu+' '+trim(frm_data_share.t_code_ctn.fieldbyname('表现形式').asstring)+': '+inttostr(teu[i]); end; end else begin end; except ; end; end; steu:=steu+' '+'其他箱型: '+inttostr(teuot); steu:=steu+' '+'合计TEU: '+inttostr(teuall); lblcount.Caption:='票数共: '+inttostr(t_op_seae.recordcount) ; lblcount.Caption:=lblcount.Caption+' '+steu; end ; } end; procedure Tfrm_op_seaictn_list.dxDBGrid1Column4CustomDrawCell(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn; ASelected, AFocused, ANewItemRow: Boolean; var AText: String; var AColor: TColor; AFont: TFont; var AAlignment: TAlignment; var ADone: Boolean); begin AColor:=dxgrid_color('海运出口',ANode.Strings[dxDBGrid1Column4.Index]); AFont.Color:=clblack; end; procedure Tfrm_op_seaictn_list.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_op_seae,'编号'); end; procedure Tfrm_op_seaictn_list.loadFindIni; begin end; procedure Tfrm_op_seaictn_list.writeFindIni; begin end; procedure Tfrm_op_seaictn_list.bsSkinButton2Click(Sender: TObject); var str,delstr:string ; begin str:='where 1=1 ' ; if edit2.Text<>'' then str:=str+' and 箱号 like '+''''+'%'+Edit2.text+'%'+''''; if edit1.Text<>'' then str:=str+' and 封号 like '+''''+'%'+Edit1.text+'%'+''''; if edit3.text<>'' then str:=str+' and 主提单号 like '+''''+'%'+Edit3.text+'%'+''''; if edit7.text<>'' then str:=str+' and 航次 like '+''''+'%'+Edit7.text+'%'+''''; if wwDBLookupCombo49.text<>''then str:=str+' and 船名 like '+''''+'%'+wwDBLookupCombo49.text+'%'+''''; if wwDBDateTimePicker1.text<>''then str:=str+' and 开船日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str:=str+' and 开船日期<='+''''+wwDBDateTimePicker2.text+''''; if RxDBLookupCombo22.DisplayValue<>''then str:=str+' and 装港代码='+''''+RxDBLookupCombo22.DisplayValues[2]+''''; if RxDBLookupCombo8.DisplayValue<>''then str:=str+' and 卸货代码='+''''+RxDBLookupCombo8.DisplayValues[2]+''''; if RxDBLookupCombo6.DisplayValues[1]<>'' then str:=str+' and 船公司='+''''+RxDBLookupCombo6.DisplayValues[1]+''''; delstr:=str; screen.Cursor:=crSQLwait ; try with t_op_seae,SQL do begin close ; Clear ; add('select * from v_op_seai_ctn '); add(str); open ; end ; setfootermsg ; finally screen.Cursor:=crDefault ; end ; end; procedure Tfrm_op_seaictn_list.bsSkinButton1Click(Sender: TObject); var Str:TStrings; i:integer; SenderCode,ReciverCode,S:String; begin if Trim(DBEdit9.Text)='' then begin ShowMessage('发送方代码不能为空!'); Exit; end; if Trim(DBEdit7.Text)='' then begin ShowMessage('接收方代码不能为空!'); Exit; end; if t_code_sendedi.State in [dsedit,dsinsert] then t_code_sendedi.Post; str:=Tstringlist.Create; try SenderCode:=trim(DBEdit9.Text) ; ReciverCode:=trim(DBEdit7.Text) ; str.Add('00:BAPLIE:BAYPLAN:9:'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),2)+#39); str.Add('10::' + trim(t_op_seae.fieldbyname('船名').asstring) +'::' + trim(t_op_seae.fieldbyname('航次').asstring)+'::::' + GetDatetime(datetimetostr(t_op_seae.fieldbyname('开船日期').asdatetime),0)+':' +trim(t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(t_op_seae.fieldbyname('装货港').asstring)+':' +trim(t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(t_op_seae.fieldbyname('卸货港').asstring)+':' +inttostr(t_op_seae.RecordCount) +#39); //船舶经营人 str.Add('11:'+getcarrierid+#39); t_op_seae.First; while not t_op_seae.eof do begin S:='50:' + trim(t_op_seae.fieldbyname('箱号').asstring) +':' + trim(GetCntrEdi(t_op_seae.fieldbyname('代码').asstring))+':' +trim(t_op_seae.fieldbyname('箱状态').asstring)+':' +trim(t_op_seae.fieldbyname('贝位').asstring)+':'; if trim(t_op_seae.fieldbyname('货物标识').asstring)='R' then begin S:=S+trim(t_op_seae.fieldbyname('温度单位').asstring)+':'+trim(t_op_seae.fieldbyname('设置温度').asstring)+':'; end else begin S:=S+':'+':'; end; S:=S+':::::::'; S:=S+trim(floattostr(t_op_seae.fieldbyname('重量').asfloat+t_op_seae.fieldbyname('箱皮重').asfloat))+':' +trim(floattostr(t_op_seae.fieldbyname('箱皮重').asfloat))+':'+t_op_seae.fieldbyname('箱经营人代码').asstring+#39; //船舶经营人 Str.add(S); str.Add('52:'+trim(t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(t_op_seae.fieldbyname('装货港').asstring)+':' +trim(t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(t_op_seae.fieldbyname('卸货港').asstring)+#39); if trim(t_op_seae.fieldbyname('货物标识').asstring)='D' then begin str.Add('54:'+trim(t_op_seae.fieldbyname('危险品分类').asstring)+':' +trim(t_op_seae.fieldbyname('危险品页号').asstring)+':' +trim(t_op_seae.fieldbyname('危险品编号').asstring) +':' +trim(t_op_seae.fieldbyname('危险品标签').asstring) +#39); end; t_op_seae.Next; end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); { for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i]) then begin MessageDlg('此票业务有中文字符或TAB等不规范字符,请去除字符后重试!',mtWarning,[mbYes],0); exit; end; end; } SaveDialog1.FileName:=t_op_seae.fieldbyname('船名').asstring; if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; finally FreeAndNil(Str); end; end; function Tfrm_op_seaictn_list.getcarrierid: string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 承运人代码 from t_code_vessel where 英文船名='''+t_op_seae.fieldbyname('船名').AsString+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('承运人代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seaictn_list.GetCntrEdi(cntrsize: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select Edi代码 from t_code_ctn where 代码='''+cntrsize+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seaictn_list.t_code_sendediAfterInsert( DataSet: TDataSet); begin t_code_sendedi.FieldByName('EDI类别').AsString:='出口船图'; end; end.