unit u_op_seae_order; 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, Menus, dxDBTLCl, dxGrClms, bsdbctrls, XPMenu, Grids, Wwdbigrd, Wwdbgrid, wwdbedit, Wwdotdot, Wwdbcomb; type Tfrm_op_seae_order = class(TForm) Panel2: TPanel; t_op_seae: TADOQuery; t_op_seae1: TDataSource; 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; t_op_ctn: TADOQuery; t_op_ctn1: TDataSource; t_op_seae_order1: TDataSource; t_op_seae_order: TADOQuery; t_ch_fee: TADOQuery; t_ch_fee1: TDataSource; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; 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; RxDBLookupCombo2: TRxDBLookupCombo; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; wwDBDateTimePicker5: TwwDBDateTimePicker; wwDBDateTimePicker6: TwwDBDateTimePicker; bsSkinButton10: TbsSkinButton; bsSkinButton15: TbsSkinButton; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinPanel1: TbsSkinPanel; Label19: TLabel; Label4: TLabel; Label2: TLabel; RxDBLookupCombo12: TRxDBLookupCombo; RxDBLookupCombo1: TRxDBLookupCombo; DBEdit2: TDBEdit; t_op_fee: TADOQuery; bsSkinPanel2: TbsSkinPanel; bsSkinButton7: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton38: TbsSkinButton; bsSkinButton5: TbsSkinButton; dxDBGrid1Column11: TdxDBGridColumn; bsSkinPageControl2: TbsSkinPageControl; tab1: TbsSkinTabSheet; bsSkinGroupBox1: TbsSkinGroupBox; Label15: TLabel; Label13: TLabel; Label35: TLabel; Label8: TLabel; Label12: TLabel; Label20: TLabel; Label11: TLabel; Label1: TLabel; wwDBDateTimePicker2: TwwDBDateTimePicker; DBEdit5: TDBEdit; RxDBLookupCombo28: TRxDBLookupCombo; bsSkinGroupBox5: TbsSkinGroupBox; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox3: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox4: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox5: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox9: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox6: TbsSkinDBCheckRadioBox; bsSkinGroupBox2: TbsSkinGroupBox; wwDBLookupCombo1: TwwDBLookupCombo; wwDBLookupCombo3: TwwDBLookupCombo; wwDBLookupCombo5: TwwDBLookupCombo; wwDBComboBox3: TwwDBComboBox; wwDBComboBox4: TwwDBComboBox; wwDBLookupCombo2: TwwDBLookupCombo; wwDBLookupCombo4: TwwDBLookupCombo; wwDBGrid1: TwwDBGrid; wwDBComboBox1: TwwDBComboBox; DBMemo1: TDBMemo; wwDBDateTimePicker7: TwwDBDateTimePicker; bsSkinDBCheckRadioBox7: TbsSkinDBCheckRadioBox; RxDBLookupCombo8: TRxDBLookupCombo; DBEdit1: TDBEdit; bsSkinGroupBox3: TbsSkinGroupBox; Label16: TLabel; Label17: TLabel; wwDBComboBox2: TwwDBComboBox; DBEdit3: TDBEdit; Label122: TLabel; Label121: TLabel; Label123: TLabel; Label21: TLabel; Label163: TLabel; Label165: TLabel; Label166: TLabel; Label167: TLabel; Label169: TLabel; Label170: TLabel; Label32: TLabel; Label27: TLabel; Label30: TLabel; DBMemo33: TDBMemo; RxDBLookupCombo4: TRxDBLookupCombo; wwDBLookupCombo6: TwwDBLookupCombo; RxDBLookupCombo5: TRxDBLookupCombo; wwDBLookupCombo7: TwwDBLookupCombo; DBMemo34: TDBMemo; DBMemo35: TDBMemo; RxDBLookupCombo6: TRxDBLookupCombo; wwDBLookupCombo8: TwwDBLookupCombo; DBMemo39: TDBMemo; DBMemo38: TDBMemo; DBMemo40: TDBMemo; DBMemo41: TDBMemo; DBMemo42: TDBMemo; wwDBLookupCombo61: TwwDBLookupCombo; DBEdit81: TDBEdit; DBEdit82: TDBEdit; DBEdit83: TDBEdit; wwDBLookupCombo21: TwwDBLookupCombo; DBEdit25: TDBEdit; RxDBLookupCombo15: TRxDBLookupCombo; Label22: TLabel; wwDBLookupCombo9: TwwDBLookupCombo; Label124: TLabel; wwDBLookupCombo52: TwwDBLookupCombo; bsSkinButton2: TbsSkinButton; dxDBGrid1Column12: TdxDBGridColumn; dxDBGrid1Column13: TdxDBGridColumn; lblsales: TLabel; Label23: TLabel; DBEdit4: TDBEdit; Label26: TLabel; wwDBDateTimePicker4: TwwDBDateTimePicker; Label24: TLabel; DBEdit6: TDBEdit; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridColumn; Label25: TLabel; RxDBLookupCombo7: TRxDBLookupCombo; dxDBGrid1Column17: TdxDBGridColumn; Label29: TLabel; wwDBComboBox5: TwwDBComboBox; dxDBGrid1Column18: TdxDBGridColumn; Label28: TLabel; wwDBLookupCombo10: TwwDBLookupCombo; dxDBGrid1Column19: TdxDBGridColumn; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; dxDBGrid1Column22: TdxDBGridColumn; dxDBGrid1Column23: TdxDBGridColumn; dxDBGrid1Column24: TdxDBGridColumn; dxDBGrid1Column25: TdxDBGridColumn; dxDBGrid1Column26: TdxDBGridColumn; dxDBGrid1Column27: TdxDBGridColumn; dxDBGrid1Column28: TdxDBGridColumn; dxDBGrid1Column29: TdxDBGridColumn; dxDBGrid1Column30: TdxDBGridColumn; Label33: TLabel; RxDBLookupCombo9: TRxDBLookupCombo; Label119: TLabel; wwDBComboBox8: TwwDBComboBox; Label109: TLabel; DBEdit37: TDBEdit; Label108: TLabel; DBEdit38: TDBEdit; dxDBGrid1Column31: TdxDBGridColumn; dxDBGrid1Column32: TdxDBGridColumn; dxDBGrid1Column33: TdxDBGridColumn; dxDBGrid1Column34: TdxDBGridColumn; DBEdit8: TDBEdit; Label34: TLabel; t_ch_fee_agentdc_detail: TADOQuery; t_ch_fee_agentdc: TADOQuery; Label31: TLabel; DBMemo3: TDBMemo; bsSkinTabSheet3: TbsSkinTabSheet; t_ch_accept1: TDataSource; t_ch_pay1: TDataSource; t_ch_accept: TADOQuery; t_ch_pay: TADOQuery; dxDBGrid3: TdxDBGrid; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGridColumn6: TdxDBGridColumn; dxDBGridColumn7: TdxDBGridColumn; dxDBGridColumn8: TdxDBGridColumn; dxDBGridColumn9: TdxDBGridColumn; dxDBGridColumn10: TdxDBGridColumn; dxDBGrid2: TdxDBGrid; dxDBGridColumn1: TdxDBGridColumn; dxDBGrid2Column2: TdxDBGridColumn; dxDBGrid2Column3: TdxDBGridColumn; dxDBGrid2Column4: TdxDBGridColumn; dxDBGrid2Column5: TdxDBGridColumn; dxDBGrid2Column6: TdxDBGridColumn; dxDBGrid2Column8: TdxDBGridColumn; dxDBGrid2Column9: TdxDBGridColumn; dxDBGrid2Column7: TdxDBGridColumn; Panel1: TPanel; Memo1: TMemo; t_op_seae_query: TADOQuery; bsSkinButton4: TbsSkinButton; RxDBLookupCombo3: TRxDBLookupCombo; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Panel2Resize(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure RxDBLookupCombo20KeyPress(Sender: TObject; var Key: Char); procedure t_op_ctnAfterPost(DataSet: TDataSet); procedure bsSkinButton15Click(Sender: TObject); procedure t_op_feeAfterInsert(DataSet: TDataSet); procedure t_op_ctnAfterInsert(DataSet: TDataSet); procedure dxDBGrid1DblClick(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); 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 t_ch_fee_agentdcAfterInsert(DataSet: TDataSet); procedure t_ch_fee_agentdc_detailAfterInsert(DataSet: TDataSet); procedure bsSkinPageControl2Change(Sender: TObject); procedure RxDBLookupCombo12Exit(Sender: TObject); procedure RxDBLookupCombo12Enter(Sender: TObject); private procedure t_billsalescharge(Sender: TField); procedure OpFeeItem(bsNo:string); procedure getsumstr; { Private declarations } public { Public declarations } end; var frm_op_seae_order: Tfrm_op_seae_order; implementation uses u_main,u_data_share, my_sys_function, u_sys_progress, u_op_seae_oder_add; {$R *.dfm} procedure Tfrm_op_seae_order.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_order.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_order.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); frm_op_seae_order.Hide; frm_op_seae_order.ManualFloat(frm_op_seae_order.BoundsRect ); frm_main.freeTabs('frm_op_seae_order'); action:=cafree; frm_op_seae_order:=nil; end; procedure Tfrm_op_seae_order.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/11); bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; bsSkinButton3.Width:=i; bsSkinButton38.Width:=i; end; procedure Tfrm_op_seae_order.bsSkinButton7Click(Sender: TObject); begin table_Prior(t_op_seae_order); end; procedure Tfrm_op_seae_order.bsSkinButton6Click(Sender: TObject); begin table_next(t_op_seae_order); end; procedure Tfrm_op_seae_order.bsSkinButton9Click(Sender: TObject); begin sys_print('海运出口订舱卡管理',2,t_op_seae1,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_order.bsSkinButton3Click(Sender: TObject); var str:string; begin if (t_op_seae_order['状态']='接受订舱') then begin MessageDlg('已经接受订舱不能驳回!', mtConfirmation, [mbYes],0); exit; end; str:=trim(InputBox('请输入驳回原因', '驳回原因:', '')); if str=''then begin showmessage('驳回原因不能为空,驳回失败!!'); exit; end else if str=''then begin exit; end; t_op_seae_order.Edit; t_op_seae_order['状态']:='驳回订舱'; t_op_seae_order['驳回原因']:=str; t_op_seae_order.Post; { Send_op_do('销售订舱驳回:委托编号:'+t_op_seae_order.fieldbyname('订舱编号').AsString,'72', '','',t_op_seae_order.fieldbyname('揽货人').AsString); } end; procedure Tfrm_op_seae_order.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_order.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; t_op_seae.Close; t_op_seae.open; t_op_seae_order.Close; t_op_seae_order.SQL.clear; t_op_seae_order.SQL.Add('select * from t_op_seae_order where 状态 in (''提交审核'',''审核通过'',''驳回提交'') and ' +open_data('0021','揽货人','no','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; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; loadreggrid(dxdbgrid1,false,caption); if if_open('330') then begin bsSkinButton1.Visible:=true; bsSkinButton2.Visible:=false; end else begin bsSkinButton1.Visible:=false; bsSkinButton2.Visible:=true; end; { if frm_data_share.t_code_ctn.locate('代码',trim(frm_data_share.t_code_ctn_de.fieldbyname('箱型1').asstring),[]) then dxdbgrid1.ColumnByFieldName('箱量1').Caption:= trim(frm_data_share.t_code_ctn.fieldbyname('表现形式').asstring); } 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; end; procedure Tfrm_op_seae_order.bsSkinButton1Click(Sender: TObject); begin if t_op_seae=nil then exit; if t_op_seae_order=nil then exit; if IsSeaeOrder(t_op_seae_order.fieldbyname('订舱编号').AsString) then begin MessageDlg('已经生成委托,不需要确认,请刷新!', mtConfirmation, [mbYes],0); exit; end; if (t_op_seae_order['状态']<>'提交审核') and (t_op_seae_order['状态']<>'驳回提交') and (t_op_seae_order['状态']<>'审核通过') then begin MessageDlg('当前状态:'+t_op_seae_order.FieldByName('状态').AsString+'不能接受订舱!', mtConfirmation, [mbYes],0); exit; end; if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then t_op_seae.post; 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; 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; procedure Tfrm_op_seae_order.bsSkinButton10Click(Sender: TObject); var str:string; begin str:=' and '+open_data('0021','揽货人','no','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.DisplayValue<>''then str:=str+' and 揽货人='+''''+RxDBLookupCombo3.DisplayValue+''''; 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+''''; 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_order.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_seae_order.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_seae_order.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,101); end; procedure Tfrm_op_seae_order.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_seae_order.RxDBLookupCombo20KeyPress(Sender: TObject; var Key: Char); begin // key_wwDBLookupCombo(Key,wwDBLookupCombo1); end; procedure Tfrm_op_seae_order.t_op_ctnAfterPost(DataSet: TDataSet); begin // update_ctn(t_op_ctn); end; procedure Tfrm_op_seae_order.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_order.t_op_feeAfterInsert(DataSet: TDataSet); begin t_op_fee['编号']:=t_op_seae['编号']; end; procedure Tfrm_op_seae_order.t_op_ctnAfterInsert(DataSet: TDataSet); begin t_op_ctn['编号']:=t_op_seae['编号']; end; procedure Tfrm_op_seae_order.dxDBGrid1DblClick(Sender: TObject); begin bsSkinPageControl1.ActivePageIndex:=1; end; procedure Tfrm_op_seae_order.bsSkinButton2Click(Sender: TObject); begin if (t_op_seae_order['状态']<>'提交审核') and (t_op_seae_order['状态']<>'驳回提交') then begin MessageDlg('当前状态下:'+t_op_seae_order.fieldByName('状态').AsString+'不能审核通过!', mtConfirmation, [mbYes],0); exit; end; t_op_seae_order.Edit; t_op_seae_order['状态']:='审核通过'; t_op_seae_order['审核人']:=employee; t_op_seae_order['审核时间']:=Now; t_op_seae_order.Post; end; procedure Tfrm_op_seae_order.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_order.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_order.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_order.t_ch_fee_agentdcAfterInsert( DataSet: TDataSet); begin t_ch_fee_agentdc['编号']:=t_op_seae['编号']; end; procedure Tfrm_op_seae_order.t_ch_fee_agentdc_detailAfterInsert( DataSet: TDataSet); begin t_ch_fee_agentdc_detail['ad_id']:=t_ch_fee_agentdc['ad_id'] end; procedure Tfrm_op_seae_order.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_order.bsSkinPageControl2Change(Sender: TObject); begin if bsSkinPageControl2.TabIndex=2 then begin if t_op_seae_order.IsEmpty then exit; t_op_seae_query.Close; t_op_seae_query.Parameters.ParamByName('委托编号').Value:=t_op_seae_order.fieldbyName('订舱编号').AsString; t_op_seae_query.Open; if Trim(t_op_seae_query.fieldbyName('编号').AsString)<>'' then OpFeeItem(t_op_seae_query.fieldbyName('编号').AsString); getsumstr; end; end; procedure Tfrm_op_seae_order.RxDBLookupCombo12Exit(Sender: TObject); begin TRxDBLookupCombo(Sender).LookupDisplay:='姓名'; end; procedure Tfrm_op_seae_order.RxDBLookupCombo12Enter(Sender: TObject); begin TRxDBLookupCombo(Sender).LookupDisplay:='代码;姓名'; end; end.