unit U_op_state_view; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, u_fee_check, StdCtrls, Mask, DBCtrls, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner, bsSkinCtrls, DB, ADODB, Menus, Grids, Wwdbigrd, Wwdbgrid, ExtCtrls, bsSkinBoxCtrls, bsdbctrls, DBGrids, DBGridEh, RxLookup, ComCtrls, bsSkinTabs, wwdblook, cxControls, cxSplitter, wwdbedit, Wwdotdot, Wwdbcomb, wwdbdatetimepicker; type Tfrm_op_state_view = class(TForm) tv_bscard_all: TADOQuery; tv_bscard_all1: TDataSource; Panel3: TPanel; DBEdit1: TDBEdit; DBEdit6: TDBEdit; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; qrytmp: TADOQuery; bsSkinPanel4: TbsSkinPanel; bsSkinPanel1: TbsSkinPanel; Label116: TLabel; Edit16: TEdit; Label40: TLabel; RxDBLookupCombo15: TRxDBLookupCombo; Label2: TLabel; RxDBLookupCombo5: TRxDBLookupCombo; bsSkinPanel6: TbsSkinPanel; Label6: TLabel; wwDBLookupCombo49: TwwDBLookupCombo; Label5: TLabel; Edit7: TEdit; bsSkinPanel7: TbsSkinPanel; bsSkinButton44: TbsSkinButton; bsSkinButton1: TbsSkinButton; Panel1: TPanel; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column9: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridDateColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridDateColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column17: TdxDBGridMaskColumn; dxDBGrid1Column18: TdxDBGridMaskColumn; dxDBGrid1Column19: TdxDBGridCurrencyColumn; dxDBGrid1Column20: TdxDBGridMaskColumn; dxDBGrid1Column21: TdxDBGridDateColumn; dxDBGrid1Column22: TdxDBGridMaskColumn; dxDBGrid1Column23: TdxDBGridMaskColumn; dxDBGrid1Column24: TdxDBGridMaskColumn; dxDBGrid1Column25: TdxDBGridMaskColumn; dxDBGrid1Column26: TdxDBGridMaskColumn; dxDBGrid1Column27: TdxDBGridCheckColumn; dxDBGrid1Column28: TdxDBGridCheckColumn; dxDBGrid1Column29: TdxDBGridCheckColumn; dxDBGrid1Column30: TdxDBGridDateColumn; dxDBGrid1Column31: TdxDBGridMaskColumn; dxDBGrid1Column32: TdxDBGridMaskColumn; dxDBGrid1Column33: TdxDBGridMaskColumn; dxDBGrid1Column34: TdxDBGridMaskColumn; dxDBGrid1Column35: TdxDBGridMaskColumn; dxDBGrid1Column36: TdxDBGridMaskColumn; dxDBGrid1Column37: TdxDBGridMaskColumn; dxDBGrid1Column38: TdxDBGridDateColumn; dxDBGrid1Column39: TdxDBGridMaskColumn; dxDBGrid1Column40: TdxDBGridMaskColumn; dxDBGrid1Column41: TdxDBGridMaskColumn; dxDBGrid1Column65: TdxDBGridDateColumn; dxDBGrid1Column68: TdxDBGridColumn; dxDBGrid1Column70: TdxDBGridColumn; bsSkinGroupBox1: TbsSkinGroupBox; bsSkinGroupBox2: TbsSkinGroupBox; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridCheckColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridMaskColumn2: TdxDBGridMaskColumn; dxDBGridMaskColumn3: TdxDBGridMaskColumn; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridDateColumn2: TdxDBGridDateColumn; dxDBGridColumn1: TdxDBGridColumn; t_op_state: TADOQuery; t_op_state1: TDataSource; t_op_fee_group: TADOQuery; t_op_fee_group1: TDataSource; cxSplitter1: TcxSplitter; Label10: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; Label1: TLabel; wwDBDateTimePicker2: TwwDBDateTimePicker; Label3: TLabel; wwDBComboBox8: TwwDBComboBox; bsSkinPanel3: TbsSkinPanel; bsSkinGroupBox3: TbsSkinGroupBox; bsSkinGroupBox4: TbsSkinGroupBox; cxSplitter2: TcxSplitter; bsSkinPanel5: TbsSkinPanel; Label4: TLabel; DBText1: TDBText; Label7: TLabel; DBText6: TDBText; Label8: TLabel; DBText7: TDBText; DBText2: TDBText; Label9: TLabel; Label11: TLabel; DBText3: TDBText; DBText8: TDBText; Label12: TLabel; Label13: TLabel; DBText5: TDBText; Label14: TLabel; DBText4: TDBText; DBText9: TDBText; t_op_fee_groupC1: TDataSource; t_op_fee_groupC: TADOQuery; bsSkinPanel2: TbsSkinPanel; bsSkinPanel8: TbsSkinPanel; bsSkinBevel1: TbsSkinBevel; bsSkinBevel2: TbsSkinBevel; Memo1: TMemo; Memo2: TMemo; DBGridEh1: TDBGridEh; DBGridEh2: TDBGridEh; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N74Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton44Click(Sender: TObject); procedure Edit16KeyPress(Sender: TObject; var Key: Char); procedure bsSkinPanel3Resize(Sender: TObject); procedure dxDBGrid1DblClick(Sender: TObject); procedure tv_bscard_allBeforeScroll(DataSet: TDataSet); procedure tv_bscard_allAfterScroll(DataSet: TDataSet); procedure t_op_fee_groupAfterScroll(DataSet: TDataSet); procedure t_op_fee_groupCAfterScroll(DataSet: TDataSet); private procedure getdrstrlist; procedure getcrstrlist; { Private declarations } public isquery,getstr:boolean; { Public declarations } end; var frm_op_state_view: Tfrm_op_state_view; implementation {$R *.dfm} uses u_main,my_sys_function, u_data_share; procedure Tfrm_op_state_view.bsSkinButton5Click(Sender: TObject); begin close ; end; procedure Tfrm_op_state_view.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption+'1'); frm_op_state_view.Hide; frm_op_state_view.ManualFloat(frm_op_state_view.BoundsRect ); frm_main.freeTabs('frm_op_state_view'); action:=cafree; frm_op_state_view:=nil; end; procedure Tfrm_op_state_view.FormShow(Sender: TObject); begin isquery:=false; with tv_bscard_all,sql do begin Close; clear ; add('select top 0 * from v_op_bscard_detail where (录入人='''+employee+''' or 操作员='''+employee+''' or 揽货人='''+employee+''') order by 会计期间 desc,船名,航次 '); //会计期间,业务类别 desc'); open; end ; loadreggrid(dxdbgrid1,true,caption+'1'); t_op_state.open; t_op_fee_group.Open; t_op_fee_groupc.Open; Edit16.SetFocus; isquery:=true; // getdrstrlist; // getcrstrlist; end; procedure Tfrm_op_state_view.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_state_view.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_state_view.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,201); end; procedure Tfrm_op_state_view.N74Click(Sender: TObject); begin update_grid_sort(dxdbgrid1,201); end; procedure Tfrm_op_state_view.bsSkinButton1Click(Sender: TObject); begin close; end; procedure Tfrm_op_state_view.bsSkinButton44Click(Sender: TObject); begin isquery:=false; t_op_fee_group.close; t_op_fee_groupC.close; with tv_bscard_all,sql do begin close ; clear ; add('select * from v_op_bscard_detail where '+open_data('0001','录入人','操作员','揽货人','no','no')); if Edit16.text<>''then add(' and (v_op_bscard_detail.主提单号 like '+''''+'%'+Edit16.text+'%'+''' or v_op_bscard_detail.分提单号 like '+''''+'%'+Edit16.text+'%'+''' or v_op_bscard_detail.委托编号 like '+''''+'%'+Edit16.text+'%'+''')'); if RxDBLookupCombo15.DisplayValue<>'' then add(' and v_op_bscard_detail.分部名称='''+RxDBLookupCombo15.DisplayValue+''''); if RxDBLookupCombo5.DisplayValue<>'' then add(' and v_op_bscard_detail.编号 in (select distinct 编号 from t_ch_fee where 客户名称='''+RxDBLookupCombo5.DisplayValues[1]+''')'); if wwDBLookupCombo49.text<>''then add(' and v_op_bscard_detail.船名 like ''%'+wwDBLookupCombo49.text+'%'''); if Edit7.text<>''then add(' and v_op_bscard_detail.航次 like ''%'+Edit7.text+'%'''); if (wwDBDateTimePicker1.text<>'')or(wwDBDateTimePicker2.text<>'') then begin if wwDBDateTimePicker1.text<>'' then add(' and v_op_bscard_detail.开船日期>='''+wwDBDateTimePicker1.text+''''); if wwDBDateTimePicker2.text<>'' then add(' and v_op_bscard_detail.开船日期<='''+wwDBDateTimePicker2.text+''''); end; if wwDBComboBox8.Text<>'' then add(' and v_op_bscard_detail.业务类型='''+wwDBComboBox8.Text+''''); add(' order by v_op_bscard_detail.编号 '); open ; end ; t_op_fee_group.open; t_op_fee_groupC.open; isquery:=true; getdrstrlist; getcrstrlist; end; procedure Tfrm_op_state_view.Edit16KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton44.OnClick(Sender); end; procedure Tfrm_op_state_view.bsSkinPanel3Resize(Sender: TObject); begin bsSkinGroupBox3.Width:=round((bsSkinPanel3.Width)/2); end; procedure Tfrm_op_state_view.dxDBGrid1DblClick(Sender: TObject); begin fee_view(tv_bscard_all.fieldbyname('编号').AsString); end; procedure Tfrm_op_state_view.getcrstrlist; var aQuery:TAdoQuery; begin Memo2.Lines.Clear; if tv_bscard_all.IsEmpty then exit; if t_op_fee_groupC.IsEmpty then exit; aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.Add('select distinct 帐单编号,结算方式,结算人,结算日期 from t_ch_balance where '); sql.Add('帐单编号 in (select 工作编号 from t_ch_fee_do where 类型=''4'' and 业务编号='''+tv_bscard_all.fieldbyname('编号').AsString+''' and '); sql.Add('ch_id in (select ch_id from t_ch_fee where 类型=''付'' and 客户名称='''+t_op_fee_groupC.fieldbyname('客户名称').AsString+''' and '); sql.Add('费用状态='''+t_op_fee_groupC.fieldbyname('费用状态').AsString+''' and 币别='''+t_op_fee_groupC.fieldbyname('币别').AsString+''' and 编号='''+tv_bscard_all.fieldbyname('编号').AsString+'''))'); open; if not IsEmpty then begin Memo2.Lines.Add('结算信息:'); first; while not eof do begin Memo2.Lines.Add('帐单编号:'+fieldbyname('帐单编号').AsString+' 结算方式:'+fieldbyname('结算方式').AsString+' 结算人:'+fieldbyname('结算人').AsString+' 结算日期:'+formatdatetime('YYYY-MM-DD',fieldbyname('结算日期').AsDatetime)); next; end; Memo2.Lines.Add('---------------------------------------------------------------------------'); end; close;sql.clear; sql.Add('select distinct 对帐编号,对帐人,对帐日期 from t_ch_dui where '); sql.Add('对帐编号 in (select 对帐编号 from t_ch_fee where 是否对帐=1 and 类型=''付'' and 客户名称='''+t_op_fee_groupC.fieldbyname('客户名称').AsString+''' and '); sql.Add('费用状态='''+t_op_fee_groupC.fieldbyname('费用状态').AsString+''' and 币别='''+t_op_fee_groupC.fieldbyname('币别').AsString+''' and 编号='''+tv_bscard_all.fieldbyname('编号').AsString+''')'); open; if not IsEmpty then begin Memo2.Lines.Add('对帐信息:'); first; while not eof do begin Memo2.Lines.Add('对帐编号:'+fieldbyname('对帐编号').AsString+' 对帐人:'+fieldbyname('对帐人').AsString+' 对帐日期:'+formatdatetime('YYYY-MM-DD',fieldbyname('对帐日期').AsDatetime)); next; end; Memo2.Lines.Add('---------------------------------------------------------------------------'); end; close;sql.clear; sql.Add('select distinct 申请编号,申请日期,申请人 from t_ch_check where '); sql.Add('申请编号 in (select 工作编号 from t_ch_fee_do where 类型=''2'' and 业务编号='''+tv_bscard_all.fieldbyname('编号').AsString+''' and '); sql.Add('ch_id in (select ch_id from t_ch_fee where 类型=''付'' and 客户名称='''+t_op_fee_groupC.fieldbyname('客户名称').AsString+''' and '); sql.Add('费用状态='''+t_op_fee_groupC.fieldbyname('费用状态').AsString+''' and 币别='''+t_op_fee_groupC.fieldbyname('币别').AsString+''' and 编号='''+tv_bscard_all.fieldbyname('编号').AsString+'''))'); open; if not IsEmpty then begin Memo2.Lines.Add('申请付费:'); first; while not eof do begin Memo2.Lines.Add('申请编号:'+fieldbyname('申请编号').AsString+' 申请日期:'+formatdatetime('YYYY-MM-DD',fieldbyname('申请日期').AsDatetime)+' 申请人:'+fieldbyname('申请人').AsString); next; end; Memo2.Lines.Add('---------------------------------------------------------------------------'); end; end; finally freeandnil(aQuery); end; end; procedure Tfrm_op_state_view.getdrstrlist; var aQuery:TAdoQuery; begin Memo1.Lines.Clear; if tv_bscard_all.IsEmpty then exit; if t_op_fee_group.IsEmpty then exit; aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.Add('select distinct 帐单编号,结算方式,结算人,结算日期 from t_ch_balance where '); sql.Add('帐单编号 in (select 工作编号 from t_ch_fee_do where 类型=''3'' and 业务编号='''+tv_bscard_all.fieldbyname('编号').AsString+''' and '); sql.Add('ch_id in (select ch_id from t_ch_fee where 类型=''收'' and 客户名称='''+t_op_fee_group.fieldbyname('客户名称').AsString+''' and '); sql.Add('费用状态='''+t_op_fee_group.fieldbyname('费用状态').AsString+''' and 币别='''+t_op_fee_group.fieldbyname('币别').AsString+''' and 编号='''+tv_bscard_all.fieldbyname('编号').AsString+'''))'); open; if not IsEmpty then begin Memo1.Lines.Add('结算信息:'); first; while not eof do begin Memo1.Lines.Add('帐单编号:'+fieldbyname('帐单编号').AsString+' 结算方式:'+fieldbyname('结算方式').AsString+' 结算人:'+fieldbyname('结算人').AsString+' 结算日期:'+formatdatetime('YYYY-MM-DD',fieldbyname('结算日期').AsDatetime)); next; end; Memo1.Lines.Add('---------------------------------------------------------------------------'); end; close;sql.clear; sql.Add('select distinct 对帐编号,对帐人,对帐日期 from t_ch_dui where '); sql.Add('对帐编号 in (select 对帐编号 from t_ch_fee where 是否对帐=1 and 类型=''收'' and 客户名称='''+t_op_fee_group.fieldbyname('客户名称').AsString+''' and '); sql.Add('费用状态='''+t_op_fee_group.fieldbyname('费用状态').AsString+''' and 币别='''+t_op_fee_group.fieldbyname('币别').AsString+''' and 编号='''+tv_bscard_all.fieldbyname('编号').AsString+''')'); open; if not IsEmpty then begin Memo1.Lines.Add('对帐信息:'); first; while not eof do begin Memo1.Lines.Add('对帐编号:'+fieldbyname('对帐编号').AsString+' 对帐人:'+fieldbyname('对帐人').AsString+' 对帐日期:'+formatdatetime('YYYY-MM-DD',fieldbyname('对帐日期').AsDatetime)); next; end; Memo1.Lines.Add('---------------------------------------------------------------------------'); end; close;sql.clear; sql.Add('select distinct 发票号码,开票日期,制单人,发票抬头 from t_ch_invoice where '); sql.Add('申请编号 in (select 工作编号 from t_ch_fee_do where 类型=''1'' and 业务编号='''+tv_bscard_all.fieldbyname('编号').AsString+''' and '); sql.Add('ch_id in (select ch_id from t_ch_fee where 类型=''收'' and 客户名称='''+t_op_fee_group.fieldbyname('客户名称').AsString+''' and '); sql.Add('费用状态='''+t_op_fee_group.fieldbyname('费用状态').AsString+''' and 币别='''+t_op_fee_group.fieldbyname('币别').AsString+''' and 编号='''+tv_bscard_all.fieldbyname('编号').AsString+'''))'); open; if not IsEmpty then begin Memo1.Lines.Add('开票信息:'); first; while not eof do begin Memo1.Lines.Add('发票号码:'+fieldbyname('发票号码').AsString+' 开票日期:'+formatdatetime('YYYY-MM-DD',fieldbyname('开票日期').AsDatetime)+' 开票人:'+fieldbyname('制单人').AsString+'发票抬头:'+fieldbyname('发票抬头').AsString); next; end; Memo1.Lines.Add('---------------------------------------------------------------------------'); end; close;sql.clear; sql.Add('select distinct 申请编号,申请日期,申请人 from t_ch_invoice_shen where '); sql.Add('申请编号 in (select 工作编号 from t_ch_fee_do where (类型=''1'' or 类型=''7'') and 业务编号='''+tv_bscard_all.fieldbyname('编号').AsString+''' and '); sql.Add('ch_id in (select ch_id from t_ch_fee where 类型=''收'' and 客户名称='''+t_op_fee_group.fieldbyname('客户名称').AsString+''' and '); sql.Add('费用状态='''+t_op_fee_group.fieldbyname('费用状态').AsString+''' and 币别='''+t_op_fee_group.fieldbyname('币别').AsString+''' and 编号='''+tv_bscard_all.fieldbyname('编号').AsString+'''))'); open; if not IsEmpty then begin Memo1.Lines.Add('申请开票信息:'); first; while not eof do begin Memo1.Lines.Add('申请编号:'+fieldbyname('申请编号').AsString+' 申请日期:'+formatdatetime('YYYY-MM-DD',fieldbyname('申请日期').AsDatetime)+' 申请人:'+fieldbyname('申请人').AsString); next; end; Memo1.Lines.Add('---------------------------------------------------------------------------'); end; end; finally freeandnil(aQuery); end; end; procedure Tfrm_op_state_view.tv_bscard_allBeforeScroll(DataSet: TDataSet); begin getstr:=false; t_op_fee_group.Close; t_op_fee_groupC.Close; end; procedure Tfrm_op_state_view.tv_bscard_allAfterScroll(DataSet: TDataSet); begin t_op_fee_group.open; t_op_fee_groupC.open; t_op_fee_group.first; t_op_fee_groupc.first; getstr:=true; if isquery then begin getdrstrlist; getcrstrlist; end; end; procedure Tfrm_op_state_view.t_op_fee_groupAfterScroll(DataSet: TDataSet); begin if getstr and isquery then begin getdrstrlist; end; end; procedure Tfrm_op_state_view.t_op_fee_groupCAfterScroll(DataSet: TDataSet); begin if getstr and isquery then begin getcrstrlist; end; end; end.