unit u_rp_dui_accepttotal; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, StdCtrls, Mask, DBCtrls, dxDBTLCl, dxGrClms, RxLookup, wwdbdatetimepicker, Menus, XPMenu, ComCtrls, bsSkinTabs, RxMemDS, wwdbedit, Wwdotdot, Wwdbcomb, Grids, DBGrids, wwdblook, kbmMemTable, bsdbctrls, DBCtrlsEh, cxFontNameComboBox, cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, dximctrl, bsSkinBoxCtrls; type Tfrm_rp_dui_accepttotal = class(TForm) Panel1: TPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton11: TbsSkinButton; Notebook1: TNotebook; dxDBGrid1: TdxDBGrid; bsSkinPanel3: TbsSkinPanel; t_ch_dui: TADOQuery; t_ch_dui1: TDataSource; bsSkinPanel4: TbsSkinPanel; Label1: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Edit4: TEdit; Edit2: TEdit; Edit3: TEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; t_op_seae: TADOQuery; t_op_seae1: TDataSource; t_ch_fee: TADOQuery; t_ch_fee1: TDataSource; PopupMenu1: TPopupMenu; N1: TMenuItem; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column9: TdxDBGridDateColumn; bsSkinButton12: TbsSkinButton; t_ch_dui_format1: TDataSource; bsSkinPanel1: TbsSkinPanel; bsSkinPanel6: TbsSkinPanel; Label2: TLabel; DBEdit2: TDBEdit; DBEdit5: TDBEdit; Label5: TLabel; Label6: TLabel; Label15: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; DBEdit6: TDBEdit; Label3: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; DBEdit7: TDBEdit; Label7: TLabel; Label4: TLabel; DBEdit4: TDBEdit; t_ch_dui_format: TADOQuery; t_ch_dui_bill: TADOQuery; p_update: TADOStoredProc; v_dui_bill: TADOQuery; v_dui_bill1: TDataSource; v_dui_fee: TADOQuery; v_dui_fee1: TDataSource; bsSkinButton6: TbsSkinButton; PopupMenu2: TPopupMenu; N5: TMenuItem; XPMenu1: TXPMenu; wwDBDateTimePicker5: TwwDBDateTimePicker; Label16: TLabel; wwDBDateTimePicker6: TwwDBDateTimePicker; Label17: TLabel; Label18: TLabel; DBEdit1: TDBEdit; t_bill_fee_dong: TRxMemoryData; t_bill_fee_dong1: TDataSource; Panel3: TPanel; dxDBGrid5: TdxDBGrid; dxDBGrid5Column1: TdxDBGridMaskColumn; dxDBGrid5Column2: TdxDBGridMaskColumn; dxDBGrid5Column6: TdxDBGridMaskColumn; dxDBGrid5Column7: TdxDBGridColumn; dxDBGrid5Column8: TdxDBGridColumn; dxDBGrid5Column9: TdxDBGridColumn; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; dxDBGrid6: TdxDBGrid; dxDBGrid6Column1: TdxDBGridMaskColumn; dxDBGrid6Column2: TdxDBGridMaskColumn; dxDBGrid6Column3: TdxDBGridMaskColumn; dxDBGrid6RMB: TdxDBGridColumn; dxDBGrid6Column20: TdxDBGridColumn; dxDBGrid6Column21: TdxDBGridColumn; dxDBGrid6USD: TdxDBGridColumn; dxDBGrid6Column23: TdxDBGridColumn; dxDBGrid6Column24: TdxDBGridColumn; dxDBGrid6Column4: TdxDBGridMaskColumn; dxDBGrid6Column5: TdxDBGridMaskColumn; dxDBGrid6Column6: TdxDBGridMaskColumn; dxDBGrid6Column7: TdxDBGridDateColumn; dxDBGrid6Column8: TdxDBGridMaskColumn; dxDBGrid6Column9: TdxDBGridMaskColumn; dxDBGrid6Column10: TdxDBGridMaskColumn; dxDBGrid6Column11: TdxDBGridMaskColumn; dxDBGrid6Column12: TdxDBGridColumn; dxDBGrid6Column13: TdxDBGridColumn; dxDBGrid6Column14: TdxDBGridMaskColumn; dxDBGrid6Column15: TdxDBGridMaskColumn; dxDBGrid6Column16: TdxDBGridMaskColumn; dxDBGrid6Column17: TdxDBGridMaskColumn; dxDBGrid6Column18: TdxDBGridMaskColumn; dxDBGrid6Column25: TdxDBGridColumn; dxDBGrid6Column26: TdxDBGridColumn; dxDBGrid2: TdxDBGrid; dxDBGridColumn4: TdxDBGridColumn; dxDBGridMaskColumn95: TdxDBGridMaskColumn; PopupMenu3: TPopupMenu; N2: TMenuItem; dxDBGrid5Column10: TdxDBGridColumn; dxDBGrid6Column27: TdxDBGridColumn; dxDBGrid6Column28: TdxDBGridColumn; dxDBGrid6Column29: TdxDBGridColumn; dxDBGrid6Column30: TdxDBGridColumn; dxDBGrid6Column31: TdxDBGridColumn; dxDBGrid6Column32: TdxDBGridColumn; Label25: TLabel; wwDBComboBox31: TwwDBComboBox; Label20: TLabel; RxDBLookupCombo16: TRxDBLookupCombo; Label41: TLabel; wwDBComboBox46: TwwDBComboBox; PopupMenu4: TPopupMenu; MenuItem1: TMenuItem; PopupMenu5: TPopupMenu; MenuItem2: TMenuItem; Label22: TLabel; RxDBLookupCombo10: TRxDBLookupCombo; wwDBComboBox1: TwwDBComboBox; Label21: TLabel; wwDBComboBox2: TwwDBComboBox; Label23: TLabel; bsSkinPageControl2: TbsSkinPageControl; bsSkinPanel5: TbsSkinPanel; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridMaskColumn2: TdxDBGridMaskColumn; dxDBGridMaskColumn3: TdxDBGridMaskColumn; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn5: TdxDBGridMaskColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridDateColumn2: TdxDBGridDateColumn; dxDBGridMaskColumn6: TdxDBGridMaskColumn; dxDBGridColumn1: TdxDBGridColumn; dxDBGridMaskColumn7: TdxDBGridMaskColumn; dxDBGridMaskColumn8: TdxDBGridMaskColumn; dxDBGridMaskColumn9: TdxDBGridMaskColumn; dxDBGridMaskColumn10: TdxDBGridMaskColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGridMaskColumn11: TdxDBGridMaskColumn; dxDBGridMaskColumn12: TdxDBGridMaskColumn; dxDBGridMaskColumn13: TdxDBGridMaskColumn; dxDBGrid3Column19: TdxDBGridColumn; dxDBGrid3Column20: TdxDBGridColumn; Panel2: TPanel; dxDBGrid4: TdxDBGrid; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid4Column5: TdxDBGridColumn; dxDBGrid1Column5: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; dxDBGrid4Column6: TdxDBGridColumn; bsSkinPanel7: TbsSkinPanel; lblSum: TLabel; bstab1: TbsSkinTabSheet; bstab2: TbsSkinTabSheet; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; dxDBGrid7: TdxDBGrid; dxDBGridMaskColumn14: TdxDBGridMaskColumn; dxDBGridMaskColumn15: TdxDBGridMaskColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGridMaskColumn16: TdxDBGridMaskColumn; dxDBGridColumn6: TdxDBGridColumn; dxDBGridColumn7: TdxDBGridColumn; dxDBGridColumn8: TdxDBGridColumn; bsSkinPanel8: TbsSkinPanel; dxDBGrid8: TdxDBGrid; dxDBGridMaskColumn17: TdxDBGridMaskColumn; dxDBGridMaskColumn18: TdxDBGridMaskColumn; dxDBGridMaskColumn19: TdxDBGridMaskColumn; dxDBGridColumn9: TdxDBGridColumn; dxDBGridColumn10: TdxDBGridColumn; dxDBGridColumn11: TdxDBGridColumn; dxDBGridColumn12: TdxDBGridColumn; dxDBGridColumn13: TdxDBGridColumn; dxDBGridColumn14: TdxDBGridColumn; dxDBGridColumn15: TdxDBGridColumn; dxDBGridColumn16: TdxDBGridColumn; dxDBGridColumn17: TdxDBGridColumn; dxDBGridColumn18: TdxDBGridColumn; dxDBGridColumn19: TdxDBGridColumn; dxDBGridColumn20: TdxDBGridColumn; dxDBGridMaskColumn20: TdxDBGridMaskColumn; dxDBGridMaskColumn21: TdxDBGridMaskColumn; dxDBGridMaskColumn22: TdxDBGridMaskColumn; dxDBGridDateColumn3: TdxDBGridDateColumn; dxDBGridMaskColumn23: TdxDBGridMaskColumn; dxDBGridMaskColumn24: TdxDBGridMaskColumn; dxDBGridMaskColumn25: TdxDBGridMaskColumn; dxDBGridMaskColumn26: TdxDBGridMaskColumn; dxDBGridColumn21: TdxDBGridColumn; dxDBGridColumn22: TdxDBGridColumn; dxDBGridMaskColumn27: TdxDBGridMaskColumn; dxDBGridMaskColumn28: TdxDBGridMaskColumn; dxDBGridMaskColumn29: TdxDBGridMaskColumn; dxDBGridMaskColumn30: TdxDBGridMaskColumn; dxDBGridMaskColumn31: TdxDBGridMaskColumn; dxDBGridColumn23: TdxDBGridColumn; dxDBGridColumn24: TdxDBGridColumn; t_dui_b: TADOQuery; t_dui_b_fee: TADOQuery; t_dui_b1: TDataSource; t_dui_b_fee1: TDataSource; dxDBGrid8Column33: TdxDBGridColumn; PopupMenu6: TPopupMenu; N3: TMenuItem; PopupMenu7: TPopupMenu; MenuItem3: TMenuItem; t_ch_dui_detail: TADOQuery; dxDBGrid4Column7: TdxDBGridColumn; dxDBGrid7Column8: TdxDBGridColumn; dxDBGrid5Column11: TdxDBGridColumn; Label125: TLabel; wwDBLookupCombo49: TwwDBLookupCombo; Label30: TLabel; Edit7: TEdit; Label45: TLabel; RxDBLookupCombo15: TRxDBLookupCombo; Label24: TLabel; Edit1: TEdit; Edit5: TEdit; Label26: TLabel; Edit6: TEdit; Label27: TLabel; Label28: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; mem_v_dui_fee1: TDataSource; mem_v_dui_fee: TADOQuery; mem_v_dui_feeCr: TADOQuery; mem_v_dui_feeCr1: TDataSource; lblsum1: TLabel; lblsum2: TLabel; dxDBGrid6Column33: TdxDBGridColumn; dxDBGrid3Column21: TdxDBGridColumn; RxDBLookupCombo4: TRxDBLookupCombo; t_dui_cust: TADOQuery; t_dui_cust1: TDataSource; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; bsSkinButton38: TbsSkinButton; PopupMenu8: TPopupMenu; MenuItem4: TMenuItem; MenuItem5: TMenuItem; N21: TMenuItem; N22: TMenuItem; N20: TMenuItem; PopupMenu9: TPopupMenu; MenuItem6: TMenuItem; MenuItem7: TMenuItem; MenuItem8: TMenuItem; MenuItem9: TMenuItem; MenuItem10: TMenuItem; dxDBGrid3Column22: TdxDBGridColumn; dxDBGrid3Column23: TdxDBGridColumn; Label29: TLabel; wwDBComboBox3: TwwDBComboBox; Label35: TLabel; Edit16: TEdit; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column11: TdxDBGridColumn; bsSkinButton13: TbsSkinButton; dxDBGrid3Column24: TdxDBGridColumn; RxDBLookupCombo20: TRxDBLookupCombo; Label31: TLabel; Splitter1: TSplitter; DBComboBoxEh1: TDBComboBoxEh; Label19: TLabel; Label32: TLabel; dxDBGrid1Column12: TdxDBGridColumn; dxDBGrid1Column13: TdxDBGridColumn; dxImageComboBox1: TdxImageComboBox; Label33: TLabel; dxDBGrid4Column8: TdxDBGridColumn; dxDBGrid5Column12: TdxDBGridColumn; dxDBGrid6Column34: TdxDBGridColumn; dxDBGrid6Column35: TdxDBGridColumn; dxDBGrid6Column36: TdxDBGridColumn; dxDBGrid6Column37: TdxDBGridColumn; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; dxDBGrid4Column9: TdxDBGridColumn; dxDBGrid4Column10: TdxDBGridColumn; dxDBGrid5Column13: TdxDBGridColumn; dxDBGrid5Column14: TdxDBGridColumn; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridColumn; dxDBGrid1Column17: TdxDBGridColumn; dxDBGrid1Column18: TdxDBGridColumn; wwDBLookupCombo52: TwwDBLookupCombo; Label34: TLabel; bsSkinButton14: TbsSkinButton; Label36: TLabel; wwDBComboBox4: TwwDBComboBox; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinComboBox2: TbsSkinComboBox; PopupMenu10: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N15: TMenuItem; N16: TMenuItem; dxDBGrid4Column11: TdxDBGridColumn; bsSkinComboBox1: TbsSkinComboBox; bsSkinComboBox3: TbsSkinComboBox; bsSkinComboBox4: TbsSkinComboBox; procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinPanel2Resize(Sender: TObject); procedure t_ch_duiAfterInsert(DataSet: TDataSet); procedure t_ch_duiBeforePost(DataSet: TDataSet); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure t_ch_duiAfterScroll(DataSet: TDataSet); procedure N1Click(Sender: TObject); procedure RxDBLookupCombo1Enter(Sender: TObject); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure bsSkinPageControl1Change(Sender: TObject); procedure MenuItem1Click(Sender: TObject); procedure MenuItem2Click(Sender: TObject); procedure dxDBGrid3SelectedCountChange(Sender: TObject); procedure dxDBGrid3Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure MenuItem3Click(Sender: TObject); procedure dxDBGrid3Column21CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure ComboBoxObj1KeyPress(Sender: TObject; var Key: Char); procedure dxDBGrid6ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure dxDBGrid2ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure RxDBLookupCombo4Enter(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure MenuItem4Click(Sender: TObject); procedure MenuItem10Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure dxDBGrid3Column22CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure dxDBGrid3Column23CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure bsSkinButton13Click(Sender: TObject); procedure DBComboBoxEh1DropDown(Sender: TObject); procedure dxDBGrid1CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure dxDBGrid6DblClick(Sender: TObject); procedure dxDBGrid3DblClick(Sender: TObject); procedure dxDBGrid1Column18CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure bsSkinButton14Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N16Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_rp_dui_accepttotal: Tfrm_rp_dui_accepttotal; implementation uses u_main, my_sys_function, u_data_share, u_rp_dui_format, u_rp_dui_query, u_rp_dui_formatrpt, u_rp_op_ttl; {$R *.dfm} procedure Tfrm_rp_dui_accepttotal.bsSkinButton8Click(Sender: TObject); begin dxImageComboBox1.ItemIndex:=0; RxDBLookupCombo4.ClearValue; Edit4.text:=''; Edit3.Text:=''; Edit2.text:=''; wwDBDateTimePicker1.Clear; wwDBDateTimePicker2.clear; wwDBDateTimePicker3.clear; wwDBDateTimePicker4.clear; wwDBComboBox31.Text:=''; wwDBComboBox46.Text:=''; RxDBLookupCombo10.ClearValue; RxDBLookupCombo16.ClearValue; RxDBLookupCombo15.ClearValue; RxDBLookupCombo2.ClearValue; wwDBLookupCombo49.Text:=''; DBComboBoxEh1.Text:=''; edit7.Text:=''; edit1.Text:=''; edit5.Text:=''; edit6.Text:=''; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton7Click(Sender: TObject); var str_fee,str_op,str_zhfee,str_zhop:widestring; Str:String; begin str_fee:=''; if RxDBLookupCombo4.DisplayValues[1]<>'' then begin if strtobool(get_parameters_value(115,'false')) then str_fee:=str_fee+' and (客户名称='+''''+RxDBLookupCombo4.DisplayValues[1]+''''+' or 第三方='+''''+RxDBLookupCombo4.DisplayValues[1]+''')' else str_fee:=str_fee+' and 客户名称='+''''+RxDBLookupCombo4.DisplayValues[1]+''''; end; if wwDBComboBox31.Text<>''then str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; if RxDBLookupCombo15.DisplayValues[1]<>''then str_fee:=str_fee+' and 币别='+''''+RxDBLookupCombo15.DisplayValues[0]+''''; if RxDBLookupCombo16.DisplayValues[1]<>''then str_fee:=str_fee+' and 费用名称='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; case dxImageComboBox1.ItemIndex of 0:; 1:str_fee:=str_fee+' and (是否垫付=0 OR 是否垫付 IS NULL)'; 2:str_fee:=str_fee+' and (是否垫付=1)'; end; str_zhfee:='where t_ch_fee.编号=v_dui_bscard.编号 and t_ch_fee.对帐编号=v_dui_bscard.对帐编号 '+str_fee; str_fee:='where 1=1'+str_fee; if NOT strtobool(get_parameters_value(84,'false')) then begin //对账是否包含录入状态 // if NOT strtobool(get_parameters_value(47,'false')) then if bsSkinCheckRadioBox2.Checked then begin str_fee:=str_fee+' and (是否对帐=0 OR 是否对帐 IS NULL) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_zhfee:=str_zhfee+' and 是否对帐=1 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:=str_fee+' and (是否对帐=0 OR 是否对帐 IS NULL) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_zhfee:=str_zhfee+' and 是否对帐=1 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; end else begin if bsSkinCheckRadioBox2.Checked then begin str_fee:=str_fee+' and (是否对帐=0 OR 是否对帐 IS NULL) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+''''+','+''''+'录入状态'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+'''' +','+''''+'禁止修改'+''''+')'; str_zhfee:=str_zhfee+' and 是否对帐=1 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+''''+','+''''+'录入状态'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:=str_fee+' and (是否对帐=0 OR 是否对帐 IS NULL) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+''''+','+''''+'录入状态'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+'''' +','+''''+'禁止修改'+''''+')'; str_zhfee:=str_zhfee+' and 是否对帐=1 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+''''+','+''''+'录入状态'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+'''' +','+''''+'禁止修改'+''''+')'; end; end; if (strtobool(get_parameters_value(64,'false'))=true) then begin if if_open('206') or if_open('207') or if_open('208') or if_open('209') then begin end else begin str_fee:=str_fee+' and 机密<>1 '; str_zhfee:=str_zhfee+' and 机密<>1 '; end; end; if (not t_ch_dui.IsEmpty) and (t_ch_dui.FieldByName('对帐编号').AsString<>'') then begin str_zhfee:=str_zhfee+'and CH_ID not in (select CH_ID from v_dui_fee where 对帐编号='''+t_ch_dui.fieldByName('对帐编号').AsString+''')' end; str_op:=''; if Edit4.text<>''then str_op:=str_op+' and 委托编号 like '+''''+'%'+Edit4.text+'%'+''''; if wwDBComboBox46.text<>''then str_op:=str_op+' and 业务类型='+''''+wwDBComboBox46.text+''''; if Edit2.text<>''then // str_op:=str_op+' and (主提单号 like '+''''+'%'+Edit2.text+'%'+''' or 分提单号 like '+''''+'%'+Edit2.text+'%'+''')'; str_op:=str_op+' and 主提单号 like '+''''+'%'+Edit2.text+'%'+''''; if Edit3.text<>''then str_op:=str_op+' and (分提单号 like '+''''+'%'+Edit3.text+'%'+''' or 编号 in (select 编号 from t_op_seae_assistant where 分提单号 like '+''''+'%'+Trim(Edit3.text)+'%'+'''))'; if Edit16.text<>''then str_op:=str_op+' and (订舱单号 like '+''''+'%'+Edit16.text+'%'+''' or 主提单号 like '+''''+'%'+Edit16.text+'%'+''' or 分提单号 like '+''''+'%'+Edit16.text+'%'+''' or 业务编号 like '+''''+'%'+Edit16.text+'%'+''' or 委托编号 like '+''''+'%'+Edit16.text+'%'+''')'; if wwDBLookupCombo52.text<>''then str_op:=str_op+' and (卸货港 like '+''''+'%'+wwDBLookupCombo52.text+'%'+''' or 目的地 like '+''''+'%'+wwDBLookupCombo52.text+'%'+''')'; if DBComboBoxEh1.Text<>''then str_op:=str_op+' and 操作员='+''''+DBComboBoxEh1.Text+''''; if wwDBComboBox4.Text<>''then str_op:=str_op+' and 费用状态='+''''+wwDBComboBox4.Text+''''; if Edit1.text<>''then str_op:=str_op+' and 核销单号 like '+''''+'%'+Edit1.text+'%'+''''; if RxDBLookupCombo10.DisplayValues[0]<>''then str_op:=str_op+' and 销售部门='+''''+RxDBLookupCombo10.DisplayValues[0]+''''; if wwDBComboBox3.text='是' then str_op:=str_op+' and 是否退舱=1 '; if wwDBComboBox3.text='否' then str_op:=str_op+' and (是否退舱=0 OR 是否退舱 IS NULL) '; if RxDBLookupCombo20.DisplayValues[1]<>'' then str_op:=str_op+' and 航线='+''''+RxDBLookupCombo20.DisplayValues[1]+''''; if RxDBLookupCombo2.DisplayValues[0]<>''then str_op:=str_op+' and 分部名称='+''''+RxDBLookupCombo2.DisplayValues[0]+''''; if (Edit5.text<>'') and (Edit6.text<>'') then begin str_op:=str_op+' and (报关单号>='+''''+Edit5.text+''''+' and 报关单号<='+''''+Edit6.Text+''''+')'; end else begin if Edit5.text<>''then str_op:=str_op+' and 报关单号 like '+''''+'%'+Edit5.text+'%'+''''; end; if wwDBDateTimePicker1.text<>''then str_op:=str_op+' and '+bsSkinComboBox2.Text+'>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str_op:=str_op+' and '+bsSkinComboBox2.Text+'<='+''''+wwDBDateTimePicker2.text+''''; if wwDBLookupCombo49.text<>''then str_op:=str_op+' and 船名 like '+''''+'%'+wwDBLookupCombo49.text+'%'+''''; if Edit7.text<>''then str_op:=str_op+' and 航次 like '+''''+'%'+Edit7.text+'%'+''''; if (((bsSkinComboBox1.ItemIndex=1) and (Edit2.Text<>'')) or ((bsSkinComboBox3.ItemIndex=1) and (wwDBLookupCombo49.Text<>'')) or ((bsSkinComboBox4.ItemIndex=1) and (Edit7.Text<>''))) then begin str_op:=str_op+' and 编号 in (select 编号 from t_op_sealocal where 1=1 '; if ((bsSkinComboBox1.ItemIndex=1) and (Edit2.Text<>'')) then str_op:=str_op+' and 反空提单号 like '+''''+'%'+Edit2.text+'%'+''''; if ((bsSkinComboBox3.ItemIndex=1) and (wwDBLookupCombo49.Text<>'')) then str_op:=str_op+' and 返空船名 like '+''''+'%'+wwDBLookupCombo49.text+'%'+''''; if ((bsSkinComboBox4.ItemIndex=1) and (Edit7.Text<>'')) then str_op:=str_op+' and 反空航次 like '+''''+'%'+Edit7.text+'%'+''''; str_op:=str_op+')'; end; if wwDBDateTimePicker3.text<>''then str_op:=str_op+' and 会计期间>='+''''+wwDBDateTimePicker3.text+''''; if wwDBDateTimePicker4.text<>''then str_op:=str_op+' and 会计期间<='+''''+wwDBDateTimePicker4.text+''''; str_zhop:='where exists (select 1 from t_ch_fee '+str_zhfee+') '+str_op; str_op:='where 编号 in (select distinct 编号 from t_ch_fee '+str_fee+')'+str_op; str_op:=str_op+' and '+open_data('0032','揽货人','操作员','客服员','报关操作','报检操作'); str_zhop:='select * from v_dui_bscard '+str_zhop+' and '+open_data('0032','揽货人','操作员','客服员','报关操作','报检操作'); str_op:='select * from v_op_bscard_ALL '+str_op+default_sort(53,'v_op_bscard_ALL','','desc'); str_fee:='select *,金额-结算金额 as 未结金额 from t_ch_fee ' +str_fee+' and 编号=:编号 order by CH_ID'; t_ch_fee.Close; t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add(str_op); t_op_seae.open; //ShowMessage(t_op_seae.sql.Text); t_ch_fee.sql.clear; t_ch_fee.sql.add(str_fee); t_ch_fee.open; // ShowMessage(t_ch_fee.sql.Text); if bsSkinCheckRadioBox1.checked then begin t_dui_b_fee.Close; t_dui_b.Close; t_dui_b.SQL.Clear; t_dui_b.SQL.Add(str_zhop); t_dui_b.Open; t_dui_b_fee.Open; end; //ShowMessage(t_dui_b.sql.Text); // ShowMessage(t_dui_b_fee.sql.Text); if not t_dui_b.IsEmpty then begin bstab2.Caption:='已经生成帐单明细'+'注意:此范围存在已对帐业务!'; bstab2.Font.Color:=clRed; // lblzh.Caption:='注意:此范围存在已对帐业务!'; end else begin bstab2.Caption:='已经生成帐单明细'; // lblzh.Caption:=''; end; end; procedure Tfrm_rp_dui_accepttotal.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption+'1'); savereggrid(dxdbgrid3,caption+'3'); savereggrid(dxdbgrid4,caption+'4'); savereggrid(dxdbgrid6,caption+'6'); savereggrid(dxdbgrid7,caption+'7'); savereggrid(dxdbgrid8,caption+'8'); frm_rp_dui_accepttotal.Hide; frm_rp_dui_accepttotal.ManualFloat(frm_rp_dui_accepttotal.BoundsRect ); frm_main.freeTabs('frm_rp_dui_accepttotal'); action:=cafree; frm_rp_dui_accepttotal:=nil; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_dui_accepttotal.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin if strtobool(get_parameters_value(187,'false')) then begin i:=round(bsSkinPanel2.width/13); bsSkinButton9.width:=i; bsSkinButton12.width:=i; bsSkinButton10.width:=i; bsSkinButton1.width:=i; bsSkinButton2.width:=i; bsSkinButton4.width:=i; bsSkinButton3.width:=i; bsSkinButton11.width:=i; bsSkinButton6.width:=i; bsSkinButton38.width:=i; bsSkinButton13.width:=i; bsSkinButton14.width:=i; end else begin i:=round(bsSkinPanel2.width/12); bsSkinButton9.width:=i; bsSkinButton12.width:=i; bsSkinButton10.width:=i; bsSkinButton1.width:=i; bsSkinButton2.width:=i; bsSkinButton4.width:=i; bsSkinButton3.width:=i; bsSkinButton11.width:=i; bsSkinButton6.width:=i; bsSkinButton38.width:=i; bsSkinButton13.width:=i; end; end; procedure Tfrm_rp_dui_accepttotal.t_ch_duiAfterInsert(DataSet: TDataSet); begin t_ch_dui['对帐日期']:=date; t_ch_dui['对帐人']:=employee; t_ch_dui['类别']:=9; t_ch_dui['收付类别']:='全部'; t_ch_dui['费用范围']:='仅未结费用'; { if not t_ch_fee.IsEmpty then t_ch_dui['对帐客户']:=t_ch_fee.fieldbyname('客户名称').asstring; } end; procedure Tfrm_rp_dui_accepttotal.t_ch_duiBeforePost(DataSet: TDataSet); var aAdoQuery:TAdoQuery; begin table_before_post(t_ch_dui,'对帐客户'); if t_ch_dui.State=dsinsert then begin if bsSkinDBCheckRadioBox1.Checked then t_ch_dui['对帐编号']:=getDCno(1,subComp,department,employee,date) else t_ch_dui['对帐编号']:=get_no(date,'D1'); end; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; SQL.Add('select sum(应收RMB金额) 应收RMB,sum(应收USD金额) 应收USD,sum(应付RMB金额) 应付RMB,sum(应付USD金额) 应付USD'); SQL.Add('from v_dui_bscard'); SQL.Add('where 对帐编号=:对帐编号'); Parameters.ParamByName('对帐编号').Value:=t_ch_dui.fieldbyname('对帐编号').asstring; open; t_ch_dui.FieldByName('应收RMB').AsFloat:=FieldByName('应收RMB').AsFloat; t_ch_dui.FieldByName('应收USD').AsFloat:=FieldByName('应收USD').AsFloat; t_ch_dui.FieldByName('应付RMB').AsFloat:=FieldByName('应付RMB').AsFloat; t_ch_dui.FieldByName('应付USD').AsFloat:=FieldByName('应付USD').AsFloat; finally Free; end; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton1Click(Sender: TObject); begin t_ch_dui.insert; Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_dui); end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton4Click(Sender: TObject); var aAdoQuery:TAdoQuery; str:widestring; begin if t_ch_dui.IsEmpty then exit; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)<>IDOK then exit; try frm_main.db.BeginTrans; aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin Close;SQL.Clear; SQL.Add('Select ch_id from t_ch_fee where 编号=:编号 and 是否对帐=1 and 对帐编号=:对帐编号'); end; v_dui_bill.first; while not v_dui_bill.eof do begin aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('编号').Value:=v_dui_bill.fieldbyname('编号').asstring; aAdoQuery.Parameters.ParamByName('对帐编号').Value:=t_ch_dui.fieldbyname('对帐编号').asstring; aAdoQuery.Open; aAdoQuery.First; while not aAdoQuery.Eof do begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+'''' +' and ch_id='+''''+aAdoQuery.fieldbyname('ch_id').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; aAdoQuery.Next; end; { str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; } str:='delete from t_ch_dui_detail' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; v_dui_bill.next; end; t_ch_dui.delete; frm_main.db.CommitTrans; finally if frm_main.db.InTransaction then begin frm_main.db.RollbackTrans; MessageDlg('删除时出现异常,请关闭重试!',mterror,[mbok],0); end; aAdoQuery.Free; if t_op_seae.Active then t_op_seae.Requery(); end; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_dui); end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton11Click(Sender: TObject); var answer:TModalResult; begin if bsSkinButton11.Caption='编辑修改' then begin Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; end else begin if (t_ch_dui.State=dsinsert)or(t_ch_dui.State=dsedit) then BEGIN answer:=messagedlg( '数据已经修改,是否保存?',mtWarning,mbYesNoCancel,0); if answer=mrYes then begin t_ch_dui.post; end; if answer=mrNo then begin t_ch_dui.cancel; end; if answer=mrCancel then begin exit; end; END; Notebook1.PageIndex:=0; bsSkinButton11.Caption:='编辑修改'; end; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton12Click(Sender: TObject); begin try if not assigned(frm_rp_dui_formatrpt) then frm_rp_dui_formatrpt:=tfrm_rp_dui_formatrpt.Create (self); dui_format_type:=9; frm_rp_dui_formatrpt.showmodal; finally frm_rp_dui_formatrpt.free; frm_rp_dui_formatrpt:=nil; t_ch_dui_format.requery; end; end; procedure Tfrm_rp_dui_accepttotal.FormShow(Sender: TObject); var str:widestring; begin Notebook1.PageIndex:=0; dxImageComboBox1.ItemIndex:=0; if strtobool(get_parameters_value(187,'false')) then begin bsSkinButton14.Visible:=true; end else begin bsSkinButton14.Visible:=false; end; try loadreggrid(dxdbgrid1,false,caption+'1'); loadreggrid(dxdbgrid3,false,caption+'3'); loadreggrid(dxdbgrid4,false,caption+'4'); loadreggrid(dxdbgrid6,false,caption+'6'); loadreggrid(dxdbgrid7,false,caption+'7'); loadreggrid(dxdbgrid8,false,caption+'8'); t_ch_dui_format.Parameters[0].value:=9; t_ch_dui_format.open; str:='select top 50 * from t_ch_dui '; str:=str+' where 类别=9 and 对帐人='+''''+employee+''''+' order by 对帐日期 desc'; t_ch_dui.close; t_ch_dui.SQL.clear; t_ch_dui.sql.Add(str); t_ch_dui.open; t_ch_dui_bill.open; t_ch_dui_detail.open; v_dui_bill.open; v_dui_fee.Parameters.ParamByName('对帐编号').value:=t_ch_dui.fieldbyname('对帐编号').asstring; v_dui_fee.open; frm_data_share.t_crm_client_all.requery; t_dui_cust.open; except on e : exception do begin showmessage(e.Message); end; end; end; procedure Tfrm_rp_dui_accepttotal.t_ch_duiAfterScroll(DataSet: TDataSet); begin if v_dui_fee.active then begin v_dui_fee.close; v_dui_fee.Parameters.ParamByName('对帐编号').value:=t_ch_dui.fieldbyname('对帐编号').asstring; v_dui_fee.open; end; end; procedure Tfrm_rp_dui_accepttotal.N1Click(Sender: TObject); var i,k:integer; aMblNo:string; function GetFeeStatus(bsNo:string):boolean; var aAdoQuery:TAdoQuery; begin result:=false; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try close;sql.clear; sql.Add('select * From t_ch_fee'); sql.Add('where 编号=:bsNo and 费用状态 in (''申请修改'',''申请删除'')'); Parameters.ParamByName('bsNo').Value:=bsNo; open; result:=not IsEmpty; finally Free; end; end; begin if t_op_seae.IsEmpty then exit; if t_ch_dui.IsEmpty then exit; if (t_ch_dui.FieldByName('对帐客户').asstring='') and (not strtobool(get_parameters_value(115,'false'))) then begin t_ch_dui.edit; t_ch_dui['对帐客户']:=t_ch_fee.FieldByName('客户名称').asstring; t_ch_dui.post; end; if dxDBGrid3.SelectedCount>=1 then begin for i:=0 to dxDBGrid3.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid3.selectedrows[i])); if GetFeeStatus(t_op_seae.FieldByName('编号').AsString) then ShowMessage('主提单号:'+t_op_seae.FieldByName('主提单号').AsString+' 存在申请修改,删除的费用'); t_ch_fee.first; while not t_ch_fee.Eof do begin if strtobool(get_parameters_value(115,'false')) then begin end else begin if t_ch_dui.FieldByName('对帐客户').asstring<>t_ch_fee.FieldByName('客户名称').asstring then begin showmessage('当前客户名称与对帐客户名称不符,加入失败!!'); exit; end; end; t_ch_fee.next; end; end; end else begin t_ch_fee.first; while not t_ch_fee.Eof do begin if strtobool(get_parameters_value(115,'false')) then begin end else begin if t_ch_dui.FieldByName('对帐客户').asstring<>t_ch_fee.FieldByName('客户名称').asstring then begin showmessage('当前客户名称与对帐客户名称不符,加入失败!!'); exit; end; end; t_ch_fee.next; end; end; if (t_ch_dui.state=dsinsert)or(t_ch_dui.state=dsedit) then t_ch_dui.Post; try t_ch_dui_bill.DisableControls; if dxDBGrid3.SelectedCount>=1 then begin for i:=0 to dxDBGrid3.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid3.selectedrows[i])); if not t_ch_fee.IsEmpty then begin if not t_ch_dui_bill.Locate('对帐编号;编号',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_op_seae.FieldByName('编号').asstring]),[]) then begin t_ch_dui_bill.insert; t_ch_dui_bill['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_bill['编号']:=t_op_seae.FieldByName('编号').asstring; t_ch_dui_bill.post; end; t_ch_fee.first; while not t_ch_fee.Eof do begin if (t_ch_dui.FieldByName('收付类别').AsString='全部') or (t_ch_dui.FieldByName('收付类别').AsString=t_ch_fee.FieldByName('类型').AsString) then begin t_ch_fee.edit; t_ch_fee['是否对帐']:=1; t_ch_fee['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_fee.post; end; t_ch_fee.next; end; end; end; end else begin if not t_ch_fee.IsEmpty then begin if not t_ch_dui_bill.Locate('对帐编号;编号',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_op_seae.FieldByName('编号').asstring]),[]) then begin t_ch_dui_bill.insert; t_ch_dui_bill['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_bill['编号']:=t_op_seae.FieldByName('编号').asstring; t_ch_dui_bill.post; end; t_ch_fee.first; while not t_ch_fee.Eof do begin if (t_ch_dui.FieldByName('收付类别').AsString='全部') or (t_ch_dui.FieldByName('收付类别').AsString=t_ch_fee.FieldByName('类型').AsString) then begin t_ch_fee.edit; t_ch_fee['是否对帐']:=1; t_ch_fee['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_fee.post; end; t_ch_fee.next; end; end; end; t_ch_dui.edit; t_ch_dui.post; t_op_seae.requery; v_dui_bill.requery; finally t_ch_dui_bill.EnableControls; end; end; procedure Tfrm_rp_dui_accepttotal.RxDBLookupCombo1Enter(Sender: TObject); begin if t_ch_dui_bill.IsEmpty then RxDBLookupCombo1.ReadOnly:=false else RxDBLookupCombo1.ReadOnly:=true; end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_ch_dui,'对帐编号'); end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton9Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton9.ClientToScreen(Point(0,bsSkinButton9.Height)); PopupMenu8.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton10Click(Sender: TObject); begin try if not assigned(frm_rp_dui_query) then frm_rp_dui_query:=tfrm_rp_dui_query.Create (self); dui_query_num:=9; frm_rp_dui_query.showmodal; finally frm_rp_dui_query.free; frm_rp_dui_query:=nil; end; end; procedure Tfrm_rp_dui_accepttotal.N5Click(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; begin if v_dui_bill.IsEmpty then exit; aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin Close;SQL.Clear; SQL.Add('Select ch_id from t_ch_fee where 编号=:编号 and 是否对帐=1 and 对帐编号=:对帐编号'); end; if dxDBGrid6.SelectedCount>=1 then begin for i:=0 to dxDBGrid6.SelectedCount-1 do begin v_dui_bill.GotoBookmark(pointer(dxDBGrid6.selectedrows[i])); aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('编号').Value:=v_dui_bill.fieldbyname('编号').asstring; aAdoQuery.Parameters.ParamByName('对帐编号').Value:=t_ch_dui.fieldbyname('对帐编号').asstring; aAdoQuery.Open; aAdoQuery.First; while not aAdoQuery.Eof do begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+'''' +' and ch_id='+''''+aAdoQuery.fieldbyname('ch_id').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; aAdoQuery.Next; end; { str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; } str:='delete from t_ch_dui_detail' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; end else begin aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('编号').Value:=v_dui_bill.fieldbyname('编号').asstring; aAdoQuery.Parameters.ParamByName('对帐编号').Value:=t_ch_dui.fieldbyname('对帐编号').asstring; aAdoQuery.Open; aAdoQuery.First; while not aAdoQuery.Eof do begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+'''' +' and ch_id='+''''+aAdoQuery.fieldbyname('ch_id').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; aAdoQuery.Next; end; { str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; } str:='delete from t_ch_dui_detail' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; t_ch_dui.edit; t_ch_dui.post; if t_op_seae.Active then t_op_seae.Requery(); v_dui_bill.Requery(); aAdoQuery.Free; end; {procedure Tfrm_rp_dui_accepttotal.N5Click(Sender: TObject); var i:integer; str:widestring; begin if v_dui_bill.IsEmpty then exit; if dxDBGrid6.SelectedCount>=1 then begin for i:=0 to dxDBGrid6.SelectedCount-1 do begin v_dui_bill.GotoBookmark(pointer(dxDBGrid6.selectedrows[i])); str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; str:='delete from t_ch_dui_detail' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; end else begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; str:='delete from t_ch_dui_detail' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; if t_op_seae.Active then t_op_seae.Requery(); v_dui_bill.Requery(); end; } procedure Tfrm_rp_dui_accepttotal.N2Click(Sender: TObject); begin grid_save_xls(dxDBGrid2); end; procedure Tfrm_rp_dui_accepttotal.bsSkinPageControl1Change( Sender: TObject); var str_list:TStringList; i:integer; str:String; begin if bsSkinPageControl1.ActivePage=bsSkinTabSheet1 then exit; if t_ch_dui.IsEmpty then exit; if t_ch_dui.State in [dsedit,dsinsert] then t_ch_dui.Post; if t_ch_dui.fieldbyname('DM_ID').asstring='' then exit; if t_ch_dui.fieldbyname('DM_ID').asstring='0' then exit; t_ch_dui_format.Locate('DM_ID',t_ch_dui.fieldbyname('DM_ID').asstring,[]); str_list:=Tstringlist.create(); try str_list.Text:=trim(t_ch_dui_format.FieldByName('排序字段').AsString); for i:=0 to str_list.Count-1 do begin if Str='' then Str:=str_list.Strings[i] else Str:=Str+';'+str_list.Strings[i]; end; finally FreeAndNil(str_list); end; // v_dui_bill.Sort:='业务编号;开船日期'; dui_gridall(t_ch_dui_format.fieldbyname('字段内容').asstring,dxdbgrid2,t_ch_dui.fieldbyname('DM_ID').AsInteger,t_ch_dui_format,t_ch_dui.fieldbyname('收付类别').asstring); dui_tableAll(t_bill_fee_dong,t_ch_dui_format.fieldbyname('字段内容').asstring,v_dui_bill,v_dui_fee,t_ch_dui.fieldbyname('DM_ID').AsInteger,str,t_ch_dui); end; procedure Tfrm_rp_dui_accepttotal.MenuItem1Click(Sender: TObject); var i,k:integer; book1:Tbookmark; begin if t_op_seae.IsEmpty then exit; if t_ch_dui.IsEmpty then exit; if (t_ch_dui.FieldByName('对帐客户').asstring='') and (not strtobool(get_parameters_value(115,'false')))then begin t_ch_dui.edit; t_ch_dui['对帐客户']:=t_ch_fee.FieldByName('客户名称').asstring; t_ch_dui.post; end; if (t_ch_dui.state=dsinsert)or(t_ch_dui.state=dsedit) then t_ch_dui.Post; if strtobool(get_parameters_value(115,'false')) then begin end else begin if t_ch_dui.FieldByName('对帐客户').asstring<>t_ch_fee.FieldByName('客户名称').asstring then begin showmessage('当前客户名称与对帐客户名称不符,加入失败!!'); exit; end; end; if not t_ch_fee.IsEmpty then begin if not t_ch_dui_bill.Locate('对帐编号;编号',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_op_seae.FieldByName('编号').asstring]),[]) then begin t_ch_dui_bill.insert; t_ch_dui_bill['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_bill['编号']:=t_op_seae.FieldByName('编号').asstring; t_ch_dui_bill.post; end; if dxDBGrid4.SelectedCount>=1 then begin for i:=0 to dxDBGrid4.SelectedCount-1 do begin t_ch_fee.GotoBookmark(pointer(dxDBGrid4.selectedrows[i])); if (t_ch_dui.FieldByName('收付类别').AsString='全部') or (t_ch_dui.FieldByName('收付类别').AsString=t_ch_fee.FieldByName('类型').AsString) then begin t_ch_fee.edit; t_ch_fee['是否对帐']:=1; t_ch_fee['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_fee.post; end; end; end else begin if (t_ch_dui.FieldByName('收付类别').AsString='全部') or (t_ch_dui.FieldByName('收付类别').AsString=t_ch_fee.FieldByName('类型').AsString) then begin t_ch_fee.edit; t_ch_fee['是否对帐']:=1; t_ch_fee['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_fee.post; end; end; end; v_dui_bill.requery; t_ch_dui.edit; t_ch_dui.post; book1:=t_op_seae.GetBookmark; t_op_seae.Refresh; t_op_seae.GotoBookmark(book1); // t_ch_fee.Requery; end; procedure Tfrm_rp_dui_accepttotal.MenuItem2Click(Sender: TObject); var Str:String; begin if v_dui_bill.IsEmpty then exit; if v_dui_fee.IsEmpty then exit; str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+'''' +' and CH_ID=' +v_dui_fee.fieldbyname('CH_ID').asstring; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; str:='delete from t_ch_dui_detail' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+'''' +' and CH_ID='+v_dui_fee.fieldbyname('CH_ID').asstring; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; t_ch_dui.edit; t_ch_dui.post; if t_op_seae.Active then t_op_seae.Requery(); v_dui_bill.Requery(); v_dui_fee.Requery(); end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid3SelectedCountChange( Sender: TObject); var i,k:integer; DR,CR,USDDR,USDCR,NDR,NCR,NUSDDR,NUSDCR,OTDR,OTCR,NOTDR,NOTCR:Double; aFieldName:string; begin if bsSkinDBCheckRadioBox2.Checked then aFieldName:='不含税金额' else aFieldName:='金额'; DR:=0; CR:=0; USDDR:=0; USDCR:=0; NDR:=0; NCR:=0; NUSDDR:=0; NUSDCR:=0; OTDR:=0; OTCR:=0; NOTDR:=0; NOTCR:=0; if t_op_seae.IsEmpty then exit; if dxDBGrid3.SelectedCount>=1 then begin for i:=0 to dxDBGrid3.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid3.selectedrows[i])); if not t_ch_fee.IsEmpty then begin t_ch_fee.first; while not t_ch_fee.Eof do begin if t_ch_fee.FieldByName('币别').AsString='USD' then begin if t_ch_fee.FieldByName('类型').AsString='收' then begin USDDR:=USDDR+t_ch_fee.fieldByName(aFieldName).AsFloat; NUSDDR:=NUSDDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin USDCR:=USDCR+t_ch_fee.fieldByName(aFieldName).AsFloat; NUSDCR:=NUSDCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end else if t_ch_fee.FieldByName('币别').AsString='RMB' then begin if t_ch_fee.FieldByName('类型').AsString='收' then begin DR:=DR+t_ch_fee.fieldByName(aFieldName).AsFloat; NDR:=NDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin CR:=CR+t_ch_fee.fieldByName(aFieldName).AsFloat; NCR:=NCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end else begin if t_ch_fee.FieldByName('类型').AsString='收' then begin OTDR:=OTDR+t_ch_fee.fieldByName(aFieldName).AsFloat; NOTDR:=NOTDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin OTCR:=OTCR+t_ch_fee.fieldByName(aFieldName).AsFloat; NOTCR:=NOTCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end; t_ch_fee.next; end; end; end; end else begin if not t_ch_fee.IsEmpty then begin t_ch_fee.first; while not t_ch_fee.Eof do begin if t_ch_fee.FieldByName('币别').AsString='USD' then begin if t_ch_fee.FieldByName('类型').AsString='收' then begin USDDR:=USDDR+t_ch_fee.fieldByName(aFieldName).AsFloat; NUSDDR:=NUSDDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin USDCR:=USDCR+t_ch_fee.fieldByName(aFieldName).AsFloat; NUSDCR:=NUSDCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end else if t_ch_fee.FieldByName('币别').AsString='RMB' then begin if t_ch_fee.FieldByName('类型').AsString='收' then begin DR:=DR+t_ch_fee.fieldByName(aFieldName).AsFloat; NDR:=NDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin CR:=CR+t_ch_fee.fieldByName(aFieldName).AsFloat; NCR:=NCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end else begin if t_ch_fee.FieldByName('类型').AsString='收' then begin OTDR:=OTDR+t_ch_fee.fieldByName(aFieldName).AsFloat; NOTDR:=NOTDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin OTCR:=OTCR+t_ch_fee.fieldByName(aFieldName).AsFloat; NOTCR:=NOTCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end; t_ch_fee.next; end; end; end; lblSum.Caption:='你选择了'+inttostr(dxDBGrid3.SelectedCount)+'票业务,'+'应收 美元:'+FormatFloat('#,##,0.00;-0.00',USDDR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NUSDDR)+';应付 美元:'+FormatFloat('#,##,0.00;-0.00',USDCR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NUSDCR); lblSum1.Caption:='应收 人民币:'+FormatFloat('#,##,0.00;-0.00',DR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NDR)+';应付 人民币:'+FormatFloat('#,##,0.00;-0.00',CR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NCR); lblSum2.Caption:='应收 其他币别:'+FormatFloat('#,##,0.00;-0.00',OTDR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NOTDR)+';应付 其他币别:'+FormatFloat('#,##,0.00;-0.00',OTCR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NOTCR); end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid3Click(Sender: TObject); var i,k:integer; DR,CR,USDDR,USDCR,NDR,NCR,NUSDDR,NUSDCR:Double; begin { DR:=0; CR:=0; USDDR:=0; USDCR:=0; NDR:=0; NCR:=0; NUSDDR:=0; NUSDCR:=0; if t_op_seae.IsEmpty then exit; if dxDBGrid3.SelectedCount>=1 then begin for i:=0 to dxDBGrid3.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid3.selectedrows[i])); if not t_ch_fee.IsEmpty then begin t_ch_fee.first; while not t_ch_fee.Eof do begin if t_ch_fee.FieldByName('币别').AsString='USD' then begin if t_ch_fee.FieldByName('类型').AsString='收' then begin USDDR:=USDDR+t_ch_fee.fieldByName('金额').AsFloat; NUSDDR:=NUSDDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin USDCR:=USDCR+t_ch_fee.fieldByName('金额').AsFloat; NUSDCR:=NUSDCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end else begin if t_ch_fee.FieldByName('类型').AsString='收' then begin DR:=DR+t_ch_fee.fieldByName('金额').AsFloat; NDR:=NDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin CR:=CR+t_ch_fee.fieldByName('金额').AsFloat; NCR:=NCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end; t_ch_fee.next; end; end; end; end else begin if not t_ch_fee.IsEmpty then begin t_ch_fee.first; while not t_ch_fee.Eof do begin if t_ch_fee.FieldByName('币别').AsString='USD' then begin if t_ch_fee.FieldByName('类型').AsString='收' then begin USDDR:=USDDR+t_ch_fee.fieldByName('金额').AsFloat; NUSDDR:=NUSDDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin USDCR:=USDCR+t_ch_fee.fieldByName('金额').AsFloat; NUSDCR:=NUSDCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end else begin if t_ch_fee.FieldByName('类型').AsString='收' then begin DR:=DR+t_ch_fee.fieldByName('金额').AsFloat; NDR:=NDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin CR:=CR+t_ch_fee.fieldByName('金额').AsFloat; NCR:=NCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end; t_ch_fee.next; end; end; end; lblSum.Caption:='你选择了'+inttostr(dxDBGrid3.SelectedCount)+'票业务,'+'应收 美元:'+FormatFloat('#,##,0.00;-0.00',USDDR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NUSDDR)+';应收 人民币:'+FormatFloat('#,##,0.00;-0.00',DR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NDR)+';应付 美元:'+FormatFloat('#,##,0.00;-0.00',USDCR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NUSDCR)+';应付 人民币:'+FormatFloat('#,##,0.00;-0.00',CR)+',未结金额:'+FormatFloat('#,##,0.00;-0.00',NCR); } end; procedure Tfrm_rp_dui_accepttotal.N3Click(Sender: TObject); var i,k:integer; begin if t_dui_b.IsEmpty then exit; if t_ch_dui.IsEmpty then exit; if t_ch_dui.FieldByName('对帐客户').asstring='' then begin if not strtobool(get_parameters_value(115,'false')) then begin t_ch_dui.edit; t_ch_dui['对帐客户']:=t_dui_b_fee.FieldByName('客户名称').asstring; t_ch_dui.post; end else begin end; end; if dxDBGrid8.SelectedCount>=1 then begin for i:=0 to dxDBGrid8.SelectedCount-1 do begin t_dui_b.GotoBookmark(pointer(dxDBGrid8.selectedrows[i])); t_dui_b_fee.first; while not t_dui_b_fee.Eof do begin if strtobool(get_parameters_value(115,'false')) then begin end else begin if t_ch_dui.FieldByName('对帐客户').asstring<>t_dui_b_fee.FieldByName('客户名称').asstring then begin showmessage('当前客户名称与对帐客户名称不符,加入失败!!'); exit; end; end; t_dui_b_fee.next; end; end; end else begin t_dui_b_fee.first; while not t_dui_b_fee.Eof do begin if strtobool(get_parameters_value(115,'false')) then begin end else begin if t_ch_dui.FieldByName('对帐客户').asstring<>t_dui_b_fee.FieldByName('客户名称').asstring then begin showmessage('当前客户名称与对帐客户名称不符,加入失败!!'); exit; end; end; t_dui_b_fee.next; end; end; if (t_ch_dui.state=dsinsert)or(t_ch_dui.state=dsedit) then t_ch_dui.Post; if dxDBGrid8.SelectedCount>=1 then begin for i:=0 to dxDBGrid8.SelectedCount-1 do begin t_dui_b.GotoBookmark(pointer(dxDBGrid8.selectedrows[i])); if not t_dui_b_fee.IsEmpty then begin if not t_ch_dui_bill.Locate('对帐编号;编号',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_dui_b.FieldByName('编号').asstring]),[]) then begin t_ch_dui_bill.insert; t_ch_dui_bill['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_bill['编号']:=t_dui_b.FieldByName('编号').asstring; t_ch_dui_bill.post; end; t_dui_b_fee.first; while not t_dui_b_fee.Eof do begin if (t_ch_dui.FieldByName('收付类别').AsString='全部') or (t_ch_dui.FieldByName('收付类别').AsString=t_dui_b_fee.FieldByName('类型').AsString) then begin if not t_ch_dui_detail.Locate('对帐编号;CH_ID',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_dui_b_fee.FieldByName('CH_ID').asinteger]),[]) then begin t_ch_dui_detail.insert; t_ch_dui_detail['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_detail['编号']:=t_dui_b.FieldByName('编号').asstring; t_ch_dui_detail['CH_ID']:=t_dui_b_fee.FieldByName('CH_ID').asinteger; t_ch_dui_detail.post; end; end; t_dui_b_fee.next; end; end; end; end else begin if not t_dui_b_fee.IsEmpty then begin if not t_ch_dui_bill.Locate('对帐编号;编号',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_dui_b.FieldByName('编号').asstring]),[]) then begin t_ch_dui_bill.insert; t_ch_dui_bill['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_bill['编号']:=t_dui_b.FieldByName('编号').asstring; t_ch_dui_bill.post; end; t_dui_b_fee.first; while not t_dui_b_fee.Eof do begin if (t_ch_dui.FieldByName('收付类别').AsString='全部') or (t_ch_dui.FieldByName('收付类别').AsString=t_dui_b_fee.FieldByName('类型').AsString) then begin if not t_ch_dui_detail.Locate('对帐编号;CH_ID',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_dui_b_fee.FieldByName('CH_ID').asinteger]),[]) then begin t_ch_dui_detail.insert; t_ch_dui_detail['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_detail['编号']:=t_dui_b.FieldByName('编号').asstring; t_ch_dui_detail['CH_ID']:=t_dui_b_fee.FieldByName('CH_ID').asinteger; t_ch_dui_detail.post; end; end; t_dui_b_fee.next; end; end; end; bsSkinButton7.OnClick(nil); // t_dui_b.requery; v_dui_bill.requery; end; procedure Tfrm_rp_dui_accepttotal.MenuItem3Click(Sender: TObject); var i,k:integer; book1:Tbookmark; begin if t_dui_b.IsEmpty then exit; if t_ch_dui.IsEmpty then exit; if (t_ch_dui.FieldByName('对帐客户').asstring='') and (not strtobool(get_parameters_value(115,'false'))) then begin t_ch_dui.edit; t_ch_dui['对帐客户']:=t_ch_fee.FieldByName('客户名称').asstring; t_ch_dui.post; end; if (t_ch_dui.state=dsinsert)or(t_ch_dui.state=dsedit) then t_ch_dui.Post; if strtobool(get_parameters_value(115,'false')) then begin end else begin if t_ch_dui.FieldByName('对帐客户').asstring<>t_dui_b_fee.FieldByName('客户名称').asstring then begin showmessage('当前客户名称与对帐客户名称不符,加入失败!!'); exit; end; end; if not t_dui_b_fee.IsEmpty then begin if not t_ch_dui_bill.Locate('对帐编号;编号',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_dui_b.FieldByName('编号').asstring]),[]) then begin t_ch_dui_bill.insert; t_ch_dui_bill['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_bill['编号']:=t_dui_b.FieldByName('编号').asstring; t_ch_dui_bill.post; end; if (t_ch_dui.FieldByName('收付类别').AsString='全部') or (t_ch_dui.FieldByName('收付类别').AsString=t_dui_b_fee.FieldByName('类型').AsString) then begin if not t_ch_dui_detail.Locate('对帐编号;CH_ID',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_dui_b_fee.FieldByName('CH_ID').asinteger]),[]) then begin t_ch_dui_detail.insert; t_ch_dui_detail['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_detail['编号']:=t_dui_b.FieldByName('编号').asstring; t_ch_dui_detail['CH_ID']:=t_dui_b_fee.FieldByName('CH_ID').asinteger; t_ch_dui_detail.post; end; end; end; v_dui_bill.requery; bsSkinButton7.OnClick(nil); book1:=t_dui_b.GetBookmark; t_dui_b.Refresh; t_dui_b.GotoBookmark(book1); end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid3Column21CustomDraw( Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin if Trim(ANode.Strings[dxDBGrid3Column21.Index])='更改单' then AColor:=clred; AFont.Color:=clblack; end; procedure Tfrm_rp_dui_accepttotal.ComboBoxObj1KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinButton7Click(Sender); end; end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid6ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(column,v_dui_bill,'业务编号'); end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid2ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort_RxMemoryData(column,t_bill_fee_dong,'BILLID'); end; procedure Tfrm_rp_dui_accepttotal.RxDBLookupCombo4Enter(Sender: TObject); var aParams : TParams; aWithObjID : Boolean; aQuery : TAdoQuery; str_fee,str_op:widestring; begin if NOT strtobool(get_parameters_value(84,'false')) then begin if bsSkinCheckRadioBox2.Checked then begin str_fee:=' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:=' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; end else begin if bsSkinCheckRadioBox2.Checked then begin str_fee:=' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+''''+','+''''+'录入状态'+''''+','+''''+'提交审核'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:=' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+''''+','+''''+'录入状态'+''''+','+''''+'提交审核'+'''' +','+''''+'禁止修改'+''''+')'; end; end; if wwDBComboBox31.Text<>''then str_fee:=str_fee+' and c.类型='+''''+wwDBComboBox31.Text+''''; if RxDBLookupCombo16.DisplayValues[1]<>''then str_fee:=str_fee+' and c.费用名称='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; if RxDBLookupCombo15.DisplayValues[1]<>''then str_fee:=str_fee+' and c.币别='+''''+RxDBLookupCombo15.DisplayValues[0]+''''; str_op:=''; if Edit4.text<>''then str_fee:=str_fee+' and b.委托编号 like '+''''+'%'+Edit4.text+'%'+''''; if wwDBComboBox46.text<>''then str_fee:=str_fee+' and b.业务类型='+''''+wwDBComboBox46.text+''''; if Edit2.text<>''then str_fee:=str_fee+' and b.主提单号 like '+''''+'%'+Edit2.text+'%'+''''; if DBComboBoxEh1.Text<>''then str_op:=str_op+' and b.操作员='+''''+DBComboBoxEh1.Text+''''; if Edit3.text<>''then str_fee:=str_fee+' and b.分提单号 like '+''''+'%'+Edit3.text+'%'+''''; if Edit5.text<>''then str_fee:=str_fee+' and 报关单号 like '+''''+'%'+Edit5.text+'%'+''''; if Edit1.text<>''then str_fee:=str_fee+' and 核销单号 like '+''''+'%'+Edit1.text+'%'+''''; if wwDBLookupCombo49.text<>''then str_fee:=str_fee+' and b.船名 like '+''''+'%'+wwDBLookupCombo49.text+'%'+''''; if Edit7.text<>''then str_fee:=str_fee+' and b.航次 like '+''''+'%'+Edit7.text+'%'+''''; if wwDBDateTimePicker1.text<>''then str_fee:=str_fee+' and b.开船日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str_fee:=str_fee+' and b.开船日期<='+''''+wwDBDateTimePicker2.text+''''; if wwDBDateTimePicker3.text<>''then str_fee:=str_fee+' and b.会计期间>='+''''+wwDBDateTimePicker3.text+''''; if wwDBDateTimePicker4.text<>''then str_fee:=str_fee+' and b.会计期间<='+''''+wwDBDateTimePicker4.text+''''; with t_dui_cust do begin Close;SQL.Clear; SQL.Add('Select distinct u.代码, u.客户简称, u.客户全称'); SQL.Add('from t_ch_fee c'); if strtobool(get_parameters_value(115,'false')) then SQL.Add('Left Join t_crm_client u on (u.客户简称=c.客户名称 OR u.客户简称=c.第三方)') else SQL.Add('Left Join t_crm_client u on (u.客户简称=c.客户名称)'); SQL.Add(', v_op_bscard_all b'); SQL.Add('where b.编号=c.编号 '); SQL.Add(str_fee); SQL.Add(' order by u.代码'); Open; end; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton38Click(Sender: TObject); var book1:Tbookmark; begin book1:=t_ch_dui.GetBookmark; t_ch_dui.Requery; t_ch_dui.GotoBookmark(book1); end; procedure Tfrm_rp_dui_accepttotal.MenuItem4Click(Sender: TObject); var str_list:TStringList; i:integer; str:String; begin if t_ch_dui.IsEmpty then exit; if t_ch_dui.State in [dsedit,dsinsert] then t_ch_dui.Post; if t_ch_dui.fieldbyname('DM_ID').asstring='' then exit; if t_ch_dui.fieldbyname('DM_ID').asstring='0' then exit; t_ch_dui_format.Locate('DM_ID',t_ch_dui.fieldbyname('DM_ID').asstring,[]); str_list:=Tstringlist.create(); try str_list.Text:=trim(t_ch_dui_format.FieldByName('排序字段').AsString); for i:=0 to str_list.Count-1 do begin if Str='' then Str:=str_list.Strings[i] else Str:=Str+';'+str_list.Strings[i]; end; finally FreeAndNil(str_list); end; // showmessage(str); // v_dui_bill.Sort:=Str; dui_gridall(t_ch_dui_format.fieldbyname('字段内容').asstring,dxdbgrid2,t_ch_dui.fieldbyname('DM_ID').AsInteger,t_ch_dui_format,t_ch_dui.fieldbyname('收付类别').asstring); dui_tableAll(t_bill_fee_dong,t_ch_dui_format.fieldbyname('字段内容').asstring,v_dui_bill,v_dui_fee,t_ch_dui.fieldbyname('DM_ID').AsInteger,str,t_ch_dui); sys_print('业务综合对帐'+t_ch_dui.fieldbyname('DM_ID').asstring,TMenuItem(Sender).tag,t_ch_dui1,nil,nil,nil,t_bill_fee_dong1,NIL,NIL,NIL,nil,nil,nil); end; procedure Tfrm_rp_dui_accepttotal.MenuItem10Click(Sender: TObject); begin if t_ch_dui.IsEmpty then exit; mem_v_dui_fee.Close; mem_v_dui_fee.sql.clear; mem_v_dui_fee.sql.add('select * from v_dui_fee'); mem_v_dui_fee.sql.add('where 编号=:编号 and 对帐编号=:对帐编号 and 类型=''收'''); mem_v_dui_fee.sql.add('order by 顺序,CH_ID'); mem_v_dui_fee.Open; mem_v_dui_feeCr.Close; mem_v_dui_feeCr.sql.clear; mem_v_dui_feeCr.sql.add('select * from v_dui_fee'); mem_v_dui_feeCr.sql.add('where 编号=:编号 and 对帐编号=:对帐编号 and 类型=''付'''); mem_v_dui_feeCr.sql.add('order by 顺序,CH_ID'); mem_v_dui_feeCr.Open; sys_print('业务综合对帐',TMenuItem(Sender).tag,t_ch_dui1,nil,nil,nil,v_dui_bill1,v_dui_fee1,mem_v_dui_fee1,mem_v_dui_feeCr1,nil,nil,nil); mem_v_dui_fee.close; mem_v_dui_feeCr.close; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton6Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton6.ClientToScreen(Point(0,bsSkinButton6.Height)); PopupMenu9.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid3Column22CustomDraw( Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin AColor:=dxgrid_color('海运出口',ANode.Strings[dxDBGrid3Column22.Index]); AFont.Color:=clblack; end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid3Column23CustomDraw( Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin AColor:=dxgrid_color_fee(ANode.strings[dxDBGrid3Column23.Index]); AFont.Color:=clblack; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton13Click(Sender: TObject); var str:widestring; aAdoQuery,aAdoQueryFeeStatus:TAdoQuery; begin if not strtobool(get_parameters_value(133,'false')) then exit; if t_ch_dui.IsEmpty then exit; if Trim(t_ch_dui.fieldbyname('对帐编号').asstring)='' then begin ShowMessage('对账单号为空,不能审核费用,请保存后在审核'); Exit; end; if application.MessageBox('您确定要审核数据吗?','警告:',MB_OKCANCEL)<>IDOK then exit; aAdoQuery:=CreateAdoQuery; aAdoQueryFeeStatus:=CreateAdoQuery; with aAdoQueryFeeStatus do begin close;sql.clear; sql.Add('select 费用状态 from t_ch_fee'); sql.Add('where ch_id=:ch_id'); end; with aAdoQuery do try close;sql.clear; str:='select * from v_dui_fee' +' where 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; sql.text:=str; Open;first; while not eof do begin aAdoQueryFeeStatus.Close; aAdoQueryFeeStatus.Parameters.ParamByName('ch_id').value:=fieldbyname('ch_id').AsInteger; aAdoQueryFeeStatus.Open; if (Trim(aAdoQueryFeeStatus.FieldByName('费用状态').AsString)='录入状态') or (Trim(aAdoQueryFeeStatus.FieldByName('费用状态').AsString)='提交审核') then begin str:='update t_ch_fee set 费用状态=''审核通过'' , 审核人='+''''+employee+''''+',审核日期='+''''+FormatDateTime('YYYY-MM-DD',date)+'''' +' where ch_id='+''''+fieldbyname('ch_id').asstring+'''' +' and 费用状态 in ( ''录入状态'',''提交审核'' ) and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; end; next; end; finally free; aAdoQueryFeeStatus.Free; end; t_ch_dui.Edit; t_ch_dui.FieldByName('审核人').Value:=employee; t_ch_dui.FieldByName('审核日期').Value:=date; t_ch_dui.post; end; procedure Tfrm_rp_dui_accepttotal.DBComboBoxEh1DropDown(Sender: TObject); var AdoQuery1:TAdoQuery; begin AdoQuery1:=CreateAdoQuery; with AdoQuery1 do try AdoQuery1.Close; AdoQuery1.sql.Clear; AdoQuery1.SQL.Add('select * from t_sys_employee where 状态=''在职'''); AdoQuery1.Open; AdoQuery1.first; while not AdoQuery1.Eof do begin DBComboBoxEh1.Items.Add(AdoQuery1.fieldbyname('姓名').AsString); ADOQuery1.Next; end; finally Free; end; end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid1CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin if uppercase(ANode.Strings[dxDBGrid1Column12.Index])<>'' then begin AColor:=clskyblue; exit; end; end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid6DblClick(Sender: TObject); begin fee_view(v_dui_bill1.dataset.fieldbyname('编号').asstring); end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid3DblClick(Sender: TObject); begin fee_view(t_op_seae1.dataset.fieldbyname('编号').asstring); end; procedure Tfrm_rp_dui_accepttotal.dxDBGrid1Column18CustomDraw( Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin if Trim(ANode.Strings[dxDBGrid1Column18.Index])='已对帐' then AColor:=clred; AFont.Color:=clblack; end; procedure Tfrm_rp_dui_accepttotal.bsSkinButton14Click(Sender: TObject); begin if not assigned(frm_rp_op_ttl) then frm_rp_op_ttl:=tfrm_rp_op_ttl.Create (self); frm_rp_op_ttl.billno:=t_ch_dui.fieldbyname('对帐编号').asstring; frm_rp_op_ttl.CorpName:=t_ch_dui.fieldbyname('对帐客户').asstring; frm_rp_op_ttl.show; end; procedure Tfrm_rp_dui_accepttotal.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_rp_dui_accepttotal.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_rp_dui_accepttotal.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; end.