unit u_op_seae_fenzhang; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, bsSkinCtrls, Grids, Wwdbigrd, Wwdbgrid, StdCtrls,Math, wwdblook, Mask, wwdbedit, Wwdotdot, Wwdbcomb, bsSkinBoxCtrls, bsdbctrls,DBGridEhImpExp, RxMemDS, RxLookup, DBCtrls, Menus, ComCtrls, bsSkinTabs, DBGridEh,inifiles, DBGrids, ToolEdit, CurrEdit; type Tfrm_op_seae_fenzhang = class(TForm) t_ch_fee_fenzhang: TADOQuery; t_ch_fee_fenzhang1: TDataSource; bsSkinPanel1: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton9: TbsSkinButton; wwDBGrid1: TwwDBGrid; t_ch_fee: TADOQuery; bsSkinButton5: TbsSkinButton; bsSkinPanel2: TbsSkinPanel; bsSkinDBEdit2: TbsSkinDBEdit; bsSkinDBEdit3: TbsSkinDBEdit; t_sum: TRxMemoryData; t_sum1: TDataSource; bsSkinDBEdit1: TbsSkinDBEdit; bsSkinPanel3: TbsSkinPanel; Label112: TLabel; RxDBLookupCombo44: TRxDBLookupCombo; Label1: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; t_op_fenzhang: TADOQuery; ds_op_fenzhang1: TDataSource; Label2: TLabel; Label3: TLabel; dbedtM: TDBEdit; dbedtH: TDBEdit; Label4: TLabel; Label5: TLabel; dbedtM1: TDBEdit; dbedtH1: TDBEdit; Label6: TLabel; PopupMenu3: TPopupMenu; N10: TMenuItem; N29: TMenuItem; N30: TMenuItem; N56: TMenuItem; N57: TMenuItem; N31: TMenuItem; N104: TMenuItem; N12: TMenuItem; N32: TMenuItem; N33: TMenuItem; N58: TMenuItem; N59: TMenuItem; N34: TMenuItem; t_ch_client: TADOQuery; t_ch_client1: TDataSource; Label7: TLabel; dbedtBAFYAS: TDBEdit; DBEdit3: TDBEdit; Label8: TLabel; Label9: TLabel; t_op_gain: TADOQuery; t_op_gain1: TDataSource; t_rp_sum1: TDataSource; t_rp_sum: TRxMemoryData; t_ch_noclient: TADOQuery; t_ch_noclient1: TDataSource; t_mem_pc: TRxMemoryData; t_mem_pc1: TDataSource; t_mem_pcField: TStringField; t_mem_pcField2: TStringField; t_mem_pcField3: TStringField; t_mem_pcField4: TFloatField; t_mem_pcField5: TFloatField; t_mem_pcField6: TFloatField; t_mem_pcPP: TFloatField; t_mem_pcCC: TFloatField; t_mem_pcPP2: TFloatField; t_mem_pcCC2: TFloatField; t_mem_pcField7: TStringField; t_mem_pcField8: TFloatField; t_mem_pcField9: TFloatField; t_mem_dc: TRxMemoryData; StringField1: TStringField; StringField2: TStringField; StringField3: TStringField; FloatField1: TFloatField; FloatField2: TFloatField; FloatField3: TFloatField; FloatField4: TFloatField; FloatField5: TFloatField; FloatField6: TFloatField; FloatField7: TFloatField; StringField4: TStringField; FloatField8: TFloatField; FloatField9: TFloatField; t_mem_dc1: TDataSource; bsSkinPanel4: TbsSkinPanel; bsSkinPanel5: TbsSkinPanel; bsSkinPanel6: TbsSkinPanel; wwDBGrid2: TwwDBGrid; t_ch_fee_fenzhangO: TADOQuery; t_ch_fee_fenzhangO1: TDataSource; wwDBComboBox2: TwwDBComboBox; wwDBLookupCombo4: TwwDBLookupCombo; wwDBLookupCombo5: TwwDBLookupCombo; wwDBLookupCombo6: TwwDBLookupCombo; bsSkinButton8: TbsSkinButton; Label10: TLabel; Label11: TLabel; DBComboBox1: TDBComboBox; DBComboBox2: TDBComboBox; DBComboBox3: TDBComboBox; DBComboBox4: TDBComboBox; t_mem_pcFD_ID: TIntegerField; ADOQuery1: TADOQuery; DataSource1: TDataSource; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; bsSkinPanel7: TbsSkinPanel; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinPanel8: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton12: TbsSkinButton; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; bsSkinButton18: TbsSkinButton; bsSkinPanel9: TbsSkinPanel; bsSkinGroupBox1: TbsSkinGroupBox; bsSkinGroupBox2: TbsSkinGroupBox; t_ch_fee_pl_detail: TADOQuery; t_ch_fee_pl_detail1: TDataSource; t_ch_fee_pl_detailf: TADOQuery; t_ch_fee_pl_detailf1: TDataSource; t_ch_fee_pl: TADOQuery; t_ch_fee_pl1: TDataSource; DBEdit1: TDBEdit; Label12: TLabel; Label13: TLabel; DBEdit2: TDBEdit; Label14: TLabel; DBEdit4: TDBEdit; Label15: TLabel; DBEdit5: TDBEdit; Label16: TLabel; DBEdit6: TDBEdit; Label17: TLabel; DBMemo1: TDBMemo; PopupMenu2: TPopupMenu; MenuItem2: TMenuItem; MenuItem3: TMenuItem; MenuItem4: TMenuItem; MenuItem5: TMenuItem; MenuItem6: TMenuItem; wwDBLookupCombo3: TwwDBLookupCombo; wwDBLookupCombo2: TwwDBLookupCombo; wwDBLookupCombo1: TwwDBLookupCombo; wwDBComboBox1: TwwDBComboBox; wwDBGrid3: TwwDBGrid; wwDBGrid4: TwwDBGrid; t_ch_fee_pl_detailfDL_ID: TAutoIncField; t_ch_fee_pl_detailfPL_ID: TIntegerField; t_ch_fee_pl_detailfDSDesigner: TStringField; t_ch_fee_pl_detailfDSDesigner2: TStringField; t_ch_fee_pl_detailfDSDesigner3: TStringField; t_ch_fee_pl_detailfDSDesigner4: TStringField; t_ch_fee_pl_detailfDSDesigner5: TStringField; t_ch_fee_pl_detailfDSDesigner6: TBCDField; t_ch_fee_pl_detailfDSDesigner7: TBCDField; t_ch_fee_pl_detailfDSDesigner8: TBCDField; t_ch_fee_pl_detailfDSDesigner9: TBCDField; t_ch_fee_pl_detailfDSDesigner10: TBCDField; t_ch_fee_pl_detailfDSDesigner11: TBCDField; t_ch_fee_pl_detailfDSDesigner12: TBCDField; t_ch_fee_pl_detailfDSDesigner13: TBCDField; t_ch_fee_pl_detailDL_ID: TAutoIncField; t_ch_fee_pl_detailPL_ID: TIntegerField; t_ch_fee_pl_detailDSDesigner: TStringField; t_ch_fee_pl_detailDSDesigner2: TStringField; t_ch_fee_pl_detailDSDesigner3: TStringField; t_ch_fee_pl_detailDSDesigner4: TStringField; t_ch_fee_pl_detailDSDesigner5: TStringField; t_ch_fee_pl_detailDSDesigner6: TBCDField; t_ch_fee_pl_detailDSDesigner7: TBCDField; t_ch_fee_pl_detailDSDesigner8: TBCDField; t_ch_fee_pl_detailDSDesigner9: TBCDField; t_ch_fee_pl_detailDSDesigner10: TBCDField; t_ch_fee_pl_detailDSDesigner11: TBCDField; t_ch_fee_pl_detailDSDesigner12: TBCDField; t_ch_fee_pl_detailDSDesigner13: TBCDField; t_op_seae_assistant: TADOQuery; t_op_seae_assistant1: TDataSource; bsSkinTabSheet3: TbsSkinTabSheet; bsSkinPanel10: TbsSkinPanel; bsSkinButton16: TbsSkinButton; bsSkinButton17: TbsSkinButton; bsSkinButton19: TbsSkinButton; bsSkinButton20: TbsSkinButton; bsSkinButton23: TbsSkinButton; bsSkinButton24: TbsSkinButton; bsSkinButton25: TbsSkinButton; bsSkinPanel11: TbsSkinPanel; DBGrid: TDBGridEh; t_ch_fee_cm: TADOQuery; t_ch_fee_cm1: TDataSource; bsSkinGroupBox3: TbsSkinGroupBox; DBMemo2: TDBMemo; bsSkinPanel12: TbsSkinPanel; PopupMenu4: TPopupMenu; MenuItem1: TMenuItem; MenuItem7: TMenuItem; MenuItem8: TMenuItem; MenuItem9: TMenuItem; MenuItem10: TMenuItem; RxDBLookupCombo19: TRxDBLookupCombo; Label18: TLabel; wwDBLookupCombo8: TwwDBLookupCombo; Label19: TLabel; Label20: TLabel; bsSkinButton15: TbsSkinButton; SaveDialog1: TSaveDialog; RxDBLookupCombo2: TRxDBLookupCombo; Label21: TLabel; wwDBLookupCombo7: TwwDBLookupCombo; t_ch_fenzhango_sum: TADOQuery; t_ch_fenzhango_sum1: TDataSource; t_ch_fenzhang_sum: TADOQuery; t_ch_fenzhang_sum1: TDataSource; t_ch_fenzhangot_sum: TADOQuery; t_ch_fenzhangot_sum1: TDataSource; t_mem_pd: TRxMemoryData; IntegerField1: TIntegerField; StringField5: TStringField; StringField6: TStringField; StringField7: TStringField; FloatField10: TFloatField; FloatField11: TFloatField; FloatField12: TFloatField; FloatField13: TFloatField; FloatField14: TFloatField; FloatField15: TFloatField; FloatField16: TFloatField; StringField8: TStringField; FloatField17: TFloatField; FloatField18: TFloatField; t_mem_pd1: TDataSource; t_mem_pdField: TStringField; bsSkinButton21: TbsSkinButton; bsSkinTabSheet4: TbsSkinTabSheet; bsSkinPanel13: TbsSkinPanel; bsSkinButton22: TbsSkinButton; bsSkinButton26: TbsSkinButton; bsSkinButton27: TbsSkinButton; bsSkinButton28: TbsSkinButton; bsSkinButton29: TbsSkinButton; bsSkinButton32: TbsSkinButton; DBGrid1: TDBGrid; bsSkinPanel14: TbsSkinPanel; bsSkinPanel15: TbsSkinPanel; bsSkinPanel16: TbsSkinPanel; bsSkinPanel17: TbsSkinPanel; PopupMenu5: TPopupMenu; MenuItem11: TMenuItem; MenuItem12: TMenuItem; MenuItem13: TMenuItem; MenuItem14: TMenuItem; MenuItem15: TMenuItem; t_ch_fee_agentdc1: TDataSource; t_ch_fee_agentdc: TADOQuery; t_ch_fee_agentdc_detail1: TDataSource; t_ch_fee_agentdc_detail: TADOQuery; DBEdit7: TDBEdit; Label22: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; Label23: TLabel; Label24: TLabel; DBEdit8: TDBEdit; Label25: TLabel; DBEdit9: TDBEdit; Label26: TLabel; DBEdit10: TDBEdit; Label27: TLabel; DBEdit11: TDBEdit; Label29: TLabel; DBMemo3: TDBMemo; Label30: TLabel; DBEdit12: TDBEdit; wwDBLookupCombo9: TwwDBLookupCombo; wwDBGrid5: TwwDBGrid; Label31: TLabel; RxDBLookupCombo4: TRxDBLookupCombo; Label32: TLabel; RxDBLookupCombo5: TRxDBLookupCombo; Label33: TLabel; wwDBLookupCombo11: TwwDBLookupCombo; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; bsSkinSpeedButton1: TbsSkinSpeedButton; bsSkinPanel18: TbsSkinPanel; bsSkinButton30: TbsSkinButton; bsSkinButton31: TbsSkinButton; bsSkinButton33: TbsSkinButton; bsSkinButton35: TbsSkinButton; bsSkinButton34: TbsSkinButton; DBEdit13: TDBEdit; wwDBLookupCombo12: TwwDBLookupCombo; wwDBComboBox3: TwwDBComboBox; bsSkinButton36: TbsSkinButton; Label28: TLabel; DBEdit14: TDBEdit; t_bz_balance: TRxMemoryData; wwDBLookupCombo10: TwwDBLookupCombo; t_bz_balance1: TDataSource; procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure t_ch_fee_fenzhangAfterInsert(DataSet: TDataSet); procedure bsSkinButton7Click(Sender: TObject); procedure wwDBGrid1ColExit(Sender: TObject); procedure t_ch_fee_fenzhangBeforePost(DataSet: TDataSet); procedure wwDBLookupCombo3Change(Sender: TObject); procedure FormShow(Sender: TObject); procedure wwDBLookupCombo2Change(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinPanel1Resize(Sender: TObject); procedure t_ch_fee_fenzhangAfterOpen(DataSet: TDataSet); procedure t_ch_fee_fenzhangAfterPost(DataSet: TDataSet); procedure bsSkinButton9Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure t_ch_fee_fenzhangBeforeInsert(DataSet: TDataSet); procedure t_ch_fee_fenzhangAfterRefresh(DataSet: TDataSet); procedure N31Click(Sender: TObject); procedure N29Click(Sender: TObject); procedure N56Click(Sender: TObject); procedure N32Click(Sender: TObject); procedure N58Click(Sender: TObject); procedure N34Click(Sender: TObject); procedure t_op_fenzhangAfterInsert(DataSet: TDataSet); procedure t_ch_fee_fenzhangOAfterInsert(DataSet: TDataSet); procedure t_ch_fee_fenzhangOBeforeInsert(DataSet: TDataSet); procedure t_ch_fee_fenzhangOBeforePost(DataSet: TDataSet); procedure wwDBLookupCombo4Change(Sender: TObject); procedure wwDBLookupCombo5Change(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure t_ch_fee_pl_detailAfterInsert(DataSet: TDataSet); procedure t_ch_fee_plAfterInsert(DataSet: TDataSet); procedure bsSkinButton10Click(Sender: TObject); procedure t_ch_fee_pl_detailBeforeInsert(DataSet: TDataSet); procedure t_ch_fee_plBeforeInsert(DataSet: TDataSet); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton18Click(Sender: TObject); procedure t_ch_fee_pl_detailAfterPost(DataSet: TDataSet); procedure t_ch_fee_pl_detailfAfterInsert(DataSet: TDataSet); procedure t_ch_fee_plDSDesigner3Change(Sender: TField); procedure bsSkinButton13Click(Sender: TObject); procedure MenuItem2Click(Sender: TObject); procedure MenuItem4Click(Sender: TObject); procedure MenuItem6Click(Sender: TObject); procedure t_ch_fee_plDSDesigner5Change(Sender: TField); procedure t_ch_fee_pl_detailfDSDesigner6Change(Sender: TField); procedure t_ch_fee_pl_detailDSDesigner6Change(Sender: TField); procedure t_ch_fee_cmAfterInsert(DataSet: TDataSet); procedure bsSkinButton25Click(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure bsSkinButton17Click(Sender: TObject); procedure t_ch_fee_cmBeforePost(DataSet: TDataSet); procedure bsSkinButton19Click(Sender: TObject); procedure MenuItem1Click(Sender: TObject); procedure MenuItem8Click(Sender: TObject); procedure MenuItem10Click(Sender: TObject); procedure bsSkinButton20Click(Sender: TObject); procedure RxDBLookupCombo19Enter(Sender: TObject); procedure RxDBLookupCombo19Exit(Sender: TObject); procedure bsSkinButton24Click(Sender: TObject); procedure bsSkinButton23Click(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure RxDBLookupCombo2Enter(Sender: TObject); procedure RxDBLookupCombo2Exit(Sender: TObject); procedure DBComboBox4DropDown(Sender: TObject); procedure t_ch_fee_cmAfterPost(DataSet: TDataSet); procedure bsSkinButton21Click(Sender: TObject); procedure t_op_fenzhangBeforeEdit(DataSet: TDataSet); procedure t_ch_fee_fenzhangBeforeEdit(DataSet: TDataSet); procedure t_ch_fee_fenzhangOBeforeEdit(DataSet: TDataSet); procedure t_ch_fee_pl_detailBeforeEdit(DataSet: TDataSet); procedure t_ch_fee_pl_detailfBeforeEdit(DataSet: TDataSet); procedure t_ch_fee_cmBeforeInsert(DataSet: TDataSet); procedure t_ch_fee_cmBeforeEdit(DataSet: TDataSet); procedure t_ch_fee_plAfterOpen(DataSet: TDataSet); procedure t_op_fenzhangBeforePost(DataSet: TDataSet); procedure bsSkinButton32Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure bsSkinButton22Click(Sender: TObject); procedure bsSkinButton26Click(Sender: TObject); procedure bsSkinButton27Click(Sender: TObject); procedure bsSkinButton28Click(Sender: TObject); procedure t_ch_fee_agentdcBeforeInsert(DataSet: TDataSet); procedure t_ch_fee_agentdcBeforeEdit(DataSet: TDataSet); procedure t_ch_fee_agentdc_detailBeforeInsert(DataSet: TDataSet); procedure t_ch_fee_agentdc_detailBeforeEdit(DataSet: TDataSet); procedure wwDBLookupCombo10Change(Sender: TObject); procedure wwDBLookupCombo9Change(Sender: TObject); procedure t_ch_fee_agentdcAfterInsert(DataSet: TDataSet); procedure MenuItem11Click(Sender: TObject); procedure t_ch_fee_agentdc_detailAfterPost(DataSet: TDataSet); procedure t_ch_fee_agentdc_detailAfterInsert(DataSet: TDataSet); procedure t_ch_fee_agentdcBeforePost(DataSet: TDataSet); procedure t_ch_fee_agentdc_detailBeforePost(DataSet: TDataSet); procedure t_ch_fee_agentdcAfterOpen(DataSet: TDataSet); procedure RxDBLookupCombo5Enter(Sender: TObject); procedure RxDBLookupCombo5Exit(Sender: TObject); procedure bsSkinButton29Click(Sender: TObject); procedure RxDBLookupCombo4Enter(Sender: TObject); procedure RxDBLookupCombo4Exit(Sender: TObject); procedure bsSkinSpeedButton1Click(Sender: TObject); procedure bsSkinButton34Click(Sender: TObject); procedure t_ch_fee_agentdc_detailAfterOpen(DataSet: TDataSet); procedure bsSkinButton30Click(Sender: TObject); procedure bsSkinButton31Click(Sender: TObject); procedure bsSkinButton33Click(Sender: TObject); procedure bsSkinButton35Click(Sender: TObject); procedure wwDBLookupCombo12Change(Sender: TObject); procedure t_ch_fee_agentdcBeforeDelete(DataSet: TDataSet); procedure t_ch_fee_agentdcBeforeCancel(DataSet: TDataSet); procedure bsSkinButton36Click(Sender: TObject); procedure RxDBLookupCombo3Enter(Sender: TObject); procedure RxDBLookupCombo3Exit(Sender: TObject); private absno:string; procedure GetRptSum; procedure setGrid; procedure t_ch_fee_agentdcdebitcharge(Sender:TField); procedure t_ch_fee_agentdc_detaildebitcharge(Sender:TField); procedure t_ch_fee_agentdc_detailfeenamecharge(Sender:TField); { Private declarations } public { Public declarations } end; var frm_op_seae_fenzhang: Tfrm_op_seae_fenzhang; frm_op_fenzhang_create:boolean; implementation uses u_main, u_op_seae, my_sys_function, u_data_share,SmpExprCalc, u_op_seae_fenzhang_his, u_ch_fee_se, u_code_fee_projectagent_add, u_code_fee_cargomainfest_add, u_sys_tab_sort; {$R *.dfm} procedure Tfrm_op_seae_fenzhang.bsSkinButton1Click(Sender: TObject); begin if ActiveControl=wwDBGrid1 then t_ch_fee_fenzhang.insert; if ActiveControl=wwDBGrid2 then t_ch_fee_fenzhango.insert; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_fee_fenzhang); table_post(t_ch_fee_fenzhango); table_post(t_op_fenzhang); end; procedure Tfrm_op_seae_fenzhang.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_fee_fenzhang); table_cancel(t_ch_fee_fenzhango); table_cancel(t_op_fenzhang); end; procedure Tfrm_op_seae_fenzhang.bsSkinButton6Click(Sender: TObject); var afield : variant; i: Integer; begin //复制添加 if ActiveControl=wwDBGrid1 then begin table_post(t_ch_fee_fenzhang); if t_ch_fee_fenzhang.IsEmpty then exit; afield := vararraycreate([0,t_ch_fee_fenzhang.fieldcount-1],varvariant); for i := 0 to (t_ch_fee_fenzhang.fieldcount-1) do begin afield[i] :=t_ch_fee_fenzhang.fields[i].value ; end; t_ch_fee_fenzhang.append; for i := 0 to (t_ch_fee_fenzhang.fieldcount-1) do begin if t_ch_fee_fenzhang.fields[i].FieldName<>'FD_ID' then t_ch_fee_fenzhang.fields[i].value := afield[i] ; end; t_ch_fee_fenzhang['是否生成']:=0; end; if ActiveControl=wwDBGrid2 then begin table_post(t_ch_fee_fenzhango); if t_ch_fee_fenzhango.IsEmpty then exit; afield := vararraycreate([0,t_ch_fee_fenzhango.fieldcount-1],varvariant); for i := 0 to (t_ch_fee_fenzhango.fieldcount-1) do begin afield[i] :=t_ch_fee_fenzhango.fields[i].value ; end; t_ch_fee_fenzhango.append; for i := 0 to (t_ch_fee_fenzhango.fieldcount-1) do begin if t_ch_fee_fenzhango.fields[i].FieldName<>'FD_ID' then t_ch_fee_fenzhango.fields[i].value := afield[i] ; end; t_ch_fee_fenzhango['是否生成']:=0; end; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_fenzhangAfterInsert( DataSet: TDataSet); begin t_ch_fee_fenzhang['是否生成']:=0; t_ch_fee_fenzhang['结算代理']:=1; t_ch_fee_fenzhang['代理名称']:=t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('代理').asstring; t_ch_fee_fenzhang['币别']:='USD'; t_ch_fee_fenzhang['分帐比例']:='手工'; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton7Click(Sender: TObject); begin try if not assigned(frm_op_seae_fenzhang_his) then frm_op_seae_fenzhang_his:=tfrm_op_seae_fenzhang_his.Create (self); frm_op_seae_fenzhang_his.ShowModal; finally frm_op_seae_fenzhang_his.free; frm_op_seae_fenzhang_his:=nil; end; end; procedure Tfrm_op_seae_fenzhang.wwDBGrid1ColExit(Sender: TObject); var li_pp,li_cc,fen_pp,fen_cc,fen:real; begin //应收应付金额计算 if (t_ch_fee_fenzhang.state<>dsinsert)and(t_ch_fee_fenzhang.state<>dsedit)then exit; IF t_ch_fee_fenzhang.IsEmpty THEN EXIT; IF (t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING='') or (t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING='手工')then exit; if (wwDBGrid1.GetActiveCol=10)or(wwDBGrid1.GetActiveCol=6) or (wwDBGrid1.GetActiveCol=7)or(wwDBGrid1.GetActiveCol=8) or (wwDBGrid1.GetActiveCol=9)then begin try IF (t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING<>'') and (t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING<>'手工')then begin li_pp:=t_ch_fee_fenzhang.fieldbyname('应收PP').asfloat-t_ch_fee_fenzhang.fieldbyname('应付PP').asfloat; fen_pp:=li_pp*strtofloat('0.'+copy(t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING,1,length(t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING)-1)); li_cc:=t_ch_fee_fenzhang.fieldbyname('应收CC').asfloat-t_ch_fee_fenzhang.fieldbyname('应付CC').asfloat; fen_cc:=li_cc*(1-strtofloat('0.'+copy(t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING,1,length(t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING)-1))); fen:=fen_pp-fen_cc; if fen>=0 then begin t_ch_fee_fenzhang['应收金额']:=0; t_ch_fee_fenzhang['应付金额']:=s_w(strtoint(get_parameters_value(65,'2')),fen); end else begin t_ch_fee_fenzhang['应收金额']:=s_w(strtoint(get_parameters_value(65,'2')),fen*-1); t_ch_fee_fenzhang['应付金额']:=0; end; end; except ; end; end; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_fenzhangBeforePost( DataSet: TDataSet); var li_pp,li_cc,fen_pp,fen_cc,fen:real; begin table_before_post(t_ch_fee_fenzhang,'代理名称'); table_before_post(t_ch_fee_fenzhang,'费用中文名'); table_before_post(t_ch_fee_fenzhang,'币别'); table_before_post(t_ch_fee_fenzhang,'汇率'); table_before_post(t_ch_fee_fenzhang,'分帐比例'); if frm_data_share.t_crm_client.Locate('客户简称',t_ch_fee_fenzhang.fieldbyname('代理名称').AsString,[]) then begin if frm_data_share.t_crm_client.fieldbyname('是否停用').AsBoolean then begin MessageDlg('此代理已停用,不能录入费用!',mtWarning,[mbok],0); abort; end; end; try IF (t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING<>'') and (t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING<>'手工')then begin li_pp:=t_ch_fee_fenzhang.fieldbyname('应收PP').asfloat-t_ch_fee_fenzhang.fieldbyname('应付PP').asfloat; fen_pp:=li_pp*strtofloat('0.'+copy(t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING,1,length(t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING)-1)); li_cc:=t_ch_fee_fenzhang.fieldbyname('应收CC').asfloat-t_ch_fee_fenzhang.fieldbyname('应付CC').asfloat; fen_cc:=li_cc*(1-strtofloat('0.'+copy(t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING,1,length(t_ch_fee_fenzhang.FieldByName('分帐比例').ASSTRING)-1))); fen:=fen_pp-fen_cc; if fen>=0 then begin t_ch_fee_fenzhang['应收金额']:=0; t_ch_fee_fenzhang['应付金额']:=s_w(strtoint(get_parameters_value(65,'2')),fen); end else begin t_ch_fee_fenzhang['应收金额']:=s_w(strtoint(get_parameters_value(65,'2')),fen*-1); t_ch_fee_fenzhang['应付金额']:=0; end; end; except ; end; { if (t_ch_fee_fenzhang.fieldbyname('应付金额').asfloat<>0)and(t_ch_fee_fenzhang.fieldbyname('应收金额').asfloat<>0)then begin showmessage('代理分帐的应收、应付费用只能有一项!!'); abort; end; } end; procedure Tfrm_op_seae_fenzhang.wwDBLookupCombo3Change(Sender: TObject); begin if (t_ch_fee_fenzhang.state=dsinsert)or(t_ch_fee_fenzhang.state=dsedit) then begin if frm_data_share.t_code_fee.Locate('中文名',wwDBLookupCombo3.text,[])then begin end; t_ch_fee_fenzhang['费用英文名']:=frm_data_share.t_code_fee.fieldbyname('英文名').asstring; end; end; procedure Tfrm_op_seae_fenzhang.FormShow(Sender: TObject); var fenzhangbandini:Tinifile; sl:tstringlist; i,j,n:integer; str_list:Tstringlist; i_1,k_1,j_1:integer; begin frm_data_share.t_code_fee.REQUERY; frm_data_share.t_crm_client_daili.REQUERY; frm_data_share.t_code_currency.REQUERY; frm_data_share.t_code_fee.Filtered:=false; frm_data_share.t_code_fee.Filter:='海运=1'; frm_data_share.t_code_fee.Filtered:=true; loadwwgrid(wwDBGrid1,'国外代理分帐'); loadwwgrid(wwDBGrid5,'国外代理DCNOTE'); //CARGOMIAFEST根据方案生产列表 if (not t_op_fenzhang.FieldByName('方案代码').IsNull) and (t_op_fenzhang.FieldByName('方案代码').AsInteger<>0) then begin setGrid; end; //帐单编号的生产 if Trim(frm_data_share.t_AgentDc_no.fieldbyname('出号规则').Asstring)='自动取号' then begin DBEdit7.Width:=124; bsSkinSpeedButton1.Visible:=false; if frm_data_share.t_AgentDc_no.fieldbyname('是否允许手动编辑').AsBoolean then begin DBEdit7.ReadOnly:=false; end else begin DBEdit7.ReadOnly:=true; end; end else if Trim(frm_data_share.t_AgentDc_no.fieldbyname('出号规则').Asstring)='手动取号' then begin DBEdit7.Width:=104; bsSkinSpeedButton1.Visible:=true; if frm_data_share.t_AgentDc_no.fieldbyname('是否允许手动编辑').AsBoolean then begin DBEdit7.ReadOnly:=false; end else begin DBEdit7.ReadOnly:=true; end; end else if Trim(frm_data_share.t_AgentDc_no.fieldbyname('出号规则').Asstring)='手动编辑' then begin DBEdit7.ReadOnly:=false; DBEdit7.Width:=124; bsSkinSpeedButton1.Visible:=false; end; //页面顺序 fenzhangbandini:=Tinifile.Create(ExtractFilePath(application.ExeName)+'fenzhangbandno.ini'); sl:=TStringList.Create; try fenzhangbandini.ReadSection('fenzhang',sl); for j:=0 to sl.Count-1 do begin n:=fenzhangbandini.Readinteger('fenzhang',sl[j],0); for i:=0 to bsSkinPageControl1.PageCount-1 do begin if bsSkinPageControl1.Pages[i].Name=sl[j] then begin bsSkinPageControl1.Pages[i].PageIndex:=n; end; end; end; bsSkinPageControl1.ActivePageIndex:=0; finally freeandnil(fenzhangbandini); freeandnil(sl); end; // t_op_fenzhang.Open; /// frm_data_share.t_code_fee_unit.Filtered:=false; frm_data_share.t_code_fee_unit.Filter:='海运=1'; frm_data_share.t_code_fee_unit.Filtered:=true; t_bz_balance.close; t_bz_balance.open; t_bz_balance.Append; t_bz_balance['one']:='1-单票'; t_bz_balance['two']:='单票'; t_bz_balance['three']:=1; t_bz_balance.post; t_bz_balance.Append; t_bz_balance['one']:='2-重量'; t_bz_balance['two']:='重量'; t_bz_balance['three']:=s_w(4,t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('重量').asfloat/1000); t_bz_balance.post; t_bz_balance.Append; t_bz_balance['one']:='3-尺码'; t_bz_balance['two']:='尺码'; if t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('尺码').asfloat>1 then t_bz_balance['three']:=t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('尺码').asfloat else t_bz_balance['three']:=1; t_bz_balance.post; try t_bz_balance.Append; t_bz_balance['one']:='4-计费吨'; t_bz_balance['two']:='计费吨'; if s_w(4,t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('重量').asfloat/1000)>t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('尺码').asfloat then begin if s_w(4,t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('重量').asfloat/1000)>1 then t_bz_balance['three']:=s_w(4,t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('重量').asfloat/1000) else t_bz_balance['three']:=1; end else begin if t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('尺码').asfloat>1 then t_bz_balance['three']:=t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('尺码').asfloat else t_bz_balance['three']:=1; end; except ; end; try t_bz_balance.post; t_bz_balance.Append; t_bz_balance['one']:='5-TEU'; t_bz_balance['two']:='TEU'; t_bz_balance['three']:=t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('箱TEU').asinteger; t_bz_balance.post; str_list:=Tstringlist.Create(); str_list.Text:=t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('计费标准').asstring; for i_1:=0 to str_list.Count-1 do begin t_bz_balance.Append; t_bz_balance['one']:=inttostr(i_1+k_1+6)+'-'+copy(str_list[i_1],1,pos('*',str_list[i_1])-1); t_bz_balance['two']:=copy(str_list[i_1],pos('-',str_list[i_1])+1,length(str_list[i_1])+1-pos('-',str_list[i_1])); t_bz_balance['three']:=strtofloat(copy(str_list[i_1],pos('*',str_list[i_1])+1,pos('-',str_list[i_1])-pos('*',str_list[i_1])-1)); t_bz_balance.post; end; finally str_list.free; end; end; procedure Tfrm_op_seae_fenzhang.wwDBLookupCombo2Change(Sender: TObject); begin if (t_ch_fee_fenzhang.state=dsinsert)or(t_ch_fee_fenzhang.state=dsedit) then begin t_ch_fee_fenzhang['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton11Click(Sender: TObject); begin table_post(t_ch_fee_fenzhang); if t_ch_fee_fenzhang.IsEmpty then exit; t_ch_fee.insert; if t_ch_fee_fenzhang.fieldbyname('应收金额').asfloat>0 then begin t_ch_fee['类型']:='收'; t_ch_fee['金额']:=t_ch_fee_fenzhang['应收金额']; t_ch_fee['单价']:=t_ch_fee_fenzhang['应收金额']; end; if t_ch_fee_fenzhang.fieldbyname('应付金额').asfloat>0 then begin t_ch_fee['类型']:='付'; t_ch_fee['金额']:=t_ch_fee_fenzhang['应付金额']; t_ch_fee['单价']:=t_ch_fee_fenzhang['应付金额']; end; t_ch_fee['费用状态']:='录入状态'; t_ch_fee['编号']:=t_ch_fee_fenzhang['编号']; t_ch_fee['费用名称']:=t_ch_fee_fenzhang['费用中文名']; t_ch_fee['客户名称']:=t_ch_fee_fenzhang['代理名称']; t_ch_fee['结算单位']:='代理'; t_ch_fee['标准']:='单票'; t_ch_fee['数量']:=1; t_ch_fee['币别']:=t_ch_fee_fenzhang['币别']; t_ch_fee['汇率']:=t_ch_fee_fenzhang['汇率']; t_ch_fee['结算金额']:=0; t_ch_fee['开票金额']:=0; t_ch_fee['申请开票']:=0; t_ch_fee['录入人']:=employee; t_ch_fee['录入日期']:=date; t_ch_fee['是否对帐']:=0; t_ch_fee['机密']:=0; if strtobool(get_parameters_value(64,'false'))then t_ch_fee['机密']:=1; t_ch_fee.post; t_ch_fee_fenzhang.edit; t_ch_fee_fenzhang['是否生成']:=1; t_ch_fee_fenzhang.post; if assigned(frm_ch_fee_sea) then begin if frm_ch_fee_sea.fra_fee1.t_ch_accept.Active then frm_ch_fee_sea.fra_fee1.t_ch_accept.Requery(); if frm_ch_fee_sea.fra_fee1.t_ch_pay.Active then frm_ch_fee_sea.fra_fee1.t_ch_pay.Requery(); end; showmessage('生成费用成功!!'); end; procedure Tfrm_op_seae_fenzhang.bsSkinButton5Click(Sender: TObject); begin table_post(t_ch_fee_fenzhang); if t_ch_fee_fenzhang.IsEmpty then exit; t_ch_fee_fenzhang.first; while not t_ch_fee_fenzhang.eof do begin t_ch_fee.insert; if t_ch_fee_fenzhang.fieldbyname('应收金额').asfloat>0 then begin t_ch_fee['类型']:='收'; t_ch_fee['金额']:=t_ch_fee_fenzhang['应收金额']; t_ch_fee['单价']:=t_ch_fee_fenzhang['应收金额']; end; if t_ch_fee_fenzhang.fieldbyname('应付金额').asfloat>0 then begin t_ch_fee['类型']:='付'; t_ch_fee['金额']:=t_ch_fee_fenzhang['应付金额']; t_ch_fee['单价']:=t_ch_fee_fenzhang['应付金额']; end; t_ch_fee['费用状态']:='录入状态'; t_ch_fee['编号']:=t_ch_fee_fenzhang['编号']; t_ch_fee['费用名称']:=t_ch_fee_fenzhang['费用中文名']; t_ch_fee['客户名称']:=t_ch_fee_fenzhang['代理名称']; t_ch_fee['结算单位']:='代理'; t_ch_fee['标准']:='单票'; t_ch_fee['数量']:=1; t_ch_fee['币别']:=t_ch_fee_fenzhang['币别']; t_ch_fee['汇率']:=t_ch_fee_fenzhang['汇率']; t_ch_fee['结算金额']:=0; t_ch_fee['开票金额']:=0; t_ch_fee['申请开票']:=0; t_ch_fee['录入人']:=employee; t_ch_fee['录入日期']:=date; t_ch_fee['是否对帐']:=0; t_ch_fee['机密']:=0; if strtobool(get_parameters_value(64,'false'))then t_ch_fee['机密']:=1; t_ch_fee.post; t_ch_fee_fenzhang.edit; t_ch_fee_fenzhang['是否生成']:=1; t_ch_fee_fenzhang.post; t_ch_fee_fenzhang.next; end; if assigned(frm_ch_fee_sea) then begin if frm_ch_fee_sea.fra_fee1.t_ch_accept.Active then frm_ch_fee_sea.fra_fee1.t_ch_accept.Requery(); if frm_ch_fee_sea.fra_fee1.t_ch_pay.Active then frm_ch_fee_sea.fra_fee1.t_ch_pay.Requery(); end; showmessage('生成费用成功!!'); end; procedure Tfrm_op_seae_fenzhang.bsSkinPanel1Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel1.width/9); bsSkinButton1.width:=i; bsSkinButton6.width:=i; bsSkinButton7.width:=i; bsSkinButton2.width:=i; bsSkinButton4.width:=i; bsSkinButton3.width:=i; bsSkinButton11.width:=i; bsSkinButton5.width:=i; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_fenzhangAfterOpen( DataSet: TDataSet); var debit,credit:real; begin //金额大写生成 debit:=0; credit:=0; t_ch_fee_fenzhang.first; while not t_ch_fee_fenzhang.eof do begin debit:=debit+t_ch_fee_fenzhang.fieldbyname('应收金额').asfloat; credit:=credit+t_ch_fee_fenzhang.fieldbyname('应付金额').asfloat; t_ch_fee_fenzhang.next; end; t_sum.close; t_sum.open; t_sum.insert; debit:=debit-credit; if debit>=0 then t_sum['收付类别']:='DEBIT' else begin t_sum['收付类别']:='CREDIT'; debit:=debit*-1; end; t_sum['合计']:=debit; t_sum['大写']:='SAY:US DOLLARS '+ntoc(debit,true)+' ONLY.'; t_sum.post; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_fenzhangAfterPost( DataSet: TDataSet); var debit,credit:real; book1:Tbookmark; begin //金额大写生成 debit:=0; credit:=0; book1:=t_ch_fee_fenzhang.GetBookmark; t_ch_fee_fenzhang.first; while not t_ch_fee_fenzhang.eof do begin debit:=debit+t_ch_fee_fenzhang.fieldbyname('应收金额').asfloat; credit:=credit+t_ch_fee_fenzhang.fieldbyname('应付金额').asfloat; t_ch_fee_fenzhang.next; end; t_ch_fee_fenzhang.GotoBookmark(book1); t_sum.close; t_sum.open; t_sum.insert; debit:=debit-credit; if debit>=0 then t_sum['收付类别']:='DEBIT' else begin t_sum['收付类别']:='CREDIT'; debit:=debit*-1; end; t_sum['合计']:=debit; t_sum['大写']:='SAY:US DOLLARS '+ntoc(debit,true)+'ONLY.'; t_sum.post; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton9Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton9.ClientToScreen(Point(0,bsSkinButton9.Height)); PopupMenu3.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_fenzhang.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_op_fenzhang_create:=false; savewwgrid(wwDBGrid1,'国外代理分帐'); savewwgrid(wwDBGrid5,'国外代理DCNOTE'); if t_ch_fee_agentdc_detail.State in [dsedit,dsinsert] then t_ch_fee_agentdc_detail.post; if t_ch_fee_agentdc.State in [dsedit,dsinsert] then t_ch_fee_agentdc.post; if t_op_fenzhang.State in [dsedit,dsinsert] then t_op_fenzhang.Post; if t_ch_fee_pl_detail.State in [dsedit,dsinsert] then t_ch_fee_pl_detail.Post; if t_ch_fee_pl_detailf.State in [dsedit,dsinsert] then t_ch_fee_pl_detailf.Post; if t_ch_fee_pl.State in [dsedit,dsinsert] then t_ch_fee_pl.Post; if t_ch_fee_cm.State in [dsedit,dsinsert] then t_ch_fee_cm.Post; frm_op_seae_fenzhang.Hide; frm_op_seae_fenzhang.ManualFloat(frm_op_seae_fenzhang.BoundsRect ); action:=cafree; frm_op_seae_fenzhang:=nil; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_fenzhangBeforeInsert( DataSet: TDataSet); begin if (DataSet.DataSource.DataSet.FieldByName('费用状态').AsString='费用封帐') then begin showmessage('费用已经封帐,不能修改费用!!'); abort; end; if t_ch_fee_fenzhang.DataSource.DataSet.State=dsinsert then t_ch_fee_fenzhang.DataSource.DataSet.post; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_fenzhangAfterRefresh( DataSet: TDataSet); var debit,credit:real; begin //刷新更新大写 debit:=0; credit:=0; t_ch_fee_fenzhang.first; while not t_ch_fee_fenzhang.eof do begin debit:=debit+t_ch_fee_fenzhang.fieldbyname('应收金额').asfloat; credit:=credit+t_ch_fee_fenzhang.fieldbyname('应付金额').asfloat; t_ch_fee_fenzhang.next; end; t_sum.close; t_sum.open; t_sum.insert; debit:=debit-credit; if debit>=0 then t_sum['收付类别']:='DEBIT' else begin t_sum['收付类别']:='CREDIT'; debit:=debit*-1; end; t_sum['合计']:=debit; t_sum['大写']:='SAY:US DOLLARS '+ntoc(debit,true)+' ONLY.'; t_sum.post; end; procedure Tfrm_op_seae_fenzhang.N31Click(Sender: TObject); begin //打印分账 t_mem_dc.Close; t_mem_dc.Open; t_mem_pc.Close; t_mem_pc.Open; t_ch_fee_fenzhangO.first; while not t_ch_fee_fenzhangO.eof do begin if (t_ch_fee_fenzhangO.FieldByName('费用英文名').Asstring<>'') then begin t_mem_pc.Insert; t_mem_pc.FieldByName('FD_ID').Asinteger:=t_ch_fee_fenzhangO.FieldByName('FD_ID').Asinteger; t_mem_pc.FieldByName('代理名称').AsString:=t_ch_fee_fenzhangO.FieldByName('代理名称').AsString; t_mem_pc.FieldByName('费用英文名').AsString:=t_ch_fee_fenzhangO.FieldByName('费用英文名').AsString; t_mem_pc.FieldByName('币别').AsString:=t_ch_fee_fenzhangO.FieldByName('币别').AsString; t_mem_pc.FieldByName('汇率').AsFloat:=t_ch_fee_fenzhangO.FieldByName('汇率').AsFloat; t_mem_pc.FieldByName('数量').AsFloat:=t_ch_fee_fenzhangO.FieldByName('数量').AsFloat; t_mem_pc.FieldByName('单价').AsFloat:=t_ch_fee_fenzhangO.FieldByName('单价').AsFloat; t_mem_pc.FieldByName('应收PP').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应收PP').AsFloat; t_mem_pc.FieldByName('应收CC').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应收CC').AsFloat; t_mem_pc.FieldByName('应付PP').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应付PP').AsFloat; t_mem_pc.FieldByName('应付CC').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应付CC').AsFloat; t_mem_pc.FieldByName('应收金额').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应收金额').AsFloat; t_mem_pc.FieldByName('应付金额').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应付金额').AsFloat; t_mem_pc.Post; end; t_ch_fee_fenzhangO.Next; end; t_mem_pc.SortOnFields('FD_ID',true,false); t_mem_pd.Close; t_mem_pd.Open; t_ch_fee_fenzhango.First; while not t_ch_fee_fenzhango.Eof do begin if (t_ch_fee_fenzhango.FieldByName('费用说明').Asstring<>'') then begin t_mem_pd.Insert; t_mem_pd.FieldByName('FD_ID').Asinteger:=t_ch_fee_fenzhango.FieldByName('FD_ID').Asinteger; t_mem_pd.FieldByName('代理名称').AsString:=t_ch_fee_fenzhango.FieldByName('代理名称').AsString; t_mem_pd.FieldByName('费用英文名').AsString:=t_ch_fee_fenzhango.FieldByName('费用英文名').AsString; t_mem_pd.FieldByName('费用说明').AsString:=t_ch_fee_fenzhango.FieldByName('费用说明').AsString; t_mem_pd.FieldByName('币别').AsString:=t_ch_fee_fenzhango.FieldByName('币别').AsString; t_mem_pd.FieldByName('汇率').AsFloat:=t_ch_fee_fenzhango.FieldByName('汇率').AsFloat; t_mem_pd.FieldByName('数量').AsFloat:=t_ch_fee_fenzhango.FieldByName('数量').AsFloat; t_mem_pd.FieldByName('单价').AsFloat:=t_ch_fee_fenzhango.FieldByName('单价').AsFloat; t_mem_pd.FieldByName('应收PP').AsFloat:=t_ch_fee_fenzhango.FieldByName('应收PP').AsFloat; t_mem_pd.FieldByName('应收CC').AsFloat:=t_ch_fee_fenzhango.FieldByName('应收CC').AsFloat; t_mem_pd.FieldByName('应付PP').AsFloat:=t_ch_fee_fenzhango.FieldByName('应付PP').AsFloat; t_mem_pd.FieldByName('应付CC').AsFloat:=t_ch_fee_fenzhango.FieldByName('应付CC').AsFloat; t_mem_pd.FieldByName('应收金额').AsFloat:=t_ch_fee_fenzhango.FieldByName('应收金额').AsFloat; t_mem_pd.FieldByName('应付金额').AsFloat:=t_ch_fee_fenzhango.FieldByName('应付金额').AsFloat; t_mem_pd.Post; end; t_ch_fee_fenzhango.Next; end; t_mem_pd.SortOnFields('FD_ID',true,false); t_op_gain.Close; t_op_gain.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_op_gain.Open; GetRptSum; if t_op_seae_assistant.Active then t_op_seae_assistant.Requery(); t_ch_fenzhango_sum.Open; t_ch_fenzhang_sum.Open; t_ch_fenzhangot_sum.Open; sys_print('海运出口分帐',2,t_ch_fee_fenzhang.DataSource,t_sum1,ds_op_fenzhang1,t_op_gain1,t_ch_fee_fenzhang1,t_mem_pd1,t_mem_pc1,t_mem_dc1,t_op_seae_assistant1,t_ch_fenzhang_sum1,t_rp_sum1,true,'',t_ch_fenzhango_sum1,t_ch_fenzhangot_sum1); t_ch_fenzhango_sum.close; t_ch_fenzhangot_sum.close; t_ch_fenzhang_sum.close; end; procedure Tfrm_op_seae_fenzhang.N29Click(Sender: TObject); begin //全部代理 打印分账 t_mem_dc.Close; t_mem_dc.Open; t_mem_pc.Close; t_mem_pc.Open; t_ch_fee_fenzhangO.First; while not t_ch_fee_fenzhangO.Eof do begin if (t_ch_fee_fenzhangO.FieldByName('费用英文名').Asstring<>'') then begin t_mem_pc.Insert; t_mem_pc.FieldByName('FD_ID').Asinteger:=t_ch_fee_fenzhangO.FieldByName('FD_ID').Asinteger; t_mem_pc.FieldByName('代理名称').AsString:=t_ch_fee_fenzhangO.FieldByName('代理名称').AsString; t_mem_pc.FieldByName('费用英文名').AsString:=t_ch_fee_fenzhangO.FieldByName('费用英文名').AsString; t_mem_pc.FieldByName('币别').AsString:=t_ch_fee_fenzhangO.FieldByName('币别').AsString; t_mem_pc.FieldByName('汇率').AsFloat:=t_ch_fee_fenzhangO.FieldByName('汇率').AsFloat; t_mem_pc.FieldByName('数量').AsFloat:=t_ch_fee_fenzhangO.FieldByName('数量').AsFloat; t_mem_pc.FieldByName('单价').AsFloat:=t_ch_fee_fenzhangO.FieldByName('单价').AsFloat; t_mem_pc.FieldByName('应收PP').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应收PP').AsFloat; t_mem_pc.FieldByName('应收CC').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应收CC').AsFloat; t_mem_pc.FieldByName('应付PP').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应付PP').AsFloat; t_mem_pc.FieldByName('应付CC').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应付CC').AsFloat; t_mem_pc.FieldByName('应收金额').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应收金额').AsFloat; t_mem_pc.FieldByName('应付金额').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应付金额').AsFloat; t_mem_pc.Post; end; t_ch_fee_fenzhangO.Next; end; t_mem_pc.SortOnFields('FD_ID',true,false); t_mem_pd.Close; t_mem_pd.Open; t_ch_fee_fenzhango.First; while not t_ch_fee_fenzhango.Eof do begin if (t_ch_fee_fenzhango.FieldByName('费用说明').Asstring<>'') then begin t_mem_pd.Insert; t_mem_pd.FieldByName('FD_ID').Asinteger:=t_ch_fee_fenzhango.FieldByName('FD_ID').Asinteger; t_mem_pd.FieldByName('代理名称').AsString:=t_ch_fee_fenzhango.FieldByName('代理名称').AsString; t_mem_pd.FieldByName('费用英文名').AsString:=t_ch_fee_fenzhango.FieldByName('费用英文名').AsString; t_mem_pd.FieldByName('费用说明').AsString:=t_ch_fee_fenzhango.FieldByName('费用说明').AsString; t_mem_pd.FieldByName('币别').AsString:=t_ch_fee_fenzhango.FieldByName('币别').AsString; t_mem_pd.FieldByName('汇率').AsFloat:=t_ch_fee_fenzhango.FieldByName('汇率').AsFloat; t_mem_pd.FieldByName('数量').AsFloat:=t_ch_fee_fenzhango.FieldByName('数量').AsFloat; t_mem_pd.FieldByName('单价').AsFloat:=t_ch_fee_fenzhango.FieldByName('单价').AsFloat; t_mem_pd.FieldByName('应收PP').AsFloat:=t_ch_fee_fenzhango.FieldByName('应收PP').AsFloat; t_mem_pd.FieldByName('应收CC').AsFloat:=t_ch_fee_fenzhango.FieldByName('应收CC').AsFloat; t_mem_pd.FieldByName('应付PP').AsFloat:=t_ch_fee_fenzhango.FieldByName('应付PP').AsFloat; t_mem_pd.FieldByName('应付CC').AsFloat:=t_ch_fee_fenzhango.FieldByName('应付CC').AsFloat; t_mem_pd.FieldByName('应收金额').AsFloat:=t_ch_fee_fenzhango.FieldByName('应收金额').AsFloat; t_mem_pd.FieldByName('应付金额').AsFloat:=t_ch_fee_fenzhango.FieldByName('应付金额').AsFloat; t_mem_pd.Post; end; t_ch_fee_fenzhango.Next; end; t_mem_pd.SortOnFields('FD_ID',true,false); t_op_gain.Close; t_op_gain.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_op_gain.Open; GetRptSum; if t_op_seae_assistant.Active then t_op_seae_assistant.Requery(); t_ch_fenzhango_sum.Open; t_ch_fenzhang_sum.Open; t_ch_fenzhangot_sum.Open; sys_print('海运出口分帐',1,t_ch_fee_fenzhang.DataSource,t_sum1,ds_op_fenzhang1,t_op_gain1,t_ch_fee_fenzhang1,t_mem_pd1,t_mem_pc1,t_mem_dc1,t_op_seae_assistant1,t_ch_fenzhang_sum1,t_rp_sum1,true,'',t_ch_fenzhango_sum1,t_ch_fenzhangot_sum1); t_ch_fenzhangot_sum.close; t_ch_fenzhango_sum.close; t_ch_fenzhang_sum.close; end; procedure Tfrm_op_seae_fenzhang.N56Click(Sender: TObject); begin t_mem_dc.Close; t_mem_dc.Open; t_mem_pc.Close; t_mem_pc.Open; t_ch_fee_fenzhangO.First; while not t_ch_fee_fenzhangO.Eof do begin if (t_ch_fee_fenzhangO.FieldByName('费用英文名').Asstring<>'') then begin t_mem_pc.Insert; t_mem_pc.FieldByName('FD_ID').Asinteger:=t_ch_fee_fenzhangO.FieldByName('FD_ID').Asinteger; t_mem_pc.FieldByName('代理名称').AsString:=t_ch_fee_fenzhangO.FieldByName('代理名称').AsString; t_mem_pc.FieldByName('费用英文名').AsString:=t_ch_fee_fenzhangO.FieldByName('费用英文名').AsString; t_mem_pc.FieldByName('币别').AsString:=t_ch_fee_fenzhangO.FieldByName('币别').AsString; t_mem_pc.FieldByName('汇率').AsFloat:=t_ch_fee_fenzhangO.FieldByName('汇率').AsFloat; t_mem_pc.FieldByName('数量').AsFloat:=t_ch_fee_fenzhangO.FieldByName('数量').AsFloat; t_mem_pc.FieldByName('单价').AsFloat:=t_ch_fee_fenzhangO.FieldByName('单价').AsFloat; t_mem_pc.FieldByName('应收PP').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应收PP').AsFloat; t_mem_pc.FieldByName('应收CC').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应收CC').AsFloat; t_mem_pc.FieldByName('应付PP').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应付PP').AsFloat; t_mem_pc.FieldByName('应付CC').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应付CC').AsFloat; t_mem_pc.FieldByName('应收金额').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应收金额').AsFloat; t_mem_pc.FieldByName('应付金额').AsFloat:=t_ch_fee_fenzhangO.FieldByName('应付金额').AsFloat; t_mem_pc.Post; end; t_ch_fee_fenzhangO.Next; end; t_mem_pc.SortOnFields('FD_ID',true,false); t_mem_pd.Close; t_mem_pd.Open; t_ch_fee_fenzhango.First; while not t_ch_fee_fenzhango.Eof do begin if (t_ch_fee_fenzhango.FieldByName('费用说明').Asstring<>'') then begin t_mem_pd.Insert; t_mem_pd.FieldByName('FD_ID').Asinteger:=t_ch_fee_fenzhango.FieldByName('FD_ID').Asinteger; t_mem_pd.FieldByName('代理名称').AsString:=t_ch_fee_fenzhango.FieldByName('代理名称').AsString; t_mem_pd.FieldByName('费用英文名').AsString:=t_ch_fee_fenzhango.FieldByName('费用英文名').AsString; t_mem_pd.FieldByName('费用说明').AsString:=t_ch_fee_fenzhango.FieldByName('费用说明').AsString; t_mem_pd.FieldByName('币别').AsString:=t_ch_fee_fenzhango.FieldByName('币别').AsString; t_mem_pd.FieldByName('汇率').AsFloat:=t_ch_fee_fenzhango.FieldByName('汇率').AsFloat; t_mem_pd.FieldByName('数量').AsFloat:=t_ch_fee_fenzhango.FieldByName('数量').AsFloat; t_mem_pd.FieldByName('单价').AsFloat:=t_ch_fee_fenzhango.FieldByName('单价').AsFloat; t_mem_pd.FieldByName('应收PP').AsFloat:=t_ch_fee_fenzhango.FieldByName('应收PP').AsFloat; t_mem_pd.FieldByName('应收CC').AsFloat:=t_ch_fee_fenzhango.FieldByName('应收CC').AsFloat; t_mem_pd.FieldByName('应付PP').AsFloat:=t_ch_fee_fenzhango.FieldByName('应付PP').AsFloat; t_mem_pd.FieldByName('应付CC').AsFloat:=t_ch_fee_fenzhango.FieldByName('应付CC').AsFloat; t_mem_pd.FieldByName('应收金额').AsFloat:=t_ch_fee_fenzhango.FieldByName('应收金额').AsFloat; t_mem_pd.FieldByName('应付金额').AsFloat:=t_ch_fee_fenzhango.FieldByName('应付金额').AsFloat; t_mem_pd.Post; end; t_ch_fee_fenzhango.Next; end; t_mem_pd.SortOnFields('FD_ID',true,false); t_op_gain.Close; t_op_gain.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_op_gain.Open; GetRptSum; if t_op_seae_assistant.Active then t_op_seae_assistant.Requery(); t_ch_fenzhangot_sum.Open; t_ch_fenzhango_sum.Open; t_ch_fenzhang_sum.Open; sys_print('海运出口分帐',3,t_ch_fee_fenzhang.DataSource,t_sum1,ds_op_fenzhang1,t_op_gain1,t_ch_fee_fenzhang1,t_mem_pd1,t_mem_pc1,t_mem_dc1,t_op_seae_assistant1,t_ch_fenzhang_sum1,t_rp_sum1,true,'',t_ch_fenzhango_sum1,t_ch_fenzhangot_sum1); t_ch_fenzhangot_sum.close; t_ch_fenzhango_sum.close; t_ch_fenzhang_sum.close; end; procedure Tfrm_op_seae_fenzhang.N32Click(Sender: TObject); begin //应收代理费用打印 if t_ch_fee_fenzhang.IsEmpty then exit; t_ch_client.close; t_ch_client.sql.clear; t_ch_client.sql.add('select * from t_ch_fee_fenzhang ' +'where 编号=:编号 and 代理名称=:代理名称 ' +' order by FD_ID'); t_ch_client.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_ch_client.Parameters.ParamByName('代理名称').value:=t_ch_fee_fenzhang.fieldbyname('代理名称').value; t_ch_client.open; t_ch_noclient.close; t_ch_noclient.sql.clear; t_ch_noclient.sql.add('select * from t_ch_fee_fenzhang ' +'where 编号=:编号 and 代理名称<>:代理名称 ' +' order by FD_ID'); t_ch_noclient.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_ch_noclient.Parameters.ParamByName('代理名称').value:=t_ch_fee_fenzhang.fieldbyname('代理名称').value; t_ch_noclient.open; t_op_gain.Close; t_op_gain.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_op_gain.Open; GetRptSum; if t_op_seae_assistant.Active then t_op_seae_assistant.Requery(); t_ch_fenzhango_sum.Open; t_ch_fenzhang_sum.Open; sys_print('海运出口代理分帐',1,t_ch_fee_fenzhang.DataSource,t_sum1,ds_op_fenzhang1,t_op_gain1,t_ch_fee_fenzhang1,t_ch_fee_fenzhango1,t_ch_client1,t_ch_noclient1,t_op_seae_assistant1,t_ch_fenzhang_sum1,t_rp_sum1,true,'',t_ch_fenzhango_sum1); t_ch_fenzhango_sum.close; t_ch_fenzhang_sum.close; end; procedure Tfrm_op_seae_fenzhang.N58Click(Sender: TObject); begin if t_ch_fee_fenzhang.IsEmpty then exit; t_ch_client.close; t_ch_client.sql.clear; t_ch_client.sql.add('select * from t_ch_fee_fenzhang ' +'where 编号=:编号 and 代理名称=:代理名称 ' +' order by FD_ID'); t_ch_client.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_ch_client.Parameters.ParamByName('代理名称').value:=t_ch_fee_fenzhang.fieldbyname('代理名称').value; t_ch_client.open; t_ch_noclient.close; t_ch_noclient.sql.clear; t_ch_noclient.sql.add('select * from t_ch_fee_fenzhang ' +'where 编号=:编号 and 代理名称<>:代理名称 ' +' order by FD_ID'); t_ch_noclient.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_ch_noclient.Parameters.ParamByName('代理名称').value:=t_ch_fee_fenzhang.fieldbyname('代理名称').value; t_ch_noclient.open; t_op_gain.Close; t_op_gain.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_op_gain.Open; GetRptSum; if t_op_seae_assistant.Active then t_op_seae_assistant.Requery(); t_ch_fenzhango_sum.Open; t_ch_fenzhang_sum.Open; sys_print('海运出口代理分帐',3,t_ch_fee_fenzhang.DataSource,t_sum1,ds_op_fenzhang1,t_op_gain1,t_ch_fee_fenzhang1,t_ch_fee_fenzhango1,t_ch_client1,t_ch_noclient1,t_op_seae_assistant1,t_ch_fenzhang_sum1,t_rp_sum1,true,'',t_ch_fenzhango_sum1); t_ch_fenzhango_sum.close; t_ch_fenzhang_sum.close; end; procedure Tfrm_op_seae_fenzhang.N34Click(Sender: TObject); begin if t_ch_fee_fenzhang.IsEmpty then exit; t_ch_client.close; t_ch_client.sql.clear; t_ch_client.sql.add('select * from t_ch_fee_fenzhang ' +'where 编号=:编号 and 代理名称=:代理名称 ' +' order by FD_ID'); t_ch_client.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_ch_client.Parameters.ParamByName('代理名称').value:=t_ch_fee_fenzhang.fieldbyname('代理名称').value; t_ch_client.open; t_ch_noclient.close; t_ch_noclient.sql.clear; t_ch_noclient.sql.add('select * from t_ch_fee_fenzhang ' +'where 编号=:编号 and 代理名称<>:代理名称 ' +' order by FD_ID'); t_ch_noclient.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_ch_noclient.Parameters.ParamByName('代理名称').value:=t_ch_fee_fenzhang.fieldbyname('代理名称').value; t_ch_noclient.open; t_op_gain.Close; t_op_gain.Parameters.ParamByName('编号').value:=t_ch_fee_fenzhang.fieldbyname('编号').value; t_op_gain.Open; GetRptSum; if t_op_seae_assistant.Active then t_op_seae_assistant.Requery(); t_ch_fenzhango_sum.Open; t_ch_fenzhang_sum.Open; sys_print('海运出口代理分帐',2,t_ch_fee_fenzhang.DataSource,t_sum1,ds_op_fenzhang1,t_op_gain1,t_ch_fee_fenzhang1,t_ch_fee_fenzhango1,t_ch_client1,t_ch_noclient1,t_op_seae_assistant1,t_ch_fenzhang_sum1,t_rp_sum1,true,'',t_ch_fenzhango_sum1); t_ch_fenzhango_sum.close; t_ch_fenzhang_sum.close; end; procedure Tfrm_op_seae_fenzhang.t_op_fenzhangAfterInsert( DataSet: TDataSet); begin t_op_fenzhang.FieldByName('编号').AsString:=t_ch_fee_fenzhang.DataSource.DataSet.FieldByName('编号').AsString; end; procedure Tfrm_op_seae_fenzhang.GetRptSum; begin //合计数据生成 t_rp_sum.Close; t_rp_sum.Open; t_ch_fee_fenzhang.First; while not t_ch_fee_fenzhang.Eof do begin if t_ch_fee_fenzhang.FieldByName('应收金额').AsFloat<>0 then begin t_rp_sum.Edit; t_rp_sum.FieldByName('DebitLocalOt合计').AsFloat:=t_rp_sum.FieldByName('DebitLocalOt合计').AsFloat+t_ch_fee_fenzhang.FieldByName('应收金额').AsFloat; t_rp_sum.FieldByName('DebitOtBafYas合计').AsFloat:=t_rp_sum.FieldByName('DebitOtBafYas合计').AsFloat+t_ch_fee_fenzhang.FieldByName('应收金额').AsFloat; t_rp_sum.Post; end; t_ch_fee_fenzhang.Next; end; if t_op_gain.FieldByName('合计应收USD').AsFloat<>0 then begin t_rp_sum.Edit; t_rp_sum.FieldByName('DebitLocalOt合计').AsFloat:=t_rp_sum.FieldByName('DebitLocalOt合计').AsFloat+t_op_gain.FieldByName('合计应收USD').AsFloat; t_rp_sum.Post; end; if t_op_fenzhang.FieldByName('其他费用').AsFloat<>0 then begin t_rp_sum.Edit; t_rp_sum.FieldByName('DebitOtBafYas合计').AsFloat:=t_rp_sum.FieldByName('DebitOtBafYas合计').AsFloat+t_op_fenzhang.FieldByName('其他费用').AsFloat; t_rp_sum.Post; end; if t_op_fenzhang.FieldByName('BAFYAS').AsFloat<>0 then begin t_rp_sum.Edit; t_rp_sum.FieldByName('DebitOtBafYas合计').AsFloat:=t_rp_sum.FieldByName('DebitOtBafYas合计').AsFloat+t_op_fenzhang.FieldByName('BAFYAS').AsFloat; t_rp_sum.Post; end; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_fenzhangOAfterInsert( DataSet: TDataSet); begin t_ch_fee_fenzhango['是否生成']:=0; t_ch_fee_fenzhango['结算代理']:=0; t_ch_fee_fenzhango['代理名称']:=t_ch_fee_fenzhang.DataSource.DataSet.fieldbyname('代理').asstring; t_ch_fee_fenzhango['币别']:='USD'; t_ch_fee_fenzhango['分帐比例']:='手工'; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_fenzhangOBeforeInsert( DataSet: TDataSet); begin if (DataSet.DataSource.DataSet.FieldByName('费用状态').AsString='费用封帐') then begin showmessage('费用已经封帐,不能修改费用!!'); abort; end; if t_ch_fee_fenzhango.DataSource.DataSet.State=dsinsert then t_ch_fee_fenzhango.DataSource.DataSet.post; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_fenzhangOBeforePost( DataSet: TDataSet); var li_pp,li_cc,fen_pp,fen_cc,fen:real; begin table_before_post(t_ch_fee_fenzhango,'代理名称'); table_before_post(t_ch_fee_fenzhango,'费用中文名'); table_before_post(t_ch_fee_fenzhango,'币别'); table_before_post(t_ch_fee_fenzhango,'汇率'); table_before_post(t_ch_fee_fenzhango,'分帐比例'); if frm_data_share.t_crm_client.Locate('客户简称',t_ch_fee_fenzhango.fieldbyname('代理名称').AsString,[]) then begin if frm_data_share.t_crm_client.fieldbyname('是否停用').AsBoolean then begin MessageDlg('此代理已停用,不能录入费用!',mtWarning,[mbok],0); abort; end; end; //保存时重新计算应收应付金额 try IF (t_ch_fee_fenzhango.FieldByName('分帐比例').ASSTRING<>'') and (t_ch_fee_fenzhango.FieldByName('分帐比例').ASSTRING<>'手工')then begin li_pp:=t_ch_fee_fenzhango.fieldbyname('应收PP').asfloat-t_ch_fee_fenzhango.fieldbyname('应付PP').asfloat; fen_pp:=li_pp*strtofloat('0.'+copy(t_ch_fee_fenzhango.FieldByName('分帐比例').ASSTRING,1,length(t_ch_fee_fenzhango.FieldByName('分帐比例').ASSTRING)-1)); li_cc:=t_ch_fee_fenzhango.fieldbyname('应收CC').asfloat-t_ch_fee_fenzhango.fieldbyname('应付CC').asfloat; fen_cc:=li_cc*(1-strtofloat('0.'+copy(t_ch_fee_fenzhango.FieldByName('分帐比例').ASSTRING,1,length(t_ch_fee_fenzhango.FieldByName('分帐比例').ASSTRING)-1))); fen:=fen_pp-fen_cc; if fen>=0 then begin t_ch_fee_fenzhango['应收金额']:=0; t_ch_fee_fenzhango['应付金额']:=s_w(strtoint(get_parameters_value(65,'2')),fen); end else begin t_ch_fee_fenzhango['应收金额']:=s_w(strtoint(get_parameters_value(65,'2')),fen*-1); t_ch_fee_fenzhango['应付金额']:=0; end; end; except ; end; { if (t_ch_fee_fenzhango.fieldbyname('应付金额').asfloat<>0)and(t_ch_fee_fenzhango.fieldbyname('应收金额').asfloat<>0)then begin showmessage('代理分帐的应收、应付费用只能有一项!!'); abort; end; } end; procedure Tfrm_op_seae_fenzhang.wwDBLookupCombo4Change(Sender: TObject); begin if (t_ch_fee_fenzhangO.state=dsinsert)or(t_ch_fee_fenzhangO.state=dsedit) then begin if frm_data_share.t_code_fee.Locate('中文名',wwDBLookupCombo4.text,[])then begin end; t_ch_fee_fenzhangO['费用英文名']:=frm_data_share.t_code_fee.fieldbyname('英文名').asstring; end; end; procedure Tfrm_op_seae_fenzhang.wwDBLookupCombo5Change(Sender: TObject); begin if (t_ch_fee_fenzhangO.state=dsinsert)or(t_ch_fee_fenzhangO.state=dsedit) then begin t_ch_fee_fenzhangO['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton8Click(Sender: TObject); begin //代理分账方案添加 try if not assigned(frm_code_fee_projectagent_add) then frm_code_fee_projectagent_add:=tfrm_code_fee_projectagent_add.Create (self); frm_code_fee_projectagent_add.op_type.text:='1'; frm_code_fee_projectagent_add.t_op_bill1.Enabled:=FALSE; frm_code_fee_projectagent_add.t_op_bill1.DataSet:=t_ch_fee_fenzhang.DataSource.DataSet; frm_code_fee_projectagent_add.t_op_bill1.Enabled:=true; frm_code_fee_projectagent_add.t_ch_fee1.Enabled:=false; frm_code_fee_projectagent_add.t_ch_fee1.DataSet:=t_ch_fee_fenzhang; frm_code_fee_projectagent_add.t_ch_fee1.Enabled:=true; frm_code_fee_projectagent_add.ShowModal; finally frm_code_fee_projectagent_add.free; frm_code_fee_projectagent_add:=nil; end; t_ch_fee_fenzhang.Close; t_ch_fee_fenzhang.Open; t_ch_fee_fenzhango.Close; t_ch_fee_fenzhango.Open; end; procedure Tfrm_op_seae_fenzhang.N1Click(Sender: TObject); begin if t_ch_fee_fenzhang.IsEmpty then exit; if t_ch_fee_fenzhang.FieldByName('是否生成').AsBoolean then begin if application.MessageBox('代理分帐费用已经产生费用,您确定要删除数据吗?','警告:',MB_OKCANCEL)=IDOK then t_ch_fee_fenzhang.delete; end else begin if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)=IDOK then t_ch_fee_fenzhang.delete; end; end; procedure Tfrm_op_seae_fenzhang.N3Click(Sender: TObject); begin if t_ch_fee_fenzhango.IsEmpty then exit; if t_ch_fee_fenzhango.FieldByName('是否生成').AsBoolean then begin if application.MessageBox('代理分帐费用已经产生费用,您确定要删除数据吗?','警告:',MB_OKCANCEL)=IDOK then t_ch_fee_fenzhango.delete; end else begin if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)=IDOK then t_ch_fee_fenzhango.delete; end; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton4Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton4.ClientToScreen(Point(0,bsSkinButton4.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_pl_detailAfterInsert( DataSet: TDataSet); begin //profit and loss 新增 t_ch_fee_pl_detail['PL_ID']:=t_ch_fee_pl['PL_ID']; t_ch_fee_pl_detail.FieldByName('类型').AsString:='收'; t_ch_fee_pl_detail.FieldByName('编号').AsString:=t_ch_fee_pl.FieldByName('编号').AsString; t_ch_fee_pl_detail.FieldByName('收入一').AsFloat:=0; t_ch_fee_pl_detail.FieldByName('收入二').AsFloat:=0; t_ch_fee_pl_detail.FieldByName('收入三').AsFloat:=0; t_ch_fee_pl_detail.FieldByName('收入合计').AsFloat:=0; t_ch_fee_pl_detail.FieldByName('支出一').AsFloat:=0; t_ch_fee_pl_detail.FieldByName('支出二').AsFloat:=0; t_ch_fee_pl_detail.FieldByName('支出三').AsFloat:=0; t_ch_fee_pl_detail.FieldByName('支出合计').AsFloat:=0; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_plAfterInsert(DataSet: TDataSet); begin t_ch_fee_pl.FieldByName('应收金额').AsFloat:=0; t_ch_fee_pl.FieldByName('应付金额').AsFloat:=0; t_ch_fee_pl.FieldByName('利润').AsFloat:=0; t_ch_fee_pl.FieldByName('合计').AsFloat:=0; t_ch_fee_pl.FieldByName('分成比例').AsFloat:=0; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton10Click(Sender: TObject); var aQuery:TAdoQuery; begin //profit and loss 费用生成 if t_ch_fee_pl.IsEmpty then begin t_ch_fee_pl.Insert; t_ch_fee_pl.Post; end; t_ch_fee_pl_detail.Insert; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('select sum(金额) as 空运费 from t_ch_fee where 类型=''收'' and 币别<>''RMB'' and 费用名称=''空运费'''); SQL.Add(' and 编号 in (select 编号 from v_op_bscard where (编号='''+t_ch_fee_pl.fieldbyname('编号').AsString+''')'); SQL.Add(' or (编号<>'''+t_ch_fee_pl.fieldbyname('编号').AsString+''' and 主编号='''+t_ch_fee_pl.fieldbyname('编号').AsString+''' and 业务来源=''R/O''))'); Open; if not IsEmpty then t_ch_fee_pl_detail.FieldByName('收入一').Asfloat:=fieldbyname('空运费').AsFloat; Close;SQL.Clear; SQL.Add('select sum(金额) as 燃油附加费 from t_ch_fee where 类型=''收'' and 币别<>''RMB'' and 费用名称=''燃油费'''); SQL.Add(' and 编号 in (select 编号 from v_op_bscard where (编号='''+t_ch_fee_pl.fieldbyname('编号').AsString+''')'); SQL.Add(' or (编号<>'''+t_ch_fee_pl.fieldbyname('编号').AsString+''' and 主编号='''+t_ch_fee_pl.fieldbyname('编号').AsString+''' and 业务来源=''R/O''))'); Open; if not IsEmpty then t_ch_fee_pl_detail.FieldByName('收入二').Asfloat:=fieldbyname('燃油附加费').AsFloat; Close;SQL.Clear; SQL.Add('select sum(金额) as 战争费 from t_ch_fee where 类型=''收'' and 币别<>''RMB'' and 费用名称=''战争费'''); SQL.Add(' and 编号 in (select 编号 from v_op_bscard where (编号='''+t_ch_fee_pl.fieldbyname('编号').AsString+''')'); SQL.Add(' or (编号<>'''+t_ch_fee_pl.fieldbyname('编号').AsString+''' and 主编号='''+t_ch_fee_pl.fieldbyname('编号').AsString+''' and 业务来源=''R/O''))'); Open; if not IsEmpty then t_ch_fee_pl_detail.FieldByName('收入三').Asfloat:=fieldbyname('战争费').AsFloat; end; finally FreeAndNil(aQuery); end; t_ch_fee_pl_detail.post; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_pl_detailBeforeInsert( DataSet: TDataSet); begin if (t_ch_fee_pl.DataSource.DataSet.FieldByName('费用状态').AsString='费用封帐') then begin showmessage('费用已经封帐,不能修改费用!!'); abort; end; if t_ch_fee_pl.IsEmpty then begin t_ch_fee_pl.Insert; t_ch_fee_pl.Post; end; if t_ch_fee_pl.State in [dsedit,dsinsert] then t_ch_fee_pl.Post; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_plBeforeInsert(DataSet: TDataSet); begin if t_ch_fee_pl.DataSource.DataSet.State=dsinsert then t_ch_fee_pl.DataSource.DataSet.post; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton12Click(Sender: TObject); begin if t_ch_fee_pl_detail.State in [dsedit,dsinsert] then t_ch_fee_pl_detail.Post; if t_ch_fee_pl_detailf.State in [dsedit,dsinsert] then t_ch_fee_pl_detailf.Post; if t_ch_fee_pl.State in [dsedit,dsinsert] then t_ch_fee_pl.Post; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton18Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton18.ClientToScreen(Point(0,bsSkinButton18.Height)); PopupMenu2.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_pl_detailAfterPost( DataSet: TDataSet); var aQuery:TAdoQuery; begin //合计数计算 aQuery:=CreateAdoQuery; try with aQuery do begin Close;sql.Clear; SQL.Add('Select sum(收入合计) as 收入,sum(支出合计) as 支出 from t_ch_fee_pl_detail where 编号='''+t_ch_fee_pl.FieldByName('编号').AsString+''''); Open; if not IsEmpty then begin t_ch_fee_pl.Edit; t_ch_fee_pl.FieldByName('应收金额').AsFloat:=FieldByName('收入').AsFloat; t_ch_fee_pl.FieldByName('应付金额').AsFloat:=FieldByName('支出').AsFloat; t_ch_fee_pl.Post; end; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_pl_detailfAfterInsert( DataSet: TDataSet); begin t_ch_fee_pl_detailf.FieldByName('类型').AsString:='付'; t_ch_fee_pl_detailf.FieldByName('编号').AsString:=t_ch_fee_pl.FieldByName('编号').AsString; t_ch_fee_pl_detailf.FieldByName('收入一').AsFloat:=0; t_ch_fee_pl_detailf.FieldByName('收入二').AsFloat:=0; t_ch_fee_pl_detailf.FieldByName('收入三').AsFloat:=0; t_ch_fee_pl_detailf.FieldByName('收入合计').AsFloat:=0; t_ch_fee_pl_detailf.FieldByName('支出一').AsFloat:=0; t_ch_fee_pl_detailf.FieldByName('支出二').AsFloat:=0; t_ch_fee_pl_detailf.FieldByName('支出三').AsFloat:=0; t_ch_fee_pl_detailf.FieldByName('支出合计').AsFloat:=0; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_plDSDesigner3Change( Sender: TField); begin t_ch_fee_pl.FieldByName('利润').AsFloat:=t_ch_fee_pl.FieldByName('应收金额').AsFloat-t_ch_fee_pl.FieldByName('应付金额').AsFloat; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton13Click(Sender: TObject); begin if MessageDlg('确实要删除此票的P&L吗?',mtWarning,[mbYes,mbNo],0)=mrYes then begin t_ch_fee_pl_detail.First; while not t_ch_fee_pl_detail.eof do begin t_ch_fee_pl_detail.Delete; end; t_ch_fee_pl_detailf.First; while not t_ch_fee_pl_detailf.eof do begin t_ch_fee_pl_detailf.Delete; end; t_ch_fee_pl.Delete; end; end; procedure Tfrm_op_seae_fenzhang.MenuItem2Click(Sender: TObject); begin sys_print('代理PL',1,t_ch_fee_pl.DataSource,t_ch_fee_pl1,nil,nil,t_ch_fee_pl_detail1,t_ch_fee_pl_detailf1,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_fenzhang.MenuItem4Click(Sender: TObject); begin sys_print('代理PL',3,t_ch_fee_pl.DataSource,t_ch_fee_pl1,nil,nil,t_ch_fee_pl_detail1,t_ch_fee_pl_detailf1,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_fenzhang.MenuItem6Click(Sender: TObject); begin sys_print('代理PL',2,t_ch_fee_pl.DataSource,t_ch_fee_pl1,nil,nil,t_ch_fee_pl_detail1,t_ch_fee_pl_detailf1,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_plDSDesigner5Change( Sender: TField); begin t_ch_fee_pl.FieldByName('合计').AsFloat:=t_ch_fee_pl.FieldByName('利润').AsFloat*t_ch_fee_pl.FieldByName('分成比例').AsFloat/100; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_pl_detailfDSDesigner6Change( Sender: TField); begin t_ch_fee_pl_detailf.FieldByName('支出合计').AsFloat:=t_ch_fee_pl_detailf.FieldByName('支出一').AsFloat+t_ch_fee_pl_detailf.FieldByName('支出二').AsFloat+t_ch_fee_pl_detailf.FieldByName('支出三').AsFloat; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_pl_detailDSDesigner6Change( Sender: TField); begin t_ch_fee_pl_detail.FieldByName('收入合计').AsFloat:=t_ch_fee_pl_detail.FieldByName('收入一').AsFloat+t_ch_fee_pl_detail.FieldByName('收入二').AsFloat+t_ch_fee_pl_detail.FieldByName('收入三').AsFloat; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_cmAfterInsert(DataSet: TDataSet); begin t_ch_fee_cm.FieldByName('编号').AsString:=t_ch_fee_cm.DataSource.DataSet.FieldByName('编号').AsString; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton25Click(Sender: TObject); begin // cargomainfest方案引入 try if not assigned(frm_code_fee_cargomainfest_add) then frm_code_fee_cargomainfest_add:=tfrm_code_fee_cargomainfest_add.Create (self); frm_code_fee_cargomainfest_add.op_type.text:='1'; frm_code_fee_cargomainfest_add.t_op_bill1.Enabled:=FALSE; frm_code_fee_cargomainfest_add.t_op_bill1.DataSet:=t_ch_fee_cm.DataSource.DataSet; frm_code_fee_cargomainfest_add.t_op_bill1.Enabled:=true; frm_code_fee_cargomainfest_add.t_ch_fee1.Enabled:=false; frm_code_fee_cargomainfest_add.t_ch_fee1.DataSet:=t_ch_fee_cm; frm_code_fee_cargomainfest_add.t_ch_fee1.Enabled:=true; frm_code_fee_cargomainfest_add.t_op_fenzhang1.Enabled:=FALSE; frm_code_fee_cargomainfest_add.t_op_fenzhang1.DataSet:=t_op_fenzhang; frm_code_fee_cargomainfest_add.t_op_fenzhang1.Enabled:=true; frm_code_fee_cargomainfest_add.ShowModal; finally frm_code_fee_cargomainfest_add.free; frm_code_fee_cargomainfest_add:=nil; end; t_ch_fee_cm.Close; t_ch_fee_cm.Open; setGrid; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton16Click(Sender: TObject); begin table_post(t_ch_fee_cm); end; procedure Tfrm_op_seae_fenzhang.bsSkinButton17Click(Sender: TObject); begin if MessageDlg('确实要删除此票的mainfast吗?',mtWarning,[mbYes,mbNo],0)=mrYes then begin t_ch_fee_cm.Delete; end; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_cmBeforePost(DataSet: TDataSet); var aQuery:TAdoQuery; s:String; i:integer; calc: TSmpExprCalc; begin //根据方案公式生成字段数值 if t_ch_fee_cm.FieldByName('模板名称').AsString='' then exit; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('select * from t_ch_project_cargomainfest_detail where 方案代码='''+t_ch_fee_cm.FieldByName('模板名称').AsString+''' and 字段类型=''计算'' order by 排序'); Open; if IsEmpty then begin end else begin first; while not eof do begin if fieldbyname('公式').AsString<>'' then begin S:=FieldByName('公式').AsString; for i:=0 to t_ch_fee_cm.FieldCount-1 do begin S:=StringReplace(S,'['+t_ch_fee_cm.Fields[I].FieldName+']',t_ch_fee_cm.Fields[I].AsString,[]); end; calc := TSmpExprCalc.Create(TRUE); try try if copy(S,1,1)='-' then S:='0'+S; calc.Expression := S; t_ch_fee_cm.fieldbyname(trim(FieldByName('字段名').AsString)).value:=strtofloat(calc.AsString); except t_ch_fee_cm.fieldbyname(trim(FieldByName('字段名').AsString)).value:=0; end; finally calc.Free; end; end; Next; end; end; end; finally FreeAndNil(aQuery); end; absno:=t_ch_fee_cm.fieldbyname('CM_ID').AsString; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton19Click(Sender: TObject); begin table_cancel(t_ch_fee_cm); end; procedure Tfrm_op_seae_fenzhang.MenuItem1Click(Sender: TObject); begin if t_op_fenzhang.State in [dsedit,dsinsert] then t_op_fenzhang.Post; if t_ch_fee_cm.State in [dsedit,dsinsert] then t_ch_fee_cm.Post; sys_print('代理CM',1,t_ch_fee_cm.DataSource,ds_op_fenzhang1,nil,nil,t_ch_fee_cm1,NIL,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_fenzhang.MenuItem8Click(Sender: TObject); begin if t_op_fenzhang.State in [dsedit,dsinsert] then t_op_fenzhang.Post; if t_ch_fee_cm.State in [dsedit,dsinsert] then t_ch_fee_cm.Post; sys_print('代理CM',3,t_ch_fee_cm.DataSource,ds_op_fenzhang1,nil,nil,t_ch_fee_cm1,NIL,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_fenzhang.MenuItem10Click(Sender: TObject); begin if t_op_fenzhang.State in [dsedit,dsinsert] then t_op_fenzhang.Post; if t_ch_fee_cm.State in [dsedit,dsinsert] then t_ch_fee_cm.Post; sys_print('代理CM',2,t_ch_fee_cm.DataSource,ds_op_fenzhang1,nil,nil,t_ch_fee_cm1,NIL,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_fenzhang.bsSkinButton20Click(Sender: TObject); var sumttl,sumttlot:double; function getfeeename(cname:string):string; var aQuery:TAdoQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.Add('select 英文名 from t_code_fee where 中文名='''+cname+''''); open; if not IsEmpty then result:=fieldbyname('英文名').AsString; end; finally FreeAndNil(aQuery); end; end; begin //cargomainfest生成到分票费用 if RxDBLookupCombo19.DisplayValue='' then begin MessageDlg('请先选择结算代理!',mtWarning,[mbok],0); exit; end; if RxDBLookupCombo2.DisplayValue='' then begin MessageDlg('请先选择费用名称!',mtWarning,[mbok],0); exit; end; if wwDBLookupCombo8.text='' then begin MessageDlg('请先选择币别!',mtWarning,[mbok],0); exit; end; table_post(t_ch_fee_cm); if t_ch_fee_cm.IsEmpty then exit; sumttl:=0; sumttlot:=0; t_ch_fee_cm.first; while not t_ch_fee_cm.eof do begin if t_ch_fee_cm.fieldbyname('合计').asfloat<>0 then begin sumttl:=t_ch_fee_cm.fieldbyname('合计').asfloat; if sumttl<>0 then begin t_ch_fee.insert; t_ch_fee['类型']:='收'; t_ch_fee['金额']:=sumttl; t_ch_fee['单价']:=sumttl; t_ch_fee['费用状态']:='录入状态'; t_ch_fee['编号']:=t_ch_fee_cm['分票编号']; t_ch_fee['费用名称']:=RxDBLookupCombo2.DisplayValue; t_ch_fee['费用英文名称']:= getfeeename(RxDBLookupCombo2.DisplayValue); t_ch_fee['客户名称']:=RxDBLookupCombo19.DisplayValue; t_ch_fee['结算单位']:='代理'; t_ch_fee['标准']:='单票'; t_ch_fee['数量']:=1; t_ch_fee['币别']:=wwDBLookupCombo8.text; IF frm_data_share.t_code_currency.Locate('币别',trim(wwDBLookupCombo8.text),[])THEN begin if trim(wwDBLookupCombo8.text)='USD' then begin t_ch_fee['汇率']:=getUsdExRate(t_ch_fee_cm.datasource.dataset.fieldbyname('开船日期').asstring); end else t_ch_fee['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; t_ch_fee['结算金额']:=0; t_ch_fee['开票金额']:=0; t_ch_fee['申请开票']:=0; t_ch_fee['冲抵金额']:=0; t_ch_fee['申请金额']:=0; t_ch_fee['是否对帐']:=0; t_ch_fee['是否垫付']:=0; t_ch_fee['不开发票']:=0; t_ch_fee['录入人']:=employee; t_ch_fee['录入日期']:=date; t_ch_fee['是否对帐']:=0; t_ch_fee['机密']:=0; t_ch_fee.post; end; { t_ch_fee_cm.edit; t_ch_fee_cm['是否生成']:=1; t_ch_fee_cm.post; } end; if wwDBLookupCombo7.text<>'' then begin if t_ch_fee_cm.fieldbyname('OT合计').asfloat<>0 then begin sumttlot:=t_ch_fee_cm.fieldbyname('OT合计').asfloat; if sumttlot<>0 then begin t_ch_fee.insert; t_ch_fee['类型']:='收'; t_ch_fee['金额']:=sumttlot; t_ch_fee['单价']:=sumttlot; t_ch_fee['费用状态']:='录入状态'; t_ch_fee['编号']:=t_ch_fee_cm['分票编号']; t_ch_fee['费用名称']:=RxDBLookupCombo2.DisplayValue; t_ch_fee['费用英文名称']:= getfeeename(RxDBLookupCombo2.DisplayValue); t_ch_fee['客户名称']:=RxDBLookupCombo19.DisplayValue; t_ch_fee['结算单位']:='代理'; t_ch_fee['标准']:='单票'; t_ch_fee['数量']:=1; t_ch_fee['币别']:=wwDBLookupCombo7.text; IF frm_data_share.t_code_currency.Locate('币别',trim(wwDBLookupCombo7.text),[])THEN begin if trim(wwDBLookupCombo7.text)='USD' then begin t_ch_fee['汇率']:=getUsdExRate(t_ch_fee_cm.datasource.dataset.fieldbyname('开船日期').asstring); end else t_ch_fee['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; t_ch_fee['结算金额']:=0; t_ch_fee['开票金额']:=0; t_ch_fee['申请开票']:=0; t_ch_fee['冲抵金额']:=0; t_ch_fee['申请金额']:=0; t_ch_fee['是否对帐']:=0; t_ch_fee['是否垫付']:=0; t_ch_fee['不开发票']:=0; t_ch_fee['录入人']:=employee; t_ch_fee['录入日期']:=date; t_ch_fee['是否对帐']:=0; t_ch_fee['机密']:=0; t_ch_fee.post; end; end; end; t_ch_fee_cm.Next; end; if t_op_fenzhang.State in [dsedit,dsinsert] then t_op_fenzhang.Post; if assigned(frm_ch_fee_sea) then begin if frm_ch_fee_sea.fra_fee1.t_ch_accept.Active then frm_ch_fee_sea.fra_fee1.t_ch_accept.Requery(); if frm_ch_fee_sea.fra_fee1.t_ch_pay.Active then frm_ch_fee_sea.fra_fee1.t_ch_pay.Requery(); end; showmessage('生成费用成功!!'); end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo19Enter(Sender: TObject); begin RxDBLookupCombo19.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo19Exit(Sender: TObject); begin RxDBLookupCombo19.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton24Click(Sender: TObject); var sumttl,sumttlot:double; function getfeeename(cname:string):string; var aQuery:TAdoQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.Add('select 英文名 from t_code_fee where 中文名='''+cname+''''); open; if not IsEmpty then result:=fieldbyname('英文名').AsString; end; finally FreeAndNil(aQuery); end; end; begin //cargomainfest生成到主票费用信息 if RxDBLookupCombo19.DisplayValue='' then begin MessageDlg('请先选择结算代理!',mtWarning,[mbok],0); exit; end; if RxDBLookupCombo2.DisplayValue='' then begin MessageDlg('请先选择费用名称!',mtWarning,[mbok],0); exit; end; if wwDBLookupCombo8.text='' then begin MessageDlg('请先选择币别!',mtWarning,[mbok],0); exit; end; table_post(t_ch_fee_cm); if t_ch_fee_cm.IsEmpty then exit; sumttl:=0; sumttlot:=0; t_ch_fee_cm.first; while not t_ch_fee_cm.eof do begin if t_ch_fee_cm.fieldbyname('合计').asfloat<>0 then begin sumttl:=sumttl+t_ch_fee_cm.fieldbyname('合计').asfloat; t_ch_fee_cm.edit; t_ch_fee_cm['是否生成']:=1; t_ch_fee_cm.post; end; if wwDBLookupCombo7.text<>'' then begin if t_ch_fee_cm.fieldbyname('OT合计').asfloat<>0 then begin sumttlot:=sumttlot+t_ch_fee_cm.fieldbyname('OT合计').asfloat; end; end; t_ch_fee_cm.Next; end; if sumttl<>0 then begin t_ch_fee.insert; t_ch_fee['类型']:='收'; t_ch_fee['金额']:=sumttl; t_ch_fee['单价']:=sumttl; t_ch_fee['费用状态']:='录入状态'; t_ch_fee['编号']:=t_ch_fee_cm['编号']; t_ch_fee['费用名称']:=RxDBLookupCombo2.DisplayValue; t_ch_fee['费用英文名称']:= getfeeename(RxDBLookupCombo2.DisplayValue); t_ch_fee['客户名称']:=RxDBLookupCombo19.DisplayValue; t_ch_fee['结算单位']:='代理'; t_ch_fee['标准']:='单票'; t_ch_fee['数量']:=1; t_ch_fee['币别']:=wwDBLookupCombo8.text; IF frm_data_share.t_code_currency.Locate('币别',wwDBLookupCombo8.text,[])THEN begin if wwDBLookupCombo8.text='USD' then begin t_ch_fee['汇率']:=getUsdExRate(t_ch_fee_cm.datasource.dataset.fieldbyname('开船日期').asstring); end else t_ch_fee['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; t_ch_fee['结算金额']:=0; t_ch_fee['开票金额']:=0; t_ch_fee['申请开票']:=0; t_ch_fee['冲抵金额']:=0; t_ch_fee['申请金额']:=0; t_ch_fee['是否对帐']:=0; t_ch_fee['是否垫付']:=0; t_ch_fee['不开发票']:=0; t_ch_fee['录入人']:=employee; t_ch_fee['录入日期']:=date; t_ch_fee['是否对帐']:=0; t_ch_fee['机密']:=0; t_ch_fee.post; end; if sumttlot<>0 then begin t_ch_fee.insert; t_ch_fee['类型']:='收'; t_ch_fee['金额']:=sumttlot; t_ch_fee['单价']:=sumttlot; t_ch_fee['费用状态']:='录入状态'; t_ch_fee['编号']:=t_ch_fee_cm['编号']; t_ch_fee['费用名称']:=RxDBLookupCombo2.DisplayValue; t_ch_fee['费用英文名称']:= getfeeename(RxDBLookupCombo2.DisplayValue); t_ch_fee['客户名称']:=RxDBLookupCombo19.DisplayValue; t_ch_fee['结算单位']:='代理'; t_ch_fee['标准']:='单票'; t_ch_fee['数量']:=1; t_ch_fee['币别']:=wwDBLookupCombo7.text; IF frm_data_share.t_code_currency.Locate('币别',wwDBLookupCombo8.text,[])THEN begin if wwDBLookupCombo8.text='USD' then begin t_ch_fee['汇率']:=getUsdExRate(t_ch_fee_cm.datasource.dataset.fieldbyname('开船日期').asstring); end else t_ch_fee['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; t_ch_fee['结算金额']:=0; t_ch_fee['开票金额']:=0; t_ch_fee['申请开票']:=0; t_ch_fee['冲抵金额']:=0; t_ch_fee['申请金额']:=0; t_ch_fee['是否对帐']:=0; t_ch_fee['是否垫付']:=0; t_ch_fee['不开发票']:=0; t_ch_fee['录入人']:=employee; t_ch_fee['录入日期']:=date; t_ch_fee['是否对帐']:=0; t_ch_fee['机密']:=0; t_ch_fee.post; end; if t_op_fenzhang.State in [dsedit,dsinsert] then t_op_fenzhang.Post; if assigned(frm_ch_fee_sea) then begin if frm_ch_fee_sea.fra_fee1.t_ch_accept.Active then frm_ch_fee_sea.fra_fee1.t_ch_accept.Requery(); if frm_ch_fee_sea.fra_fee1.t_ch_pay.Active then frm_ch_fee_sea.fra_fee1.t_ch_pay.Requery(); end; showmessage('生成费用成功!!'); end; procedure Tfrm_op_seae_fenzhang.bsSkinButton23Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton23.ClientToScreen(Point(0,bsSkinButton23.Height)); PopupMenu4.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_fenzhang.bsSkinButton15Click(Sender: TObject); var ExpClass:TDBGridEhExportClass; Ext:String; begin DBGrid.Selection.SelectAll; SaveDialog1.FileName := 'file1'; if SaveDialog1.Execute then begin case SaveDialog1.FilterIndex of 1: begin ExpClass := TDBGridEhExportAsXLS; Ext := 'xls'; end; 2: begin ExpClass := TDBGridEhExportAsCSV; Ext := 'csv'; end; 3: begin ExpClass := TDBGridEhExportAsHTML; Ext := 'htm'; end; 4: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; end; 5: begin ExpClass := TDBGridEhExportAsText; Ext := 'txt'; end; else ExpClass := nil; Ext := ''; end; if ExpClass <> nil then begin if UpperCase(Copy(SaveDialog1.FileName,Length(SaveDialog1.FileName)-2,3)) <> UpperCase(Ext) then SaveDialog1.FileName := SaveDialog1.FileName + '.' + Ext; SaveDBGridEhToExportFile(ExpClass,DBGrid, SaveDialog1.FileName,False); end; end; end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo2Enter(Sender: TObject); begin RxDBLookupCombo2.LookupDisplay:='代码;中文名'; end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo2Exit(Sender: TObject); begin RxDBLookupCombo2.LookupDisplay:='中文名'; end; procedure Tfrm_op_seae_fenzhang.setGrid; var aQuery:TADOQuery; S:String; l:integer; begin //根据方案生成列表 if t_op_fenzhang.FieldByName('方案代码').IsNull OR (t_op_fenzhang.FieldByName('方案代码').AsInteger=0) then exit; aQuery:=CreateAdoQuery; try with aQuery do begin close;SQL.Clear; SQL.Add('Select * from t_ch_project_cargomainfest_detail where 方案代码='+t_op_fenzhang.fieldByName('方案代码').AsString+' order by 排序'); Open; if Recordset.RecordCount>0 then begin first; DBGrid.FrozenCols:=0; DBGrid.FooterRowCount:=0; DBGrid.SumList.Active:=false; DBGrid.Columns.Clear; DBGrid.RowHeight:=18; while not Eof do begin with DBGrid.Columns.Add do begin AutoDropDown:=false; // ButtonStyle:=cbsNone; WordWrap:=true; ToolTips:=true; FieldName:=FieldByName('字段名').AsString; Title.Caption:=FieldByName('显示名称').AsString; S:=''; L:=Max(FieldByName('字段宽度').AsInteger, Length(Title.Caption)); while Length(S)=0 then sender.DataSet['收付类别']:='DEBIT' else begin sender.DataSet['收付类别']:='CREDIT'; debit:=debit*-1; end; sender.DataSet['金额大写']:='SAY:US DOLLARS '+ntoc(debit,true)+'ONLY.'; end; end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo5Enter(Sender: TObject); begin RxDBLookupCombo5.LookupDisplay:='代码;中文名'; end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo5Exit(Sender: TObject); begin RxDBLookupCombo5.LookupDisplay:='中文名'; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton29Click(Sender: TObject); var sumttl:double; function getfeeename(cname:string):string; var aQuery:TAdoQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.Add('select 英文名 from t_code_fee where 中文名='''+cname+''''); open; if not IsEmpty then result:=fieldbyname('英文名').AsString; end; finally FreeAndNil(aQuery); end; end; begin //D/C NOTE 生成到费用信息 if t_ch_fee_agentdc.State in [dsedit,dsinsert] then t_ch_fee_agentdc.Post; if t_ch_fee_agentdc.FieldByName('结算代理').AsString='' then begin MessageDlg('请先选择结算代理!',mtWarning,[mbok],0); exit; end; if t_ch_fee_agentdc.FieldByName('费用名称').AsString='' then begin MessageDlg('请先选择费用名称!',mtWarning,[mbok],0); exit; end; if t_ch_fee_agentdc.FieldByName('币别').AsString='' then begin MessageDlg('请先选择币别!',mtWarning,[mbok],0); exit; end; if t_ch_fee_agentdc.fieldbyname('结余金额').asfloat<>0 then begin sumttl:=t_ch_fee_agentdc.fieldbyname('结余金额').asfloat; if sumttl<>0 then begin t_ch_fee.insert; if sumttl>0 then begin t_ch_fee['类型']:='收'; t_ch_fee['金额']:=sumttl*t_ch_fee_agentdc.FieldByName('汇率').value; t_ch_fee['单价']:=sumttl*t_ch_fee_agentdc.FieldByName('汇率').value; end else begin t_ch_fee['类型']:='付'; t_ch_fee['金额']:=-sumttl*t_ch_fee_agentdc.FieldByName('汇率').value;; t_ch_fee['单价']:=-sumttl*t_ch_fee_agentdc.FieldByName('汇率').value;; end; t_ch_fee['费用状态']:='录入状态'; t_ch_fee['编号']:=t_ch_fee_agentdc['编号']; t_ch_fee['费用名称']:=t_ch_fee_agentdc.FieldByName('费用名称').AsString; t_ch_fee['费用英文名称']:= getfeeename(t_ch_fee_agentdc.FieldByName('费用名称').AsString); t_ch_fee['客户名称']:=t_ch_fee_agentdc.FieldByName('结算代理').AsString; t_ch_fee['结算单位']:='代理'; t_ch_fee['标准']:='单票'; t_ch_fee['数量']:=1; t_ch_fee['币别']:=t_ch_fee_agentdc.FieldByName('币别').AsString; if frm_data_share.t_code_currency.Locate('币别',trim(t_ch_fee_agentdc.FieldByName('币别').AsString),[])THEN begin if trim(wwDBLookupCombo8.text)='USD' then begin t_ch_fee['汇率']:=getUsdExRate(t_ch_fee_agentdc.datasource.dataset.fieldbyname('开船日期').asstring); end else t_ch_fee['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; t_ch_fee['结算金额']:=0; t_ch_fee['开票金额']:=0; t_ch_fee['申请开票']:=0; t_ch_fee['冲抵金额']:=0; t_ch_fee['申请金额']:=0; t_ch_fee['是否对帐']:=0; t_ch_fee['是否垫付']:=0; t_ch_fee['不开发票']:=0; t_ch_fee['录入人']:=employee; t_ch_fee['录入日期']:=date; t_ch_fee['是否对帐']:=0; t_ch_fee['机密']:=0; t_ch_fee.post; end; t_ch_fee_agentdc.edit; t_ch_fee_agentdc['是否生成']:=1; t_ch_fee_agentdc.post; end; end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo4Enter(Sender: TObject); begin RxDBLookupCombo4.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo4Exit(Sender: TObject); begin RxDBLookupCombo4.LookupDisplay:='客户简称'; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_agentdcAfterOpen( DataSet: TDataSet); begin dataset.FieldByName('应收金额').OnChange:=t_ch_fee_agentdcdebitcharge; dataset.FieldByName('应付金额').OnChange:=t_ch_fee_agentdcdebitcharge; end; procedure Tfrm_op_seae_fenzhang.bsSkinSpeedButton1Click(Sender: TObject); begin //生成帐单编号 if t_ch_fee_agentdc.fieldbyname('帐单编号').isnull or (t_ch_fee_agentdc['帐单编号']='') then begin t_ch_fee_agentdc.Edit; if Trim(frm_data_share.t_sys_noset.fieldbyname('日期规则').Asstring)='会计期间' then t_ch_fee_agentdc['帐单编号']:=getDCno(1,subComp,department,employee,t_ch_fee_agentdc.DataSource.DataSet['会计期间']) else t_ch_fee_agentdc['帐单编号']:=getDCno(1,subComp,department,employee,t_ch_fee_agentdc['录入日期']); end; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton34Click(Sender: TObject); begin //代理方案引入 try if not assigned(frm_code_fee_projectagent_add) then frm_code_fee_projectagent_add:=tfrm_code_fee_projectagent_add.Create (self); frm_code_fee_projectagent_add.op_type.text:='1'; frm_code_fee_projectagent_add.EditDc.text:='1'; frm_code_fee_projectagent_add.t_op_bill1.Enabled:=FALSE; frm_code_fee_projectagent_add.t_op_bill1.DataSet:=t_ch_fee_agentdc.DataSource.DataSet; frm_code_fee_projectagent_add.t_op_bill1.Enabled:=true; frm_code_fee_projectagent_add.t_ch_fee1.Enabled:=false; frm_code_fee_projectagent_add.t_ch_fee1.DataSet:=t_ch_fee_agentdc_detail; frm_code_fee_projectagent_add.t_ch_fee1.Enabled:=true; frm_code_fee_projectagent_add.ShowModal; finally frm_code_fee_projectagent_add.free; frm_code_fee_projectagent_add:=nil; end; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_agentdc_detaildebitcharge( Sender: TField); var li_pp,li_cc,fen_pp,fen_cc,fen:real; begin try IF (t_ch_fee_agentdc_detail.State in [dsedit,dsinsert]) and (t_ch_fee_agentdc_detail.FieldByName('分帐比例').ASSTRING<>'') and (t_ch_fee_agentdc_detail.FieldByName('分帐比例').ASSTRING<>'手工')then begin li_pp:=t_ch_fee_agentdc_detail.fieldbyname('应收PP').asfloat-t_ch_fee_agentdc_detail.fieldbyname('应付PP').asfloat; fen_pp:=li_pp*strtofloat('0.'+copy(t_ch_fee_agentdc_detail.FieldByName('分帐比例').ASSTRING,1,length(t_ch_fee_agentdc_detail.FieldByName('分帐比例').ASSTRING)-1)); li_cc:=t_ch_fee_agentdc_detail.fieldbyname('应收CC').asfloat-t_ch_fee_agentdc_detail.fieldbyname('应付CC').asfloat; fen_cc:=li_cc*(1-strtofloat('0.'+copy(t_ch_fee_agentdc_detail.FieldByName('分帐比例').ASSTRING,1,length(t_ch_fee_agentdc_detail.FieldByName('分帐比例').ASSTRING)-1))); fen:=fen_pp-fen_cc; if fen>=0 then begin t_ch_fee_agentdc_detail['应收金额']:=0; t_ch_fee_agentdc_detail['应付金额']:=s_w(strtoint(get_parameters_value(65,'2')),fen); end else begin t_ch_fee_agentdc_detail['应收金额']:=s_w(strtoint(get_parameters_value(65,'2')),fen*-1); t_ch_fee_agentdc_detail['应付金额']:=0; end; end; except ; end; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_agentdc_detailfeenamecharge( Sender: TField); begin if (t_ch_fee_agentdc_detail.state=dsinsert)or(t_ch_fee_agentdc_detail.state=dsedit) then begin if frm_data_share.t_code_fee.Locate('中文名',t_ch_fee_agentdc_detail.fieldbyname('费用中文名').AsString,[])then begin t_ch_fee_agentdc_detail['费用英文名']:=frm_data_share.t_code_fee.fieldbyname('英文名').asstring; end; end; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_agentdc_detailAfterOpen( DataSet: TDataSet); begin dataset.FieldByName('应收PP').OnChange:=t_ch_fee_agentdc_detaildebitcharge; dataset.FieldByName('应收CC').OnChange:=t_ch_fee_agentdc_detaildebitcharge; dataset.FieldByName('应付PP').OnChange:=t_ch_fee_agentdc_detaildebitcharge; dataset.FieldByName('应付CC').OnChange:=t_ch_fee_agentdc_detaildebitcharge; dataset.FieldByName('分帐比例').OnChange:=t_ch_fee_agentdc_detaildebitcharge; dataset.FieldByName('费用中文名').OnChange:=t_ch_fee_agentdc_detailfeenamecharge; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton30Click(Sender: TObject); begin t_ch_fee_agentdc_detail.Insert; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton31Click(Sender: TObject); begin if t_ch_fee_agentdc_detail.State in [dsedit,dsinsert] then t_ch_fee_agentdc_detail.post; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton33Click(Sender: TObject); begin if t_ch_fee_agentdc_detail.IsEmpty then exit; t_ch_fee_agentdc_detail.Delete; end; procedure Tfrm_op_seae_fenzhang.bsSkinButton35Click(Sender: TObject); begin if t_ch_fee_agentdc_detail.State in [dsedit,dsinsert] then t_ch_fee_agentdc_detail.cancel; end; procedure Tfrm_op_seae_fenzhang.wwDBLookupCombo12Change(Sender: TObject); begin if (t_ch_fee_agentdc_detail.state=dsinsert)or(t_ch_fee_agentdc_detail.state=dsedit) then begin t_ch_fee_agentdc_detail['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_agentdcBeforeDelete( DataSet: TDataSet); begin if (DataSet.DataSource.DataSet.FieldByName('费用状态').AsString='费用封帐') then begin showmessage('费用已经封帐,不能修改费用!!'); abort; end; if not t_ch_fee_agentdc.FieldByName('帐单编号').IsNull then delDCno(t_ch_fee_agentdc['帐单编号']); end; procedure Tfrm_op_seae_fenzhang.t_ch_fee_agentdcBeforeCancel( DataSet: TDataSet); begin if not (t_ch_fee_agentdc.State in [dsinsert]) then exit; if not t_ch_fee_agentdc.FieldByName('帐单编号').IsNull then delDCno(t_ch_fee_agentdc['帐单编号']); end; procedure Tfrm_op_seae_fenzhang.bsSkinButton36Click(Sender: TObject); var i,j,l:integer; s:string; fenzhangbandini:tinifile ; begin //保存页面顺序 fenzhangbandini:=Tinifile.Create(ExtractFilePath(application.ExeName)+'fenzhangbandno.ini'); frm_sys_tab_sort:=tfrm_sys_tab_sort.create(self); try frm_sys_tab_sort.ListBox2.Clear; for i:=0 to bsSkinPageControl1.PageCount-1 do begin frm_sys_tab_sort.ListBox2.Items.Add(bsSkinPageControl1.Pages[i].Caption+':'+bsSkinPageControl1.Pages[i].Name); end; frm_sys_tab_sort.ShowModal; if frm_sys_tab_sort.ModalResult=mrOk then begin for j:=0 to frm_sys_tab_sort.ListBox2.Items.Count-1 do begin s:=frm_sys_tab_sort.ListBox2.Items[j]; l:=pos(':',s)+1; for i:=0 to bsSkinPageControl1.PageCount-1 do begin if bsSkinPageControl1.Pages[i].Name=copy(s,l,length(s)-l+1) then begin bsSkinPageControl1.Pages[i].PageIndex:=j; fenzhangbandini.Writeinteger('fenzhang',copy(s,l,length(s)-l+1),j); end; end; end; end; finally FreeAndNil(frm_sys_tab_sort); freeandnil(fenzhangbandini); end; end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo3Enter(Sender: TObject); begin RxDBLookupCombo3.LookupDisplay:='代码;客户简称'; end; procedure Tfrm_op_seae_fenzhang.RxDBLookupCombo3Exit(Sender: TObject); begin RxDBLookupCombo3.LookupDisplay:='客户简称'; end; end.