unit u_fee_check; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, StdCtrls, Mask, bsSkinBoxCtrls, bsdbctrls, bsSkinCtrls,Variants, ExtCtrls, DBCtrls, Grids, Wwdbigrd, Wwdbgrid, Menus, XPMenu, RxLookup, wwdblook, RxMemDS; type Tfra_fee_check = class(TFrame) bsSkinPanel1: TbsSkinPanel; bsSkinPanel3: TbsSkinPanel; Panel1: TPanel; bsSkinButton1: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinPanel4: TbsSkinPanel; a_bo: TbsSkinGroupBox; DBMemo1: TDBMemo; a_delete: TbsSkinGroupBox; DBMemo2: TDBMemo; a_modify_old: TbsSkinGroupBox; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; DBEdit1: TDBEdit; DBEdit2: TDBEdit; DBEdit3: TDBEdit; DBEdit4: TDBEdit; DBEdit5: TDBEdit; DBEdit6: TDBEdit; DBEdit7: TDBEdit; DBEdit8: TDBEdit; a_modify_new: TbsSkinGroupBox; Label16: TLabel; Label17: TLabel; Label18: TLabel; Label19: TLabel; Label20: TLabel; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; DBEdit9: TDBEdit; DBEdit10: TDBEdit; DBEdit11: TDBEdit; DBEdit12: TDBEdit; DBEdit13: TDBEdit; DBEdit14: TDBEdit; DBEdit15: TDBEdit; DBEdit16: TDBEdit; DBMemo3: TDBMemo; wwDBGrid1: TwwDBGrid; DBEdit17: TDBEdit; bsSkinPanel5: TbsSkinPanel; bsSkinPanel6: TbsSkinPanel; p_bo: TbsSkinGroupBox; DBMemo4: TDBMemo; p_delete: TbsSkinGroupBox; DBMemo5: TDBMemo; p_modify_old: TbsSkinGroupBox; Label25: TLabel; Label26: TLabel; Label27: TLabel; Label28: TLabel; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; DBEdit19: TDBEdit; DBEdit20: TDBEdit; DBEdit21: TDBEdit; DBEdit22: TDBEdit; DBEdit23: TDBEdit; DBEdit24: TDBEdit; DBEdit25: TDBEdit; DBEdit26: TDBEdit; p_modify_new: TbsSkinGroupBox; Label33: TLabel; Label34: TLabel; Label35: TLabel; Label36: TLabel; Label37: TLabel; Label38: TLabel; Label39: TLabel; Label40: TLabel; DBEdit27: TDBEdit; DBEdit28: TDBEdit; DBEdit29: TDBEdit; DBEdit30: TDBEdit; DBEdit31: TDBEdit; DBEdit32: TDBEdit; DBEdit33: TDBEdit; DBEdit34: TDBEdit; wwDBGrid2: TwwDBGrid; DBEdit18: TDBEdit; Panel2: TPanel; bsSkinButton5: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton9: TbsSkinButton; t_ch_accept: TADOQuery; t_ch_accept1: TDataSource; t_ch_pay: TADOQuery; t_ch_pay1: TDataSource; t_op_gain: TADOQuery; t_op_gain1: TDataSource; a_shen_delete: TADOQuery; a_shen_modify_old: TADOQuery; a_shen_modify_new: TADOQuery; a_shen_modify_new1: TDataSource; a_shen_modify_old1: TDataSource; a_shen_delete1: TDataSource; p_shen_delete: TADOQuery; p_shen_delete1: TDataSource; p_shen_modify_old: TADOQuery; p_shen_modify_old1: TDataSource; p_shen_modify_new: TADOQuery; p_shen_modify_new1: TDataSource; PopupMenu4: TPopupMenu; N82: TMenuItem; N83: TMenuItem; N84: TMenuItem; N85: TMenuItem; N86: TMenuItem; N87: TMenuItem; N88: TMenuItem; PopupMenu5: TPopupMenu; MenuItem5: TMenuItem; MenuItem6: TMenuItem; MenuItem10: TMenuItem; MenuItem11: TMenuItem; MenuItem12: TMenuItem; MenuItem13: TMenuItem; MenuItem14: TMenuItem; XPMenu1: TXPMenu; bsSkinButton10: TbsSkinButton; bsSkinButton12: TbsSkinButton; Label1: TLabel; DBEdit35: TDBEdit; Label2: TLabel; DBEdit36: TDBEdit; DBEdit37: TDBEdit; DBEdit38: TDBEdit; Label4: TLabel; Label3: TLabel; bsSkinPanel7: TbsSkinPanel; Label5: TLabel; Label6: TLabel; DBEdit39: TDBEdit; DBEdit40: TDBEdit; bsSkinPanel8: TbsSkinPanel; Label7: TLabel; Label42: TLabel; DBEdit41: TDBEdit; DBEdit42: TDBEdit; Panel3: TPanel; bsSkinPanel2: TbsSkinPanel; bsSkinStdLabel1: TbsSkinStdLabel; bsSkinStdLabel2: TbsSkinStdLabel; bsSkinStdLabel3: TbsSkinStdLabel; bsSkinStdLabel4: TbsSkinStdLabel; bsSkinStdLabel5: TbsSkinStdLabel; bsSkinStdLabel6: TbsSkinStdLabel; bsSkinStdLabel7: TbsSkinStdLabel; bsSkinStdLabel8: TbsSkinStdLabel; bsSkinStdLabel9: TbsSkinStdLabel; bsSkinStdLabel10: TbsSkinStdLabel; bsSkinDBEdit1: TbsSkinDBEdit; bsSkinDBEdit2: TbsSkinDBEdit; bsSkinDBEdit3: TbsSkinDBEdit; bsSkinDBEdit4: TbsSkinDBEdit; bsSkinDBEdit5: TbsSkinDBEdit; bsSkinDBEdit6: TbsSkinDBEdit; bsSkinDBEdit7: TbsSkinDBEdit; bsSkinDBEdit8: TbsSkinDBEdit; bsSkinDBEdit9: TbsSkinDBEdit; bsSkinDBEdit10: TbsSkinDBEdit; bsSkinPanel9: TbsSkinPanel; bsSkinStdLabel11: TbsSkinStdLabel; bsSkinStdLabel12: TbsSkinStdLabel; bsSkinStdLabel13: TbsSkinStdLabel; bsSkinStdLabel14: TbsSkinStdLabel; bsSkinStdLabel15: TbsSkinStdLabel; bsSkinStdLabel16: TbsSkinStdLabel; bsSkinStdLabel17: TbsSkinStdLabel; bsSkinStdLabel18: TbsSkinStdLabel; bsSkinStdLabel19: TbsSkinStdLabel; bsSkinStdLabel20: TbsSkinStdLabel; bsSkinDBEdit11: TbsSkinDBEdit; bsSkinDBEdit12: TbsSkinDBEdit; bsSkinDBEdit13: TbsSkinDBEdit; bsSkinDBEdit14: TbsSkinDBEdit; bsSkinDBEdit15: TbsSkinDBEdit; bsSkinDBEdit16: TbsSkinDBEdit; bsSkinDBEdit17: TbsSkinDBEdit; bsSkinDBEdit18: TbsSkinDBEdit; bsSkinDBEdit19: TbsSkinDBEdit; bsSkinDBEdit20: TbsSkinDBEdit; t_op_gain_main: TADOQuery; t_op_gain_main1: TDataSource; DBEdit43: TDBEdit; Label43: TLabel; DBEdit44: TDBEdit; Label44: TLabel; DBEdit45: TDBEdit; Label45: TLabel; DBEdit46: TDBEdit; Label41: TLabel; DBEdit47: TDBEdit; Label46: TLabel; DBMemo6: TDBMemo; limited_str: TEdit; chk_accept: TEdit; chk_pay: TEdit; ywlb: TEdit; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; bsSkinPanel10: TbsSkinPanel; bsSkinGroupBox1: TbsSkinGroupBox; Memo1: TMemo; bsSkinButton15: TbsSkinButton; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; table_new1: TDataSource; t_bz_balance: TRxMemoryData; bsSkinButton17: TbsSkinButton; bsSkinButton16: TbsSkinButton; Label47: TLabel; Label48: TLabel; DBEdit48: TDBEdit; DBEdit49: TDBEdit; Label49: TLabel; DBEdit50: TDBEdit; Label50: TLabel; Label51: TLabel; DBEdit51: TDBEdit; DBEdit52: TDBEdit; Label52: TLabel; DBEdit53: TDBEdit; Label53: TLabel; Label54: TLabel; DBEdit54: TDBEdit; DBEdit55: TDBEdit; Label55: TLabel; DBEdit56: TDBEdit; Label56: TLabel; Label57: TLabel; DBEdit57: TDBEdit; DBEdit58: TDBEdit; Label58: TLabel; DBEdit59: TDBEdit; procedure DBEdit17Change(Sender: TObject); procedure DBEdit18Change(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure wwDBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); procedure wwDBGrid2DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinPanel2Resize(Sender: TObject); procedure Panel1Resize(Sender: TObject); procedure Panel2Resize(Sender: TObject); procedure t_ch_acceptBeforePost(DataSet: TDataSet); procedure t_ch_payBeforePost(DataSet: TDataSet); procedure N82Click(Sender: TObject); procedure N84Click(Sender: TObject); procedure N86Click(Sender: TObject); procedure N88Click(Sender: TObject); procedure MenuItem5Click(Sender: TObject); procedure MenuItem10Click(Sender: TObject); procedure MenuItem12Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure DBEdit43Change(Sender: TObject); procedure bsSkinPanel1Resize(Sender: TObject); procedure bsSkinPanel9Resize(Sender: TObject); procedure wwDBGrid1DblClick(Sender: TObject); procedure wwDBGrid2DblClick(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure bsSkinDBEdit8Change(Sender: TObject); procedure bsSkinDBEdit18Change(Sender: TObject); procedure getsumstr; procedure t_ch_acceptAfterOpen(DataSet: TDataSet); procedure t_ch_payAfterOpen(DataSet: TDataSet); procedure t_ch_payAfterScroll(DataSet: TDataSet); procedure t_ch_acceptAfterScroll(DataSet: TDataSet); procedure bsSkinButton15Click(Sender: TObject); procedure FrameEnter(Sender: TObject); procedure N3Click(Sender: TObject); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); private { Private declarations } procedure showPcmx(mydataset:TADOQUERY); public { Public declarations } end; implementation uses my_sys_function, u_fee_check_shen, u_main,u_lcxunit, u_data_share, u_Pcd_mx,u_check_modify, u_Amend_FeeList, u_amend_shenhe; {$R *.dfm} procedure Tfra_fee_check.getsumstr; var aQuery1,aQuery2:TAdoQuery; str1,str2:string; acceptstr,paystr:widestring; accepteof,payeof:boolean; armb,ausd,aot,atotal,prmb,pusd,pot,ptotal:double; begin if not strtobool(get_parameters_value(150,'false')) then exit; //费用下部合计字符串生成 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 (edit_type.text='1') and if_open('226') then memo1.Lines.Add(str1+'|'+str2); // if (edit_type.text='2') and if_open('227') then // memo1.Lines.Add(str1+'|'+str2); // if (edit_type.text='3') and if_open('228') then /// memo1.Lines.Add(str1+'|'+str2); // if (edit_type.text='4') and if_open('229') 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 Tfra_fee_check.DBEdit17Change(Sender: TObject); begin //应收驳回提交、申请删除、申请修改的显示 if t_ch_accept.IsEmpty then begin a_bo.Visible:=false; a_bo.Align:=alNone; a_delete.Visible:=false; a_delete.Align:=alNone; a_modify_old.Visible:=false; a_modify_old.Align:=alNone; a_modify_new.Visible:=false; a_modify_new.Align:=alNone; exit; end; if (t_ch_accept.FieldByName('费用状态').asstring='驳回提交') or (t_ch_accept.FieldByName('费用状态').asstring='复核驳回')then begin a_delete.Visible:=false; a_delete.Align:=alNone; a_modify_old.Visible:=false; a_modify_old.Align:=alNone; a_modify_new.Visible:=false; a_modify_new.Align:=alNone; a_bo.Visible:=true; a_bo.Align:=alRight; exit; end; if t_ch_accept.FieldByName('费用状态').asstring='申请删除'then begin a_bo.Visible:=false; a_bo.Align:=alNone; a_modify_old.Visible:=false; a_modify_old.Align:=alNone; a_modify_new.Visible:=false; a_modify_new.Align:=alNone; a_delete.Visible:=true; a_delete.Align:=alRight; exit; end; if t_ch_accept.FieldByName('费用状态').asstring='申请修改'then begin a_bo.Visible:=false; a_bo.Align:=alNone; a_delete.Visible:=false; a_delete.Align:=alNone; a_modify_new.Visible:=true; a_modify_new.Align:=alRight; a_modify_old.Visible:=true; a_modify_old.Align:=alRight; exit; end; a_bo.Visible:=false; a_bo.Align:=alNone; a_delete.Visible:=false; a_delete.Align:=alNone; a_modify_old.Visible:=false; a_modify_old.Align:=alNone; a_modify_new.Visible:=false; a_modify_new.Align:=alNone; end; procedure Tfra_fee_check.DBEdit18Change(Sender: TObject); begin //应付驳回提交、申请删除、申请修改的显示 if t_ch_pay.IsEmpty then begin p_bo.Visible:=false; p_bo.Align:=alNone; p_delete.Visible:=false; p_delete.Align:=alNone; p_modify_old.Visible:=false; p_modify_old.Align:=alNone; p_modify_new.Visible:=false; p_modify_new.Align:=alNone; exit; end; if (t_ch_pay.FieldByName('费用状态').asstring='驳回提交') or (t_ch_pay.FieldByName('费用状态').asstring='复核驳回') then begin p_delete.Visible:=false; p_delete.Align:=alNone; p_modify_old.Visible:=false; p_modify_old.Align:=alNone; p_modify_new.Visible:=false; p_modify_new.Align:=alNone; p_bo.Visible:=true; p_bo.Align:=alRight; exit; end; if t_ch_pay.FieldByName('费用状态').asstring='申请删除'then begin p_bo.Visible:=false; p_bo.Align:=alNone; p_modify_old.Visible:=false; p_modify_old.Align:=alNone; p_modify_new.Visible:=false; p_modify_new.Align:=alNone; p_delete.Visible:=true; p_delete.Align:=alRight; exit; end; if t_ch_pay.FieldByName('费用状态').asstring='申请修改'then begin p_bo.Visible:=false; p_bo.Align:=alNone; p_delete.Visible:=false; p_delete.Align:=alNone; p_modify_new.Visible:=true; p_modify_new.Align:=alRight; p_modify_old.Visible:=true; p_modify_old.Align:=alRight; exit; end; p_bo.Visible:=false; p_bo.Align:=alNone; p_delete.Visible:=false; p_delete.Align:=alNone; p_modify_old.Visible:=false; p_modify_old.Align:=alNone; p_modify_new.Visible:=false; p_modify_new.Align:=alNone; end; procedure Tfra_fee_check.bsSkinButton1Click(Sender: TObject); var M_field:string ; i:integer ; begin if not if_open('266') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; if G_Arrivdate='true' then begin M_field:=getfield(ywlb.text); if Varisnull(t_ch_accept.DataSource.DataSet.FieldByName(M_field).Value) then begin showmessage(M_field+'不能为空,请输入'+M_field); exit ; end ; end ; if (Trim(t_ch_accept.DataSource.DataSet.FieldByName('业务类型').asstring)='更改单') then begin UpdateopseaeStatus(t_ch_accept.DataSource.DataSet.FieldByName('编号').AsString,'公司货'); t_ch_accept.Refresh end else fee_check_part(limited_str.text,t_ch_accept,wwDBGrid1,chk_accept.Text,ywlb.text); end; procedure Tfra_fee_check.bsSkinButton5Click(Sender: TObject); var M_field:string ; i:integer ; begin if not if_open('266') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; if G_Arrivdate='true' then begin M_field:=getfield(ywlb.text); if Varisnull(t_ch_pay.DataSource.DataSet.FieldByName(M_field).Value) then begin showmessage(M_field+'不能为空,请输入'+M_field); exit ; end ; end ; if (Trim(t_ch_pay.DataSource.DataSet.FieldByName('业务类型').asstring)='更改单') then begin UpdateopseaeStatus(t_ch_pay.DataSource.DataSet.FieldByName('编号').AsString,'公司货'); t_ch_pay.Refresh end else fee_check_part(limited_str.text,t_ch_pay,wwDBGrid2,chk_pay.Text,ywlb.text); end; procedure Tfra_fee_check.bsSkinButton2Click(Sender: TObject); begin if not if_open('267') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; fee_back(limited_str.text,t_ch_accept,wwDBGrid1,chk_accept.Text,ywlb.Text); end; procedure Tfra_fee_check.bsSkinButton7Click(Sender: TObject); begin if not if_open('267') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; fee_back(limited_str.text,t_ch_pay,wwDBGrid2,chk_pay.Text,ywlb.Text); end; procedure Tfra_fee_check.wwDBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); begin fee_color(t_ch_accept,wwDBGrid1,Rect,Field); end; procedure Tfra_fee_check.wwDBGrid2DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); begin fee_color(t_ch_pay,wwDBGrid2,Rect,Field); end; procedure Tfra_fee_check.bsSkinButton4Click(Sender: TObject); begin if not if_open('268') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; // fee_shen_check_ok(limited_str.text,t_ch_accept,a_shen_delete,a_shen_modify_old,a_shen_modify_new); fee_shen_check_reok(limited_str.text,t_ch_accept,a_shen_delete, a_shen_modify_old,a_shen_modify_new,chk_accept.Text,ywlb.text); if Panel3.Visible then t_op_gain.Requery(); if bsSkinPanel9.Visible then t_op_gain_main.Requery(); end; procedure Tfra_fee_check.bsSkinButton8Click(Sender: TObject); begin if not if_open('268') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; // fee_shen_check_ok(limited_str.text,t_ch_pay,p_shen_delete,p_shen_modify_old,p_shen_modify_new); fee_shen_check_reok(limited_str.text,t_ch_pay,p_shen_delete,p_shen_modify_old,p_shen_modify_new, chk_pay.Text,ywlb.text); if Panel3.Visible then t_op_gain.Requery(); if bsSkinPanel9.Visible then t_op_gain_main.Requery(); end; procedure Tfra_fee_check.bsSkinButton3Click(Sender: TObject); begin if not if_open('269') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; fee_shen_check_back(limited_str.text,t_ch_accept,a_shen_delete,a_shen_modify_old,a_shen_modify_new); end; procedure Tfra_fee_check.bsSkinButton9Click(Sender: TObject); begin if not if_open('269') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; fee_shen_check_back(limited_str.text,t_ch_pay,p_shen_delete,p_shen_modify_old,p_shen_modify_new); end; procedure Tfra_fee_check.bsSkinButton11Click(Sender: TObject); begin try frm_fee_check_shen:=tfrm_fee_check_shen.Create(self); frm_fee_check_shen.t_ch_fee.Parameters.ParamByName('类型').value:='收'; frm_fee_check_shen.t_ch_fee.Parameters.ParamByName('编号').value:=t_ch_accept.DataSource.DataSet.fieldbyname('编号').Value; frm_fee_check_shen.t_ch_fee.open; frm_fee_check_shen.t_ch_fee_new.open; frm_fee_check_shen.ShowModal; finally frm_fee_check_shen.Free; end; end; procedure Tfra_fee_check.bsSkinButton6Click(Sender: TObject); begin try frm_fee_check_shen:=tfrm_fee_check_shen.Create(self); frm_fee_check_shen.t_ch_fee.Parameters.ParamByName('类型').value:='付'; frm_fee_check_shen.t_ch_fee.Parameters.ParamByName('编号').value:=t_ch_pay.DataSource.DataSet.fieldbyname('编号').Value; frm_fee_check_shen.t_ch_fee.open; frm_fee_check_shen.t_ch_fee_new.open; frm_fee_check_shen.ShowModal; finally frm_fee_check_shen.Free; end; end; procedure Tfra_fee_check.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=round((bsSkinPanel2.Width-196)/10); bsSkinDBEdit1.Width:=i; bsSkinDBEdit2.Width:=i; bsSkinDBEdit3.Width:=i; bsSkinDBEdit4.Width:=i; bsSkinDBEdit5.Width:=i; bsSkinDBEdit6.Width:=i; bsSkinDBEdit7.Width:=i; bsSkinDBEdit8.Width:=i; bsSkinDBEdit9.Width:=i; end; procedure Tfra_fee_check.Panel1Resize(Sender: TObject); var i:integer; begin i:=round(Panel1.Width/9); bsSkinButton1.Width:=i; bsSkinButton10.Width:=i; bsSkinButton2.Width:=i; bsSkinButton3.Width:=i; bsSkinButton4.Width:=i; bsSkinButton13.Width:=i; bsSkinButton14.Width:=i; bsSkinButton17.Width:=i; end; procedure Tfra_fee_check.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/7); bsSkinButton5.Width:=i; bsSkinButton12.Width:=i; bsSkinButton9.Width:=i; bsSkinButton7.Width:=i; bsSkinButton8.Width:=i; bsSkinButton16.Width:=i; end; procedure Tfra_fee_check.t_ch_acceptBeforePost(DataSet: TDataSet); begin t_ch_accept['费用状态']:=t_ch_accept['费用状态']; t_ch_accept['开票金额']:=t_ch_accept['开票金额']; t_ch_accept['申请开票']:=t_ch_accept['申请开票']; t_ch_accept['结算金额']:=t_ch_accept['结算金额']; end; procedure Tfra_fee_check.t_ch_payBeforePost(DataSet: TDataSet); begin t_ch_pay['费用状态']:=t_ch_pay['费用状态']; t_ch_pay['开票金额']:=t_ch_pay['开票金额']; t_ch_pay['申请开票']:=t_ch_pay['申请开票']; t_ch_pay['结算金额']:=t_ch_pay['结算金额']; end; procedure Tfra_fee_check.N82Click(Sender: TObject); begin fee_balance_view(t_ch_accept); end; procedure Tfra_fee_check.N84Click(Sender: TObject); begin fee_invoice_view(t_ch_accept); end; procedure Tfra_fee_check.N86Click(Sender: TObject); begin fee_modify_view(t_ch_accept); end; procedure Tfra_fee_check.N88Click(Sender: TObject); begin price_person_view; end; procedure Tfra_fee_check.MenuItem5Click(Sender: TObject); begin fee_balance_view(t_ch_pay); end; procedure Tfra_fee_check.MenuItem10Click(Sender: TObject); begin fee_check_view(t_ch_pay); end; procedure Tfra_fee_check.MenuItem12Click(Sender: TObject); begin fee_modify_view(t_ch_pay); end; procedure Tfra_fee_check.bsSkinButton10Click(Sender: TObject); var M_field:string ; begin if not if_open('266') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; if G_Arrivdate='true' then begin M_field:=getfield(ywlb.text); if Varisnull(t_ch_accept.DataSource.DataSet.FieldByName(M_field).Value) then begin showmessage(M_field+'不能为空,请输入'+M_field); exit ; end ; end ; if (Trim(t_ch_accept.DataSource.DataSet.FieldByName('业务类型').asstring)='更改单') then begin UpdateopseaeStatus(t_ch_accept.DataSource.DataSet.FieldByName('编号').AsString,'公司货'); t_ch_accept.Refresh end else fee_check_all(limited_str.text,t_ch_accept,chk_accept.text,ywlb.text); end; procedure Tfra_fee_check.bsSkinButton12Click(Sender: TObject); var M_field:string ; begin //全部审核 if not if_open('266') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; if G_Arrivdate='true' then begin M_field:=getfield(ywlb.text); if Varisnull(t_ch_pay.DataSource.DataSet.FieldByName(M_field).Value) then begin showmessage(M_field+'不能为空,请输入'+M_field); exit ; end ; end ; if (Trim(t_ch_pay.DataSource.DataSet.FieldByName('业务类型').asstring)='更改单') then begin UpdateopseaeStatus(t_ch_pay.DataSource.DataSet.FieldByName('编号').AsString,'公司货'); t_ch_pay.Refresh end else fee_check_all(limited_str.text,t_ch_pay,chk_pay.text,ywlb.text); end; procedure Tfra_fee_check.DBEdit43Change(Sender: TObject); begin //主票按钮的显示 if Panel3.Visible then begin if (DBEdit43.Text='拼箱主票') or (DBEdit43.Text='空运主票') or (DBEdit43.Text='铁路主票') then begin bsSkinPanel9.Visible:=true; Panel3.Height:=40; end else begin bsSkinPanel9.Visible:=false; Panel3.Height:=20; end; end; end; procedure Tfra_fee_check.bsSkinPanel1Resize(Sender: TObject); begin bsSkinPanel3.Height:=round((bsSkinPanel1.height)/2); end; procedure Tfra_fee_check.bsSkinPanel9Resize(Sender: TObject); var i:integer; begin //按钮长度计算 i:=round((bsSkinPanel9.Width-196)/10); bsSkinDBEdit11.Width:=i; bsSkinDBEdit12.Width:=i; bsSkinDBEdit13.Width:=i; bsSkinDBEdit14.Width:=i; bsSkinDBEdit15.Width:=i; bsSkinDBEdit16.Width:=i; bsSkinDBEdit17.Width:=i; bsSkinDBEdit18.Width:=i; bsSkinDBEdit19.Width:=i; end; procedure Tfra_fee_check.showPcmx(mydataset:TADOQUERY); begin //显示派车明细 if mydataset.FieldByName('结算单位').asstring='车队' then begin frm_Pcd_mx:=Tfrm_Pcd_mx.create(self); with frm_Pcd_mx.t_op_letter do begin Close ; parameters.ParamByName('编号').Value:=mydataset.fieldbyname('编号').value ; open ; end ; frm_Pcd_mx.t_op_letter_pc.Open ; frm_Pcd_mx.showmodal ; frm_Pcd_mx.free ; end ; end; procedure Tfra_fee_check.wwDBGrid1DblClick(Sender: TObject); begin showPcmx(t_ch_accept); end; procedure Tfra_fee_check.wwDBGrid2DblClick(Sender: TObject); begin showPcmx(t_ch_Pay); end; procedure Tfra_fee_check.bsSkinButton13Click(Sender: TObject); var aQuery:TADOQuery; begin //不开发票 aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('update t_ch_fee set 不开发票=1 where CH_ID='+inttostr(t_ch_accept.FieldbyName('CH_ID').asinteger)); ExecSQL; end; finally FreeAndNil(aQuery); end; t_ch_accept.Requery(); end; procedure Tfra_fee_check.bsSkinButton14Click(Sender: TObject); var aQuery:TADOQuery; begin //取消不开发票 aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('update t_ch_fee set 不开发票=0 where CH_ID='+inttostr(t_ch_accept.FieldbyName('CH_ID').asinteger)); ExecSQL; end; finally FreeAndNil(aQuery); end; t_ch_accept.Requery(); end; procedure Tfra_fee_check.bsSkinDBEdit8Change(Sender: TObject); begin if t_op_gain.FieldByName('毛利润').AsFloat<=0 then bsSkinDBEdit8.font.Color:=clRed else bsSkinDBEdit8.font.Color:=clBlue; end; procedure Tfra_fee_check.bsSkinDBEdit18Change(Sender: TObject); begin if t_op_gain_main.FieldByName('毛利润').AsFloat<=0 then bsSkinDBEdit18.font.Color:=clRed else bsSkinDBEdit18.font.Color:=clBlue; end; procedure Tfra_fee_check.t_ch_acceptAfterOpen(DataSet: TDataSet); begin getsumstr; end; procedure Tfra_fee_check.t_ch_payAfterOpen(DataSet: TDataSet); begin getsumstr; end; procedure Tfra_fee_check.t_ch_payAfterScroll(DataSet: TDataSet); begin getsumstr; end; procedure Tfra_fee_check.t_ch_acceptAfterScroll(DataSet: TDataSet); begin getsumstr; end; procedure Tfra_fee_check.bsSkinButton15Click(Sender: TObject); begin if t_ch_pay.DataSource.DataSet.FieldByName('费用状态').asstring='费用封帐' then begin showmessage('业务费用已经封帐,不能添加费用!'); exit; end; if t_ch_pay.DataSource.DataSet.FieldByName('费用状态').asstring='提交财务' then begin showmessage('业务费用已经提交财务,不能添加费用!'); exit; end; try if not ASSIGNED(frm_check_modify) then frm_check_modify:=Tfrm_check_modify.Create(application); frm_check_modify.RxDBLookupCombo1.Value:='海运费'; frm_check_modify.RxDBLookupCombo2.Value:='元增(付费)'; { ShowMessage('000'); frm_check_modify.wwDBLookupCombo3.Value:='USD'; ShowMessage('001'); ShowMessage(IntToStr(frm_data_share.t_code_currency.RecordCount)); ShowMessage('002'); if frm_data_share.t_code_currency.Locate('币别','USD',[])THEN frm_check_modify.Edit4.text:=frm_data_share.t_code_currency.fieldbyname('汇率').AsString; // frm_check_modify.Edit4.text:=FormatFloat('0.00;-0.00;0', getUsdExRate(FormatDateTime('YYYY-MM-DD',t_ch_Pay1.dataset.fieldbyname('录入日期').AsDateTime))); } frm_check_modify.table_new1:=t_ch_Pay1; frm_check_modify.ywlb.Text:=ywlb.Text; frm_check_modify.chk_pay.Text:=chk_pay.Text; frm_check_modify.ShowModal; finally frm_check_modify.Free; frm_check_modify:=nil; end; end; procedure Tfra_fee_check.FrameEnter(Sender: TObject); var str_list:Tstringlist; i,k,j:integer; begin //进费用模块需处理 //生成数据集录入费用时自动计算数量,客户名称 //海运业务 if (ywlb.Text='海运出口')or(ywlb.Text='海运进口') then begin 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; try 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_accept.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_accept.DataSource.DataSet.fieldbyname('尺码').asfloat>1 then t_bz_balance['three']:=t_ch_accept.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_accept.DataSource.DataSet.fieldbyname('重量').asfloat/1000)>t_ch_accept.DataSource.DataSet.fieldbyname('尺码').asfloat then begin if s_w(4,t_ch_accept.DataSource.DataSet.fieldbyname('重量').asfloat/1000)>1 then t_bz_balance['three']:=s_w(4,t_ch_accept.DataSource.DataSet.fieldbyname('重量').asfloat/1000) else t_bz_balance['three']:=1; end else begin if t_ch_accept.DataSource.DataSet.fieldbyname('尺码').asfloat>1 then t_bz_balance['three']:=t_ch_accept.DataSource.DataSet.fieldbyname('尺码').asfloat else t_bz_balance['three']:=1; end; except ; end; k:=0; 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_accept.DataSource.DataSet.fieldbyname('箱TEU').asinteger; t_bz_balance.post; str_list:=Tstringlist.Create(); str_list.Text:=t_ch_accept.DataSource.DataSet.fieldbyname('计费标准').asstring; for i:=0 to str_list.Count-1 do begin t_bz_balance.Append; t_bz_balance['one']:=inttostr(i+k+6)+'-'+copy(str_list[i],1,pos('*',str_list[i])-1); t_bz_balance['two']:=copy(str_list[i],pos('-',str_list[i])+1,length(str_list[i])+1-pos('-',str_list[i])); t_bz_balance['three']:=strtofloat(copy(str_list[i],pos('*',str_list[i])+1,pos('-',str_list[i])-pos('*',str_list[i])-1)); t_bz_balance.post; end; finally str_list.free; end; frm_data_share.t_code_fee_unit.First; while not frm_data_share.t_code_fee_unit.eof do begin t_bz_balance.Append; t_bz_balance['one']:=frm_data_share.t_code_fee_unit.fieldbyname('代码').asstring+'-'+frm_data_share.t_code_fee_unit.fieldbyname('标准名称').asstring; t_bz_balance['two']:=frm_data_share.t_code_fee_unit.fieldbyname('标准名称').asstring; t_bz_balance['three']:=frm_data_share.t_code_fee_unit.fieldbyname('默认数量').asfloat; t_bz_balance.post; frm_data_share.t_code_fee_unit.next; end; end; //空运业务 if (ywlb.Text='空运出口')or(ywlb.Text='空运进口') then begin try 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_accept.DataSource.DataSet.fieldbyname('计价重量').asfloat); t_bz_balance.post; t_bz_balance.Append; t_bz_balance['one']:='3-件数'; t_bz_balance['two']:='件数'; t_bz_balance['three']:=t_ch_accept.DataSource.DataSet.fieldbyname('件数').asfloat; t_bz_balance.post; t_bz_balance.Append; t_bz_balance['one']:='4-尺码'; t_bz_balance['two']:='尺码'; t_bz_balance['three']:=t_ch_accept.DataSource.DataSet.fieldbyname('尺码').asfloat; t_bz_balance.post; frm_data_share.t_code_fee_unit.First; while not frm_data_share.t_code_fee_unit.eof do begin t_bz_balance.Append; t_bz_balance['one']:=frm_data_share.t_code_fee_unit.fieldbyname('代码').asstring+'-'+frm_data_share.t_code_fee_unit.fieldbyname('标准名称').asstring; t_bz_balance['two']:=frm_data_share.t_code_fee_unit.fieldbyname('标准名称').asstring; t_bz_balance['three']:=frm_data_share.t_code_fee_unit.fieldbyname('默认数量').asfloat; t_bz_balance.post; frm_data_share.t_code_fee_unit.next; end; finally ; end; end; //监管车业务 if (ywlb.Text='监管车业务') then begin try 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_accept.DataSource.DataSet.fieldbyname('重量').asfloat); t_bz_balance.post; t_bz_balance.Append; t_bz_balance['one']:='3-件数'; t_bz_balance['two']:='件数'; t_bz_balance['three']:=t_ch_accept.DataSource.DataSet.fieldbyname('件数').asfloat; t_bz_balance.post; finally ; end; end; //铁路业务 if (ywlb.Text='铁路业务') then begin try 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']:=t_ch_accept.DataSource.DataSet.fieldbyname('件数').asfloat; t_bz_balance.post; finally ; end; end; end; procedure Tfra_fee_check.N3Click(Sender: TObject); begin if t_ch_pay.FieldByName('录入人').asstring<>employee then begin showmessage('对不起你无权删除此数据!'); Exit; end; fee_befor_modify(t_ch_pay); end; procedure Tfra_fee_check.bsSkinButton17Click(Sender: TObject); begin t_ch_accept.DataSource.DataSet.Edit; if t_ch_accept.DataSource.DataSet.FieldByName('自责更改').AsBoolean=True then t_ch_accept.DataSource.DataSet.FieldByName('自责更改').AsBoolean:=False else t_ch_accept.DataSource.DataSet.FieldByName('自责更改').value:=True; t_ch_accept.DataSource.DataSet.post; end; procedure Tfra_fee_check.bsSkinButton16Click(Sender: TObject); begin t_ch_pay.DataSource.DataSet.Edit; if t_ch_pay.DataSource.DataSet.FieldByName('自责更改').AsBoolean=True then t_ch_pay.DataSource.DataSet.FieldByName('自责更改').AsBoolean:=False else t_ch_pay.DataSource.DataSet.FieldByName('自责更改').value:=True; t_ch_pay.DataSource.DataSet.post; end; end.