unit u_code_UsdExRate; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, BusinessSkinForm, bsSkinCtrls, ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid,Dialogs, dxDBTLCl, dxGrClms, DB, ADODB; 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; bsSkinButton11: TbsSkinButton; bsSkinButton10: TbsSkinButton; 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 bsSkinButton11Click(Sender: TObject); private procedure Upbsrate(bsno,aCurrency:string); { Private declarations } public { Public declarations } 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 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.bsSkinButton10Click(Sender: TObject); var aAdoQuery:TAdoQuery; s:string; begin 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,'USD'); 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,'USD'); Next; end; end; finally frm_sys_progress.close; frm_sys_progress:=nil; Free; end; end; procedure Tfrm_code_UsdExRate.bsSkinButton11Click(Sender: TObject); var aAdoQuery:TAdoQuery; s:string; begin 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,'USD'); Next; end; end; finally frm_sys_progress.close; frm_sys_progress:=nil; Free; end; 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; end.