unit u_ch_invoice_query; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, RxLookup, wwdbdatetimepicker, StdCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb, ComCtrls, bsSkinTabs, DB, ADODB, wwdblook; type Tfrm_ch_invoice_query = class(TForm) bsSkinButton1: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; Label12: TLabel; Label13: TLabel; Label15: TLabel; Label16: TLabel; Label17: TLabel; Label18: TLabel; Label19: TLabel; Label20: TLabel; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; wwDBComboBox7: TwwDBComboBox; Edit3: TEdit; wwDBComboBox8: TwwDBComboBox; Edit5: TEdit; wwDBComboBox16: TwwDBComboBox; Edit6: TEdit; wwDBComboBox9: TwwDBComboBox; Edit7: TEdit; wwDBComboBox10: TwwDBComboBox; wwDBDateTimePicker5: TwwDBDateTimePicker; wwDBComboBox12: TwwDBComboBox; wwDBDateTimePicker6: TwwDBDateTimePicker; wwDBDateTimePicker7: TwwDBDateTimePicker; wwDBComboBox13: TwwDBComboBox; wwDBDateTimePicker8: TwwDBDateTimePicker; wwDBComboBox20: TwwDBComboBox; wwDBComboBox24: TwwDBComboBox; RxDBLookupCombo5: TRxDBLookupCombo; wwDBComboBox22: TwwDBComboBox; RxDBLookupCombo6: TRxDBLookupCombo; RxDBLookupCombo7: TRxDBLookupCombo; wwDBComboBox23: TwwDBComboBox; wwDBComboBox25: TwwDBComboBox; RxDBLookupCombo8: TRxDBLookupCombo; bsSkinTabSheet2: TbsSkinTabSheet; Label25: TLabel; Label26: TLabel; Label27: TLabel; Label28: TLabel; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; Label33: TLabel; Label34: TLabel; Label35: TLabel; Label36: TLabel; wwDBComboBox26: TwwDBComboBox; Edit8: TEdit; wwDBComboBox27: TwwDBComboBox; Edit9: TEdit; wwDBComboBox28: TwwDBComboBox; Edit10: TEdit; wwDBComboBox29: TwwDBComboBox; Edit11: TEdit; wwDBComboBox30: TwwDBComboBox; wwDBDateTimePicker9: TwwDBDateTimePicker; wwDBComboBox31: TwwDBComboBox; wwDBDateTimePicker10: TwwDBDateTimePicker; wwDBComboBox32: TwwDBComboBox; wwDBDateTimePicker11: TwwDBDateTimePicker; wwDBComboBox33: TwwDBComboBox; wwDBDateTimePicker12: TwwDBDateTimePicker; RxDBLookupCombo9: TRxDBLookupCombo; wwDBComboBox34: TwwDBComboBox; RxDBLookupCombo10: TRxDBLookupCombo; wwDBComboBox35: TwwDBComboBox; wwDBComboBox36: TwwDBComboBox; RxDBLookupCombo11: TRxDBLookupCombo; wwDBComboBox37: TwwDBComboBox; RxDBLookupCombo12: TRxDBLookupCombo; bsSkinTabSheet3: TbsSkinTabSheet; Label37: TLabel; Label38: TLabel; Label39: TLabel; Label40: TLabel; Label41: TLabel; Label42: TLabel; Label43: TLabel; Label44: TLabel; Label45: TLabel; Label46: TLabel; Label47: TLabel; Label48: TLabel; wwDBComboBox38: TwwDBComboBox; Edit12: TEdit; wwDBComboBox39: TwwDBComboBox; Edit13: TEdit; Edit14: TEdit; wwDBComboBox40: TwwDBComboBox; Edit15: TEdit; wwDBComboBox41: TwwDBComboBox; wwDBComboBox42: TwwDBComboBox; wwDBDateTimePicker13: TwwDBDateTimePicker; wwDBComboBox43: TwwDBComboBox; wwDBDateTimePicker14: TwwDBDateTimePicker; wwDBDateTimePicker15: TwwDBDateTimePicker; wwDBComboBox44: TwwDBComboBox; wwDBDateTimePicker16: TwwDBDateTimePicker; wwDBComboBox45: TwwDBComboBox; wwDBComboBox46: TwwDBComboBox; RxDBLookupCombo13: TRxDBLookupCombo; wwDBComboBox47: TwwDBComboBox; RxDBLookupCombo14: TRxDBLookupCombo; RxDBLookupCombo15: TRxDBLookupCombo; wwDBComboBox48: TwwDBComboBox; RxDBLookupCombo16: TRxDBLookupCombo; wwDBComboBox49: TwwDBComboBox; bsSkinTabSheet4: TbsSkinTabSheet; Label49: TLabel; Label50: TLabel; Label51: TLabel; Label52: TLabel; Label53: TLabel; Label54: TLabel; Label55: TLabel; Label56: TLabel; Label57: TLabel; Label58: TLabel; Label59: TLabel; Label60: TLabel; wwDBComboBox50: TwwDBComboBox; Edit16: TEdit; wwDBComboBox51: TwwDBComboBox; Edit17: TEdit; Edit18: TEdit; wwDBComboBox52: TwwDBComboBox; Edit19: TEdit; wwDBComboBox53: TwwDBComboBox; wwDBComboBox54: TwwDBComboBox; wwDBDateTimePicker17: TwwDBDateTimePicker; wwDBComboBox55: TwwDBComboBox; wwDBDateTimePicker18: TwwDBDateTimePicker; wwDBDateTimePicker19: TwwDBDateTimePicker; wwDBComboBox56: TwwDBComboBox; wwDBDateTimePicker20: TwwDBDateTimePicker; wwDBComboBox57: TwwDBComboBox; wwDBComboBox58: TwwDBComboBox; RxDBLookupCombo17: TRxDBLookupCombo; wwDBComboBox59: TwwDBComboBox; RxDBLookupCombo18: TRxDBLookupCombo; RxDBLookupCombo19: TRxDBLookupCombo; wwDBComboBox60: TwwDBComboBox; RxDBLookupCombo20: TRxDBLookupCombo; wwDBComboBox61: TwwDBComboBox; bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinGroupBox2: TbsSkinGroupBox; Label63: TLabel; Label64: TLabel; Label65: TLabel; Label68: TLabel; Label70: TLabel; Label72: TLabel; wwDBComboBox64: TwwDBComboBox; RxDBLookupCombo21: TRxDBLookupCombo; wwDBComboBox67: TwwDBComboBox; RxDBLookupCombo22: TRxDBLookupCombo; wwDBDateTimePicker21: TwwDBDateTimePicker; RxDBLookupCombo24: TRxDBLookupCombo; wwDBDateTimePicker24: TwwDBDateTimePicker; wwDBComboBox68: TwwDBComboBox; wwDBComboBox69: TwwDBComboBox; wwDBComboBox71: TwwDBComboBox; wwDBComboBox73: TwwDBComboBox; wwDBComboBox74: TwwDBComboBox; Label62: TLabel; wwDBComboBox63: TwwDBComboBox; Edit21: TEdit; Label71: TLabel; wwDBComboBox70: TwwDBComboBox; Edit22: TEdit; Label6: TLabel; wwDBComboBox15: TwwDBComboBox; Edit2: TEdit; Label10: TLabel; wwDBComboBox18: TwwDBComboBox; wwDBDateTimePicker1: TwwDBDateTimePicker; Label5: TLabel; wwDBComboBox6: TwwDBComboBox; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; wwDBComboBox11: TwwDBComboBox; Label11: TLabel; Label14: TLabel; wwDBComboBox14: TwwDBComboBox; RxDBLookupCombo3: TRxDBLookupCombo; RxDBLookupCombo4: TRxDBLookupCombo; wwDBDateTimePicker3: TwwDBDateTimePicker; wwDBComboBox19: TwwDBComboBox; wwDBComboBox5: TwwDBComboBox; Label8: TLabel; Label4: TLabel; Label1: TLabel; wwDBComboBox1: TwwDBComboBox; Label2: TLabel; wwDBComboBox2: TwwDBComboBox; wwDBComboBox3: TwwDBComboBox; Label3: TLabel; wwDBComboBox4: TwwDBComboBox; wwDBComboBox17: TwwDBComboBox; Label7: TLabel; wwDBComboBox21: TwwDBComboBox; Edit4: TEdit; Label9: TLabel; wwDBComboBox62: TwwDBComboBox; t_ch_invoice_head: TADOQuery; t_ch_invoice_head1: TDataSource; wwDBLookupCombo1: TwwDBLookupCombo; Edit1: TEdit; Label61: TLabel; wwDBComboBox65: TwwDBComboBox; RxDBLookupCombo1: TRxDBLookupCombo; Label66: TLabel; wwDBComboBox66: TwwDBComboBox; RxDBLookupCombo2: TRxDBLookupCombo; Label67: TLabel; wwDBComboBox72: TwwDBComboBox; RxDBLookupCombo23: TRxDBLookupCombo; Label69: TLabel; wwDBComboBox75: TwwDBComboBox; RxDBLookupCombo25: TRxDBLookupCombo; procedure FormShow(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure wwDBComboBox63KeyPress(Sender: TObject; var Key: Char); private { Private declarations } public { Public declarations } end; var frm_ch_invoice_query: Tfrm_ch_invoice_query; inv_query_type:integer; inv_query_limited:string; inv_query_op_limited:string; implementation uses u_data_share, u_ch_invoice, my_sys_function, u_ch_balance_accept, u_ch_invoice_jk; {$R *.dfm} procedure Tfrm_ch_invoice_query.FormShow(Sender: TObject); begin wwDBComboBox63.text:='模糊'; wwDBComboBox21.text:='模糊'; wwDBComboBox69.text:='等于'; wwDBComboBox70.text:='等于'; wwDBComboBox71.text:='等于'; wwDBComboBox73.text:='等于'; wwDBComboBox18.text:='等于'; wwDBComboBox19.text:='等于'; wwDBComboBox64.text:='等于'; wwDBComboBox74.text:='等于'; wwDBComboBox1.text:='模糊'; wwDBComboBox67.text:='等于'; wwDBComboBox15.text:='模糊'; wwDBComboBox6.text:='等于'; wwDBComboBox11.text:='等于'; wwDBComboBox14.text:='等于'; wwDBComboBox62.text:='等于'; wwDBComboBox7.text:='模糊'; wwDBComboBox16.text:='模糊'; wwDBComboBox10.text:='等于'; wwDBComboBox20.text:='等于'; wwDBComboBox24.text:='等于'; wwDBComboBox25.text:='等于'; wwDBComboBox8.text:='模糊'; wwDBComboBox9.text:='模糊'; wwDBComboBox12.text:='等于'; wwDBComboBox13.text:='等于'; wwDBComboBox22.text:='等于'; wwDBComboBox23.text:='等于'; wwDBComboBox26.text:='模糊'; wwDBComboBox28.text:='模糊'; wwDBComboBox30.text:='等于'; wwDBComboBox32.text:='等于'; wwDBComboBox35.text:='等于'; wwDBComboBox36.text:='等于'; wwDBComboBox27.text:='模糊'; wwDBComboBox29.text:='模糊'; wwDBComboBox31.text:='等于'; wwDBComboBox33.text:='等于'; wwDBComboBox34.text:='等于'; wwDBComboBox37.text:='等于'; wwDBComboBox38.text:='模糊'; wwDBComboBox39.text:='模糊'; wwDBComboBox40.text:='模糊'; wwDBComboBox41.text:='模糊'; wwDBComboBox42.text:='等于'; wwDBComboBox43.text:='等于'; wwDBComboBox44.text:='等于'; wwDBComboBox45.text:='等于'; wwDBComboBox46.text:='等于'; wwDBComboBox47.text:='等于'; wwDBComboBox48.text:='等于'; wwDBComboBox49.text:='等于'; wwDBComboBox50.text:='模糊'; wwDBComboBox51.text:='模糊'; wwDBComboBox52.text:='模糊'; wwDBComboBox53.text:='模糊'; wwDBComboBox54.text:='等于'; wwDBComboBox55.text:='等于'; wwDBComboBox56.text:='等于'; wwDBComboBox57.text:='等于'; wwDBComboBox58.text:='等于'; wwDBComboBox59.text:='等于'; wwDBComboBox60.text:='等于'; wwDBComboBox61.text:='等于'; wwDBComboBox65.text:='等于'; wwDBComboBox66.text:='等于'; wwDBComboBox72.text:='等于'; wwDBComboBox75.text:='等于'; wwDBComboBox4.text:='等于'; wwDBComboBox2.text:='等于'; frm_data_share.t_crm_client_all.requery; frm_data_share.t_code_currency.requery; frm_data_share.t_sys_employee.requery; t_ch_invoice_head.OPEN; end; procedure Tfrm_ch_invoice_query.bsSkinButton10Click(Sender: TObject); begin Edit21.text:=''; Edit4.text:=''; wwDBComboBox68.text:=''; Edit22.text:=''; wwDBDateTimePicker24.text:=''; RxDBLookupCombo24.ClearValue; wwDBDateTimePicker1.text:=''; wwDBDateTimePicker3.text:=''; RxDBLookupCombo4.ClearValue; RxDBLookupCombo21.ClearValue; Edit1.text:=''; RxDBLookupCombo22.ClearValue; wwDBDateTimePicker21.text:=''; Edit2.text:=''; wwDBDateTimePicker2.text:=''; wwDBDateTimePicker4.text:=''; RxDBLookupCombo3.ClearValue; Edit1.text:=''; Edit3.text:=''; Edit6.text:=''; wwDBDateTimePicker5.Clear; wwDBDateTimePicker8.Clear; RxDBLookupCombo5.ClearValue; RxDBLookupCombo8.ClearValue; Edit5.text:=''; Edit7.text:=''; wwDBDateTimePicker6.Clear; wwDBDateTimePicker7.Clear; RxDBLookupCombo6.ClearValue; RxDBLookupCombo7.ClearValue; Edit8.text:=''; Edit10.text:=''; wwDBDateTimePicker9.Clear; wwDBDateTimePicker11.Clear; RxDBLookupCombo10.ClearValue; RxDBLookupCombo11.ClearValue; Edit9.text:=''; Edit11.text:=''; wwDBDateTimePicker10.Clear; wwDBDateTimePicker12.Clear; RxDBLookupCombo9.ClearValue; RxDBLookupCombo12.ClearValue; RxDBLookupCombo1.ClearValue; RxDBLookupCombo2.ClearValue; RxDBLookupCombo23.ClearValue; RxDBLookupCombo25.ClearValue; end; procedure Tfrm_ch_invoice_query.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_ch_invoice_query.bsSkinButton1Click(Sender: TObject); var str,str_in,str_shen,op_string:widestring; begin //str_in:=query_tiaojian(1,str_in,'发票号码',wwDBComboBox63.text,Edit21.text); str_in:=query_tiaojian(1,str_in,'客户名称',wwDBComboBox64.text,RxDBLookupCombo21.DisplayValues[1]); str_in:=query_tiaojian(1,str_in,'发票类别',wwDBComboBox69.text,wwDBComboBox68.text); str_in:=query_tiaojian(1,str_in,'发票抬头',wwDBComboBox1.text,wwDBLookupCombo1.text); str_in:=query_tiaojian(2,str_in,'合计金额',wwDBComboBox70.text,Edit22.text); str_in:=query_tiaojian(1,str_in,'币别',wwDBComboBox74.text,RxDBLookupCombo22.DisplayValues[0]); str_in:=query_tiaojian(1,str_in,'开票日期',wwDBComboBox71.text,wwDBDateTimePicker24.text); str_in:=query_tiaojian(1,str_in,'开票日期',wwDBComboBox67.text,wwDBDateTimePicker21.text); str_in:=query_tiaojian(1,str_in,'制单人',wwDBComboBox73.text,RxDBLookupCombo24.DisplayValues[0]); str_in:=query_tiaojian(3,str_in,'是否废除',wwDBComboBox2.text,wwDBComboBox3.text); str_in:=query_tiaojian(3,str_in,'是否打印',wwDBComboBox4.text,wwDBComboBox17.text); str_in:=query_tiaojian(1,str_in,'委托编号',wwDBComboBox62.text,Edit1.text); if (Edit21.text<>'')and(Edit4.text<>'') then begin if str_in='' then str_in:='where 发票号码 between '+''''+Edit21.text+''''+' and '+''''+Edit4.text+'''' else str_in:=str_in+' and 发票号码 between '+''''+Edit21.text+''''+' and '+''''+Edit4.text+''''; end else begin str_in:=query_tiaojian(1,str_in,'发票号码',wwDBComboBox63.text,Edit21.text); str_in:=query_tiaojian(1,str_in,'发票号码',wwDBComboBox21.text,Edit4.text); end; str_shen:=query_tiaojian(1,str_shen,'申请编号',wwDBComboBox15.text,Edit2.text); str_shen:=query_tiaojian(1,str_shen,'申请日期',wwDBComboBox18.text,wwDBDateTimePicker1.text); str_shen:=query_tiaojian(1,str_shen,'申请日期',wwDBComboBox6.text,wwDBDateTimePicker2.text); str_shen:=query_tiaojian(1,str_shen,'审核日期',wwDBComboBox19.text,wwDBDateTimePicker3.text); str_shen:=query_tiaojian(1,str_shen,'审核日期',wwDBComboBox11.text,wwDBDateTimePicker4.text); str_shen:=query_tiaojian(1,str_shen,'申请人',wwDBComboBox5.text,RxDBLookupCombo4.DisplayValues[0]); str_shen:=query_tiaojian(1,str_shen,'审核人',wwDBComboBox14.text,RxDBLookupCombo3.DisplayValues[0]); if bsSkinTabSheet1.Showing then begin op_string:=query_tiaojian(1,op_string,'业务编号',wwDBComboBox7.text,Edit3.text); op_string:=query_tiaojian(1,op_string,'主提单号',wwDBComboBox16.text,Edit6.text); op_string:=query_tiaojian(1,op_string,'开船日期',wwDBComboBox10.text,wwDBDateTimePicker5.text); op_string:=query_tiaojian(1,op_string,'会计期间',wwDBComboBox20.text,wwDBDateTimePicker8.text); op_string:=query_tiaojian(1,op_string,'客服员',wwDBComboBox24.text,RxDBLookupCombo5.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'操作员',wwDBComboBox25.text,RxDBLookupCombo8.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'委托编号',wwDBComboBox8.text,Edit5.text); op_string:=query_tiaojian(1,op_string,'分提单号',wwDBComboBox9.text,Edit7.text); op_string:=query_tiaojian(1,op_string,'开船日期',wwDBComboBox12.text,wwDBDateTimePicker6.text); op_string:=query_tiaojian(1,op_string,'会计期间',wwDBComboBox13.text,wwDBDateTimePicker7.text); op_string:=query_tiaojian(1,op_string,'揽货人',wwDBComboBox22.text,RxDBLookupCombo6.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'录入人',wwDBComboBox23.text,RxDBLookupCombo7.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'分部名称',wwDBComboBox65.text,RxDBLookupCombo1.DisplayValue); if trim(op_string)<>''then op_string:='(select 编号 from t_op_seae '+op_string+')'; end; if bsSkinTabSheet2.Showing then begin op_string:=query_tiaojian(1,op_string,'业务编号',wwDBComboBox26.text,Edit8.text); op_string:=query_tiaojian(1,op_string,'主提单号',wwDBComboBox28.text,Edit10.text); op_string:=query_tiaojian(1,op_string,'进口日期',wwDBComboBox30.text,wwDBDateTimePicker9.text); op_string:=query_tiaojian(1,op_string,'会计期间',wwDBComboBox32.text,wwDBDateTimePicker11.text); op_string:=query_tiaojian(1,op_string,'客服员',wwDBComboBox35.text,RxDBLookupCombo10.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'操作员',wwDBComboBox36.text,RxDBLookupCombo11.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'委托编号',wwDBComboBox27.text,Edit9.text); op_string:=query_tiaojian(1,op_string,'分提单号',wwDBComboBox29.text,Edit11.text); op_string:=query_tiaojian(1,op_string,'进口日期',wwDBComboBox31.text,wwDBDateTimePicker10.text); op_string:=query_tiaojian(1,op_string,'会计期间',wwDBComboBox33.text,wwDBDateTimePicker12.text); op_string:=query_tiaojian(1,op_string,'揽货人',wwDBComboBox34.text,RxDBLookupCombo9.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'录入人',wwDBComboBox37.text,RxDBLookupCombo12.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'分部名称',wwDBComboBox66.text,RxDBLookupCombo2.DisplayValue); if trim(op_string)<>''then op_string:='(select 编号 from t_op_seai '+op_string+')'; end; if bsSkinTabSheet3.Showing then begin op_string:=query_tiaojian(1,op_string,'业务编号',wwDBComboBox38.text,Edit12.text); op_string:=query_tiaojian(1,op_string,'主运单号',wwDBComboBox41.text,Edit15.text); op_string:=query_tiaojian(1,op_string,'委托编号',wwDBComboBox39.text,Edit13.text); op_string:=query_tiaojian(1,op_string,'分运单号',wwDBComboBox40.text,Edit14.text); op_string:=query_tiaojian(1,op_string,'一程开航日期',wwDBComboBox42.text,wwDBDateTimePicker13.text); op_string:=query_tiaojian(1,op_string,'一程开航日期',wwDBComboBox43.text,wwDBDateTimePicker14.text); op_string:=query_tiaojian(1,op_string,'会计期间',wwDBComboBox45.text,wwDBDateTimePicker16.text); op_string:=query_tiaojian(1,op_string,'会计期间',wwDBComboBox44.text,wwDBDateTimePicker15.text); op_string:=query_tiaojian(1,op_string,'客服员',wwDBComboBox46.text,RxDBLookupCombo13.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'操作员',wwDBComboBox49.text,RxDBLookupCombo16.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'揽货人',wwDBComboBox47.text,RxDBLookupCombo14.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'录入人',wwDBComboBox48.text,RxDBLookupCombo15.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'分部名称',wwDBComboBox72.text,RxDBLookupCombo23.DisplayValue); if trim(op_string)<>''then op_string:='(select 编号 from t_op_aire '+op_string+')'; end; if bsSkinTabSheet4.Showing then begin op_string:=query_tiaojian(1,op_string,'业务编号',wwDBComboBox50.text,Edit16.text); op_string:=query_tiaojian(1,op_string,'主运单号',wwDBComboBox53.text,Edit19.text); op_string:=query_tiaojian(1,op_string,'委托编号',wwDBComboBox51.text,Edit17.text); op_string:=query_tiaojian(1,op_string,'分运单号',wwDBComboBox52.text,Edit18.text); op_string:=query_tiaojian(1,op_string,'进口日期',wwDBComboBox54.text,wwDBDateTimePicker17.text); op_string:=query_tiaojian(1,op_string,'进口日期',wwDBComboBox55.text,wwDBDateTimePicker18.text); op_string:=query_tiaojian(1,op_string,'会计期间',wwDBComboBox57.text,wwDBDateTimePicker20.text); op_string:=query_tiaojian(1,op_string,'会计期间',wwDBComboBox56.text,wwDBDateTimePicker19.text); op_string:=query_tiaojian(1,op_string,'客服员',wwDBComboBox58.text,RxDBLookupCombo17.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'操作员',wwDBComboBox61.text,RxDBLookupCombo20.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'揽货人',wwDBComboBox59.text,RxDBLookupCombo18.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'录入人',wwDBComboBox60.text,RxDBLookupCombo19.DisplayValues[0]); op_string:=query_tiaojian(1,op_string,'分部名称',wwDBComboBox75.text,RxDBLookupCombo25.DisplayValue); if trim(op_string)<>''then op_string:='(select 编号 from t_op_airi '+op_string+')'; end; if str_shen<>'' then begin str:='(select 发票号码 from t_ch_invoice_shen '+str_shen; if op_string<>''then str:=str+' and 申请编号 in (select 工作编号 from t_ch_fee_do where 类型='+''''+'1'+'''' +' and 业务编号 in '+op_string+')'; str:=str+')'; end else begin if op_string<>''then str:='(select 发票号码 from t_ch_invoice where 申请编号 in (select 工作编号 from t_ch_fee_do where 类型='+''''+'1'+'''' +' and 业务编号 in '+op_string+'))'; end; str_shen:=str; ///(case when t_ch_fee_do.原始金额<0 then t_ch_fee_do.原始金额 end)<(t_ch_fee.金额-t_ch_fee.结算金额) ) if str_in<>''then begin str:='select * from t_ch_invoice '+str_in; if str_shen<>''then str:=str+' and 发票号码 in '+str_shen; if inv_query_type=7 then begin str:=str+' and 申请编号<>'''' and (是否收费=0 or 是否收费 is null) and (申请编号 NOT IN (SELECT DISTINCT t_ch_fee_do.工作编号' +' FROM t_ch_fee_do INNER JOIN t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID ' +' AND (case when t_ch_fee_do.原始金额<0 then t_ch_fee_do.原始金额 end)<(t_ch_fee.金额-t_ch_fee.结算金额)' //+' AND t_ch_fee_do.原始金额 >(t_ch_fee.金额-t_ch_fee.结算金额) ' +' AND t_ch_fee_do.类型 = '+''''+'1'+''''+')) '; end; str:=str+' order by 发票号码'; end else begin str:='select * from t_ch_invoice '; if str_shen<>''then begin str:=str+' where 发票号码 in '+str_shen; if inv_query_type=7 then begin str:=str+' and 申请编号<>'''' and (是否收费=0 or 是否收费 is null) and (申请编号 NOT IN (SELECT DISTINCT t_ch_fee_do.工作编号' +' FROM t_ch_fee_do INNER JOIN t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID ' +' AND (case when t_ch_fee_do.原始金额<0 then t_ch_fee_do.原始金额 end)<(t_ch_fee.金额-t_ch_fee.结算金额)' // +' AND t_ch_fee_do.原始金额 >(t_ch_fee.金额-t_ch_fee.结算金额) ' +'AND t_ch_fee_do.类型 = '+''''+'1'+''''+')) '; end; end else begin if inv_query_type=7 then begin str:=str+' where 申请编号<>'''' and (是否收费=0 or 是否收费 is null) and (申请编号 NOT IN (SELECT DISTINCT t_ch_fee_do.工作编号' +' FROM t_ch_fee_do INNER JOIN t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID ' +' AND (case when t_ch_fee_do.原始金额<0 then t_ch_fee_do.原始金额 end)<(t_ch_fee.金额-t_ch_fee.结算金额)' //+'AND t_ch_fee_do.原始金额 >(t_ch_fee.金额-t_ch_fee.结算金额) ' +'AND t_ch_fee_do.类型 = '+''''+'1'+''''+')) '; end; end; str:=str+' order by 发票号码'; end; //ShowMessage(str); if inv_query_type=7 then begin frm_ch_balance_accept.t_ch_invoice_shen.Close; frm_ch_balance_accept.t_ch_invoice_shen.sql.clear; frm_ch_balance_accept.t_ch_invoice_shen.sql.add(str); frm_ch_balance_accept.t_ch_invoice_shen.open; if frm_ch_balance_accept.t_ch_invoice_shen.IsEmpty then begin showmessage('没有检索出所需申请!!'); exit; end; end if inv_query_type=3 then begin frm_ch_invoice_jk.t_ch_invoice.close; frm_ch_invoice_jk.t_ch_invoice.sql.clear; frm_ch_invoice_jk.t_ch_invoice.sql.add(str); frm_ch_invoice_jk.t_ch_invoice.open; if frm_ch_invoice_jk.t_ch_invoice.isempty then begin showmessage('没有检索出符合条件的数据!!'); exit; end; end else begin frm_ch_invoice.t_ch_invoice.close; frm_ch_invoice.t_ch_invoice.sql.clear; frm_ch_invoice.t_ch_invoice.sql.add(str); frm_ch_invoice.t_ch_invoice.open; if frm_ch_invoice.t_ch_invoice.isempty then begin showmessage('没有检索出符合条件的数据!!'); exit; end; end; inv_query_type:=0; close; end; procedure Tfrm_ch_invoice_query.wwDBComboBox63KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; frm_ch_invoice_query.bsSkinButton1Click(Sender); end; end; end.