unit u_code_UsdExRate; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, BusinessSkinForm, bsSkinCtrls, ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, dxDBTLCl, dxGrClms, DB, ADODB,Dialogs, StdCtrls, wwdblook, RxLookup; type Tfrm_code_UsdExRate = class(TForm) Panel1: TPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsBusinessSkinForm1: TbsBusinessSkinForm; dsrUsdExRate: TDataSource; t_code_usdexrate: TADOQuery; bsSkinGroupBox1: TbsSkinGroupBox; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridDateColumn; dxDBGrid1Column2: TdxDBGridDateColumn; bsSkinGroupBox2: TbsSkinGroupBox; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridDateColumn2: TdxDBGridDateColumn; ds_code_jpexrate1: TDataSource; t_code_jpexrate: TADOQuery; Panel2: TPanel; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton9: TbsSkinButton; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1Column5: TdxDBGridColumn; bsSkinButton10: TbsSkinButton; p_op_gain: TADOStoredProc; dxDBGrid1Column6: TdxDBGridLookupColumn; t_code_usdexrateID: TAutoIncField; t_code_usdexrateDSDesigner2: TDateTimeField; t_code_usdexrateDSDesigner3: TDateTimeField; t_code_usdexrateDSDesigner6: TStringField; t_code_usdexratelk_currency: TStringField; RxDBLookupCombo2: TRxDBLookupCombo; bsSkinButton11: TbsSkinButton; t_code_usdexrateDSDesigner: TBCDField; t_code_usdexrateDSDesigner4: TBCDField; t_code_usdexrateDSDesigner5: TBCDField; procedure FormShow(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure t_code_usdexrateBeforeInsert(DataSet: TDataSet); procedure t_code_usdexrateAfterInsert(DataSet: TDataSet); procedure RxDBLookupCombo2Change(Sender: TObject); procedure t_code_usdexrateBeforePost(DataSet: TDataSet); procedure bsSkinButton11Click(Sender: TObject); private { Private declarations } public { Public declarations } procedure Upbsrate(bsno,aCurrency:string); end; var frm_code_UsdExRate: Tfrm_code_UsdExRate; implementation uses u_data_share, my_sys_function, u_main, u_sys_progress; {$R *.dfm} procedure Tfrm_code_UsdExRate.FormShow(Sender: TObject); begin RxDBLookupCombo2.DisplayValue:='USD'; if not t_code_usdexrate.Active then t_code_usdexrate.Open; { if not t_code_jpexrate.Active then t_code_jpexrate.Open; } end; procedure Tfrm_code_UsdExRate.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin CanClose:=frm_close_query(t_code_usdexrate); // CanClose:=frm_close_query(t_code_jpexrate); end; procedure Tfrm_code_UsdExRate.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_code_UsdExRate.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_code_usdexrate); end; procedure Tfrm_code_UsdExRate.bsSkinButton2Click(Sender: TObject); begin table_post(t_code_usdexrate); end; procedure Tfrm_code_UsdExRate.bsSkinButton4Click(Sender: TObject); begin table_delete(t_code_usdexrate); end; procedure Tfrm_code_UsdExRate.bsSkinButton1Click(Sender: TObject); begin t_code_usdexrate.Insert; end; procedure Tfrm_code_UsdExRate.bsSkinButton6Click(Sender: TObject); begin // t_code_jpexrate.Insert; end; procedure Tfrm_code_UsdExRate.bsSkinButton7Click(Sender: TObject); begin // table_post(t_code_jpexrate); end; procedure Tfrm_code_UsdExRate.bsSkinButton8Click(Sender: TObject); begin // table_delete(t_code_jpexrate); end; procedure Tfrm_code_UsdExRate.bsSkinButton9Click(Sender: TObject); begin // table_cancel(t_code_jpexrate); end; procedure Tfrm_code_UsdExRate.Upbsrate(bsno,aCurrency:string); var aAdoQuery:TAdoQuery; begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; sql.Add('Select * from t_ch_fee'); sql.Add('where 编号=:编号 and 币别=:币别'); Parameters.ParamByName('编号').Value:=bsno; Parameters.ParamByName('币别').Value:=trim(aCurrency); Open;First; while not Eof do begin Edit; FieldByName('汇率').Value:=t_code_usdexrate.FieldByName('汇率').Value; Post; Next; end; finally Free; end; end; procedure Tfrm_code_UsdExRate.bsSkinButton10Click(Sender: TObject); var aAdoQuery:TAdoQuery; s:string; begin if trim(RxDBLookupCombo2.DisplayValues[0])='' then begin showmessage('请先选择币别'); Exit; end; if t_code_usdexrate.FieldByName('汇率').IsNull then Exit; s:='从:'+t_code_usdexrate.FieldByName('开始日期').AsString+' 到:'+ t_code_usdexrate.FieldByName('结束日期').AsString+' 的汇率 '+'更新为'+t_code_usdexrate.FieldByName('汇率').AsString; if MessageDlg('确实要将开船日期(会计日期-更改单)'+s+'要更新吗?',mtWarning,[mbyes,mbno],0)<>mryes then Exit; if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.bsSkinGauge1.ProgressText:='加载数据请等候。。。'; frm_sys_progress.Show; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; sql.Add('Select * from V_op_bscard_All where 业务种类=''普通货'''); sql.Add('and 开船日期 between :beginEtd and :endETD'); Parameters.ParamByName('beginEtd').Value:=t_code_usdexrate.FieldByName('开始日期').AsDateTime; Parameters.ParamByName('endETD').Value:=t_code_usdexrate.FieldByName('结束日期').AsDateTime; Open;First; if not IsEmpty then begin frm_sys_progress.bsSkinGauge1.MaxValue:=recordcount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; while not Eof do begin frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.bsSkinGauge1.ProgressText:='主提单号:'+FieldByName('主提单号').Asstring; Upbsrate(FieldByName('编号').Asstring,t_code_usdexrate.FieldByName('币别').Value); Next; end; end; Close;SQL.Clear; sql.Add('Select * from V_op_bscard_All where 业务种类=''更改单'''); sql.Add('and 会计期间 between :beginEtd and :endETD'); Parameters.ParamByName('beginEtd').Value:=t_code_usdexrate.FieldByName('开始日期').AsDateTime; Parameters.ParamByName('endETD').Value:=t_code_usdexrate.FieldByName('结束日期').AsDateTime; Open;First; if not IsEmpty then begin Open;First; frm_sys_progress.bsSkinGauge1.MaxValue:=recordcount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; while not Eof do begin frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.bsSkinGauge1.ProgressText:='主提单号:'+FieldByName('主提单号').Asstring; Upbsrate(FieldByName('编号').Asstring,t_code_usdexrate.FieldByName('币别').Value); Next; end; end; finally frm_sys_progress.close; frm_sys_progress:=nil; Free; end; end; procedure Tfrm_code_UsdExRate.t_code_usdexrateBeforeInsert( DataSet: TDataSet); begin if trim(RxDBLookupCombo2.DisplayValues[0])='' then begin showmessage('请先选择币别'); Abort; end; end; procedure Tfrm_code_UsdExRate.t_code_usdexrateAfterInsert( DataSet: TDataSet); begin t_code_usdexrate.FieldByName('币别').AsString:=trim(trim(RxDBLookupCombo2.DisplayValues[0])); end; procedure Tfrm_code_UsdExRate.RxDBLookupCombo2Change(Sender: TObject); begin if not frm_data_share.t_code_currency.Locate('币别',trim(RxDBLookupCombo2.DisplayValues[0]),[]) then begin exit; end; with t_code_usdexrate do begin close;sql.clear; sql.add('select * from t_code_usdexrate'); sql.add('where 币别=:币别'); Parameters.ParamByName('币别').Value:=trim(RxDBLookupCombo2.DisplayValues[0]); sql.add('order by 开始日期 desc'); Open;First; end; end; procedure Tfrm_code_UsdExRate.t_code_usdexrateBeforePost(DataSet: TDataSet); begin if t_code_usdexrate.FieldByName('币别').AsString<>trim(trim(RxDBLookupCombo2.DisplayValues[0])) then begin showmessage('新币别:'+t_code_usdexrate.FieldByName('币别').AsString+' 不等于 已经选择的币别: '+trim(trim(RxDBLookupCombo2.DisplayValues[0]))); abort; end; table_before_post(t_code_usdexrate,'币别'); table_before_post(t_code_usdexrate,'开始日期'); table_before_post(t_code_usdexrate,'结束日期'); end; procedure Tfrm_code_UsdExRate.bsSkinButton11Click(Sender: TObject); var aAdoQuery:TAdoQuery; s:string; begin if trim(RxDBLookupCombo2.DisplayValues[0])='' then begin showmessage('请先选择币别'); Exit; end; if t_code_usdexrate.FieldByName('汇率').IsNull then Exit; s:='从:'+t_code_usdexrate.FieldByName('开始日期').AsString+' 到:'+ t_code_usdexrate.FieldByName('结束日期').AsString+' 的汇率 '+'更新为'+t_code_usdexrate.FieldByName('汇率').AsString; if MessageDlg('确实要将会计日期'+s+'要更新吗?',mtWarning,[mbyes,mbno],0)<>mryes then Exit; if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.bsSkinGauge1.ProgressText:='加载数据请等候。。。'; frm_sys_progress.Show; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; sql.Add('Select * from V_op_bscard_All where 1=1 '); sql.Add('and 会计期间 between :beginEtd and :endETD'); Parameters.ParamByName('beginEtd').Value:=t_code_usdexrate.FieldByName('开始日期').AsDateTime; Parameters.ParamByName('endETD').Value:=t_code_usdexrate.FieldByName('结束日期').AsDateTime; Open;First; if not IsEmpty then begin frm_sys_progress.bsSkinGauge1.MaxValue:=recordcount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; while not Eof do begin frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.bsSkinGauge1.ProgressText:='主提单号:'+FieldByName('主提单号').Asstring; Upbsrate(FieldByName('编号').Asstring,t_code_usdexrate.FieldByName('币别').Value); Next; end; end; finally frm_sys_progress.close; frm_sys_progress:=nil; Free; end; end; end.