unit u_op_seae_weituo; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, DB, ADODB, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, ComCtrls, bsSkinTabs, RxLookup, StdCtrls, Mask, DBCtrls, wwdbdatetimepicker, wwdblook, u_op_sate, u_fee, u_op_card, Menus, dxDBTLCl, dxGrClms, bsdbctrls, XPMenu, Grids, Wwdbigrd, Wwdbgrid, RxMemDS, wwdbedit, Wwdotdot, Wwdbcomb, DBCtrlsEh,DateUtils, bsSkinBoxCtrls; type Tfrm_op_seae_weituo = class(TForm) Panel2: TPanel; bsSkinButton7: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton38: TbsSkinButton; t_op_seae_order: TADOQuery; t_op_seae_order1: TDataSource; t_ch_fee: TADOQuery; PopupMenu3: TPopupMenu; N37: TMenuItem; N38: TMenuItem; N62: TMenuItem; N25: TMenuItem; N64: TMenuItem; N63: TMenuItem; N17: TMenuItem; N18: TMenuItem; N34: TMenuItem; N35: TMenuItem; N36: TMenuItem; XPMenu1: TXPMenu; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinPanel1: TbsSkinPanel; Label19: TLabel; RxDBLookupCombo12: TRxDBLookupCombo; Label4: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; wwDBDateTimePicker4: TwwDBDateTimePicker; Label26: TLabel; t_ch_fee1: TDataSource; t_bz_balance: TRxMemoryData; DBEdit2: TDBEdit; Label2: TLabel; bsSkinPanel4: TbsSkinPanel; dxDBGrid1: TdxDBGrid; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column114: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridDateColumn; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; bsSkinPanel3: TbsSkinPanel; Label6: TLabel; Label39: TLabel; Label14: TLabel; Label9: TLabel; Label10: TLabel; Label5: TLabel; Label3: TLabel; Label7: TLabel; Edit1: TEdit; wwDBComboBox44: TwwDBComboBox; RxDBLookupCombo3: TRxDBLookupCombo; RxDBLookupCombo2: TRxDBLookupCombo; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; wwDBDateTimePicker5: TwwDBDateTimePicker; wwDBDateTimePicker6: TwwDBDateTimePicker; bsSkinButton10: TbsSkinButton; bsSkinButton15: TbsSkinButton; dxDBGrid1Column11: TdxDBGridColumn; bsSkinPageControl2: TbsSkinPageControl; bsSkinGroupBox1: TbsSkinGroupBox; Label124: TLabel; Label15: TLabel; Label13: TLabel; Label35: TLabel; Label8: TLabel; Label12: TLabel; Label20: TLabel; wwDBLookupCombo52: TwwDBLookupCombo; wwDBDateTimePicker2: TwwDBDateTimePicker; DBEdit5: TDBEdit; RxDBLookupCombo28: TRxDBLookupCombo; bsSkinGroupBox5: TbsSkinGroupBox; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox3: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox4: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox5: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox9: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox6: TbsSkinDBCheckRadioBox; bsSkinGroupBox2: TbsSkinGroupBox; wwDBGrid1: TwwDBGrid; wwDBLookupCombo1: TwwDBLookupCombo; wwDBLookupCombo3: TwwDBLookupCombo; wwDBLookupCombo5: TwwDBLookupCombo; bsSkinPanel2: TbsSkinPanel; bsSkinButton8: TbsSkinButton; bsSkinButton12: TbsSkinButton; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; wwDBLookupCombo4: TwwDBLookupCombo; wwDBComboBox3: TwwDBComboBox; wwDBComboBox4: TwwDBComboBox; wwDBComboBox1: TwwDBComboBox; bsSkinDBCheckRadioBox7: TbsSkinDBCheckRadioBox; DBMemo1: TDBMemo; wwDBLookupCombo2: TwwDBLookupCombo; wwDBDateTimePicker7: TwwDBDateTimePicker; bsSkinGroupBox3: TbsSkinGroupBox; Label16: TLabel; Label17: TLabel; Label18: TLabel; wwDBComboBox2: TwwDBComboBox; DBEdit3: TDBEdit; DBMemo2: TDBMemo; Label122: TLabel; DBMemo33: TDBMemo; RxDBLookupCombo4: TRxDBLookupCombo; wwDBLookupCombo6: TwwDBLookupCombo; Label121: TLabel; RxDBLookupCombo5: TRxDBLookupCombo; wwDBLookupCombo7: TwwDBLookupCombo; DBMemo34: TDBMemo; DBMemo35: TDBMemo; RxDBLookupCombo6: TRxDBLookupCombo; wwDBLookupCombo8: TwwDBLookupCombo; Label123: TLabel; Label21: TLabel; DBMemo39: TDBMemo; Label163: TLabel; DBMemo38: TDBMemo; Label165: TLabel; DBMemo40: TDBMemo; Label166: TLabel; DBMemo41: TDBMemo; Label167: TLabel; DBMemo42: TDBMemo; wwDBLookupCombo61: TwwDBLookupCombo; DBEdit81: TDBEdit; DBEdit82: TDBEdit; Label169: TLabel; DBEdit83: TDBEdit; Label170: TLabel; Label32: TLabel; wwDBLookupCombo21: TwwDBLookupCombo; Label27: TLabel; DBEdit25: TDBEdit; Label30: TLabel; RxDBLookupCombo15: TRxDBLookupCombo; Label22: TLabel; wwDBLookupCombo9: TwwDBLookupCombo; qrysales: TADOQuery; dsrsales: TDataSource; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; lblsales: TLabel; dxDBGrid1Column12: TdxDBGridColumn; dxDBGrid1Column13: TdxDBGridColumn; Label23: TLabel; DBEdit4: TDBEdit; Label24: TLabel; DBEdit6: TDBEdit; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridColumn; Label25: TLabel; DBEdit7: TDBEdit; dxDBGrid1Column17: TdxDBGridColumn; Label28: TLabel; RxDBLookupCombo7: TRxDBLookupCombo; dxDBGrid1Column18: TdxDBGridColumn; wwDBComboBox5: TwwDBComboBox; Label29: TLabel; dxDBGrid1Column19: TdxDBGridColumn; Label31: TLabel; wwDBLookupCombo10: TwwDBLookupCombo; t_op_ctn: TADOQuery; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; dxDBGrid1Column22: TdxDBGridColumn; dxDBGrid1Column23: TdxDBGridColumn; dxDBGrid1Column24: TdxDBGridColumn; dxDBGrid1Column25: TdxDBGridColumn; dxDBGrid1Column26: TdxDBGridColumn; dxDBGrid1Column27: TdxDBGridColumn; dxDBGrid1Column28: TdxDBGridColumn; dxDBGrid1Column29: TdxDBGridColumn; dxDBGrid1Column30: TdxDBGridColumn; dxDBGrid1Column31: TdxDBGridColumn; dxDBGrid1Column32: TdxDBGridColumn; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinButton21: TbsSkinButton; RxDBLookupCombo9: TRxDBLookupCombo; Label33: TLabel; DBEdit37: TDBEdit; Label108: TLabel; DBEdit38: TDBEdit; Label109: TLabel; wwDBComboBox8: TwwDBComboBox; Label119: TLabel; dxDBGrid1Column33: TdxDBGridColumn; dxDBGrid1Column34: TdxDBGridColumn; dxDBGrid1Column35: TdxDBGridColumn; Label34: TLabel; DBEdit8: TDBEdit; dxDBGrid1Column36: TdxDBGridColumn; bsSkinTabSheet3: TbsSkinTabSheet; t_ch_accept: TADOQuery; t_ch_accept1: TDataSource; t_ch_pay: TADOQuery; t_ch_pay1: TDataSource; t_op_seae: TADOQuery; dxDBGrid2: TdxDBGrid; dxDBGridColumn1: TdxDBGridColumn; dxDBGrid2Column2: TdxDBGridColumn; dxDBGrid2Column3: TdxDBGridColumn; dxDBGrid2Column4: TdxDBGridColumn; dxDBGrid2Column5: TdxDBGridColumn; dxDBGrid2Column6: TdxDBGridColumn; dxDBGrid2Column7: TdxDBGridColumn; dxDBGrid2Column8: TdxDBGridColumn; dxDBGrid2Column9: TdxDBGridColumn; dxDBGrid3: TdxDBGrid; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGridColumn6: TdxDBGridColumn; dxDBGridColumn7: TdxDBGridColumn; dxDBGridColumn8: TdxDBGridColumn; dxDBGridColumn9: TdxDBGridColumn; dxDBGridColumn10: TdxDBGridColumn; Panel1: TPanel; Memo1: TMemo; bsSkinButton18: TbsSkinButton; ADOQuery1: TADOQuery; t_op_seae1: TDataSource; t_op_fee: TADOQuery; t_op_ctn_insert: TADOQuery; bsSkinTabSheet4: TbsSkinTabSheet; DBMemo3: TDBMemo; DBMemo4: TDBMemo; DBMemo5: TDBMemo; Label36: TLabel; Label37: TLabel; Label38: TLabel; t_op_seae_act1: TDataSource; t_op_seae_act: TADOQuery; DBEdit9: TDBEdit; Label40: TLabel; Label41: TLabel; DBMemo6: TDBMemo; Label42: TLabel; DBMemo7: TDBMemo; DBEdit10: TDBEdit; wwDBLookupCombo11: TwwDBLookupCombo; DBMemo8: TDBMemo; DBMemo9: TDBMemo; DBEdit11: TDBEdit; DBEdit12: TDBEdit; RxDBLookupCombo10: TRxDBLookupCombo; DBEdit13: TDBEdit; Label44: TLabel; Label45: TLabel; Label46: TLabel; Label47: TLabel; Label48: TLabel; wwDBLookupCombo12: TwwDBLookupCombo; Label11: TLabel; RxDBLookupCombo8: TRxDBLookupCombo; Label1: TLabel; DBEdit1: TDBEdit; dxDBGrid1Column37: TdxDBGridColumn; Label43: TLabel; DBMemo10: TDBMemo; RxDBLookupCombo19: TRxDBLookupCombo; wwDBLookupCombo13: TwwDBLookupCombo; Edit2: TEdit; Button1: TButton; dxDBGrid1Column38: TdxDBGridColumn; Label49: TLabel; Edit3: TEdit; Label50: TLabel; DBEdit14: TDBEdit; Label51: TLabel; DBEdit15: TDBEdit; Label52: TLabel; DBEdit16: TDBEdit; Label53: TLabel; DBEdit17: TDBEdit; bsSkinDBCheckRadioBox8: TbsSkinDBCheckRadioBox; Edit4: TEdit; Edit5: TEdit; Edit6: TEdit; CheckBox1: TCheckBox; Edit7: TEdit; bsSkinDBComboBox1: TbsSkinDBComboBox; bsSkinLabel1: TbsSkinLabel; Label54: TLabel; RxDBLookupCombo31: TRxDBLookupCombo; Label55: TLabel; wwDBComboBox9: TwwDBComboBox; dxDBGrid1Column39: TdxDBGridColumn; dxDBGrid1Column41: TdxDBGridColumn; dxDBGrid1Column42: TdxDBGridColumn; Label56: TLabel; RxDBLookupCombo16: TRxDBLookupCombo; Label57: TLabel; RxDBLookupCombo17: TRxDBLookupCombo; Label73: TLabel; dxDBGrid1Column43: TdxDBGridColumn; dxDBGrid1Column44: TdxDBGridCheckColumn; bsSkinButton16: TbsSkinButton; t_op_seae2: TADOQuery; wwDBLookupCombo25: TwwDBLookupCombo; bsSkinButton17: TbsSkinButton; bsSkinButton19: 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 bsSkinButton9Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure t_op_seae_orderBeforeCancel(DataSet: TDataSet); procedure t_op_seae_orderPostError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure t_op_seae_orderBeforePost(DataSet: TDataSet); procedure t_ch_feeAfterInsert(DataSet: TDataSet); procedure t_ch_feeBeforePost(DataSet: TDataSet); procedure t_op_seae_orderBeforeEdit(DataSet: TDataSet); procedure bsSkinButton15Click(Sender: TObject); procedure DBEdit5Click(Sender: TObject); procedure wwDBLookupCombo1Change(Sender: TObject); procedure wwDBLookupCombo3Change(Sender: TObject); procedure wwDBLookupCombo5Change(Sender: TObject); procedure dxDBGrid1DblClick(Sender: TObject); procedure RxDBLookupCombo12Change(Sender: TObject); procedure RxDBLookupCombo1Enter(Sender: TObject); procedure RxDBLookupCombo8Enter(Sender: TObject); procedure RxDBLookupCombo1Exit(Sender: TObject); procedure RxDBLookupCombo8Exit(Sender: TObject); procedure RxDBLookupCombo4Change(Sender: TObject); procedure RxDBLookupCombo5Change(Sender: TObject); procedure RxDBLookupCombo6Change(Sender: TObject); procedure DBMemo40Change(Sender: TObject); procedure DBMemo41Change(Sender: TObject); procedure DBMemo42Change(Sender: TObject); procedure wwDBLookupCombo6Change(Sender: TObject); procedure wwDBLookupCombo7Change(Sender: TObject); procedure wwDBLookupCombo8Change(Sender: TObject); procedure wwDBLookupCombo6Exit(Sender: TObject); procedure wwDBLookupCombo7Exit(Sender: TObject); procedure wwDBLookupCombo8Exit(Sender: TObject); procedure N1Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure RxDBLookupCombo1Change(Sender: TObject); procedure t_ch_feeAfterOpen(DataSet: TDataSet); procedure t_ch_feeAfterPost(DataSet: TDataSet); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure dxDBGrid1Column9CustomDraw(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 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 wwDBLookupCombo52Change(Sender: TObject); procedure bsSkinButton21Click(Sender: TObject); procedure wwDBComboBox3DropDown(Sender: TObject); procedure wwDBComboBox4DropDown(Sender: TObject); procedure bsSkinPageControl2Change(Sender: TObject); procedure bsSkinButton18Click(Sender: TObject); procedure t_op_ctn_insertAfterInsert(DataSet: TDataSet); procedure wwDBComboBox3Change(Sender: TObject); procedure wwDBComboBox4Change(Sender: TObject); procedure RxDBLookupCombo19Change(Sender: TObject); procedure Button1Click(Sender: TObject); procedure RxDBLookupCombo31Change(Sender: TObject); procedure RxDBLookupCombo31Enter(Sender: TObject); procedure RxDBLookupCombo31Exit(Sender: TObject); procedure wwDBComboBox9DropDown(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure t_op_seaeBeforeRefresh(DataSet: TDataSet); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinButton19Click(Sender: TObject); private procedure t_billsalescharge(Sender: TField); procedure OpFeeItem(bsNo:string); function checkctn(aOR_ID:integer):Boolean; procedure t_ch_acceptdjoncharge(Sender: TField); procedure t_ch_paydjoncharge(Sender: TField); procedure getsumstr; { Private declarations } public { Public declarations } end; var frm_op_seae_weituo: Tfrm_op_seae_weituo; implementation uses u_main,u_data_share, my_sys_function, u_sys_progress, u_op_seae_apply_add, u_op_add_code, u_op_ctn, u_opor_ctn,u_op_seae_oder_add, u_op_seaewt_pladd, u_op_seae_oder_pladd; {$R *.dfm} procedure Tfrm_op_seae_weituo.getsumstr; var aQuery1,aQuery2:TAdoQuery; str1,str2:string; acceptstr,paystr:widestring; accepteof,payeof:boolean; armb,ausd,aot,atotal,prmb,pusd,pot,ptotal:double; begin //费用下部合计字符串生成 memo1.Lines.Clear; if (t_ch_accept.IsEmpty or (not t_ch_accept.Active)) and (t_ch_pay.IsEmpty or (not t_ch_pay.Active)) then exit; aQuery1:=CreateAdoQuery; aQuery2:=CreateAdoQuery; armb:=0; ausd:=0; aot:=0; atotal:=0; prmb:=0; pusd:=0; pot:=0; ptotal:=0; try accepteof:=false; payeof:=false; if (t_ch_accept.IsEmpty or (not t_ch_accept.Active)) then aQuery1.SQL.Text:='select 客户名称,sum(case 币别 when ''RMB'' then 金额 else 0 end) as 人民币金额,' +'sum(case 币别 when ''USD'' then 金额 else 0 end) as 美元金额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 金额 end) end) as 其他金额,' +'sum(金额*汇率) as 合计金额' +' from t_ch_fee where 1=2 group by 客户名称' else begin acceptstr:=new_query(t_ch_accept); aQuery1.SQL.Text:='select 客户名称,sum(case 币别 when ''RMB'' then 金额 else 0 end) as 人民币金额,' +'sum(case 币别 when ''USD'' then 金额 else 0 end) as 美元金额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 金额 end) end) as 其他金额,' +'sum(金额*汇率) as 合计金额' +' from t_ch_fee '+acceptstr+' group by 客户名称'; aQuery1.DataSource:=t_ch_accept.DataSource; end; aQuery1.Open; aQuery1.first; if (t_ch_pay.IsEmpty or (not t_ch_pay.Active)) then aQuery2.SQL.Text:='select 客户名称,sum(case 币别 when ''RMB'' then 金额 else 0 end) as 人民币金额,' +'sum(case 币别 when ''USD'' then 金额 else 0 end) as 美元金额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 金额 end) end) as 其他金额,' +'sum(金额*汇率) as 合计金额' +' from t_ch_fee where 1=2 group by 客户名称' else begin paystr:=new_query(t_ch_pay); aQuery2.SQL.Text:='select 客户名称,sum(case 币别 when ''RMB'' then 金额 else 0 end) as 人民币金额,' +'sum(case 币别 when ''USD'' then 金额 else 0 end) as 美元金额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 金额 end) end) as 其他金额,' +'sum(金额*汇率) as 合计金额' +' from t_ch_fee '+paystr+' group by 客户名称'; aQuery2.DataSource:=t_ch_pay.DataSource; end; aQuery2.Open; aQuery2.first; while (not aQuery1.Eof) or (not aQuery2.Eof) do begin if aQuery1.Eof then begin str1:=FixLenStr('',72); end else begin str1:=FixLenStr(aQuery1.fieldbyname('客户名称').AsString,20)+' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('人民币金额').Asfloat),12,' ',false) +' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('美元金额').Asfloat),12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('其他金额').Asfloat),12,' ',false) +' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('合计金额').Asfloat),12,' ',false); armb:=armb+aquery1.fieldbyname('人民币金额').AsFloat; ausd:=ausd+aquery1.fieldbyname('美元金额').AsFloat; aot:=aot+aquery1.fieldbyname('其他金额').AsFloat; atotal:=atotal+aquery1.fieldbyname('合计金额').AsFloat; aQuery1.Next; end; if aQuery2.Eof then begin str2:=FixLenStr('',72); end else begin str2:=FixLenStr(aQuery2.fieldbyname('客户名称').AsString,20)+' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('人民币金额').Asfloat),12,' ',false) +' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('美元金额').Asfloat),12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('其他金额').Asfloat),12,' ',false) +' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('合计金额').Asfloat),12,' ',false); prmb:=prmb+aquery2.fieldbyname('人民币金额').AsFloat; pusd:=pusd+aquery2.fieldbyname('美元金额').AsFloat; pot:=pot+aquery2.fieldbyname('其他金额').AsFloat; ptotal:=ptotal+aquery2.fieldbyname('合计金额').AsFloat; aQuery2.Next; end; memo1.Lines.Add(str1+'|'+str2); end; str1:=FixLenStr('-',72,'-'); str2:=FixLenStr('-',72,'-'); memo1.Lines.Add(str1+'|'+str2); str1:=FixLenStr('应收合计',20)+' '+FixLenStr(FormatFloat('#,##0.00',armb),12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',ausd),12,' ',false) +' '+FixLenStr(FormatFloat('#,##0.00',aot),12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',atotal),12,' ',false); str2:=FixLenStr('应付合计',20)+' '+FixLenStr(FormatFloat('#,##0.00',prmb),12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',pusd),12,' ',false) +' '+FixLenStr(FormatFloat('#,##0.00',pot),12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',ptotal),12,' ',false); memo1.Lines.Add(str1+'|'+str2); str1:=FixLenStr('-',72,'-'); str2:=FixLenStr('-',72,'-'); memo1.Lines.Add(str1+'|'+str2); str1:=FixLenStr('利润合计:',20)+' '+FixLenStr('人民币利润:',12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',armb-prmb),12,' ',false) +' '+FixLenStr('美元利润:',12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',ausd-pusd),12,' ',false); str2:=FixLenStr('',19)+' '+FixLenStr('其他币别利润:',13,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',aot-pot),12,' ',false) +' '+FixLenStr('合计利润:',12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',atotal-ptotal),12,' ',false); if if_open('226') then memo1.Lines.Add(str1+'|'+str2); if if_open('319') then memo1.Lines.Add(str1+'|'+str2); finally freeandnil(aQuery1); freeandnil(aQuery2); end; if memo1.Lines.Count>0 then begin str1:=FixLenStr('应收客户',20)+' '+FixLenStr('应收人民币',12,' ',false)+' '+FixLenStr('应收美元',12,' ',false)+' '+FixLenStr('应收其他',12,' ',false)+' '+FixLenStr('应收合计',12,' ',false); str2:=FixLenStr('应付客户',20)+' '+FixLenStr('应付人民币',12,' ',false)+' '+FixLenStr('应付美元',12,' ',false)+' '+FixLenStr('应付其他',12,' ',false)+' '+FixLenStr('应付合计',12,' ',false); Memo1.Lines.Insert(0,str1+'|'+str2); end; end; procedure Tfrm_op_seae_weituo.t_ch_acceptdjoncharge(Sender: TField); begin if (t_ch_fee.state=dsedit)or(t_ch_fee.state=dsinsert)then begin if (t_ch_fee.fieldbyname('应收单价').asfloat<>0) and (t_ch_fee.fieldbyname('应收数量').asfloat<>0)then t_ch_fee['应收金额']:=s_w(strtoint(apointnum),t_ch_fee.fieldbyname('应收单价').asfloat*t_ch_fee.fieldbyname('应收数量').asfloat); end; end; procedure Tfrm_op_seae_weituo.t_ch_paydjoncharge(Sender: TField); begin if (t_ch_fee.state=dsedit)or(t_ch_fee.state=dsinsert)then begin if (t_ch_fee.fieldbyname('应付单价').asfloat<>0) and (t_ch_fee.fieldbyname('应付数量').asfloat<>0)then t_ch_fee['应付金额']:=s_w(strtoint(apointnum),t_ch_fee.fieldbyname('应付单价').asfloat*t_ch_fee.fieldbyname('应付数量').asfloat); end; end; procedure Tfrm_op_seae_weituo.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_weituo.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); frm_op_seae_weituo.Hide; frm_op_seae_weituo.ManualFloat(frm_op_seae_weituo.BoundsRect ); frm_main.freeTabs('frm_op_seae_weituo'); action:=cafree; frm_op_seae_weituo:=nil; end; procedure Tfrm_op_seae_weituo.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/13); bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; bsSkinButton11.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; bsSkinButton38.Width:=i; bsSkinButton16.Width:=i; bsSkinButton19.Width:=i; bsSkinButton17.Width:=i; end; procedure Tfrm_op_seae_weituo.bsSkinButton7Click(Sender: TObject); begin table_Prior(t_op_seae_order); end; procedure Tfrm_op_seae_weituo.bsSkinButton6Click(Sender: TObject); begin table_next(t_op_seae_order); end; procedure Tfrm_op_seae_weituo.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_fee); table_post(t_op_seae_order); end; procedure Tfrm_op_seae_weituo.bsSkinButton9Click(Sender: TObject); begin sys_print('海运出口订舱卡',2,t_op_seae_order1,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_weituo.bsSkinButton11Click(Sender: TObject); begin table_before_post(t_op_seae_order,'录入日期'); table_before_post(t_op_seae_order,'委托单位'); table_before_post(t_op_seae_order,'揽货人'); table_before_post(t_op_seae_order,'付费方式'); table_before_post(t_op_seae_order,'录入日期'); table_before_post(t_op_seae_order,'装货港'); table_before_post(t_op_seae_order,'卸货港'); table_before_post(t_op_seae_order,'目的地'); //// if t_op_seae_order.State in [dsedit,dsinsert] then t_op_seae_order.post; { if t_op_seae_order.FieldByName('香港付费').AsBoolean and (Trim(t_op_seae_order.FieldByName('香港付费对象').AsString)='') then begin ShowMessage('香港付费对象不能为空'); exit; end; } if Trim(t_op_seae_order.FieldByName('业务来源').AsString)='' then begin ShowMessage('业务来源不能为空'); exit; end; if Trim(t_op_seae_order.FieldByName('业务来源').AsString)='Sales' then begin if Trim(t_op_seae_order.FieldByName('来源明细').AsString)='' then begin ShowMessage('来源明细不能为空'); exit; end; end; if strtobool(get_parameters_value(161,'false')) then begin if t_op_seae_order.IsEmpty or (Trim(t_op_seae_order.FieldByName('订舱编号').AsString)='') then begin ShowMessage('委托编号'); exit; end; t_op_seae_order.edit; if t_op_seae_order.FieldByName('状态').AsString='驳回订舱' then begin t_op_seae_order.FieldByName('状态').AsString:='驳回提交'; t_op_seae_order.post; end else begin t_op_seae_order.FieldByName('状态').AsString:='提交审核'; t_op_seae_order.post; // Send_saleorder_shen('销售订舱提交审核,委托编号:'+t_op_seae_order.FieldByName('订舱编号').AsString,employee) end; end else begin if t_op_seae_order=nil then exit; if IsSeaeOrder(t_op_seae_order.fieldbyname('订舱编号').AsString) then begin MessageDlg('已经生成委托,不需要确认,请刷新!', mtConfirmation, [mbYes],0); exit; end; try frm_op_seae_order_add:=tfrm_op_seae_order_add.Create (self); frm_op_seae_order_add.data1.Enabled:=false; frm_op_seae_order_add.data1.DataSet:=t_op_seae; frm_op_seae_order_add.data1.Enabled:=true; frm_op_seae_order_add.data2.Enabled:=false; frm_op_seae_order_add.data2.DataSet:=t_op_seae_order; frm_op_seae_order_add.data2.Enabled:=true; frm_op_seae_order_add.data3.Enabled:=false; frm_op_seae_order_add.data3.DataSet:=t_op_ctn_insert; frm_op_seae_order_add.data3.Enabled:=true; frm_op_seae_order_add.data4.Enabled:=false; frm_op_seae_order_add.data4.DataSet:=t_op_fee; frm_op_seae_order_add.data4.Enabled:=true; frm_op_seae_order_add.data5.Enabled:=false; frm_op_seae_order_add.data5.DataSet:=t_ch_fee; frm_op_seae_order_add.data5.Enabled:=true; frm_op_seae_order_add.ShowModal; finally frm_op_seae_order_add.Free; frm_op_seae_order_add:=nil; end; end; end; procedure Tfrm_op_seae_weituo.bsSkinButton4Click(Sender: TObject); begin if not t_ch_fee.IsEmpty then begin showmessage('对不起业务存在费用信息,不能删除!!'); exit; end; table_delete(t_op_seae_order); end; procedure Tfrm_op_seae_weituo.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_seae_order); end; procedure Tfrm_op_seae_weituo.bsSkinButton38Click(Sender: TObject); var book1:Tbookmark; begin book1:=t_op_seae_order.GetBookmark; t_op_seae_order.Requery; t_op_seae_order.GotoBookmark(book1); end; procedure Tfrm_op_seae_weituo.OpFeeItem(bsno:string); begin if if_open('293') then begin if (strtobool(get_parameters_value(153,'false'))=true) then begin if (strtobool(get_parameters_value(64,'false'))=true) and (if_open('206')=false) then begin t_ch_accept.close; t_ch_accept.SQL.Clear; t_ch_accept.SQL.Add('select * from t_ch_fee where 类型=' +''''+'收'+''''+' and 编号='+''''+bsno+''''+ ' and (录入人=' +''''+employee+''''+' or (录入人<>'+''''+employee+'''' +' and 机密<>1) ) and '+open_data('7000','录入人','no','no','no','no') +' order by 顺序,CH_ID'); // t_ch_accept.Parameters.ParamByName('编号').Value:=bsno; t_ch_accept.open; end else begin t_ch_accept.close; t_ch_accept.SQL.Clear; t_ch_accept.SQL.Add('select * from t_ch_fee where 类型=' +''''+'收'+''''+' and 编号='+''''+bsno+''''+ ' and ' +open_data('7000','录入人','no','no','no','no') +' order by 顺序,CH_ID'); // t_ch_accept.Parameters.ParamByName('编号').Value:=bsno; t_ch_accept.open; end; end else begin if (strtobool(get_parameters_value(64,'false'))=true) and (if_open('206')=false) then begin t_ch_accept.close; t_ch_accept.SQL.Clear; t_ch_accept.SQL.Add('select * from t_ch_fee where 类型=' +''''+'收'+''''+' and 编号='+''''+bsno+''''+ ' and (录入人=' +''''+employee+''''+' or (录入人<>'+''''+employee+'''' +' and 机密<>1) ) order by 顺序,CH_ID'); t_ch_accept.Parameters.ParamByName('编号').Value:=bsno; // t_ch_accept.open; end; end; end; if if_open('294') then begin if (strtobool(get_parameters_value(153,'false'))=true) then begin if (strtobool(get_parameters_value(64,'false'))=true) and (if_open('206')=false) then begin t_ch_pay.close; t_ch_pay.SQL.Clear; t_ch_pay.SQL.Add('select * from t_ch_fee where 类型=' +''''+'付'+''''+' and 编号='+''''+bsno+''''+ ' and (录入人=' +''''+employee+''''+' or (录入人<>'+''''+employee+'''' +' and 机密<>1) ) and '+open_data('7000','录入人','no','no','no','no') +' order by 顺序,CH_ID'); // t_ch_pay.Parameters.ParamByName('编号').Value:=bsno; t_ch_pay.open; end else begin t_ch_pay.close; t_ch_pay.SQL.Clear; t_ch_pay.SQL.Add('select * from t_ch_fee where 类型=' +''''+'付'+''''+' and 编号='+''''+bsno+''''+ ' and ' +open_data('7000','录入人','no','no','no','no') +' order by 顺序,CH_ID'); // t_ch_pay.Parameters.ParamByName('编号').Value:=bsno; t_ch_pay.open; end; end else begin if (strtobool(get_parameters_value(64,'false'))=true) and (if_open('206')=false) then begin t_ch_pay.close; t_ch_pay.SQL.Clear; t_ch_pay.SQL.Add('select * from t_ch_fee where 类型=' +''''+'付'+''''+' and 编号='+''''+bsno+''''+ ' and (录入人=' +''''+employee+''''+' or (录入人<>'+''''+employee+'''' +' and 机密<>1) ) order by 顺序,CH_ID'); // t_ch_pay.Parameters.ParamByName('编号').Value:=bsno; t_ch_pay.open; end; end; end; end; procedure Tfrm_op_seae_weituo.FormShow(Sender: TObject); begin 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; bsSkinPageControl1.ActivePageIndex:=0; t_op_seae_order.Close; t_op_seae_order.SQL.clear; t_op_seae_order.SQL.Add('select * from t_op_seae_order where (状态=''新建订舱'' or 状态=''驳回订舱'') and ' +open_data('0021','揽货人','录入人','no','no','no') +' order by 录入日期'); t_op_seae_order.open; t_op_seae_order.FieldByName('揽货人').OnChange:=t_billsalescharge; t_op_seae_order.FieldByName('默认揽货人').OnChange:=t_billsalescharge; t_billsalescharge(nil); t_ch_fee.Open; t_op_seae.Close; t_op_seae.open; loadreggrid(dxdbgrid1,false,caption); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; wwDBDateTimePicker2.MinDate:=Date; if strtobool(get_parameters_value(161,'true')) then bsSkinButton11.Caption:='提交审核' else bsSkinButton11.Caption:='确认订舱'; if if_open('501') then bsSkinButton16.Visible:=True else bsSkinButton16.Visible:=false; end; procedure Tfrm_op_seae_weituo.t_op_seae_orderBeforeCancel(DataSet: TDataSet); begin delete_no(t_op_seae_order); end; procedure Tfrm_op_seae_weituo.t_op_seae_orderPostError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); var str:widestring; begin end; procedure Tfrm_op_seae_weituo.bsSkinButton10Click(Sender: TObject); var str:string; begin str:=' and '+open_data('0021','揽货人','录入人','no','no','no'); if Edit1.text<>''then str:=str+' and 订舱编号 like '+''''+'%'+Edit1.text+'%'+''''; if wwDBComboBox44.text<>''then str:=str+' and 状态='+''''+wwDBComboBox44.text+''''; if RxDBLookupCombo2.DisplayValues[1]<>''then str:=str+' and 委托单位='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; if RxDBLookupCombo3.DisplayValues[1]<>''then str:=str+' and 揽货人='+''''+RxDBLookupCombo3.DisplayValues[1]+''''; if RxDBLookupCombo16.DisplayValues[1]<>''then str:=str+' and 业务来源='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; if RxDBLookupCombo17.DisplayValues[1]<>''then str:=str+' and 来源明细='+''''+RxDBLookupCombo17.DisplayValues[1]+''''; if Edit3.text<>''then str:=str+' and 运费协议号 like '+''''+'%'+Edit3.text+'%'+''''; if wwDBDateTimePicker1.text<>''then str:=str+' and 开船日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker3.text<>''then str:=str+' and 开船日期<='+''''+wwDBDateTimePicker3.text+''''; if wwDBDateTimePicker5.text<>''then str:=str+' and 录入日期>='+''''+wwDBDateTimePicker5.text+''''; if wwDBDateTimePicker6.text<>''then str:=str+' and 录入日期<='+''''+wwDBDateTimePicker6.text+''''; if bsSkinCheckRadioBox1.Checked then str:=str+' and 状态<>''已退舱'''; t_op_seae_order.Close; t_op_seae_order.SQL.clear; t_op_seae_order.SQL.Add('select * from t_op_seae_order where 1=1 ' +str +' order by 录入日期'); t_op_seae_order.open; end; procedure Tfrm_op_seae_weituo.bsSkinButton8Click(Sender: TObject); begin t_ch_fee.insert; end; procedure Tfrm_op_seae_weituo.bsSkinButton12Click(Sender: TObject); begin t_ch_fee.Post; end; procedure Tfrm_op_seae_weituo.bsSkinButton13Click(Sender: TObject); begin table_delete(t_ch_fee); end; procedure Tfrm_op_seae_weituo.bsSkinButton14Click(Sender: TObject); begin table_cancel(t_ch_fee); end; procedure Tfrm_op_seae_weituo.t_op_seae_orderBeforePost(DataSet: TDataSet); var aQuery:TADOQuery; begin if not checkctn( t_op_seae_order.FieldByName('OR_ID').AsInteger) then begin ShowMessage('集装箱信息不正确!不能继续!'); Abort; end; table_before_post(t_op_seae_order,'录入日期'); table_before_post(t_op_seae_order,'委托单位'); table_before_post(t_op_seae_order,'揽货人'); table_before_post(t_op_seae_order,'付费方式'); table_before_post(t_op_seae_order,'业务来源'); table_before_post(t_op_seae_order,'录入日期'); table_before_post(t_op_seae_order,'船公司'); table_before_post(t_op_seae_order,'装货港'); table_before_post(t_op_seae_order,'航线'); table_before_post(t_op_seae_order,'卸货港'); table_before_post(t_op_seae_order,'目的地'); if ((t_op_seae_order.FieldByName('装运方式').AsString='拼箱单票') or (t_op_seae_order.FieldByName('装运方式').AsString='拼箱分票')) and (t_op_seae_order.FieldByName('集装箱').AsString<>'') then begin if MessageDlg('此票业务存在集装箱信息不能更改为拼箱单票,如想更改,集装箱信息将删除!',mtWarning,[mbyes,mbno],0)=mrno then Abort; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('delete from t_opor_ctn where OR_ID='''+t_op_seae_order.fieldbyname('OR_ID').AsString+''''); ExecSQL; end; finally FreeAndNil(aQuery); end; t_op_seae_order['集装箱']:=''; end; if Trim(frm_data_share.t_sys_noset.fieldbyname('日期规则').Asstring)='业务日期' then begin table_before_post(t_op_seae_order,'开船日期'); if t_op_seae_order.FieldByName('订舱编号').IsNull or (trim(t_op_seae_order['订舱编号'])='') then t_op_seae_order['订舱编号']:=getwtno(1,subComp,department,employee,t_op_seae_order['开船日期']); end else begin if t_op_seae_order.FieldByName('订舱编号').IsNull or (trim(t_op_seae_order['订舱编号'])='') then t_op_seae_order['订舱编号']:=getwtno(1,subComp,department,employee,t_op_seae_order.fieldbyname('录入日期').AsDateTime); end; end; procedure Tfrm_op_seae_weituo.t_ch_feeAfterInsert(DataSet: TDataSet); begin t_ch_fee['OR_ID']:=t_op_seae_order['OR_ID']; t_ch_fee['费用状态']:='录入状态'; t_ch_fee['应收单价']:=0; t_ch_fee['应收数量']:=0; t_ch_fee['应收金额']:=0; t_ch_fee['应付单价']:=0; t_ch_fee['应付数量']:=0; t_ch_fee['应付金额']:=0; if t_op_seae_order.FieldByName('委托单位').AsString<>'' then t_ch_fee.FieldByName('应收客户').AsString:=t_op_seae_order.FieldByName('委托单位').AsString; if t_op_seae_order.FieldByName('货代公司').AsString<>'' then t_ch_fee.FieldByName('应付客户').AsString:=t_op_seae_order.FieldByName('货代公司').AsString; end; procedure Tfrm_op_seae_weituo.t_ch_feeBeforePost(DataSet: TDataSet); begin if t_ch_fee.fieldbyname('费用名称').AsString='' then begin MessageDlg('费用名称不能为空!',mtWarning,[mbOk],0); abort; end; if (t_ch_fee.fieldbyname('应收单价').asfloat<>0) and (t_ch_fee.fieldbyname('应收数量').asfloat<>0) then begin t_ch_fee['应收金额']:= s_w(strtoint(apointnum),t_ch_fee.fieldbyname('应收单价').asfloat*t_ch_fee.fieldbyname('应收数量').asfloat); end; if (t_ch_fee.fieldbyname('应收金额').asfloat<>0) then begin if t_ch_fee.fieldbyname('应收币别').AsString='' then begin MessageDlg('应收币别不能为空!',mtWarning,[mbOk],0); abort; end; if t_ch_fee.fieldbyname('应收汇率').Asfloat=0 then begin MessageDlg('应收汇率不能为空!',mtWarning,[mbOk],0); abort; end; end; t_ch_fee['应收金额']:=s_w(strtoint(apointnum),t_ch_fee['应收金额']); if (t_ch_fee.fieldbyname('应付单价').asfloat<>0) and (t_ch_fee.fieldbyname('应付数量').asfloat<>0)then begin t_ch_fee['应付金额']:= s_w(strtoint(apointnum),t_ch_fee.fieldbyname('应付单价').asfloat*t_ch_fee.fieldbyname('应付数量').asfloat); end; if (t_ch_fee.fieldbyname('应付金额').asfloat<>0) then begin if t_ch_fee.fieldbyname('应付币别').AsString='' then begin MessageDlg('应付币别不能为空!',mtWarning,[mbOk],0); abort; end; if t_ch_fee.fieldbyname('应付汇率').Asfloat=0 then begin MessageDlg('应付汇率不能为空!',mtWarning,[mbOk],0); abort; end; end; t_ch_fee['应付金额']:=s_w(strtoint(apointnum),t_ch_fee['应付金额']); end; procedure Tfrm_op_seae_weituo.t_op_seae_orderBeforeEdit(DataSet: TDataSet); begin if (t_op_seae_order.FieldByName('录入人').AsString<>employee) and (t_op_seae_order.FieldByName('揽货人').AsString<>employee) then begin MessageDlg('只有自己的业务才能修改和删除!',mtWarning,[mbyes],0); abort; end; if t_op_seae_order.FieldByName('状态').AsString='接受订舱' then begin MessageDlg('已接受订舱不能修改!',mtWarning,[mbyes],0); abort; end; if t_op_seae_order.FieldByName('状态').AsString='已退舱' then begin MessageDlg('已退舱不能修改!',mtWarning,[mbyes],0); abort; end; if t_op_seae_order.FieldByName('状态').AsString='审核通过' then begin MessageDlg('已退舱不能修改!',mtWarning,[mbyes],0); abort; end; if t_op_seae_order.State in [dsedit,dsinsert] then t_op_seae_order.post; end; procedure Tfrm_op_seae_weituo.bsSkinButton15Click(Sender: TObject); begin Edit1.text:=''; wwDBComboBox44.text:=''; RxDBLookupCombo2.ClearValue; RxDBLookupCombo3.ClearValue; wwDBDateTimePicker1.text:=''; wwDBDateTimePicker3.text:=''; wwDBDateTimePicker5.text:=''; wwDBDateTimePicker6.text:=''; end; procedure Tfrm_op_seae_weituo.DBEdit5Click(Sender: TObject); begin if (t_op_seae_order.State=dsinsert)then t_op_seae_order.post; if t_op_seae_order.IsEmpty then exit; if (t_op_seae_order.fieldbyname('装运方式').asstring='拼箱分票') or (t_op_seae_order.fieldbyname('装运方式').asstring='拼箱单票')then exit; try frm_opor_ctn:=tfrm_opor_ctn.Create (self); frm_opor_ctn.t_op_ctn.DataSource:=t_op_seae_order1; frm_opor_ctn_type:=true; frm_opor_ctn.ShowModal; finally frm_opor_ctn.Free; end; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo1Change(Sender: TObject); var aAdoQuery:TAdoQuery; begin try aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin Close;SQL.Clear; SQL.Add('select Top 1 表现形式,数量 from t_opor_ctn'); SQL.Add('where OR_ID=:OR_ID'); Parameters.ParamByName('OR_ID').Value:=t_op_seae_order.fieldbyname('OR_ID').asinteger; open; end; if (t_ch_fee.state=dsinsert)or(t_ch_fee.state=dsedit) then begin if not frm_data_share.t_code_fee.IsEmpty then if frm_data_share.t_code_fee.locate('代码',wwDBLookupCombo1.text,[]) then begin t_ch_fee['应收币别']:=frm_data_share.t_code_fee.fieldbyname('默认币别').asstring; t_ch_fee['应付币别']:=frm_data_share.t_code_fee.fieldbyname('默认币别').asstring; if frm_data_share.t_code_fee.fieldbyname('标准').asstring='箱量' then begin if not aAdoQuery.IsEmpty then begin t_ch_fee['应收标准']:=aAdoQuery.fieldByName('表现形式').asstring; t_ch_fee['应收数量']:=aAdoQuery.fieldByName('数量').asinteger; t_ch_fee['应付标准']:=aAdoQuery.fieldByName('表现形式').asstring; t_ch_fee['应付数量']:=aAdoQuery.fieldByName('数量').asinteger; end; end else begin t_ch_fee['应收标准']:=frm_data_share.t_code_fee.fieldbyname('标准').asstring; t_ch_fee['应付标准']:=frm_data_share.t_code_fee.fieldbyname('标准').asstring; end; end; end; finally aAdoQuery.Free; end; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo3Change(Sender: TObject); begin if (t_ch_fee.state=dsinsert)or(t_ch_fee.state=dsedit) then begin IF frm_data_share.t_code_currency.Locate('币别',wwDBLookupCombo3.text,[])THEN begin if wwDBLookupCombo3.text='USD' then begin t_ch_fee['应收汇率']:=getUsdExRate(t_ch_fee.datasource.dataset.fieldbyname('录入日期').asstring); end else t_ch_fee['应收汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo5Change(Sender: TObject); begin if (t_ch_fee.state=dsinsert)or(t_ch_fee.state=dsedit) then begin IF frm_data_share.t_code_currency.Locate('币别',wwDBLookupCombo5.text,[])THEN begin if wwDBLookupCombo5.text='USD' then begin t_ch_fee['应付汇率']:=getUsdExRate(t_ch_fee.datasource.dataset.fieldbyname('录入日期').asstring); end else t_ch_fee['应付汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; procedure Tfrm_op_seae_weituo.dxDBGrid1DblClick(Sender: TObject); begin bsSkinPageControl1.ActivePageIndex:=1; end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo12Change(Sender: TObject); begin if RxDBLookupCombo12.DisplayValue='' then exit; if frm_data_share.t_sys_employee.locate('姓名',RxDBLookupCombo12.DisplayValue,[]) then begin t_op_seae_order['销售部门']:=frm_data_share.t_sys_employee['部门名称']; t_op_seae_order['业务来源']:=frm_data_share.t_sys_employee['业务来源']; t_op_seae_order['来源明细']:=frm_data_share.t_sys_employee['来源明细']; end; end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo1Enter(Sender: TObject); begin RxLookupComboEnter_All(RxDBLookupCombo1); end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo8Enter(Sender: TObject); begin RxLookupComboEnter(RxDBLookupCombo8); end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo1Exit(Sender: TObject); begin RxLookupComboExit(RxDBLookupCombo1); end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo8Exit(Sender: TObject); begin RxLookupComboExit(RxDBLookupCombo8); end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo4Change(Sender: TObject); begin if (t_op_seae_order.State=dsinsert)or(t_op_seae_order.State=dsedit)then begin if RxDBLookupCombo4.DisplayValue<>'' then t_op_seae_order['发货人代码']:=frm_data_share.t_crm_client_shiper.fieldbyname('快捷代码').asstring; end; end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo5Change(Sender: TObject); begin if (t_op_seae_order.State=dsinsert)or(t_op_seae_order.State=dsedit)then begin if RxDBLookupCombo5.DisplayValue<>'' then t_op_seae_order['收货人代码']:=frm_data_share.t_crm_client_shouhuo.fieldbyname('快捷代码').asstring; end; end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo6Change(Sender: TObject); begin if (t_op_seae_order.State=dsinsert)or(t_op_seae_order.State=dsedit)then begin if RxDBLookupCombo6.DisplayValue<>'' then t_op_seae_order['通知人代码']:=frm_data_share.t_crm_client_tongzhi.fieldbyname('快捷代码').asstring; end; end; procedure Tfrm_op_seae_weituo.DBMemo40Change(Sender: TObject); begin if (t_op_seae_order.state=dsedit)or(t_op_seae_order.state=dsinsert)then begin t_op_seae_order['件数']:=total_num(DBMemo40); t_op_seae_order['包装']:=total_package(dbmemo40); t_op_seae_order['件数大写'] :='SAY:'+ntoc(t_op_seae_order.FieldByName('件数').asfloat,true) +t_op_seae_order.FieldByName('包装').asstring+' ONLY.'; end; end; procedure Tfrm_op_seae_weituo.DBMemo41Change(Sender: TObject); begin if (t_op_seae_order.state=dsedit)or(t_op_seae_order.state=dsinsert)then begin t_op_seae_order['重量']:=total_num(DBMemo41); end; end; procedure Tfrm_op_seae_weituo.DBMemo42Change(Sender: TObject); begin if (t_op_seae_order.state=dsedit)or(t_op_seae_order.state=dsinsert)then begin t_op_seae_order['尺码']:=total_num(DBMemo42); end; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo6Change(Sender: TObject); begin if frm_data_share.t_code_code.locate('代码',wwDBLookupCombo6.text,[]) then begin t_op_seae_order.edit; t_op_seae_order['发货人代码']:=frm_data_share.t_code_code.fieldbyname('内容').asstring; end; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo7Change(Sender: TObject); begin if frm_data_share.t_code_code.locate('代码',wwDBLookupCombo7.text,[]) then begin t_op_seae_order.edit; t_op_seae_order['收货人代码']:=frm_data_share.t_code_code.fieldbyname('内容').asstring; end; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo8Change(Sender: TObject); begin if frm_data_share.t_code_code.locate('代码',wwDBLookupCombo8.text,[]) then begin t_op_seae_order.edit; t_op_seae_order['通知人代码']:=frm_data_share.t_code_code.fieldbyname('内容').asstring; end; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo6Exit(Sender: TObject); begin wwDBLookupCombo6.Clear; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo7Exit(Sender: TObject); begin wwDBLookupCombo7.Clear; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo8Exit(Sender: TObject); begin wwDBLookupCombo8.Clear; end; procedure Tfrm_op_seae_weituo.N1Click(Sender: TObject); begin t_op_seae_order.Insert; t_op_seae_order['揽货人']:=employee; t_op_seae_order['录入人']:=employee; t_op_seae_order['录入日期']:=date; t_op_seae_order['销售部门']:=department; t_op_seae_order['状态']:='新建订舱'; t_op_seae_order['装运方式']:='整箱'; t_op_seae_order['报关服务']:=0; t_op_seae_order['报验服务']:=0; t_op_seae_order['拖车服务']:=0; t_op_seae_order['接货服务']:=0; t_op_seae_order['分单']:=0; t_op_seae_order['代理']:=0; t_op_seae_order['请求派车']:=0; t_op_seae_order['是否退佣']:=0; t_op_seae_order['是否美金结算']:=0; t_op_seae_order['箱型1']:=0; t_op_seae_order['箱型2']:=0; t_op_seae_order['箱型3']:=0; t_op_seae_order['箱型4']:=0; t_op_seae_order['箱型5']:=0; t_op_seae_order['箱型6']:=0; t_op_seae_order['箱型7']:=0; t_op_seae_order['箱型8']:=0; t_op_seae_order['箱型9']:=0; t_op_seae_order['箱型10']:=0; t_op_seae_order['其他箱型']:=0; t_op_seae_order['箱TEU']:=0; t_op_seae_order['集装箱']:=''; t_op_seae_order['箱数大写']:=''; t_op_seae_order['装货港']:=get_parameters_value(14,'QINGDAO,CHINA'); t_op_seae_order['应收海运费']:=0; t_op_seae_order['应付海运费']:=0; t_op_seae_order['船公司代理费']:=0; t_op_seae_order['捷丰代理费']:=0; t_op_seae_order['香港付费']:=0; if frm_data_share.t_sys_employee.Locate('姓名',employee,[]) then begin t_op_seae_order['业务来源']:=frm_data_share.t_sys_employee.fieldbyname('业务来源').AsString; t_op_seae_order['来源明细']:=frm_data_share.t_sys_employee.fieldbyname('来源明细').AsString; end; t_op_seae_order['操作员']:=''; t_op_seae_order['客服员']:=''; bsSkinPageControl1.ActivePageIndex:=1; end; procedure Tfrm_op_seae_weituo.bsSkinButton1Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton1.ClientToScreen(Point(0,bsSkinButton1.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; function Tfrm_op_seae_weituo.checkctn(aOR_ID:integer):Boolean; var aQuery:TAdoQuery; begin Result:=True; aQuery:=CreateAdoQuery; with aQuery do begin close;sql.clear; sql.Add('select a.表现形式 as opor表现 ,b.表现形式 from t_opor_ctn a inner join t_code_ctn b on a.代码=b.代码 where a.OR_ID='+inttostr(aOR_ID)); open; end; aQuery.First; while not aQuery.Eof do begin if aQuery.FieldByName('opor表现').AsString<> aQuery.FieldByName('表现形式').AsString then begin Result:=False; Break; end; aQuery.Next; end; end; procedure Tfrm_op_seae_weituo.N3Click(Sender: TObject); var afield,afieldfee : variant; aOR_ID:integer; aQuery:TAdoQuery; i:integer; s:string; begin if t_op_seae_order.IsEmpty then begin exit; MessageDlg('没有复制的信息,不能复制添加!',mtWarning,[mbok],0); end; afield := vararraycreate([0,t_op_seae_order.fieldcount-1],varvariant); for i := 0 to (t_op_seae_order.fieldcount-1) do begin afield[i] :=t_op_seae_order.fields[i].value ; end; aOR_ID:=t_op_seae_order.fieldbyname('OR_ID').AsInteger; if not checkctn(aOR_ID) then begin ShowMessage('集装箱信息不正确!不能继续!'); Exit; end; s:=t_op_seae_order.fieldbyname('集装箱').AsString; t_op_seae_order.append; for i := 0 to (t_op_seae_order.fieldcount-1) do begin if t_op_seae_order.fields[i].FieldName<>'OR_ID' then t_op_seae_order.fields[i].value := afield[i] ; end; t_op_seae_order['揽货人']:=employee; t_op_seae_order['录入人']:=employee; t_op_seae_order['录入日期']:=date; t_op_seae_order['开船日期']:=date; t_op_seae_order['海运费']:=0; t_op_seae_order['销售部门']:=department; t_op_seae_order['状态']:='新建订舱'; t_op_seae_order['驳回原因']:=''; t_op_seae_order['驳回原因']:=''; t_op_seae_order['订舱编号']:=''; t_op_seae_order['开船日期']:=null; t_op_seae_order['状态']:='新建订舱'; t_op_seae_order['编号']:=''; t_op_seae_order['业务编号']:=''; t_op_seae_order['提交人']:=''; t_op_seae_order['提交时间']:=null; t_op_seae_order['审核人']:=''; t_op_seae_order['审核时间']:=null; t_op_seae_order['主提单号']:=''; if frm_data_share.t_sys_employee.Locate('姓名',employee,[]) then begin t_op_seae_order['业务来源']:=frm_data_share.t_sys_employee.fieldbyname('业务来源').AsString; t_op_seae_order['来源明细']:=frm_data_share.t_sys_employee.fieldbyname('来源明细').AsString; end; t_op_seae_order['操作员']:=''; t_op_seae_order['客服员']:=''; t_op_seae_order.Post; bsSkinPageControl1.ActivePageIndex:=1; aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.Add('select * from t_opor_ctn where OR_ID='+inttostr(aOR_ID)); 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.fieldbyname('代码').AsString:=aQuery.fieldbyname('代码').AsString; t_op_ctn.fieldbyname('尺寸').AsString:=aQuery.fieldbyname('尺寸').AsString; t_op_ctn.fieldbyname('箱型').AsString:=aQuery.fieldbyname('箱型').AsString; t_op_ctn.fieldbyname('数量').Asinteger:=aQuery.fieldbyname('数量').Asinteger; t_op_ctn.fieldbyname('TEU').Asinteger:=aQuery.fieldbyname('TEU').Asinteger; t_op_ctn.fieldbyname('件数').Asinteger:=aQuery.fieldbyname('件数').Asinteger; t_op_ctn.fieldbyname('重量').Asfloat:=aQuery.fieldbyname('重量').Asfloat; t_op_ctn.fieldbyname('尺码').Asfloat:=aQuery.fieldbyname('尺码').Asfloat; t_op_ctn.fieldbyname('表现形式').AsString:=aQuery.fieldbyname('表现形式').AsString; t_op_ctn.fieldbyname('箱号').AsString:=aQuery.fieldbyname('箱号').AsString; t_op_ctn.fieldbyname('封号').AsString:=aQuery.fieldbyname('封号').AsString; t_op_ctn.fieldbyname('包装').AsString:=aQuery.fieldbyname('包装').AsString; t_op_ctn.fieldbyname('品名').AsString:=aQuery.fieldbyname('品名').AsString; t_op_ctn.fieldbyname('唛头').AsString:=aQuery.fieldbyname('唛头').AsString; t_op_ctn.fieldbyname('备注').AsString:=aQuery.fieldbyname('备注').AsString; t_op_ctn.Post; next; end; if Application.MessageBox('是否复制费用信息?','提示',MB_YESNO+ MB_ICONINFORMATION)=IDYES then begin close;sql.clear; sql.Add('select * from t_ch_orderfee where OR_ID='+inttostr(aOR_ID)); open; if not IsEmpty then begin first; while not eof do begin t_ch_fee.Insert; t_ch_fee.fieldbyname('费用名称').AsString:=aQuery.fieldbyname('费用名称').AsString; t_ch_fee.fieldbyname('应收标准').AsString:=aQuery.fieldbyname('应收标准').AsString; t_ch_fee.fieldbyname('应收币别').AsString:=aQuery.fieldbyname('应收币别').AsString; t_ch_fee.fieldbyname('应收单价').Asfloat:=aQuery.fieldbyname('应收单价').Asfloat; t_ch_fee.fieldbyname('应收数量').Asfloat:=aQuery.fieldbyname('应收数量').Asfloat; t_ch_fee.fieldbyname('应收金额').Asfloat:=aQuery.fieldbyname('应收金额').Asfloat; t_ch_fee.fieldbyname('应收汇率').Asfloat:=aQuery.fieldbyname('应收汇率').Asfloat; t_ch_fee.fieldbyname('应收客户').AsString:=aQuery.fieldbyname('应收客户').AsString; t_ch_fee.fieldbyname('应付标准').AsString:=aQuery.fieldbyname('应付标准').AsString; t_ch_fee.fieldbyname('应付币别').AsString:=aQuery.fieldbyname('应付币别').AsString; t_ch_fee.fieldbyname('应付单价').Asfloat:=aQuery.fieldbyname('应付单价').Asfloat; t_ch_fee.fieldbyname('应付数量').Asfloat:=aQuery.fieldbyname('应付数量').Asfloat; t_ch_fee.fieldbyname('应付金额').Asfloat:=aQuery.fieldbyname('应付金额').Asfloat; t_ch_fee.fieldbyname('应付汇率').Asfloat:=aQuery.fieldbyname('应付汇率').Asfloat; t_ch_fee.fieldbyname('应付客户').AsString:=aQuery.fieldbyname('应付客户').AsString; t_ch_fee.post; next; end; end; end; end; finally freeandnil(aQuery); end; t_op_seae_order.Edit; t_op_seae_order['开船日期']:=null; t_op_seae_order['状态']:='新建订舱'; t_op_seae_order['编号']:=''; t_op_seae_order['业务编号']:=''; t_op_seae_order['提交人']:=''; t_op_seae_order['提交时间']:=null; t_op_seae_order['审核人']:=''; t_op_seae_order['审核时间']:=null; t_op_seae_order['主提单号']:=''; // t_op_seae_order['集装箱']:=s; t_op_seae_order.post; end; procedure Tfrm_op_seae_weituo.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_seae_weituo.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_seae_weituo.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_seae_weituo.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,209); end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo1Change(Sender: TObject); begin if t_op_seae_order.State in [dsedit,dsinsert] then begin if frm_data_share.t_crm_client_weituo.Locate('客户简称',RxDBLookupCombo1.DisplayValues[1],[])then begin if frm_data_share.t_crm_client_weituo.fieldbyname('揽货人').asstring<>''then begin t_op_seae_order['默认揽货人']:=frm_data_share.t_crm_client_weituo.fieldbyname('揽货人').asstring; end else t_op_seae_order['默认揽货人']:=''; end; end; end; procedure Tfrm_op_seae_weituo.t_billsalescharge(Sender: TField); begin lblsales.Caption:=''; if (t_op_seae_order.FieldByName('揽货人').AsString<>'') and (t_op_seae_order.FieldByName('默认揽货人').AsString<>'') then if t_op_seae_order.FieldByName('揽货人').AsString<>t_op_seae_order.FieldByName('默认揽货人').AsString then begin lblsales.Caption:='注意:此委托单位的默认揽货人为'+t_op_seae_order.FieldByName('默认揽货人').AsString; end; end; procedure Tfrm_op_seae_weituo.t_ch_feeAfterOpen(DataSet: TDataSet); begin t_ch_fee.FieldByName('应收单价').OnChange:=t_ch_acceptdjoncharge; t_ch_fee.FieldByName('应收数量').OnChange:=t_ch_acceptdjoncharge; t_ch_fee.FieldByName('应付单价').OnChange:=t_ch_paydjoncharge; t_ch_fee.FieldByName('应付数量').OnChange:=t_ch_paydjoncharge; end; procedure Tfrm_op_seae_weituo.t_ch_feeAfterPost(DataSet: TDataSet); var aQuery:TAdOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.add('select sum(应收金额) as 应收金额 from t_ch_orderfee where 费用名称=''海运费'' and 应收金额<>0 and OR_ID='+DataSet.fieldbyname('OR_ID').AsString); open; if not IsEmpty then begin t_op_seae_order.Edit; t_op_seae_order.FieldByName('海运费').AsFloat:=fieldbyname('应收金额').AsFloat; t_op_seae_order.post; end else begin t_op_seae_order.Edit; t_op_seae_order.FieldByName('海运费').AsFloat:=0; t_op_seae_order.post; end; end; finally freeandnil(aQuery); end; end; procedure Tfrm_op_seae_weituo.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin table_post(t_ch_fee); table_post(t_op_seae_order); end; procedure Tfrm_op_seae_weituo.dxDBGrid1Column9CustomDraw(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 ANode.Strings[dxDBGrid1Column9.Index]='驳回订舱' then AColor:=clRed; if ANode.Strings[dxDBGrid1Column9.Index]='审核通过' then AColor:=clYellow; if ANode.Strings[dxDBGrid1Column9.Index]='接受订舱' then AColor:=clGreen; AFont.Color:=clblack; end; procedure Tfrm_op_seae_weituo.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 trim(ANode.Strings[dxDBGrid1Column9.Index])='已退舱' then begin AFont.Style:=AFont.Style+[fsStrikeOut]; AFont.Color:=clred; end; if trim(ANode.Strings[dxDBGrid1Column9.Index])='已推航次' then begin // AFont.Style:=AFont.Style+[fsStrikeOut]; AColor:=clFuchsia; end; if trim(ANode.Strings[dxDBGrid1Column9.Index])='已改港' then begin // AFont.Style:=AFont.Style+[fsStrikeOut]; AColor:=clYellow; end; end; procedure Tfrm_op_seae_weituo.wwDBLookupCombo52Change(Sender: TObject); begin if t_op_seae_order1.DataSet=nil then exit; if (t_op_seae_order1.DataSet.state=dsedit)or(t_op_seae_order1.DataSet.state=dsinsert)then begin if frm_data_share.t_code_disport.Locate('英文名',wwDBLookupCombo52.text,[]) then begin t_op_seae_order1.DataSet['目的地']:=wwDBLookupCombo52.text; end; end; end; procedure Tfrm_op_seae_weituo.bsSkinButton21Click(Sender: TObject); begin frm_main.view_momo(t_op_seae_order1,'备注'); end; procedure Tfrm_op_seae_weituo.wwDBComboBox3DropDown(Sender: TObject); var str_list:tstringlist; i:Integer; begin wwDBComboBox3.Items.Clear; wwDBComboBox3.Items.Add('单票'); wwDBComboBox3.Items.Add('尺码'); wwDBComboBox3.Items.Add('计费吨'); wwDBComboBox3.Items.Add('TEU'); str_list:=Tstringlist.Create(); try str_list.Text:=t_op_seae_order.fieldbyname('计费标准').asstring; for i:=0 to str_list.Count-1 do begin wwDBComboBox3.Items.Add(copy(str_list[i],pos('-',str_list[i])+1,length(str_list[i])+1-pos('-',str_list[i]))); end; finally freeandnil(str_list); end; end; procedure Tfrm_op_seae_weituo.wwDBComboBox4DropDown(Sender: TObject); var str_list:tstringlist; i:Integer; begin wwDBComboBox4.Items.Clear; wwDBComboBox4.Items.Add('单票'); wwDBComboBox4.Items.Add('尺码'); wwDBComboBox4.Items.Add('计费吨'); wwDBComboBox4.Items.Add('TEU'); str_list:=Tstringlist.Create(); try str_list.Text:=t_op_seae_order.fieldbyname('计费标准').asstring; for i:=0 to str_list.Count-1 do begin wwDBComboBox4.Items.Add(copy(str_list[i],pos('-',str_list[i])+1,length(str_list[i])+1-pos('-',str_list[i]))); end; finally freeandnil(str_list); end; end; procedure Tfrm_op_seae_weituo.bsSkinPageControl2Change(Sender: TObject); begin if bsSkinPageControl2.TabIndex=2 then begin if t_op_seae_order.IsEmpty then exit; { t_op_seae.Close; t_op_seae.Parameters.ParamByName('委托编号').Value:=t_op_seae_order.fieldbyName('订舱编号').AsString; t_op_seae.Open; } if Trim(t_op_seae_order.fieldbyName('编号').AsString)<>'' then begin OpFeeItem(t_op_seae_order.fieldbyName('编号').AsString); getsumstr; end; end; if bsSkinPageControl2.TabIndex=3 then begin if Trim(t_op_seae_order.fieldbyName('编号').AsString)<>'' then begin t_op_seae_act.SQL.Clear; t_op_seae_act.SQL.Add('select 收货人代码,发货人代码,通知人代码,货物描述,件数包装,件数,包装,货物重量,货物尺码,重量,尺码,付费方式,签单地点,运输条款 from t_op_seae'); t_op_seae_act.SQL.Add('where 编号=:编号'); t_op_seae_act.Parameters.ParamByName('编号').Value:=t_op_seae_order.fieldbyName('编号').AsString; t_op_seae_act.Open; end; end; end; procedure Tfrm_op_seae_weituo.bsSkinButton18Click(Sender: TObject); var aAdoQuery,aAdoQueryInsert:TAdoQuery; begin if t_op_seae=nil then exit; if t_op_seae_order=nil then exit; if t_ch_fee=nil then exit; if t_op_seae_order.fieldbyname('编号').AsString='' then begin MessageDlg('还没有生成订舱委托不能提交费用!', mtConfirmation, [mbYes],0); exit; end; if IsSeaeOrderStatus(t_op_seae_order.fieldbyname('编号').AsString) then begin MessageDlg('订舱委托费用已经费用封帐,不能提交费用!', mtConfirmation, [mbYes],0); exit; end; aAdoQuery:=CreateAdoQuery; aAdoQueryInsert:=CreateAdoQuery; with aAdoQuery do begin Close;SQL.Clear; SQL.Add('Update t_ch_orderfee set 费用状态=''审核通过'''); SQL.Add('where or_id='+t_op_seae_order.fieldbyname('or_id').AsString); end; with aAdoQueryInsert do begin Close;SQL.Clear; SQL.Add('Insert Into t_ch_fee (客户名称 ,类型 ,费用状态 ,费用名称 ,标准 ,单价 ,数量 ,金额 ,币别 ,汇率 ,录入人 ,结算金额 ,申请开票 ,开票金额 ,冲抵金额 ,申请金额 ,录入日期 ,是否对帐 ,是否垫付 ,不开发票 ,结算单位 ,顺序 ,机密 ,编号)'); SQL.Add('values (:客户名称,:类型,:费用状态,:费用名称,:标准,:单价,:数量,:金额,:币别,:汇率,:录入人,:结算金额,:申请开票,:开票金额,:冲抵金额,:申请金额,:录入日期,:是否对帐,:是否垫付,:不开发票,:结算单位,:顺序,:机密,:编号)'); end; frm_main.db.BeginTrans; try with t_ch_fee do begin First; while not Eof do begin if t_ch_fee.FieldByName('费用状态').AsString='录入状态' then begin if t_ch_fee.FieldByName('应付金额').AsFloat<>0 then begin aAdoQueryInsert.Close; aAdoQueryInsert.Parameters.ParamByName('客户名称').Value:=t_ch_fee.FieldByName('应付客户').AsString; aAdoQueryInsert.Parameters.ParamByName('类型').Value:='付'; aAdoQueryInsert.Parameters.ParamByName('费用状态').Value:='录入状态'; aAdoQueryInsert.Parameters.ParamByName('费用名称').Value:=t_ch_fee.FieldByName('费用名称').AsString; aAdoQueryInsert.Parameters.ParamByName('标准').Value:=t_ch_fee.FieldByName('应付标准').AsString; aAdoQueryInsert.Parameters.ParamByName('单价').Value:=t_ch_fee.FieldByName('应付单价').AsString; aAdoQueryInsert.Parameters.ParamByName('数量').Value:=t_ch_fee.FieldByName('应付数量').AsString; aAdoQueryInsert.Parameters.ParamByName('金额').Value:=t_ch_fee.FieldByName('应付金额').AsString; aAdoQueryInsert.Parameters.ParamByName('币别').Value:=t_ch_fee.FieldByName('应付币别').AsString; aAdoQueryInsert.Parameters.ParamByName('汇率').Value:=t_ch_fee.FieldByName('应付汇率').AsString; aAdoQueryInsert.Parameters.ParamByName('录入人').Value:=t_op_seae_order.FieldByName('揽货人').AsString; aAdoQueryInsert.Parameters.ParamByName('结算金额').Value:=0; aAdoQueryInsert.Parameters.ParamByName('申请开票').Value:=0; aAdoQueryInsert.Parameters.ParamByName('开票金额').Value:=0; aAdoQueryInsert.Parameters.ParamByName('冲抵金额').Value:=0; aAdoQueryInsert.Parameters.ParamByName('申请金额').Value:=0; aAdoQueryInsert.Parameters.ParamByName('录入日期').Value:=FormatDateTime('YYYY-MM-DD',now); aAdoQueryInsert.Parameters.ParamByName('是否对帐').Value:=0; aAdoQueryInsert.Parameters.ParamByName('是否垫付').Value:=0; aAdoQueryInsert.Parameters.ParamByName('不开发票').Value:=0; aAdoQueryInsert.Parameters.ParamByName('结算单位').Value:='货代公司'; aAdoQueryInsert.Parameters.ParamByName('顺序').Value:=0; aAdoQueryInsert.Parameters.ParamByName('机密').Value:=0; aAdoQueryInsert.Parameters.ParamByName('编号').Value:=t_op_seae_order.FieldByName('编号').AsString; aAdoQueryInsert.ExecSQL; end; if t_ch_fee.FieldByName('应收金额').AsFloat<>0 then begin aAdoQueryInsert.Close; aAdoQueryInsert.Parameters.ParamByName('客户名称').Value:=t_ch_fee.FieldByName('应收客户').AsString; aAdoQueryInsert.Parameters.ParamByName('类型').Value:='收'; aAdoQueryInsert.Parameters.ParamByName('费用状态').Value:='录入状态'; aAdoQueryInsert.Parameters.ParamByName('费用名称').Value:=t_ch_fee.FieldByName('费用名称').AsString; aAdoQueryInsert.Parameters.ParamByName('标准').Value:=t_ch_fee.FieldByName('应收标准').AsString; aAdoQueryInsert.Parameters.ParamByName('单价').Value:=t_ch_fee.FieldByName('应收单价').AsString; aAdoQueryInsert.Parameters.ParamByName('数量').Value:=t_ch_fee.FieldByName('应收数量').AsString; aAdoQueryInsert.Parameters.ParamByName('金额').Value:=t_ch_fee.FieldByName('应收金额').AsString; aAdoQueryInsert.Parameters.ParamByName('币别').Value:=t_ch_fee.FieldByName('应收币别').AsString; aAdoQueryInsert.Parameters.ParamByName('汇率').Value:=t_ch_fee.FieldByName('应收汇率').AsString; aAdoQueryInsert.Parameters.ParamByName('录入人').Value:=t_op_seae_order.FieldByName('揽货人').AsString; aAdoQueryInsert.Parameters.ParamByName('结算金额').Value:=0; aAdoQueryInsert.Parameters.ParamByName('申请开票').Value:=0; aAdoQueryInsert.Parameters.ParamByName('开票金额').Value:=0; aAdoQueryInsert.Parameters.ParamByName('冲抵金额').Value:=0; aAdoQueryInsert.Parameters.ParamByName('申请金额').Value:=0; aAdoQueryInsert.Parameters.ParamByName('录入日期').Value:=FormatDateTime('YYYY-MM-DD',now); aAdoQueryInsert.Parameters.ParamByName('是否对帐').Value:=0; aAdoQueryInsert.Parameters.ParamByName('是否垫付').Value:=0; aAdoQueryInsert.Parameters.ParamByName('不开发票').Value:=0; aAdoQueryInsert.Parameters.ParamByName('结算单位').Value:='货代公司'; aAdoQueryInsert.Parameters.ParamByName('顺序').Value:=0; aAdoQueryInsert.Parameters.ParamByName('机密').Value:=0; aAdoQueryInsert.Parameters.ParamByName('编号').Value:=t_op_seae_order.FieldByName('编号').AsString; aAdoQueryInsert.ExecSQL; end; end; Next; end; end; aAdoQuery.ExecSQL; frm_main.db.CommitTrans; finally aAdoQuery.Free; aAdoQueryInsert.Free; t_ch_fee.Requery(); if frm_main.db.InTransaction then begin frm_main.db.RollbackTrans; end; end; end; procedure Tfrm_op_seae_weituo.t_op_ctn_insertAfterInsert( DataSet: TDataSet); begin t_op_ctn_insert['编号']:=t_op_seae['编号']; end; procedure Tfrm_op_seae_weituo.wwDBComboBox3Change(Sender: TObject); var AAdoQuery : TADOQuery; begin AAdoQuery :=CreateAdoQuery; with AAdoQuery do try Close;SQL.Clear; SQL.Add('select * from t_opor_ctn'); SQL.Add('where OR_ID=:OR_ID'); SQL.Add('order by 代码'); Parameters.ParamByName('OR_ID').Value:=t_op_seae_order.fieldbyname('OR_ID').AsInteger; Open; if not AAdoQuery.IsEmpty then if AAdoQuery.Locate('表现形式',wwDBComboBox3.text,[])then begin if t_ch_fee.State in [dsedit,dsInsert] then t_ch_fee['应收数量']:=AAdoQuery.fieldbyname('数量').asfloat; end; finally AAdoQuery.Free; end; end; procedure Tfrm_op_seae_weituo.wwDBComboBox4Change(Sender: TObject); var AAdoQuery : TADOQuery; begin AAdoQuery :=CreateAdoQuery; with AAdoQuery do try Close;SQL.Clear; SQL.Add('select * from t_opor_ctn'); SQL.Add('where OR_ID=:OR_ID'); SQL.Add('order by 代码'); Parameters.ParamByName('OR_ID').Value:=t_op_seae_order.fieldbyname('OR_ID').AsInteger; Open; if not AAdoQuery.IsEmpty then if AAdoQuery.Locate('表现形式',wwDBComboBox4.text,[])then begin if t_ch_fee.State in [dsedit,dsInsert] then t_ch_fee['应付数量']:=AAdoQuery.fieldbyname('数量').asfloat; end; finally AAdoQuery.Free; end; end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo19Change(Sender: TObject); begin if (t_op_seae_order.State=dsinsert)or(t_op_seae_order.State=dsedit)then begin if RxDBLookupCombo19.DisplayValue<>'' then t_op_seae_order['代理内容']:=frm_data_share.t_crm_client_daili.fieldbyname('快捷代码').asstring; end; end; procedure Tfrm_op_seae_weituo.Button1Click(Sender: TObject); var aADOQuery :TADOQuery; begin if trim(Edit2.Text)='' then begin ShowMessage('订舱说明不能为空'); Exit; end; if trim(t_op_seae_order1.DataSet.fieldbyname('编号').AsString)='' then begin ShowMessage('单据没有流转到操作部门,直接编辑订舱说明就可以'); Exit; end; if not t_op_seae_order1.DataSet.fieldbyname('开船日期').IsNull then begin if (Date-t_op_seae_order1.DataSet.fieldbyname('开船日期').AsDateTime)>=3 then begin ShowMessage('已经开船不能修改'); Exit; end; end; aADOQuery:=CreateADOQuery; with aADOQuery do try Close;SQL.Clear; SQL.Add('Update t_op_seae set 销售订舱说明=:订舱说明'); SQL.Add(',应收海运费=:应收海运费,应付海运费=:应付海运费'); SQL.Add(',船公司代理费=:船公司代理费,捷丰代理费=:捷丰代理费'); SQL.Add(',香港付费=:香港付费'); SQL.Add('where 编号='+''''+t_op_seae_order1.DataSet.fieldbyname('编号').AsString+''''); Parameters.ParamByName('订舱说明').Value:=trim(Edit2.Text); Parameters.ParamByName('应收海运费').Value:=StrToFloat(Edit4.Text); Parameters.ParamByName('应付海运费').Value:=StrToFloat(Edit5.Text); Parameters.ParamByName('船公司代理费').Value:=StrToFloat(Edit6.Text); Parameters.ParamByName('捷丰代理费').Value:=StrToFloat(Edit7.Text); if CheckBox1.Checked then Parameters.ParamByName('香港付费').Value:=1 else Parameters.ParamByName('香港付费').Value:=0; ExecSQL; Close;SQL.Clear; SQL.Add('Update t_op_seae_order set 订舱说明=:订舱说明'); SQL.Add(',应收海运费=:应收海运费,应付海运费=:应付海运费'); SQL.Add(',船公司代理费=:船公司代理费,捷丰代理费=:捷丰代理费'); SQL.Add(',香港付费=:香港付费'); SQL.Add('where OR_ID=:OR_ID'); Parameters.ParamByName('订舱说明').Value:=trim(Edit2.Text); Parameters.ParamByName('OR_ID').Value:=t_op_seae_order1.DataSet.fieldbyname('OR_ID').Asinteger; Parameters.ParamByName('应收海运费').Value:=StrToFloat(Edit4.Text); Parameters.ParamByName('应付海运费').Value:=StrToFloat(Edit5.Text); Parameters.ParamByName('船公司代理费').Value:=StrToFloat(Edit6.Text); Parameters.ParamByName('捷丰代理费').Value:=StrToFloat(Edit7.Text); if CheckBox1.Checked then Parameters.ParamByName('香港付费').Value:=1 else Parameters.ParamByName('香港付费').Value:=0; ExecSQL; finally Free; end; end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo31Change(Sender: TObject); begin t_op_seae_order1.DataSet.FieldByName('来源明细').AsString:=''; end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo31Enter(Sender: TObject); begin RxDBLookupCombo31.LookupDisplay:='代码;业务来源'; end; procedure Tfrm_op_seae_weituo.RxDBLookupCombo31Exit(Sender: TObject); begin RxDBLookupCombo31.LookupDisplay:='业务来源'; end; procedure Tfrm_op_seae_weituo.wwDBComboBox9DropDown(Sender: TObject); var aQuery:TAdoQuery; begin wwDBComboBox9.Items.Clear; if t_op_seae_order1.DataSet.FieldByName('业务来源').AsString='' then begin exit; end; aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.Clear; sql.Add('select 来源明细 from t_code_source_dl where 业务来源='''+t_op_seae_order1.DataSet.FieldByName('业务来源').AsString+''' order by 来源明细 '); open; first; while not eof do begin wwDBComboBox9.Items.Add(FieldByName('来源明细').AsString); next; end; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_weituo.bsSkinButton16Click(Sender: TObject); var aQuery:TADOQuery; begin t_op_seae2.close; t_op_seae2.SQL.Text:='select * from t_op_seae where 编号='''+t_op_seae_order.fieldbyname('编号').AsString+''''; t_op_seae2.Open; if t_op_seae2.IsEmpty then begin ShowMessage('无相关业务,不能更新!'); end else begin if (t_op_seae2.FieldByName('费用状态').AsString='提交财务') or (t_op_seae2.FieldByName('费用状态').AsString='费用封帐') then begin ShowMessage('此票业务已提交财务或费用封帐,不能更新!'); end else begin t_op_seae2.Edit; t_op_seae2.FieldByName('香港付费').AsBoolean:=true; t_op_seae2.post; aQuery:=CreateAdoQuery; try aQuery.SQL.Text:='update t_op_seae_order set 香港付费=1 where 编号='''+t_op_seae_order.fieldbyname('编号').AsString+''''; aQuery.ExecSQL; finally FreeAndNil(aQuery); end; ShowMessage('已更新!'); end; end; end; procedure Tfrm_op_seae_weituo.t_op_seaeBeforeRefresh(DataSet: TDataSet); begin if not checkctn(t_op_seae_order.fieldbyname('OR_ID').AsInteger) then begin ShowMessage('集装箱信息不正确!不能保存 请检查'); Abort; end; end; procedure Tfrm_op_seae_weituo.bsSkinButton17Click(Sender: TObject); var aOR_ID:integer; begin if t_op_seae_order.IsEmpty then begin exit; MessageDlg('没有复制的信息,不能复制添加!',mtWarning,[mbok],0); end; aOR_ID:=t_op_seae_order.fieldbyname('OR_ID').AsInteger; if not checkctn(aOR_ID) then begin ShowMessage('集装箱信息不正确!不能继续!'); Exit; end; try frm_op_seaewt_pladd:=tfrm_op_seaewt_pladd.Create (self); frm_op_seaewt_pladd.data1.Enabled:=false; frm_op_seaewt_pladd.data1.DataSet:=t_op_seae_order; frm_op_seaewt_pladd.data1.Enabled:=true; frm_op_seaewt_pladd.ShowModal; finally frm_op_seaewt_pladd.Free; end; end; procedure Tfrm_op_seae_weituo.bsSkinButton19Click(Sender: TObject); begin table_before_post(t_op_seae_order,'录入日期'); table_before_post(t_op_seae_order,'委托单位'); table_before_post(t_op_seae_order,'揽货人'); table_before_post(t_op_seae_order,'付费方式'); table_before_post(t_op_seae_order,'录入日期'); table_before_post(t_op_seae_order,'装货港'); table_before_post(t_op_seae_order,'卸货港'); table_before_post(t_op_seae_order,'目的地'); if t_op_seae_order.State in [dsedit,dsinsert] then t_op_seae_order.post; if t_op_seae_order=nil then exit; if IsSeaeOrder(t_op_seae_order.fieldbyname('订舱编号').AsString) then begin MessageDlg('已经生成委托,不需要确认,请刷新!', mtConfirmation, [mbYes],0); exit; end; try frm_op_seae_order_pladd:=tfrm_op_seae_order_pladd.Create (self); frm_op_seae_order_pladd.data1.Enabled:=false; frm_op_seae_order_pladd.data1.DataSet:=t_op_seae; frm_op_seae_order_pladd.data1.Enabled:=true; frm_op_seae_order_pladd.data2.Enabled:=false; frm_op_seae_order_pladd.data2.DataSet:=t_op_seae_order; frm_op_seae_order_pladd.data2.Enabled:=true; frm_op_seae_order_pladd.data3.Enabled:=false; frm_op_seae_order_pladd.data3.DataSet:=t_op_ctn_insert; frm_op_seae_order_pladd.data3.Enabled:=true; frm_op_seae_order_pladd.data4.Enabled:=false; frm_op_seae_order_pladd.data4.DataSet:=t_op_fee; frm_op_seae_order_pladd.data4.Enabled:=true; frm_op_seae_order_pladd.data5.Enabled:=false; frm_op_seae_order_pladd.data5.DataSet:=t_ch_fee; frm_op_seae_order_pladd.data5.Enabled:=true; frm_op_seae_order_pladd.ShowModal; finally frm_op_seae_order_pladd.Free; frm_op_seae_order_pladd:=nil; end; end; end.