unit u_ch_add_do; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, bsSkinTabs, bsSkinCtrls, wwdbdatetimepicker, StdCtrls, RxLookup, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, ExtCtrls, DB, ADODB, dxDBTLCl, dxGrClms, Menus, RxMemDS, Grids, DBGrids, XPMenu, Mask, wwdbedit, Wwdotdot, Wwdbcomb, wwdblook, DBGridEh, kbmMemTable, DBCtrlsEh, bsSkinBoxCtrls; type Tfra_ch_add_do = class(TFrame) bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinTabSheet3: TbsSkinTabSheet; bsSkinTabSheet4: TbsSkinTabSheet; bsSkinPanel1: TbsSkinPanel; bsSkinPanel2: TbsSkinPanel; Edit4: TEdit; Label1: TLabel; Edit2: TEdit; Edit3: TEdit; Label2: TLabel; Label3: TLabel; Label8: TLabel; Label10: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; Label5: TLabel; Label11: TLabel; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; Label9: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; bsSkinButton10: TbsSkinButton; bsSkinButton3: TbsSkinButton; dxDBGrid2: TdxDBGrid; Panel1: TPanel; dxDBGrid1: TdxDBGrid; dxDBGrid3: TdxDBGrid; t_op_seae: TADOQuery; t_op_seae1: TDataSource; dxDBGrid2Column1: TdxDBGridMaskColumn; dxDBGrid2Column2: TdxDBGridMaskColumn; dxDBGrid2Column3: TdxDBGridMaskColumn; dxDBGrid2Column4: TdxDBGridMaskColumn; dxDBGrid2Column5: TdxDBGridMaskColumn; dxDBGrid2Column6: TdxDBGridDateColumn; dxDBGrid2Column7: TdxDBGridMaskColumn; dxDBGrid2Column8: TdxDBGridMaskColumn; dxDBGrid2Column9: TdxDBGridDateColumn; dxDBGrid2Column10: TdxDBGridMaskColumn; dxDBGrid2Column11: TdxDBGridMaskColumn; dxDBGrid2Column14: TdxDBGridMaskColumn; dxDBGrid2Column15: TdxDBGridMaskColumn; dxDBGrid2Column16: TdxDBGridMaskColumn; dxDBGrid2Column17: TdxDBGridMaskColumn; dxDBGrid2Column18: TdxDBGridColumn; dxDBGrid2Column13: TdxDBGridColumn; dxDBGrid2Column12: TdxDBGridColumn; t_ch_fee1: TDataSource; t_ch_fee: TADOQuery; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; t_ch_fee_sum: TADOQuery; t_ch_fee_sum1: TDataSource; dxDBGrid3Column1: TdxDBGridMaskColumn; dxDBGrid3Column2: TdxDBGridColumn; dxDBGrid3Column3: TdxDBGridColumn; PopupMenu1: TPopupMenu; N1: TMenuItem; PopupMenu2: TPopupMenu; MenuItem1: TMenuItem; bs_text: TEdit; dxDBGrid1Column5: TdxDBGridColumn; do_ban1: TDataSource; t_ch_fee_do: TADOQuery; t_rate: TRxMemoryData; XPMenu1: TXPMenu; bsSkinPanel3: TbsSkinPanel; Label4: TLabel; Label6: TLabel; Label7: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; Label16: TLabel; Edit1: TEdit; Edit5: TEdit; Edit6: TEdit; wwDBDateTimePicker5: TwwDBDateTimePicker; wwDBDateTimePicker6: TwwDBDateTimePicker; wwDBDateTimePicker7: TwwDBDateTimePicker; wwDBDateTimePicker8: TwwDBDateTimePicker; RxDBLookupCombo1: TRxDBLookupCombo; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinPanel4: TbsSkinPanel; dxDBGrid4: 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; Panel2: TPanel; dxDBGrid5: TdxDBGrid; dxDBGridMaskColumn14: TdxDBGridMaskColumn; dxDBGridMaskColumn15: TdxDBGridMaskColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGridColumn6: TdxDBGridColumn; dxDBGrid6: TdxDBGrid; dxDBGridMaskColumn16: TdxDBGridMaskColumn; dxDBGridColumn7: TdxDBGridColumn; dxDBGridColumn8: TdxDBGridColumn; t_op_seai: TADOQuery; t_op_seai1: TDataSource; t_op_aire: TADOQuery; t_op_aire1: TDataSource; bsSkinPanel5: TbsSkinPanel; Label17: TLabel; Label18: TLabel; Label19: TLabel; Label20: TLabel; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; Edit8: TEdit; Edit9: TEdit; Edit10: TEdit; wwDBDateTimePicker9: TwwDBDateTimePicker; wwDBDateTimePicker10: TwwDBDateTimePicker; wwDBDateTimePicker11: TwwDBDateTimePicker; wwDBDateTimePicker12: TwwDBDateTimePicker; RxDBLookupCombo3: TRxDBLookupCombo; bsSkinButton4: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinPanel6: TbsSkinPanel; dxDBGrid7: TdxDBGrid; dxDBGridMaskColumn17: TdxDBGridMaskColumn; dxDBGridMaskColumn18: TdxDBGridMaskColumn; dxDBGridMaskColumn19: TdxDBGridMaskColumn; dxDBGridMaskColumn20: TdxDBGridMaskColumn; dxDBGridMaskColumn21: TdxDBGridMaskColumn; dxDBGridDateColumn3: TdxDBGridDateColumn; dxDBGridDateColumn4: TdxDBGridDateColumn; dxDBGridColumn9: TdxDBGridColumn; dxDBGridMaskColumn24: TdxDBGridMaskColumn; dxDBGridMaskColumn26: TdxDBGridMaskColumn; dxDBGridColumn10: TdxDBGridColumn; dxDBGridColumn11: TdxDBGridColumn; dxDBGridMaskColumn27: TdxDBGridMaskColumn; dxDBGridMaskColumn28: TdxDBGridMaskColumn; dxDBGridMaskColumn29: TdxDBGridMaskColumn; Panel3: TPanel; dxDBGrid8: TdxDBGrid; dxDBGridMaskColumn30: TdxDBGridMaskColumn; dxDBGridMaskColumn31: TdxDBGridMaskColumn; dxDBGridColumn12: TdxDBGridColumn; dxDBGridColumn13: TdxDBGridColumn; dxDBGridColumn14: TdxDBGridColumn; dxDBGrid9: TdxDBGrid; dxDBGridMaskColumn32: TdxDBGridMaskColumn; dxDBGridColumn15: TdxDBGridColumn; dxDBGridColumn16: TdxDBGridColumn; edit_open: TEdit; bsSkinPanel7: TbsSkinPanel; Label25: TLabel; Label26: TLabel; Label27: TLabel; Label28: TLabel; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; Edit7: TEdit; Edit11: TEdit; Edit12: TEdit; wwDBDateTimePicker13: TwwDBDateTimePicker; wwDBDateTimePicker14: TwwDBDateTimePicker; wwDBDateTimePicker15: TwwDBDateTimePicker; wwDBDateTimePicker16: TwwDBDateTimePicker; RxDBLookupCombo4: TRxDBLookupCombo; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinPanel8: TbsSkinPanel; dxDBGrid10: TdxDBGrid; dxDBGridMaskColumn22: TdxDBGridMaskColumn; dxDBGridMaskColumn23: TdxDBGridMaskColumn; dxDBGridMaskColumn25: TdxDBGridMaskColumn; dxDBGridMaskColumn33: TdxDBGridMaskColumn; dxDBGridMaskColumn34: TdxDBGridMaskColumn; dxDBGridDateColumn5: TdxDBGridDateColumn; dxDBGridDateColumn6: TdxDBGridDateColumn; dxDBGridColumn17: TdxDBGridColumn; dxDBGridMaskColumn35: TdxDBGridMaskColumn; dxDBGridMaskColumn36: TdxDBGridMaskColumn; dxDBGridColumn18: TdxDBGridColumn; dxDBGridColumn19: TdxDBGridColumn; dxDBGridMaskColumn37: TdxDBGridMaskColumn; dxDBGridMaskColumn38: TdxDBGridMaskColumn; dxDBGridMaskColumn39: TdxDBGridMaskColumn; Panel4: TPanel; dxDBGrid11: TdxDBGrid; dxDBGridMaskColumn40: TdxDBGridMaskColumn; dxDBGridMaskColumn41: TdxDBGridMaskColumn; dxDBGridColumn20: TdxDBGridColumn; dxDBGridColumn21: TdxDBGridColumn; dxDBGridColumn22: TdxDBGridColumn; dxDBGrid12: TdxDBGrid; dxDBGridMaskColumn42: TdxDBGridMaskColumn; dxDBGridColumn23: TdxDBGridColumn; dxDBGridColumn24: TdxDBGridColumn; t_op_airi: TADOQuery; t_op_airi1: TDataSource; dxDBGrid4Column19: TdxDBGridColumn; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; N5: TMenuItem; N6: TMenuItem; N7: TMenuItem; N8: TMenuItem; N9: TMenuItem; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid3Column4: TdxDBGridColumn; dxDBGrid5Column6: TdxDBGridColumn; dxDBGrid6Column4: TdxDBGridColumn; dxDBGrid8Column6: TdxDBGridColumn; dxDBGrid9Column4: TdxDBGridColumn; dxDBGrid11Column6: TdxDBGridColumn; dxDBGrid12Column4: TdxDBGridColumn; N10: TMenuItem; N11: TMenuItem; dxDBGrid2Column19: TdxDBGridColumn; dxDBGrid2Column20: TdxDBGridColumn; dxDBGrid4Column20: TdxDBGridColumn; dxDBGrid4Column21: TdxDBGridColumn; dxDBGrid13: TdxDBGrid; dxDBGridColumn59: TdxDBGridColumn; dxDBGridColumn60: TdxDBGridColumn; dxDBGridColumn61: TdxDBGridColumn; dxDBGridColumn62: TdxDBGridColumn; dxDBGridColumn63: TdxDBGridColumn; dxDBGridColumn64: TdxDBGridColumn; dxDBGridColumn65: TdxDBGridColumn; dxDBGridColumn66: TdxDBGridColumn; dxDBGridColumn67: TdxDBGridColumn; dxDBGridColumn68: TdxDBGridColumn; dxDBGridColumn69: TdxDBGridColumn; dxDBGridColumn70: TdxDBGridColumn; dxDBGridColumn71: TdxDBGridColumn; dxDBGridColumn72: TdxDBGridColumn; dxDBGridColumn73: TdxDBGridColumn; dxDBGridColumn74: TdxDBGridColumn; dxDBGridColumn75: TdxDBGridColumn; dxDBGridColumn76: TdxDBGridColumn; dxDBGridColumn77: TdxDBGridColumn; dxDBGridColumn78: TdxDBGridColumn; dxDBGridColumn79: TdxDBGridColumn; dxDBGrid14: TdxDBGrid; dxDBGridColumn25: TdxDBGridColumn; dxDBGridColumn26: TdxDBGridColumn; dxDBGridColumn27: TdxDBGridColumn; dxDBGridColumn28: TdxDBGridColumn; dxDBGridColumn29: TdxDBGridColumn; dxDBGridColumn30: TdxDBGridColumn; dxDBGridColumn31: TdxDBGridColumn; dxDBGridColumn32: TdxDBGridColumn; dxDBGridColumn33: TdxDBGridColumn; dxDBGridColumn34: TdxDBGridColumn; dxDBGridColumn35: TdxDBGridColumn; dxDBGridColumn36: TdxDBGridColumn; dxDBGridColumn37: TdxDBGridColumn; dxDBGridColumn38: TdxDBGridColumn; dxDBGridColumn39: TdxDBGridColumn; dxDBGridColumn40: TdxDBGridColumn; dxDBGridColumn41: TdxDBGridColumn; dxDBGridColumn42: TdxDBGridColumn; dxDBGridColumn43: TdxDBGridColumn; dxDBGridColumn44: TdxDBGridColumn; dxDBGridColumn45: TdxDBGridColumn; dxDBGrid15: TdxDBGrid; dxDBGridColumn46: TdxDBGridColumn; dxDBGridColumn47: TdxDBGridColumn; dxDBGridColumn48: TdxDBGridColumn; dxDBGridColumn49: TdxDBGridColumn; dxDBGridColumn50: TdxDBGridColumn; dxDBGridColumn51: TdxDBGridColumn; dxDBGridColumn52: TdxDBGridColumn; dxDBGridColumn53: TdxDBGridColumn; dxDBGridColumn54: TdxDBGridColumn; dxDBGridColumn55: TdxDBGridColumn; dxDBGridColumn56: TdxDBGridColumn; dxDBGridColumn57: TdxDBGridColumn; dxDBGridColumn58: TdxDBGridColumn; dxDBGridColumn80: TdxDBGridColumn; dxDBGridColumn81: TdxDBGridColumn; dxDBGridColumn82: TdxDBGridColumn; dxDBGridColumn83: TdxDBGridColumn; dxDBGridColumn84: TdxDBGridColumn; dxDBGridColumn85: TdxDBGridColumn; dxDBGridColumn86: TdxDBGridColumn; dxDBGridColumn87: TdxDBGridColumn; dxDBGrid16: TdxDBGrid; dxDBGridColumn88: TdxDBGridColumn; dxDBGridColumn89: TdxDBGridColumn; dxDBGridColumn90: TdxDBGridColumn; dxDBGridColumn91: TdxDBGridColumn; dxDBGridColumn92: TdxDBGridColumn; dxDBGridColumn93: TdxDBGridColumn; dxDBGridColumn94: TdxDBGridColumn; dxDBGridColumn95: TdxDBGridColumn; dxDBGridColumn96: TdxDBGridColumn; dxDBGridColumn97: TdxDBGridColumn; dxDBGridColumn98: TdxDBGridColumn; dxDBGridColumn99: TdxDBGridColumn; dxDBGridColumn100: TdxDBGridColumn; dxDBGridColumn101: TdxDBGridColumn; dxDBGridColumn102: TdxDBGridColumn; dxDBGridColumn103: TdxDBGridColumn; dxDBGridColumn104: TdxDBGridColumn; dxDBGridColumn105: TdxDBGridColumn; dxDBGridColumn106: TdxDBGridColumn; dxDBGridColumn107: TdxDBGridColumn; dxDBGridColumn108: TdxDBGridColumn; Label34: TLabel; Edit14: TEdit; Label33: TLabel; Edit13: TEdit; bsSkinTabSheet5: TbsSkinTabSheet; bsSkinPanel10: TbsSkinPanel; Label35: TLabel; Label36: TLabel; Label37: TLabel; Label38: TLabel; Label39: TLabel; Label40: TLabel; Label41: TLabel; Label42: TLabel; Label43: TLabel; Edit15: TEdit; Edit16: TEdit; Edit17: TEdit; wwDBDateTimePicker17: TwwDBDateTimePicker; wwDBDateTimePicker18: TwwDBDateTimePicker; wwDBDateTimePicker19: TwwDBDateTimePicker; wwDBDateTimePicker20: TwwDBDateTimePicker; RxDBLookupCombo5: TRxDBLookupCombo; bsSkinButton8: TbsSkinButton; bsSkinButton9: TbsSkinButton; Edit18: TEdit; Panel5: TPanel; dxDBGrid17: TdxDBGrid; dxDBGridColumn109: TdxDBGridColumn; dxDBGridMaskColumn43: TdxDBGridMaskColumn; dxDBGridMaskColumn44: TdxDBGridMaskColumn; dxDBGridColumn110: TdxDBGridColumn; dxDBGridColumn111: TdxDBGridColumn; dxDBGridColumn112: TdxDBGridColumn; dxDBGrid19: TdxDBGrid; dxDBGridMaskColumn46: TdxDBGridMaskColumn; dxDBGridMaskColumn47: TdxDBGridMaskColumn; dxDBGridMaskColumn49: TdxDBGridMaskColumn; dxDBGridColumn116: TdxDBGridColumn; dxDBGridColumn117: TdxDBGridColumn; dxDBGridMaskColumn50: TdxDBGridMaskColumn; dxDBGridDateColumn7: TdxDBGridDateColumn; dxDBGridDateColumn8: TdxDBGridDateColumn; dxDBGridMaskColumn51: TdxDBGridMaskColumn; dxDBGridColumn118: TdxDBGridColumn; dxDBGridMaskColumn52: TdxDBGridMaskColumn; dxDBGridMaskColumn53: TdxDBGridMaskColumn; dxDBGridMaskColumn54: TdxDBGridMaskColumn; dxDBGridMaskColumn55: TdxDBGridMaskColumn; dxDBGridColumn119: TdxDBGridColumn; dxDBGridColumn120: TdxDBGridColumn; dxDBGridMaskColumn56: TdxDBGridMaskColumn; dxDBGridMaskColumn57: TdxDBGridMaskColumn; dxDBGridMaskColumn58: TdxDBGridMaskColumn; v_op_bscard: TADOQuery; v_op_bscard1: TDataSource; dxDBGrid19Column21: TdxDBGridColumn; wwDBComboBox46: TwwDBComboBox; Label44: TLabel; Label45: TLabel; RxDBLookupCombo15: TRxDBLookupCombo; Label46: TLabel; RxDBLookupCombo16: TRxDBLookupCombo; ComboBoxObjBsCard: TComboBox; ComboBoxObjairi: TComboBox; ComboBoxObjAire: TComboBox; ComboBoxObjSeai: TComboBox; ComboBoxObjSeae: TComboBox; Label47: TLabel; Edit19: TEdit; Label48: TLabel; Edit20: TEdit; Label49: TLabel; Edit21: TEdit; Label50: TLabel; RxDBLookupCombo6: TRxDBLookupCombo; Label51: TLabel; RxDBLookupCombo7: TRxDBLookupCombo; Edit22: TEdit; Label52: TLabel; Label53: TLabel; Edit23: TEdit; Label54: TLabel; RxDBLookupCombo8: TRxDBLookupCombo; Label55: TLabel; RxDBLookupCombo9: TRxDBLookupCombo; Label56: TLabel; Edit24: TEdit; Label57: TLabel; Edit25: TEdit; Label58: TLabel; Edit26: TEdit; Label59: TLabel; RxDBLookupCombo10: TRxDBLookupCombo; Label60: TLabel; RxDBLookupCombo11: TRxDBLookupCombo; Label61: TLabel; Edit27: TEdit; Label62: TLabel; Edit28: TEdit; Label63: TLabel; Edit29: TEdit; Label64: TLabel; RxDBLookupCombo12: TRxDBLookupCombo; Label65: TLabel; RxDBLookupCombo13: TRxDBLookupCombo; wwDBLookupCombo49: TwwDBLookupCombo; Edit30: TEdit; Label66: TLabel; Label67: TLabel; Label68: TLabel; wwDBComboBox31: TwwDBComboBox; Label69: TLabel; wwDBLookupCombo1: TwwDBLookupCombo; Label70: TLabel; Edit31: TEdit; Label71: TLabel; wwDBComboBox1: TwwDBComboBox; Label72: TLabel; wwDBComboBox2: TwwDBComboBox; Label73: TLabel; wwDBComboBox3: TwwDBComboBox; Label74: TLabel; wwDBComboBox4: TwwDBComboBox; Label75: TLabel; Edit32: TEdit; Label76: TLabel; Edit33: TEdit; bsSkinPanel11: TbsSkinPanel; bsSkinPanel9: TbsSkinPanel; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinCheckRadioBox3: TbsSkinCheckRadioBox; bsSkinCheckRadioBox4: TbsSkinCheckRadioBox; bsSkinPanel12: TbsSkinPanel; bsSkinCheckRadioBox5: TbsSkinCheckRadioBox; bsSkinCheckRadioBox6: TbsSkinCheckRadioBox; bsSkinPanel13: TbsSkinPanel; Label77: TLabel; ComboBoxCurry: TComboBox; Label78: TLabel; Edit34: TEdit; dxDBGrid19Column22: TdxDBGridColumn; t_ch_cust: TADOQuery; t_ch_cust1: TDataSource; t_ch_fee_detail: TADOQuery; t_op_bscard_all: TADOQuery; t_op_bscard_all1: TDataSource; Label79: TLabel; wwDBComboBox5: TwwDBComboBox; dxDBGrid19Column23: TdxDBGridColumn; dxDBGrid19Column24: TdxDBGridColumn; dxDBGrid19Column25: TdxDBGridColumn; Label80: TLabel; Edit35: TEdit; Splitter1: TSplitter; dxDBGrid19Column26: TdxDBGridColumn; dxDBGrid19Column27: TdxDBGridColumn; dxDBGrid19Column28: TdxDBGridColumn; dxDBGrid19Column29: TdxDBGridColumn; bsSkinButton12: TbsSkinButton; dxDBGrid19Column31: TdxDBGridMaskColumn; Label81: TLabel; ComboBoxObjBs: TComboBox; N12: TMenuItem; dxDBGrid19Column32: TdxDBGridColumn; dxDBGrid19Column33: TdxDBGridColumn; ComboBox1: TComboBox; Label83: TLabel; Edit36: TEdit; dxDBGrid17Column7: TdxDBGridColumn; dxDBGrid17Column8: TdxDBGridColumn; bsSkinComboBox1: TbsSkinComboBox; do_ban_fee1: TDataSource; dxDBGrid17Column9: TdxDBGridColumn; t_ch_fee_sum_all: TADOQuery; t_ch_fee_sum_all1: TDataSource; t_ch_fee_sum_ttl: TADOQuery; t_ch_fee_sum_ttl1: TDataSource; Panel6: TPanel; dxDBGrid18: TdxDBGrid; dxDBGridColumn113: TdxDBGridColumn; dxDBGridMaskColumn45: TdxDBGridMaskColumn; dxDBGridColumn114: TdxDBGridColumn; dxDBGridColumn115: TdxDBGridColumn; dxDBGrid20: TdxDBGrid; dxDBGridColumn121: TdxDBGridColumn; dxDBGridMaskColumn48: TdxDBGridMaskColumn; dxDBGridColumn123: TdxDBGridColumn; bsSkinComboBox2: TbsSkinComboBox; dxDBGrid19Column34: TdxDBGridColumn; dxDBGrid17Column10: TdxDBGridColumn; Label82: TLabel; dxDBGrid19Column35: TdxDBGridColumn; procedure bsSkinButton3Click(Sender: TObject); procedure bs_textChange(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure MenuItem1Click(Sender: TObject); procedure Edit4KeyPress(Sender: TObject; var Key: Char); procedure FrameEnter(Sender: TObject); procedure bsSkinPageControl1Change(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure N7Click(Sender: TObject); procedure N9Click(Sender: TObject); procedure RxDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo4KeyPress(Sender: TObject; var Key: Char); procedure dxDBGrid2DblClick(Sender: TObject); procedure dxDBGrid4DblClick(Sender: TObject); procedure dxDBGrid7DblClick(Sender: TObject); procedure dxDBGrid10DblClick(Sender: TObject); procedure N11Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure ComboBoxObjBsCardEnter(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure ComboBoxObjairiEnter(Sender: TObject); procedure ComboBoxObjAireEnter(Sender: TObject); procedure ComboBoxObjSeaiEnter(Sender: TObject); procedure ComboBoxObjSeaeEnter(Sender: TObject); procedure dxDBGrid19DblClick(Sender: TObject); procedure bsSkinCheckRadioBox5Click(Sender: TObject); procedure wwDBLookupCombo49KeyPress(Sender: TObject; var Key: Char); procedure dxDBGrid19Column22CustomDraw(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 RxDBLookupCombo14Enter(Sender: TObject); procedure dxDBGrid19Column24CustomDraw(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 v_op_bscardBeforeScroll(DataSet: TDataSet); procedure Edit34KeyPress(Sender: TObject; var Key: Char); procedure bsSkinButton12Click(Sender: TObject); procedure ComboBoxObjBsEnter(Sender: TObject); procedure ComboBoxObjBsKeyPress(Sender: TObject; var Key: Char); procedure N13Click(Sender: TObject); procedure ComboBox1Enter(Sender: TObject); procedure dxDBGrid19SelectedCountChange(Sender: TObject); private function GetCustID(var aCustID : String) : Boolean; //获取客户名称 function _GetCustID(var aCustID : String) : Boolean; //获取客户名称 function CheckDrFeeExsit(bsno:string) : string; // function CheckDrFeeExsitItems(bsno:string) : string; // { Private declarations } public { Public declarations } old_sum_str,sum_str:WideString; acust_sum:string; end; implementation uses u_main, my_sys_function, u_data_share, FindListu; {$R *.dfm} function Tfra_ch_add_do.CheckDrFeeExsit(bsno:string) : string; // var aAdoQueryDr:TAdoQuery; begin result:=''; if strtobool(get_parameters_value(319,'false')) then begin if (bs_text.text='2') then begin aAdoQueryDr:=CreateAdoQuery; with aAdoQueryDr do try Close;Sql.Clear; SQL.Add('select 费用名称 from t_ch_fee'); SQL.Add('where 编号=:编号 and 类型=''收'''); Parameters.ParamByName('编号').Value:=bsno; Open;First; with t_ch_fee_detail do begin t_ch_fee_detail.First; while not t_ch_fee_detail.Eof do begin if not aAdoQueryDr.Locate('费用名称',t_ch_fee_detail.FieldByName('费用名称').AsString,[]) then begin if result='' then result:=t_ch_fee_detail.FieldByName('费用名称').AsString else if pos(t_ch_fee_detail.FieldByName('费用名称').AsString,result)<=0 then result:=result+','+t_ch_fee_detail.FieldByName('费用名称').AsString; end; t_ch_fee_detail.Next; end; end; finally free; end; end; end; end; function Tfra_ch_add_do.CheckDrFeeExsitItems(bsno:string) : string; // var aAdoQueryDr:TAdoQuery; begin result:=''; if strtobool(get_parameters_value(319,'false')) then begin if (bs_text.text='2') then begin aAdoQueryDr:=CreateAdoQuery; with aAdoQueryDr do try Close;Sql.Clear; SQL.Add('select 费用名称 from t_ch_fee'); SQL.Add('where 编号=:编号 and 类型=''收'''); Parameters.ParamByName('编号').Value:=bsno; Open;First; if not aAdoQueryDr.Locate('费用名称',t_ch_fee.FieldByName('费用名称').AsString,[]) then begin if result='' then result:=t_ch_fee.FieldByName('费用名称').AsString else if pos(t_ch_fee.FieldByName('费用名称').AsString,result)<=0 then result:=result+','+t_ch_fee.FieldByName('费用名称').AsString; end; finally free; end; end; end; end; function Tfra_ch_add_do.GetCustID(var aCustID : String) : Boolean; var aQuery : TAdoQuery; S : String; begin //获取客户名称 Result:=false; S:=Trim(ComboBoxObjBsCard.Text); if (S<>'') and (length(S)>10) then begin // if ComboBoxObjBsCard.items. aCustID:=Trim(Copy(S,11,length(S)-10)); acust_sum:=aCustID; result:=true; exit; end; if S='' then begin aCustID:=''; acust_sum:=aCustID; Result:=true; end else begin aQuery:=CreateAdoQuery; with aQuery do try SQL.Add('Select 代码,客户简称,客户全称'); SQL.Add('from t_crm_client'); SQL.Add('where 代码 like ''%'+S+'%'''); SQL.Add('or 客户简称 like ''%'+S+'%'''); SQL.Add('Order By 代码'); Open; if RecordCount=0 then begin MessageDlg('客户代码或简称不正确!',mtWarning,[mbOK],0); end else if RecordCount=1 then begin ComboBoxObjBsCard.Text:=FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString; aCustID:=FieldByName('客户简称').AsString; acust_sum:=aCustID; Result:=true; end else begin S:=SQL.Text; frmFindList:=TfrmFindList.Create(Self); try with frmFindList, qryCust, SQL do begin Close;Clear; Text:=S; Open; if ShowModal=mrOK then begin ComboBoxObjBsCard.Text:=FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString; aCustID:=FieldByName('客户简称').AsString; acust_sum:=aCustID; Result:=true; end; Close; end; finally FreeAndNil(frmFindList); end; end; finally Close; FreeAndNil(aQuery); end; end; end; function Tfra_ch_add_do._GetCustID(var aCustID : String) : Boolean; var aQuery : TAdoQuery; S : String; begin //获取客户名称 Result:=false; S:=Trim(ComboBoxObjBs.Text); if (S<>'') and (length(S)>10) then begin aCustID:=Trim(Copy(S,11,length(S)-10)); result:=true; exit; end; if S='' then begin aCustID:=''; Result:=true; end else begin aQuery:=CreateAdoQuery; with aQuery do try SQL.Add('Select 代码,客户简称,客户全称'); SQL.Add('from t_crm_client'); SQL.Add('where 代码 like ''%'+S+'%'''); SQL.Add('or 客户简称 like ''%'+S+'%'''); SQL.Add('Order By 代码'); Open; if RecordCount=0 then begin MessageDlg('客户代码或简称不正确!',mtWarning,[mbOK],0); end else if RecordCount=1 then begin ComboBoxObjBs.Text:=FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString; aCustID:=FieldByName('客户简称').AsString; Result:=true; end else begin S:=SQL.Text; frmFindList:=TfrmFindList.Create(Self); try with frmFindList, qryCust, SQL do begin Close;Clear; Text:=S; Open; if ShowModal=mrOK then begin ComboBoxObjBs.Text:=FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString; aCustID:=FieldByName('客户简称').AsString; Result:=true; end; Close; end; finally FreeAndNil(frmFindList); end; end; finally Close; FreeAndNil(aQuery); end; end; end; procedure Tfra_ch_add_do.bsSkinButton3Click(Sender: TObject); begin ComboBoxObjSeae.Text:=''; Edit4.text:=''; Edit3.Text:=''; Edit2.text:=''; wwDBDateTimePicker1.Clear; wwDBDateTimePicker2.clear; wwDBDateTimePicker3.clear; wwDBDateTimePicker4.clear; end; procedure Tfra_ch_add_do.bs_textChange(Sender: TObject); begin if bs_text.text='' then exit; case strtoint(bs_text.text) of 1,7: //发票和发票申请 begin dxDBGrid1Column3.Caption:='应收金额'; dxDBGrid1Column4.Caption:='未开金额'; dxDBGrid1Column4.FieldName:='未开金额'; dxDBGrid3Column2.Caption:='应收金额'; dxDBGrid3Column3.Caption:='未开金额'; dxDBGrid3Column3.FieldName:='未开金额'; dxDBGridColumn5.Caption:='应收金额'; dxDBGridColumn6.Caption:='未开金额'; dxDBGridColumn6.FieldName:='未开金额'; dxDBGridColumn7.Caption:='应收金额'; dxDBGridColumn8.Caption:='未开金额'; dxDBGridColumn8.FieldName:='未开金额'; dxDBGridColumn13.Caption:='应收金额'; dxDBGridColumn14.Caption:='未开金额'; dxDBGridColumn14.FieldName:='未开金额'; dxDBGridColumn15.Caption:='应收金额'; dxDBGridColumn16.Caption:='未开金额'; dxDBGridColumn16.FieldName:='未开金额'; dxDBGridColumn21.Caption:='应收金额'; dxDBGridColumn22.Caption:='未开金额'; dxDBGridColumn22.FieldName:='未开金额'; dxDBGridColumn23.Caption:='应收金额'; dxDBGridColumn24.Caption:='未开金额'; dxDBGridColumn24.FieldName:='未开金额'; dxDBGridColumn111.Caption:='应收金额'; dxDBGridColumn112.Caption:='未开金额'; dxDBGridColumn112.FieldName:='未开金额'; dxDBGridColumn114.Caption:='应收金额'; dxDBGridColumn115.Caption:='未开金额'; dxDBGridColumn115.FieldName:='未开金额'; dxDBGrid1Column6.Visible:=false; dxDBGrid3Column4.Visible:=false; dxDBGrid5Column6.Visible:=false; dxDBGrid6Column4.Visible:=false; dxDBGrid8Column6.Visible:=false; dxDBGrid9Column4.Visible:=false; dxDBGrid11Column6.Visible:=false; dxDBGrid12Column4.Visible:=false; dxDBGridColumn109.Visible:=true; dxDBGridColumn113.Visible:=true; end; 2: //付费申请 begin dxDBGrid1Column3.Caption:='应付金额'; dxDBGrid1Column4.Caption:='未申请金额'; dxDBGrid1Column4.FieldName:='未开金额'; dxDBGrid3Column2.Caption:='应付金额'; dxDBGrid3Column3.Caption:='未申请金额'; dxDBGrid3Column3.FieldName:='未开金额'; dxDBGridColumn5.Caption:='应付金额'; dxDBGridColumn6.Caption:='未申请金额'; dxDBGridColumn6.FieldName:='未开金额'; dxDBGridColumn7.Caption:='应付金额'; dxDBGridColumn8.Caption:='未申请金额'; dxDBGridColumn8.FieldName:='未开金额'; dxDBGridColumn13.Caption:='应付金额'; dxDBGridColumn14.Caption:='未申请金额'; dxDBGridColumn14.FieldName:='未开金额'; dxDBGridColumn15.Caption:='应付金额'; dxDBGridColumn16.Caption:='未申请金额'; dxDBGridColumn16.FieldName:='未开金额'; dxDBGridColumn21.Caption:='应付金额'; dxDBGridColumn22.Caption:='未申请金额'; dxDBGridColumn22.FieldName:='未开金额'; dxDBGridColumn23.Caption:='应付金额'; dxDBGridColumn24.Caption:='未申请金额'; dxDBGridColumn24.FieldName:='未开金额'; dxDBGridColumn111.Caption:='应付金额'; dxDBGridColumn112.Caption:='未申请金额'; dxDBGridColumn112.FieldName:='未开金额'; dxDBGridColumn114.Caption:='应付金额'; dxDBGridColumn115.Caption:='未申请金额'; dxDBGridColumn115.FieldName:='未开金额'; dxDBGrid1Column6.Visible:=true; dxDBGrid3Column4.Visible:=true; dxDBGrid5Column6.Visible:=true; dxDBGrid6Column4.Visible:=true; dxDBGrid8Column6.Visible:=true; dxDBGrid9Column4.Visible:=true; dxDBGrid11Column6.Visible:=true; dxDBGrid12Column4.Visible:=true; dxDBGridColumn109.Visible:=True; dxDBGridColumn113.Visible:=True; end; 3: //收费结算 begin dxDBGrid1Column3.Caption:='金额'; dxDBGrid1Column4.Caption:='未结金额'; dxDBGrid1Column4.FieldName:='未结金额'; dxDBGrid3Column2.Caption:='金额'; dxDBGrid3Column3.Caption:='未结金额'; dxDBGrid3Column3.FieldName:='未结金额'; dxDBGridColumn5.Caption:='金额'; dxDBGridColumn6.Caption:='未结金额'; dxDBGridColumn6.FieldName:='未结金额'; dxDBGridColumn7.Caption:='金额'; dxDBGridColumn8.Caption:='未结金额'; dxDBGridColumn8.FieldName:='未结金额'; dxDBGridColumn13.Caption:='金额'; dxDBGridColumn14.Caption:='未结金额'; dxDBGridColumn14.FieldName:='未结金额'; dxDBGridColumn15.Caption:='金额'; dxDBGridColumn16.Caption:='未结金额'; dxDBGridColumn16.FieldName:='未结金额'; dxDBGridColumn21.Caption:='金额'; dxDBGridColumn22.Caption:='未结金额'; dxDBGridColumn22.FieldName:='未结金额'; dxDBGridColumn23.Caption:='金额'; dxDBGridColumn24.Caption:='未结金额'; dxDBGridColumn24.FieldName:='未结金额'; dxDBGridColumn111.Caption:='金额'; dxDBGridColumn112.Caption:='未结金额'; dxDBGridColumn112.FieldName:='未结金额'; dxDBGridColumn114.Caption:='金额'; dxDBGridColumn115.Caption:='未结金额'; dxDBGridColumn115.FieldName:='未结金额'; dxDBGrid1Column6.Visible:=true; dxDBGrid3Column4.Visible:=true; dxDBGrid5Column6.Visible:=true; dxDBGrid6Column4.Visible:=true; dxDBGrid8Column6.Visible:=true; dxDBGrid9Column4.Visible:=true; dxDBGrid11Column6.Visible:=true; dxDBGrid12Column4.Visible:=true; dxDBGridColumn109.Visible:=True; dxDBGridColumn113.Visible:=True; end; 4: //付费结算 begin dxDBGrid1Column3.Caption:='金额'; dxDBGrid1Column4.Caption:='未结金额'; dxDBGrid1Column4.FieldName:='未结金额'; dxDBGrid3Column2.Caption:='金额'; dxDBGrid3Column3.Caption:='未结金额'; dxDBGrid3Column3.FieldName:='未结金额'; dxDBGridColumn5.Caption:='金额'; dxDBGridColumn6.Caption:='未结金额'; dxDBGridColumn6.FieldName:='未结金额'; dxDBGridColumn7.Caption:='金额'; dxDBGridColumn8.Caption:='未结金额'; dxDBGridColumn8.FieldName:='未结金额'; dxDBGridColumn13.Caption:='金额'; dxDBGridColumn14.Caption:='未结金额'; dxDBGridColumn14.FieldName:='未结金额'; dxDBGridColumn15.Caption:='金额'; dxDBGridColumn16.Caption:='未结金额'; dxDBGridColumn16.FieldName:='未结金额'; dxDBGridColumn21.Caption:='金额'; dxDBGridColumn22.Caption:='未结金额'; dxDBGridColumn22.FieldName:='未结金额'; dxDBGridColumn23.Caption:='金额'; dxDBGridColumn24.Caption:='未结金额'; dxDBGridColumn24.FieldName:='未结金额'; dxDBGridColumn111.Caption:='金额'; dxDBGridColumn112.Caption:='未结金额'; dxDBGridColumn112.FieldName:='未结金额'; dxDBGridColumn114.Caption:='金额'; dxDBGridColumn115.Caption:='未结金额'; dxDBGridColumn115.FieldName:='未结金额'; dxDBGrid1Column6.Visible:=true; dxDBGrid3Column4.Visible:=true; dxDBGrid5Column6.Visible:=true; dxDBGrid6Column4.Visible:=true; dxDBGrid8Column6.Visible:=true; dxDBGrid9Column4.Visible:=true; dxDBGrid11Column6.Visible:=true; dxDBGrid12Column4.Visible:=true; dxDBGridColumn109.Visible:=True; dxDBGridColumn113.Visible:=True; end; 6: //收费申请 begin dxDBGrid1Column3.Caption:='应收金额'; dxDBGrid1Column4.Caption:='未开金额'; dxDBGrid1Column4.FieldName:='未开金额'; dxDBGrid3Column2.Caption:='应收金额'; dxDBGrid3Column3.Caption:='未开金额'; dxDBGrid3Column3.FieldName:='未开金额'; dxDBGridColumn5.Caption:='应收金额'; dxDBGridColumn6.Caption:='未开金额'; dxDBGridColumn6.FieldName:='未开金额'; dxDBGridColumn7.Caption:='应收金额'; dxDBGridColumn8.Caption:='未开金额'; dxDBGridColumn8.FieldName:='未开金额'; dxDBGridColumn13.Caption:='应收金额'; dxDBGridColumn14.Caption:='未开金额'; dxDBGridColumn14.FieldName:='未开金额'; dxDBGridColumn15.Caption:='应收金额'; dxDBGridColumn16.Caption:='未开金额'; dxDBGridColumn16.FieldName:='未开金额'; dxDBGridColumn21.Caption:='应收金额'; dxDBGridColumn22.Caption:='未开金额'; dxDBGridColumn22.FieldName:='未开金额'; dxDBGridColumn23.Caption:='应收金额'; dxDBGridColumn24.Caption:='未开金额'; dxDBGridColumn24.FieldName:='未开金额'; dxDBGridColumn111.Caption:='应收金额'; dxDBGridColumn112.Caption:='未开金额'; dxDBGridColumn112.FieldName:='未开金额'; dxDBGridColumn114.Caption:='应收金额'; dxDBGridColumn115.Caption:='未开金额'; dxDBGridColumn115.FieldName:='未开金额'; dxDBGrid1Column6.Visible:=true; dxDBGrid3Column4.Visible:=true; dxDBGrid5Column6.Visible:=true; dxDBGrid6Column4.Visible:=true; dxDBGrid8Column6.Visible:=true; dxDBGrid9Column4.Visible:=true; dxDBGrid11Column6.Visible:=true; dxDBGrid12Column4.Visible:=true; dxDBGridColumn109.Visible:=True; dxDBGridColumn113.Visible:=True; end; end; end; procedure Tfra_ch_add_do.bsSkinButton10Click(Sender: TObject); var str_fee,str_op:widestring; op_str,fee_str,sum_str,Str_bill:widestring; str:String; begin //海运出口业务查询 if not t_op_bscard_all.active then t_op_bscard_all.Open; t_ch_fee.close; t_ch_fee_sum.close; t_op_seae.Close; t_ch_fee.DataSource:=t_op_seae1; t_ch_fee_sum.DataSource:=t_op_seae1; case strtoint(bs_text.text) of 1: begin str_fee:='where 金额<>(开票金额+申请开票) and 不开发票<>1 and 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 7: begin str_fee:='where 金额<>(开票金额+申请开票) and 不开发票<>1 and 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 2: //付费申请 begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_fee:=str_fee+'and (金额<>申请金额 and 金额<>冲抵金额)'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if wwDBComboBox1.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox1.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 3,8: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if wwDBComboBox1.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox1.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 4: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if wwDBComboBox1.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox1.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 6: //收费申请 begin str_fee:='where ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_fee:=str_fee+'and (金额<>申请金额 and 金额<>冲抵金额)'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; // if not strtobool(get_parameters_value(46,'true')) then // str_fee:=str_fee+' and 类型='+''''+'收'+''''; end; end; { if RxDBLookupCombo2.DisplayValues[1]<>''then str_fee:=str_fee+' and 客户名称='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; } str:=Trim(ComboBoxObjseae.Text); if (Str<>'') and (length(Str)>10) then str_fee:=str_fee+' and 客户名称='+''''+Trim(Copy(Str,11,length(Str)-10))+''''; if RxDBLookupCombo6.DisplayValues[1]<>''then str_fee:=str_fee+' and 币别='+''''+RxDBLookupCombo6.DisplayValues[0]+''''; if RxDBLookupCombo7.DisplayValues[1]<>''then str_fee:=str_fee+' and 费用名称='+''''+RxDBLookupCombo7.DisplayValues[1]+''''; { if Trim(Edit20.Text)<>'' then begin str_fee:=str_fee+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit20.Text)+''')'; end; } str_op:=''; if Edit4.text<>''then str_op:=str_op+' and t_op_seae.委托编号 like '+''''+'%'+Edit4.text+'%'+''''; if Edit2.text<>''then str_op:=str_op+' and t_op_seae.主提单号 like '+''''+'%'+Edit2.text+'%'+''''; if Edit13.text<>''then str_op:=str_op+' and t_op_seae.报检单号 like '+''''+'%'+Edit13.text+'%'+''''; if Edit32.text<>''then str_op:=str_op+' and t_op_seae.核销单号 like '+''''+'%'+Edit32.text+'%'+''''; if Edit3.text<>''then str_op:=str_op+' and t_op_seae.分提单号 like '+''''+'%'+Edit3.text+'%'+''''; if Edit21.text<>''then str_op:=str_op+' and t_op_seae.报关单号 like '+''''+'%'+Edit21.text+'%'+''''; if wwDBLookupCombo1.text<>''then str_op:=str_op+' and t_op_seae.船名 like '+''''+'%'+wwDBLookupCombo1.text+'%'+''''; if Edit31.text<>''then str_op:=str_op+' and t_op_seae.航次 like '+''''+'%'+Edit31.text+'%'+''''; if wwDBDateTimePicker1.text<>''then str_op:=str_op+' and t_op_seae.开船日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str_op:=str_op+' and t_op_seae.开船日期<='+''''+wwDBDateTimePicker2.text+''''; if wwDBDateTimePicker3.text<>''then str_op:=str_op+' and t_op_seae.会计期间>='+''''+wwDBDateTimePicker3.text+''''; if wwDBDateTimePicker4.text<>''then str_op:=str_op+' and t_op_seae.会计期间<='+''''+wwDBDateTimePicker4.text+''''; if Trim(Edit20.Text)<>'' then begin str_op:=str_op+' and 编号 in (select distinct 编号 from v_dui_fee where 对帐编号='''+Trim(Edit20.Text)+''')'; end; if strtoint(bs_text.text)=8 then str_op:='where t_op_seae.编号=主编号 and t_op_seae.编号 in (select distinct 编号 from v_ch_fee '+str_fee+')'+str_op else begin str_op:='where t_op_seae.编号 in (select distinct 编号 from v_ch_fee '+str_fee+')'+str_op; end; case strtoint(bs_text.text) of 1,7: begin str_op:=str_op+' and '+open_data('1002','揽货人','操作员','客服员','报关操作','报检操作'); end; 2,6: begin str_op:=str_op+' and '+open_data('1004','揽货人','操作员','客服员','报关操作','报检操作'); end; 3,4: begin str_op:=str_op+' and '+open_data('1003','揽货人','操作员','客服员','报关操作','报检操作'); end; end; op_str:='select * from t_op_seae '+str_op +default_sort(53,'t_op_seae','','desc'); case strtoint(bs_text.text) of 1: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,税率,财务税率,金额,(金额-开票金额-申请开票) as 未开金额 from t_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit19.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit19.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 7: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,税率,财务税率,金额,(金额-开票金额-申请开票) as 未开金额 from t_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit20.Text)<>'' then begin // fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit20.Text)+''')'; fee_str:=fee_str+' and EXISTS (select 1 from v_dui_fee where v_dui_fee.CH_ID=t_ch_fee.CH_ID AND v_dui_fee.对帐编号='''+Trim(Edit20.Text)+''')'; end; if Trim(Edit36.Text)<>'' then begin fee_str:=fee_str+' and EXISTS (select 1 from t_ch_fee_do where t_ch_fee_do.CH_ID=t_ch_fee.CH_ID AND t_ch_fee_do.工作编号='''+Trim(Edit36.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 2: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,税率,财务税率,金额, 未开金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit20.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit20.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 3: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,税率,财务税率,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit20.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit20.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 4: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,税率,财务税率,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit20.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit20.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 6: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,税率,财务税率,金额, 未开金额= ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit20.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit20.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 8: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,税率,财务税率,金额,未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号 in (select 编号 from t_op_seae where 主编号=:编号) order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号 in (select 编号 from t_op_seae where 主编号=:编号) group by 类型,币别 order by 类型,币别'; end; end; t_ch_fee.Close; t_ch_fee_sum.close; t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add(op_str); t_op_seae.open; //ShowMessage(op_str); t_ch_fee.sql.clear; t_ch_fee.sql.add(fee_str); t_ch_fee.open; // ShowMessage(fee_str); t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; end; procedure Tfra_ch_add_do.N1Click(Sender: TObject); var i,j,c,f:integer; RE:Boolean; str,feestr,sumstr:widestring; aLlist:TStringList; vatrate:double; s:string; begin //业务列表加入 s:=''; if bsSkinTabSheet1.Showing then begin if not t_op_seae.Active then exit; if t_op_seae.IsEmpty then exit; end; if bsSkinTabSheet2.Showing then begin if not t_op_seai.Active then exit; if t_op_seai.IsEmpty then exit; end; if bsSkinTabSheet3.Showing then begin if not t_op_aire.Active then exit; if t_op_aire.IsEmpty then exit; end; if bsSkinTabSheet4.Showing then begin if not t_op_airi.Active then exit; if t_op_airi.IsEmpty then exit; end; if bsSkinTabSheet5.Showing then begin if not v_op_bscard.Active then exit; if v_op_bscard.IsEmpty then exit; end; if bsSkinCheckRadioBox6.Checked then c:=1 else c:=0; t_ch_fee.DisableControls; t_ch_fee_sum.DisableControls; try if bsSkinPanel9.Visible then begin if bsSkinCheckRadioBox1.Checked then i:=2 else i:=1; if bsSkinCheckRadioBox3.Checked then j:=1 else j:=0; end else begin i:=0; j:=0; end; RE:=false; t_rate.open; feestr:=t_ch_fee.SQL.text; if bsSkinTabSheet1.Showing then begin delete_do_type_num:=1; t_op_seae.DisableControls; try if dxDBGrid2.SelectedCount>=1 then begin t_ch_fee.DataSource:=t_op_bscard_all1; t_ch_fee_sum.DataSource:=t_op_bscard_all1; for f:=0 to dxDBGrid2.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid2.selectedrows[f])); if str='' then str:='编号='+''''+t_op_seae.fieldbyname('编号').AsString+'''' else str:=str+' or 编号='+''''+t_op_seae.fieldbyname('编号').AsString+'''' end; dxDBGrid2.ClearSelection; str:='and ('+str+')'; t_ch_fee_detail.close; t_ch_fee_detail.sql.text:=StringReplace(feestr,'and 编号=:编号',str,[rfReplaceAll]); t_ch_fee_detail.open; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(t_op_seae,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid2,i,j,c,ComboBoxCurry.text,do_ban_fee1) else shen_yewwu(t_op_seae,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid2,i,j,do_ban_fee1); t_ch_fee_detail.close; t_op_seae.close; t_op_seae.open; end else begin { if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(t_op_seae,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid2,i,j,c,ComboBoxCurry.text) else shen_yewwu(t_op_seae,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid2,i,j); 李俊平 屏蔽 如果没有被选择的数据就 不做处理 } end; finally t_op_seae.EnableControls; t_ch_fee.DataSource:=t_op_seae1; t_ch_fee_sum.DataSource:=t_op_seae1; end; end; if bsSkinTabSheet2.Showing then begin delete_do_type_num:=2; t_op_seai.DisableControls; try if dxDBGrid4.SelectedCount>=1 then begin t_ch_fee.DataSource:=t_op_bscard_all1; t_ch_fee_sum.DataSource:=t_op_bscard_all1; for f:=0 to dxDBGrid4.SelectedCount-1 do begin t_op_seai.GotoBookmark(pointer(dxDBGrid4.selectedrows[f])); if str='' then str:='编号='+''''+t_op_seai.fieldbyname('编号').AsString+'''' else str:=str+' or 编号='+''''+t_op_seai.fieldbyname('编号').AsString+'''' end; dxDBGrid4.ClearSelection; str:='and ('+str+')'; t_ch_fee_detail.close; t_ch_fee_detail.sql.text:=StringReplace(feestr,'and 编号=:编号',str,[rfReplaceAll]); t_ch_fee_detail.open; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(t_op_seai,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid4,i,j,c,ComboBoxCurry.text,do_ban_fee1) else shen_yewwu(t_op_seai,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid4,i,j,do_ban_fee1); t_ch_fee_detail.close; t_op_seai.close; t_op_seai.open; end else begin { if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(t_op_seai,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid4,i,j,c,ComboBoxCurry.text) else shen_yewwu(t_op_seai,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid4,i,j); 李俊平 屏蔽 如果没有被选择的数据就 不做处理 } end; finally t_op_seai.EnableControls; t_ch_fee.DataSource:=t_op_seai1; t_ch_fee_sum.DataSource:=t_op_seai1; end; end; if bsSkinTabSheet3.Showing then begin delete_do_type_num:=3; t_op_aire.DisableControls; try if dxDBGrid7.SelectedCount>=1 then begin t_ch_fee.DataSource:=t_op_bscard_all1; t_ch_fee_sum.DataSource:=t_op_bscard_all1; for f:=0 to dxDBGrid7.SelectedCount-1 do begin t_op_aire.GotoBookmark(pointer(dxDBGrid7.selectedrows[f])); if str='' then str:='编号='+''''+t_op_aire.fieldbyname('编号').AsString+'''' else str:=str+' or 编号='+''''+t_op_aire.fieldbyname('编号').AsString+'''' end; dxDBGrid7.ClearSelection; str:='and ('+str+')'; t_ch_fee_detail.close; t_ch_fee_detail.sql.text:=StringReplace(feestr,'and 编号=:编号',str,[rfReplaceAll]); t_ch_fee_detail.open; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(t_op_aire,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid7,i,j,c,ComboBoxCurry.text,do_ban_fee1) else shen_yewwu(t_op_aire,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid7,i,j,do_ban_fee1); t_ch_fee_detail.close; t_op_aire.close; t_op_aire.open; end else begin { if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(t_op_aire,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid7,i,j,c,ComboBoxCurry.text) else shen_yewwu(t_op_aire,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid7,i,j); 李俊平 屏蔽 如果没有被选择的数据就 不做处理 } end; finally t_op_aire.EnableControls; t_ch_fee.DataSource:=t_op_aire1; t_ch_fee_sum.DataSource:=t_op_aire1; end; end; if bsSkinTabSheet4.Showing then begin delete_do_type_num:=4; t_op_airi.DisableControls; try if dxDBGrid10.SelectedCount>=1 then begin t_ch_fee.DataSource:=t_op_bscard_all1; t_ch_fee_sum.DataSource:=t_op_bscard_all1; for f:=0 to dxDBGrid10.SelectedCount-1 do begin t_op_airi.GotoBookmark(pointer(dxDBGrid10.selectedrows[f])); if str='' then str:='编号='+''''+t_op_airi.fieldbyname('编号').AsString+'''' else str:=str+' or 编号='+''''+t_op_airi.fieldbyname('编号').AsString+'''' end; dxDBGrid10.ClearSelection; str:='and ('+str+')'; t_ch_fee_detail.close; t_ch_fee_detail.sql.text:=StringReplace(feestr,'and 编号=:编号',str,[rfReplaceAll]); t_ch_fee_detail.open; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(t_op_airi,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid10,i,j,c,ComboBoxCurry.text,do_ban_fee1) else shen_yewwu(t_op_airi,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid10,i,j,do_ban_fee1); t_ch_fee_detail.close; t_op_airi.close; t_op_airi.open; end else begin { if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(t_op_airi,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid10,i,j,c,ComboBoxCurry.text) else shen_yewwu(t_op_airi,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid10,i,j); 李俊平 屏蔽 如果没有被选择的数据就 不做处理 } end; finally t_op_airi.EnableControls; t_ch_fee.DataSource:=t_op_airi1; t_ch_fee_sum.DataSource:=t_op_airi1; end; end; if bsSkinTabSheet5.Showing then begin delete_do_type_num:=5; v_op_bscard.DisableControls; try if dxDBGrid19.SelectedCount>=1 then begin t_ch_fee.DataSource:=t_op_bscard_all1; { try if dxDBGrid19.SelectedCount>1 then begin t_ch_fee_sum.close; t_ch_fee_sum.DataSource:=nil; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; end else begin t_ch_fee_sum.close; t_ch_fee_sum.DataSource:=v_op_bscard1; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; end; finally end; } t_ch_fee_sum.DataSource:=t_op_bscard_all1; for f:=0 to dxDBGrid19.SelectedCount-1 do begin v_op_bscard.GotoBookmark(pointer(dxDBGrid19.selectedrows[f])); if str='' then str:='编号='+''''+v_op_bscard.fieldbyname('编号').AsString+'''' else str:=str+' or 编号='+''''+v_op_bscard.fieldbyname('编号').AsString+'''' end; dxDBGrid19.ClearSelection; str:='and ('+str+')'; t_ch_fee_detail.close; if Trim(Edit36.Text)<>'' then t_ch_fee_detail.sql.text:=StringReplace(feestr,'and t_ch_fee.编号=:编号',str,[rfReplaceAll]) else t_ch_fee_detail.sql.text:=StringReplace(feestr,'and 编号=:编号',str,[rfReplaceAll]); // t_ch_fee_detail.sql.text:=StringReplace(feestr,'and 编号=:编号',str,[rfReplaceAll]); t_ch_fee_detail.open; if (bs_text.text='7') or (bs_text.text='1') then begin aLlist:=TStringList.Create; with t_ch_fee_detail do try First; while not eof do begin vatrate:=t_ch_fee_detail.FieldByName('财务税率').AsFloat; if aLlist.IndexOf(FloatToStr(vatrate))<0 then begin aLlist.Add(FloatToStr(vatrate)); end; Next; end; if aLlist.Count>1 then begin if strtobool(get_parameters_value(322,'false')) then begin if wwDBComboBox31.text='付' then begin if MessageDlg('选定的数据里存在不同的税率:'+aLlist.CommaText+' 是否继续?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end else begin showmessage('选定的数据里存在不同的税率,不能申请发票'); exit; end; end else if MessageDlg('选定的数据里存在不同的税率:'+aLlist.CommaText+' 是否继续?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end; if do_ban_fee1.DataSet.RecordCount>=1 then begin if aLlist.Count=1 then begin if strtobool(get_parameters_value(322,'false')) then begin if vatrate<>do_ban1.DataSet.FieldByName('税率').AsFloat then begin if wwDBComboBox31.text='付' then begin if MessageDlg('选定的数据里存在不同的税率:'+aLlist.CommaText+' 是否继续?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end else begin showmessage('不同的税率,不能申请在同一张发票'); exit; end; end; end end; end; finally aLlist.Free; end; end; s:=CheckDrFeeExsit(v_op_bscard.fieldbyname('编号').asstring); if s<>'' then begin if MessageDlg('付费存在,收费不存在的费用为:'+#13#10+s+' 是否继续?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(v_op_bscard,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,c,ComboBoxCurry.text,do_ban_fee1) //v_op_bscard else shen_yewwu(v_op_bscard,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,do_ban_fee1); t_ch_fee_detail.close; v_op_bscard.close; v_op_bscard.open; end else begin if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(v_op_bscard,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,c,ComboBoxCurry.text,do_ban_fee1) else shen_yewwu(v_op_bscard,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,do_ban_fee1); t_ch_fee_detail.close; v_op_bscard.close; v_op_bscard.open; end; finally v_op_bscard.EnableControls; t_ch_fee.DataSource:=v_op_bscard1; { try if dxDBGrid19.SelectedCount>1 then begin t_ch_fee_sum.close; t_ch_fee_sum.DataSource:=nil; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; end else begin t_ch_fee_sum.close; t_ch_fee_sum.DataSource:=v_op_bscard1; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; end; finally end; } t_ch_fee_sum.DataSource:=v_op_bscard1; end; end; t_rate.close; { except on e:exception do begin ShowMessage(e.Message); end; end; } finally t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; do_ban1.DataSet.Refresh; end; end; procedure Tfra_ch_add_do.MenuItem1Click(Sender: TObject); var i,j,c,k:integer; RE:boolean; aLlist:TStringList; vatrate:double; s:string; begin //费用列表加入 if not t_ch_fee.active then exit; if t_ch_fee.IsEmpty then exit; // if fra_ch_add_do1.dxgrid.SelectedCount<=0 then then exit; if bsSkinCheckRadioBox6.Checked then c:=1 else c:=0; t_ch_fee.DisableControls; t_ch_fee_sum.DisableControls; if bsSkinPanel9.Visible then begin if bsSkinCheckRadioBox1.Checked then i:=2 else i:=1; if bsSkinCheckRadioBox3.Checked then j:=1 else j:=0; end else begin i:=0; j:=0; end; // RE:=false; // if (bs_text.Text<>'3') and (do_ban1.DataSet.FieldByName('结算类别').asstring<>'流程') then // RE:=true; try t_rate.open; if bsSkinTabSheet1.Showing then begin delete_do_type_num:=1; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_fee_selectsb(bs_text.text,t_op_seae,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid1,i,j,c,ComboBoxCurry.text,do_ban_fee1) else shen_fee_select(bs_text.text,t_op_seae,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid1,i,j,do_ban_fee1); end; if bsSkinTabSheet2.Showing then begin delete_do_type_num:=2; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_fee_selectsb(bs_text.text,t_op_seai,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid5,i,j,c,ComboBoxCurry.text,do_ban_fee1) else shen_fee_select(bs_text.text,t_op_seai,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid5,i,j,do_ban_fee1); end; if bsSkinTabSheet3.Showing then begin delete_do_type_num:=3; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_fee_selectsb(bs_text.text,t_op_aire,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid8,i,j,c,ComboBoxCurry.text,do_ban_fee1) else shen_fee_select(bs_text.text,t_op_aire,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid8,i,j,do_ban_fee1); end; if bsSkinTabSheet4.Showing then begin delete_do_type_num:=4; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_fee_selectsb(bs_text.text,t_op_airi,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid11,i,j,c,ComboBoxCurry.text,do_ban_fee1) else shen_fee_select(bs_text.text,t_op_airi,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid11,i,j,do_ban_fee1); end; if bsSkinTabSheet5.Showing then begin if (bs_text.text='7') or (bs_text.text='1') then begin aLlist:=TStringList.Create; try if dxDBGrid17.SelectedCount>=1 then begin for k:=0 to dxDBGrid17.SelectedCount-1 do begin t_ch_fee.GotoBookmark(pointer(dxDBGrid17.selectedrows[k])); vatrate:=t_ch_fee.FieldByName('财务税率').AsFloat; if aLlist.IndexOf(FloatToStr(vatrate))<0 then begin aLlist.Add(FloatToStr(vatrate)); end; end; end; if aLlist.Count>1 then begin if strtobool(get_parameters_value(322,'false')) then begin if wwDBComboBox31.text='付' then begin if MessageDlg('选定的数据里存在不同的税率:'+aLlist.CommaText+' 是否继续?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end else begin showmessage('选定的数据里存在不同的税率,不能申请发票'); exit; end; end else if MessageDlg('选定的数据里存在不同的税率:'+aLlist.CommaText+' 是否继续?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end; if do_ban_fee1.DataSet.RecordCount>=1 then begin if aLlist.Count=1 then begin if strtobool(get_parameters_value(322,'false')) then begin if vatrate<>do_ban1.DataSet.FieldByName('税率').AsFloat then begin if wwDBComboBox31.text='付' then begin if MessageDlg('选定的数据里存在不同的税率:'+aLlist.CommaText+' 是否继续?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end else begin showmessage('选定的数据里存在不同的税率,不能申请发票'); exit; end; end; end end; end; finally aLlist.Free; end; end; s:=CheckDrFeeExsitItems(v_op_bscard.fieldbyname('编号').asstring); if s<>'' then begin if MessageDlg('付费存在,收费不存在的费用为:'+#13#10+s+' 是否继续?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end; if dxDBGrid17.SelectedCount>0 then begin delete_do_type_num:=5; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then begin shen_fee_selectsb(bs_text.text,v_op_bscard,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid17,i,j,c,ComboBoxCurry.text,do_ban_fee1) end else begin shen_fee_select(bs_text.text,v_op_bscard,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid17,i,j,do_ban_fee1); end; end else begin end; end; finally t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; end; end; procedure Tfra_ch_add_do.Edit4KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinButton10Click(Sender); end; end; procedure Tfra_ch_add_do.FrameEnter(Sender: TObject); begin { edit_open.Text:='12341234'; if strtobool(get_parameters_value(66,'false'))then begin Label2.Caption:='报检单号'; Label6.Caption:='报检单号'; end; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') then begin N3.Visible:=false; N6.Visible:=false; N5.Visible:=false; N8.Visible:=false; end; } end; procedure Tfra_ch_add_do.bsSkinPageControl1Change(Sender: TObject); begin if edit_open.Text='' then exit; { t_ch_fee.close; t_ch_fee_sum.close; t_ch_fee.DataSource.DataSet.close; } end; procedure Tfra_ch_add_do.bsSkinButton1Click(Sender: TObject); var str_fee,str_op:widestring; op_str,fee_str,sum_str:widestring; str:String; begin //海运进口业务查询 if not t_op_bscard_all.active then t_op_bscard_all.Open; t_ch_fee.close; t_ch_fee_sum.close; t_op_seai.Close; t_ch_fee.DataSource:=t_op_seai1; t_ch_fee_sum.DataSource:=t_op_seai1; case strtoint(bs_text.text) of 1: begin str_fee:='where 金额<>(开票金额+申请开票) and 不开发票<>1 and 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 7: begin str_fee:='where 金额<>(开票金额+申请开票) and 不开发票<>1 and 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 2: //付费申请 begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_fee:=str_fee+'and (金额<>申请金额 and 金额<>冲抵金额)'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if wwDBComboBox2.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox2.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 3: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if wwDBComboBox2.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox2.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 4: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if wwDBComboBox2.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox2.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 6: begin str_fee:='where ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_fee:=str_fee+'and (金额<>申请金额 and 金额<>冲抵金额)'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; // str_fee:=str_fee+' and 类型='+''''+'收'+''''; end; end; { if RxDBLookupCombo1.DisplayValues[1]<>''then str_fee:=str_fee+' and 客户名称='+''''+RxDBLookupCombo1.DisplayValues[1]+''''; } str:=Trim(ComboBoxObjseai.Text); if (Str<>'') and (length(Str)>10) then str_fee:=str_fee+' and 客户名称='+''''+Trim(Copy(Str,11,length(Str)-10))+''''; if RxDBLookupCombo9.DisplayValues[1]<>''then str_fee:=str_fee+' and 币别='+''''+RxDBLookupCombo9.DisplayValues[0]+''''; if RxDBLookupCombo8.DisplayValues[1]<>''then str_fee:=str_fee+' and 费用名称='+''''+RxDBLookupCombo8.DisplayValues[1]+''''; { if Trim(Edit22.Text)<>'' then begin str_fee:=str_fee+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit22.Text)+''')'; end; } str_op:=''; if Edit1.text<>''then str_op:=str_op+' and t_op_seai.委托编号 like '+''''+'%'+Edit1.text+'%'+''''; if Edit5.text<>''then str_op:=str_op+' and t_op_seai.主提单号 like '+''''+'%'+Edit5.text+'%'+''''; if Edit14.text<>''then str_op:=str_op+' and t_op_seai.报检单号 like '+''''+'%'+Edit14.text+'%'+''''; if Edit23.text<>''then str_op:=str_op+' and t_op_seai.报关单号 like '+''''+'%'+Edit23.text+'%'+''''; if Edit6.text<>''then str_op:=str_op+' and t_op_seai.分提单号 like '+''''+'%'+Edit6.text+'%'+''''; if wwDBDateTimePicker5.text<>''then str_op:=str_op+' and t_op_seai.进口日期>='+''''+wwDBDateTimePicker5.text+''''; if wwDBDateTimePicker7.text<>''then str_op:=str_op+' and t_op_seai.进口日期<='+''''+wwDBDateTimePicker7.text+''''; if wwDBDateTimePicker6.text<>''then str_op:=str_op+' and t_op_seai.会计期间>='+''''+wwDBDateTimePicker6.text+''''; if wwDBDateTimePicker8.text<>''then str_op:=str_op+' and t_op_seai.会计期间<='+''''+wwDBDateTimePicker8.text+''''; if Trim(Edit22.Text)<>'' then begin str_op:=str_op+' and 编号 in (select distinct 编号 from v_dui_fee where 对帐编号='''+Trim(Edit22.Text)+''')'; end; str_op:='where t_op_seai.编号 in (select distinct 编号 from v_ch_fee '+str_fee+')'+str_op; case strtoint(bs_text.text) of 1,7: begin str_op:=str_op+' and '+open_data('1002','揽货人','操作员','客服员','报关操作','报检操作'); end; 2: begin str_op:=str_op+' and '+open_data('1004','揽货人','操作员','客服员','报关操作','报检操作'); end; 3,4: begin str_op:=str_op+' and '+open_data('1003','揽货人','操作员','客服员','报关操作','报检操作'); end; end; op_str:='select * from t_op_seai '+str_op+default_sort(54,'t_op_seai','','desc'); case strtoint(bs_text.text) of 1: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额,(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit22.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit22.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 7: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额,(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit22.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit22.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 2: //付费申请 begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未开金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit22.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit22.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 3: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit22.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit22.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 4: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit22.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit22.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 6: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未开金额= ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit22.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit22.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; end; t_ch_fee.Close; t_ch_fee_sum.close; t_op_seai.close; t_op_seai.sql.clear; t_op_seai.sql.add(op_str); t_op_seai.open; t_ch_fee.sql.clear; t_ch_fee.sql.add(fee_str); t_ch_fee.open; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; end; procedure Tfra_ch_add_do.bsSkinButton2Click(Sender: TObject); begin ComboBoxObjSeai.Text:=''; Edit1.text:=''; Edit5.Text:=''; Edit6.text:=''; wwDBDateTimePicker5.Clear; wwDBDateTimePicker6.clear; wwDBDateTimePicker7.clear; wwDBDateTimePicker8.clear; end; procedure Tfra_ch_add_do.bsSkinButton4Click(Sender: TObject); var str_fee,str_op:widestring; op_str,fee_str,sum_str:widestring; Str:String; begin //空运出口查询 if not t_op_bscard_all.active then t_op_bscard_all.Open; t_ch_fee.close; t_ch_fee_sum.close; t_op_aire.Close; t_ch_fee.DataSource:=t_op_aire1; t_ch_fee_sum.DataSource:=t_op_aire1; case strtoint(bs_text.text) of 1: begin str_fee:='where 金额<>(开票金额+申请开票) and 不开发票<>1 and 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 7: begin str_fee:='where 金额<>(开票金额+申请开票) and 不开发票<>1 and 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 2: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_fee:=str_fee+'and (金额<>申请金额 and 金额<>冲抵金额)'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if wwDBComboBox3.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox3.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 3: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额))' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if wwDBComboBox3.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox3.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 4: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if wwDBComboBox3.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox3.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 6: begin str_fee:='where ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额))' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_fee:=str_fee+'and (金额<>申请金额 and 金额<>冲抵金额)'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; // if not strtobool(get_parameters_value(46,'true')) then // str_fee:=str_fee+' and 类型='+''''+'收'+''''; end; end; { if RxDBLookupCombo3.DisplayValues[1]<>''then str_fee:=str_fee+' and 客户名称='+''''+RxDBLookupCombo3.DisplayValues[1]+''''; } str:=Trim(ComboBoxObjaire.Text); if (Str<>'') and (length(Str)>10) then str_fee:=str_fee+' and 客户名称='+''''+Trim(Copy(Str,11,length(Str)-10))+''''; if RxDBLookupCombo11.DisplayValues[1]<>''then str_fee:=str_fee+' and 币别='+''''+RxDBLookupCombo11.DisplayValues[0]+''''; if RxDBLookupCombo10.DisplayValues[1]<>''then str_fee:=str_fee+' and 费用名称='+''''+RxDBLookupCombo10.DisplayValues[1]+''''; { if Trim(Edit24.Text)<>'' then begin str_fee:=str_fee+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit24.Text)+''')'; end; } str_op:=''; if Edit8.text<>''then str_op:=str_op+' and t_op_aire.委托编号 like '+''''+'%'+Edit8.text+'%'+''''; if Edit9.text<>''then str_op:=str_op+' and t_op_aire.主运单号 like '+''''+'%'+Edit9.text+'%'+''''; if Edit10.text<>''then str_op:=str_op+' and t_op_aire.分运单号 like '+''''+'%'+Edit10.text+'%'+''''; if Edit25.text<>''then str_op:=str_op+' and t_op_aire.报检单号 like '+''''+'%'+Edit25.text+'%'+''''; if Edit26.text<>''then str_op:=str_op+' and t_op_aire.报关单号 like '+''''+'%'+Edit26.text+'%'+''''; if wwDBDateTimePicker9.text<>''then str_op:=str_op+' and t_op_aire.一程开航日期>='+''''+wwDBDateTimePicker9.text+''''; if wwDBDateTimePicker11.text<>''then str_op:=str_op+' and t_op_aire.一程开航日期<='+''''+wwDBDateTimePicker11.text+''''; if wwDBDateTimePicker10.text<>''then str_op:=str_op+' and t_op_aire.会计期间>='+''''+wwDBDateTimePicker10.text+''''; if wwDBDateTimePicker12.text<>''then str_op:=str_op+' and t_op_aire.会计期间<='+''''+wwDBDateTimePicker12.text+''''; if Trim(Edit24.Text)<>'' then begin str_op:=str_op+' and 编号 in (select distinct 编号 from v_dui_fee where 对帐编号='''+Trim(Edit24.Text)+''')'; end; str_op:='where t_op_aire.编号 in (select distinct 编号 from v_ch_fee '+str_fee+')'+str_op; case strtoint(bs_text.text) of 1,7: begin str_op:=str_op+' and '+open_data('1002','揽货人','操作员','客服员','no','no'); end; 2: begin str_op:=str_op+' and '+open_data('1004','揽货人','操作员','客服员','no','no'); end; 3,4: begin str_op:=str_op+' and '+open_data('1003','揽货人','操作员','客服员','报关操作','报检操作'); end; end; op_str:='select * from t_op_aire '+str_op+default_sort(55,'t_op_aire','','desc'); case strtoint(bs_text.text) of 1: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额,(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit24.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit24.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 7: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额,(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit24.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit24.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 2: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未开金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit24.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit24.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 3: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit24.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit24.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 4: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit24.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit24.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 6: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未开金额= ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit24.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit24.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; end; t_ch_fee.Close; t_ch_fee_sum.close; t_op_aire.close; t_op_aire.sql.clear; t_op_aire.sql.add(op_str); t_op_aire.open; t_ch_fee.sql.clear; t_ch_fee.sql.add(fee_str); t_ch_fee.open; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; end; procedure Tfra_ch_add_do.bsSkinButton5Click(Sender: TObject); begin ComboBoxObjAire.text:=''; Edit8.text:=''; Edit9.Text:=''; Edit10.text:=''; wwDBDateTimePicker9.Clear; wwDBDateTimePicker10.clear; wwDBDateTimePicker11.clear; wwDBDateTimePicker12.clear; end; procedure Tfra_ch_add_do.bsSkinButton6Click(Sender: TObject); var str_fee,str_op:widestring; op_str,fee_str,sum_str:widestring; Str:String; begin //空运进口查询 if not t_op_bscard_all.active then t_op_bscard_all.Open; t_ch_fee.close; t_ch_fee_sum.close; t_op_airi.Close; t_ch_fee.DataSource:=t_op_airi1; t_ch_fee_sum.DataSource:=t_op_airi1; case strtoint(bs_text.text) of 1: begin str_fee:='where 金额<>(开票金额+申请开票) and 不开发票<>1 and 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 ' else begin if wwDBComboBox4.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox4.Text+''''; end; end; end; 7: begin str_fee:='where 金额<>(开票金额+申请开票) and 不开发票<>1 and 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 ' else begin if wwDBComboBox4.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox4.Text+''''; end; end; end; 2: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_fee:=str_fee+'and (金额<>申请金额 and 金额<>冲抵金额)'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if wwDBComboBox4.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox4.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 3: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if wwDBComboBox4.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox4.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 4: begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if wwDBComboBox4.Text<>'' then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox4.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 6: begin str_fee:='where ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; str_fee:=str_fee+'and (金额<>申请金额 and 金额<>冲抵金额)'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; // if not strtobool(get_parameters_value(46,'true')) then // str_fee:=str_fee+' and 类型='+''''+'收'+''''; end; end; { if RxDBLookupCombo4.DisplayValues[1]<>''then str_fee:=str_fee+' and 客户名称='+''''+RxDBLookupCombo4.DisplayValues[1]+''''; } str:=Trim(ComboBoxObjairi.Text); if (Str<>'') and (length(Str)>10) then str_fee:=str_fee+' and 客户名称='+''''+Trim(Copy(Str,11,length(Str)-10))+''''; if RxDBLookupCombo13.DisplayValues[1]<>''then str_fee:=str_fee+' and 币别='+''''+RxDBLookupCombo13.DisplayValues[0]+''''; if RxDBLookupCombo12.DisplayValues[1]<>''then str_fee:=str_fee+' and 费用名称='+''''+RxDBLookupCombo12.DisplayValues[1]+''''; { if Trim(Edit27.Text)<>'' then begin str_fee:=str_fee+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit27.Text)+''')'; end; } str_op:=''; if Edit7.text<>''then str_op:=str_op+' and t_op_airi.委托编号 like '+''''+'%'+Edit7.text+'%'+''''; if Edit11.text<>''then str_op:=str_op+' and t_op_airi.主运单号 like '+''''+'%'+Edit11.text+'%'+''''; if Edit12.text<>''then str_op:=str_op+' and t_op_airi.分运单号 like '+''''+'%'+Edit12.text+'%'+''''; if Edit28.text<>''then str_op:=str_op+' and t_op_airi.报检单号 like '+''''+'%'+Edit28.text+'%'+''''; if Edit29.text<>''then str_op:=str_op+' and t_op_airi.报关单号 like '+''''+'%'+Edit29.text+'%'+''''; if wwDBDateTimePicker13.text<>''then str_op:=str_op+' and t_op_airi.进口日期>='+''''+wwDBDateTimePicker13.text+''''; if wwDBDateTimePicker15.text<>''then str_op:=str_op+' and t_op_airi.进口日期<='+''''+wwDBDateTimePicker15.text+''''; if wwDBDateTimePicker14.text<>''then str_op:=str_op+' and t_op_airi.会计期间>='+''''+wwDBDateTimePicker14.text+''''; if wwDBDateTimePicker16.text<>''then str_op:=str_op+' and t_op_airi.会计期间<='+''''+wwDBDateTimePicker16.text+''''; if Trim(Edit27.Text)<>'' then begin str_op:=str_op+' and 编号 in (select distinct 编号 from v_dui_fee where 对帐编号='''+Trim(Edit27.Text)+''')'; end; str_op:='where t_op_airi.编号 in (select distinct 编号 from v_ch_fee '+str_fee+')'+str_op; case strtoint(bs_text.text) of 1,7: begin str_op:=str_op+' and '+open_data('1002','揽货人','操作员','客服员','no','no'); end; 2: begin str_op:=str_op+' and '+open_data('1004','揽货人','操作员','客服员','no','no'); end; 3,4: begin str_op:=str_op+' and '+open_data('1003','揽货人','操作员','客服员','报关操作','报检操作'); end; end; op_str:='select * from t_op_airi '+str_op+default_sort(56,'t_op_airi','','desc'); case strtoint(bs_text.text) of 1: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额,(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit27.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit27.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 7: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额,(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit27.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit27.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 2: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未开金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit27.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit27.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 3: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit27.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit27.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 4: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit27.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit27.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 6: begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未开金额= ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit27.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit27.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; end; t_ch_fee.Close; t_ch_fee_sum.close; t_op_airi.close; t_op_airi.sql.clear; t_op_airi.sql.add(op_str); t_op_airi.open; t_ch_fee.sql.clear; t_ch_fee.sql.add(fee_str); t_ch_fee.open; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; end; procedure Tfra_ch_add_do.bsSkinButton7Click(Sender: TObject); begin ComboBoxObjairi.Text:=''; Edit7.text:=''; Edit11.Text:=''; Edit12.text:=''; wwDBDateTimePicker13.Clear; wwDBDateTimePicker14.clear; wwDBDateTimePicker15.clear; wwDBDateTimePicker16.clear; end; procedure Tfra_ch_add_do.N3Click(Sender: TObject); var i,j,c:integer; begin { if bsSkinCheckRadioBox6.Checked then c:=1 else c:=0; t_ch_fee.DisableControls; t_ch_fee_sum.DisableControls; try frm_main.db.BeginTrans; try if bsSkinPanel9.Visible then begin if bsSkinCheckRadioBox1.Checked then i:=2 else i:=1; if bsSkinCheckRadioBox3.Checked then j:=1 else j:=0; end else begin i:=0; j:=0; end; t_rate.open; if bsSkinTabSheet1.Showing then begin delete_do_type_num:=1; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_cursb(t_op_seae,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid2,i,j,c,ComboBoxCurry.Text) else shen_yewwu_cur(t_op_seae,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid2,i,j); end; if bsSkinTabSheet2.Showing then begin delete_do_type_num:=2; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_cursb(t_op_seai,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid4,i,j,c,ComboBoxCurry.Text) else shen_yewwu_cur(t_op_seai,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid4,i,j); end; if bsSkinTabSheet3.Showing then begin delete_do_type_num:=3; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_cursb(t_op_aire,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid7,i,j,c,ComboBoxCurry.Text) else shen_yewwu_cur(t_op_aire,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid7,i,j); end; if bsSkinTabSheet4.Showing then begin delete_do_type_num:=4; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_cursb(t_op_airi,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid10,i,j,c,ComboBoxCurry.Text) else shen_yewwu_cur(t_op_airi,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid10,i,j); end; if bsSkinTabSheet5.Showing then begin delete_do_type_num:=5; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_cursb(v_op_bscard,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,c,ComboBoxCurry.Text) else shen_yewwu_cur(v_op_bscard,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j); end; frm_main.db.CommitTrans; except MessageDlg('提交费用时出错,请刷新重试!',mterror,[mbok],0); frm_main.db.RollbackTrans; end; t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); finally t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; end; } end; procedure Tfra_ch_add_do.N5Click(Sender: TObject); var i,j,c:integer; begin { if bsSkinCheckRadioBox6.Checked then c:=1 else c:=0; if bsSkinPanel9.Visible then begin if bsSkinCheckRadioBox1.Checked then i:=2 else i:=1; if bsSkinCheckRadioBox3.Checked then j:=1 else j:=0; end else begin i:=0; j:=0; end; t_rate.open; if bsSkinTabSheet1.Showing then begin delete_do_type_num:=1; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_cursb(bs_text.text,t_op_seae,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid1,i,j,c,ComboBoxCurry.text) else shen_fee_select_cur(bs_text.text,t_op_seae,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid1,i,j); end; if bsSkinTabSheet2.Showing then begin delete_do_type_num:=2; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_cursb(bs_text.text,t_op_seai,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid5,i,j,c,ComboBoxCurry.text) else shen_fee_select_cur(bs_text.text,t_op_seai,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid5,i,j); end; if bsSkinTabSheet3.Showing then begin delete_do_type_num:=3; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_cursb(bs_text.text,t_op_aire,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid8,i,j,c,ComboBoxCurry.text) else shen_fee_select_cur(bs_text.text,t_op_aire,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid8,i,j); end; if bsSkinTabSheet4.Showing then begin delete_do_type_num:=4; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_cursb(bs_text.text,t_op_airi,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid11,i,j,c,ComboBoxCurry.text) else shen_fee_select_cur(bs_text.text,t_op_airi,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid11,i,j); end; if bsSkinTabSheet5.Showing then begin delete_do_type_num:=5; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_cursb(bs_text.text,v_op_bscard,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid17,i,j,c,ComboBoxCurry.text) else shen_fee_select_cur(bs_text.text,v_op_bscard,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid17,i,j); end; t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); } end; procedure Tfra_ch_add_do.N7Click(Sender: TObject); var i,j,c:integer; begin { if bsSkinCheckRadioBox6.Checked then c:=1 else c:=0; t_ch_fee.DisableControls; t_ch_fee_sum.DisableControls; try frm_main.db.BeginTrans; try if bsSkinPanel9.Visible then begin if bsSkinCheckRadioBox1.Checked then i:=2 else i:=1; if bsSkinCheckRadioBox3.Checked then j:=1 else j:=0; end else begin i:=0; j:=0; end; t_rate.open; if bsSkinTabSheet1.Showing then begin delete_do_type_num:=1; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_feesb(t_op_seae,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid2,i,j,c,ComboBoxCurry.Text) else shen_yewwu_fee(t_op_seae,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid2,i,j); end; if bsSkinTabSheet2.Showing then begin delete_do_type_num:=2; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_feesb(t_op_seai,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid4,i,j,c,ComboBoxCurry.Text) else shen_yewwu_fee(t_op_seai,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid4,i,j); end; if bsSkinTabSheet3.Showing then begin delete_do_type_num:=3; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_feesb(t_op_aire,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid7,i,j,c,ComboBoxCurry.Text) else shen_yewwu_fee(t_op_aire,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid7,i,j); end; if bsSkinTabSheet4.Showing then begin delete_do_type_num:=4; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_feesb(t_op_airi,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid10,i,j,c,ComboBoxCurry.Text) else shen_yewwu_fee(t_op_airi,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid10,i,j); end; if bsSkinTabSheet5.Showing then begin delete_do_type_num:=5; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_yewwu_feesb(v_op_bscard,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,c,ComboBoxCurry.Text) else shen_yewwu_fee(v_op_bscard,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j); end; frm_main.db.CommitTrans; except MessageDlg('提交费用时出错,请刷新重试!',mterror,[mbok],0); frm_main.db.RollbackTrans; end; t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); finally t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; end; } end; procedure Tfra_ch_add_do.N9Click(Sender: TObject); var i,j,c:integer; begin { if bsSkinCheckRadioBox6.Checked then c:=1 else c:=0; t_ch_fee.DisableControls; t_ch_fee_sum.DisableControls; try if bsSkinPanel9.Visible then begin if bsSkinCheckRadioBox1.Checked then i:=2 else i:=1; if bsSkinCheckRadioBox3.Checked then j:=1 else j:=0; end else begin i:=0; j:=0; end; t_rate.open; if bsSkinTabSheet1.Showing then begin delete_do_type_num:=1; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_feesb(bs_text.text,t_op_seae,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid1,i,j,c,ComboBoxCurry.text) else shen_fee_select_fee(bs_text.text,t_op_seae,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid1,i,j); end; if bsSkinTabSheet2.Showing then begin delete_do_type_num:=2; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_feesb(bs_text.text,t_op_seai,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid5,i,j,c,ComboBoxCurry.text) else shen_fee_select_fee(bs_text.text,t_op_seai,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid5,i,j); end; if bsSkinTabSheet3.Showing then begin delete_do_type_num:=3; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_feesb(bs_text.text,t_op_aire,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid8,i,j,c,ComboBoxCurry.text) else shen_fee_select_fee(bs_text.text,t_op_aire,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid8,i,j); end; if bsSkinTabSheet4.Showing then begin delete_do_type_num:=4; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_feesb(bs_text.text,t_op_airi,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid11,i,j,c,ComboBoxCurry.text) else shen_fee_select_fee(bs_text.text,t_op_airi,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid11,i,j); end; if bsSkinTabSheet5.Showing then begin delete_do_type_num:=5; if (strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7') then shen_fee_select_feesb(bs_text.text,v_op_bscard,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid17,i,j,c,ComboBoxCurry.text) else shen_fee_select_fee(bs_text.text,v_op_bscard,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid17,i,j); end; t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); finally t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; end; } end; procedure Tfra_ch_add_do.RxDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinButton10Click(Sender); end; end; procedure Tfra_ch_add_do.RxDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinButton1Click(Sender); end; end; procedure Tfra_ch_add_do.RxDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinButton4Click(Sender); end; end; procedure Tfra_ch_add_do.RxDBLookupCombo4KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinButton6Click(Sender); end; end; procedure Tfra_ch_add_do.dxDBGrid2DblClick(Sender: TObject); begin fee_view(t_op_seae.fieldbyname('编号').asstring); end; procedure Tfra_ch_add_do.dxDBGrid4DblClick(Sender: TObject); begin fee_view(t_op_seai.fieldbyname('编号').asstring); end; procedure Tfra_ch_add_do.dxDBGrid7DblClick(Sender: TObject); begin fee_view(t_op_aire.fieldbyname('编号').asstring); end; procedure Tfra_ch_add_do.dxDBGrid10DblClick(Sender: TObject); begin fee_view(t_op_airi.fieldbyname('编号').asstring); end; procedure Tfra_ch_add_do.N11Click(Sender: TObject); var i,j,c:integer; RE:Boolean; s:string; begin //费用部分加入 if not t_ch_fee.active then exit; if t_ch_fee.IsEmpty then exit; if bsSkinCheckRadioBox6.Checked then c:=1 else c:=0; t_ch_fee.DisableControls; t_ch_fee_sum.DisableControls; if t_ch_fee.IsEmpty then exit; if bsSkinPanel9.Visible then begin if bsSkinCheckRadioBox1.Checked then i:=2 else i:=1; if bsSkinCheckRadioBox3.Checked then j:=1 else j:=0; end else begin i:=0; j:=0; end; // RE:=false; // if (bs_text.Text<>'3') and (do_ban1.DataSet.FieldByName('结算类别').asstring<>'流程') then // RE:=true; { if (bs_text.Text='2') and (t_ch_fee.FieldByName('类型').AsString='收') then begin try ShowMessage('冲抵金额不能部分冲抵'); Exit; finally t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; end; end; } try t_rate.open; if bsSkinTabSheet1.Showing then begin delete_do_type_num:=1; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_fee_select_fee_fensb(bs_text.text,t_op_seae,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,c,ComboBoxCurry.text,do_ban_fee1) else shen_fee_select_fee_fen(bs_text.text,t_op_seae,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,i,do_ban_fee1); end; if bsSkinTabSheet2.Showing then begin delete_do_type_num:=2; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_fee_select_fee_fensb(bs_text.text,t_op_seai,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,c,ComboBoxCurry.text,do_ban_fee1) else shen_fee_select_fee_fen(bs_text.text,t_op_seai,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,i,do_ban_fee1); end; if bsSkinTabSheet3.Showing then begin delete_do_type_num:=3; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_fee_select_fee_fensb(bs_text.text,t_op_aire,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,c,ComboBoxCurry.text,do_ban_fee1) else shen_fee_select_fee_fen(bs_text.text,t_op_aire,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,i,do_ban_fee1); end; if bsSkinTabSheet4.Showing then begin delete_do_type_num:=4; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_fee_select_fee_fensb(bs_text.text,t_op_airi,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,c,ComboBoxCurry.text,do_ban_fee1) else shen_fee_select_fee_fen(bs_text.text,t_op_airi,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,i,do_ban_fee1); end; if bsSkinTabSheet5.Showing then begin s:=CheckDrFeeExsitItems(v_op_bscard.fieldbyname('编号').asstring); if s<>'' then begin if MessageDlg('付费存在,收费不存在的费用为:'+#13#10+s+' 是否继续?',mtWarning,[mbyes,mbno],0)<>mryes then begin Exit; end; end; delete_do_type_num:=5; if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_fee_select_fee_fensb(bs_text.text,v_op_bscard,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,c,ComboBoxCurry.text,do_ban_fee1) else shen_fee_select_fee_fen(bs_text.text,v_op_bscard,t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,i,do_ban_fee1); end; finally t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; end; end; procedure Tfra_ch_add_do.bsSkinButton8Click(Sender: TObject); var str_fee,str_fee_I,str_op:widestring; op_str,fee_str,sum_str,Str_bill:widestring; Str,aCust,aCuster:String; begin // v_op_bscard.BeforeScroll:=nil; //多业务合并查询 if not t_op_bscard_all.active then t_op_bscard_all.Open; if not GetCustID(aCust) then exit; if not _GetCustID(aCuster) then exit; t_ch_fee.close; t_ch_fee_sum.close; v_op_bscard.Close; t_ch_fee.DataSource:=v_op_bscard1; t_ch_fee_sum.DataSource:=v_op_bscard1; case strtoint(bs_text.text) of 1: //发票 begin if (strtobool(get_parameters_value(87,'false'))=true) then begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+')'; if Trim(Edit36.Text)<>'' then begin // fee_str:=fee_str+' and CH_ID in (select CH_ID from t_ch_fee_do where 工作编号='''+Trim(Edit36.Text)+''')'; fee_str:=fee_str+' and EXISTS (select 1 from t_ch_fee_do where t_ch_fee_do.CH_ID=t_ch_fee.CH_ID AND t_ch_fee_do.工作编号='''+Trim(Edit36.Text)+''')'; end; str_fee_I:='where t_ch_fee.金额<>(t_ch_fee.申请开票+t_ch_fee.开票金额) and t_ch_fee.不开发票<>1' +' and t_ch_fee.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+')'; end else begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if Trim(Edit36.Text)<>'' then begin // fee_str:=fee_str+' and CH_ID in (select CH_ID from t_ch_fee_do where 工作编号='''+Trim(Edit36.Text)+''')'; fee_str:=fee_str+' and EXISTS (select 1 from t_ch_fee_do where t_ch_fee_do.CH_ID=t_ch_fee.CH_ID AND t_ch_fee_do.工作编号='''+Trim(Edit36.Text)+''')'; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; str_fee_I:=str_fee_I+' and t_ch_fee.类型='+''''+wwDBComboBox31.Text+''''; 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 (机密=0 or 机密 is null)'; str_fee_I:=str_fee_I+' and (t_ch_fee.机密=0 or t_ch_fee.机密 is null) '; end; end; end; 7: //发票申请 begin if (strtobool(get_parameters_value(87,'false'))=true) then begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+')'; end else begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; 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 (机密=0 or 机密 is null)'; end; end; end; 2: //业务支付申请 begin if strtobool(get_parameters_value(323,'false')) then begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; 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 (机密=0 or 机密 is null)'; end; end; if strtobool(get_parameters_value(175,'false')) then str_fee:=str_fee+ ' and '+ open_data('7000','录入人','no','no','no','no'); { str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; 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 '; end; end; } end; 3,8: //3 应收费用结算 begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; { 20130525 ljp } if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; 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 (机密=0 or 机密 is null)'; end; end; end; 4: //应付费用结算 begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额))' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; 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 (机密=0 or 机密 is null)'; end; end; end; 6: //业务收费申请 2123 begin if strtobool(get_parameters_value(323,'false')) then begin str_fee:='where ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额-冲抵金额) THEN (金额-申请金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:='where ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额-冲抵金额) THEN (金额-申请金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; 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 (机密=0 or 机密 is null)'; end; end; end; end; if RxDBLookupCombo5.DisplayValues[1]<>''then str_fee:=str_fee+' and 客户名称='+''''+RxDBLookupCombo5.DisplayValues[1]+''''; { str:=Trim(ComboBoxObjbscard.Text); if (Str<>'') and (length(Str)>10) then str_fee:=str_fee+' and 客户名称='+''''+Trim(Copy(Str,11,length(Str)-10))+''''; } if acust<>'' then begin str_fee:=str_fee+' and 客户名称='+''''+acust+''''; str_fee_i:=str_fee_i+' and t_ch_fee.客户名称='+''''+acust+''''; end; if RxDBLookupCombo15.DisplayValues[1]<>''then begin str_fee:=str_fee+' and 币别='+''''+RxDBLookupCombo15.DisplayValues[0]+''''; str_fee_i:=str_fee_i+' and t_ch_fee.币别='+''''+RxDBLookupCombo15.DisplayValues[0]+''''; end; if RxDBLookupCombo16.DisplayValues[1]<>''then begin str_fee:=str_fee+' and 费用名称='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; str_fee_I:=str_fee_I+' and t_ch_fee.费用名称='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; end; str_op:=''; if Edit15.text<>''then str_op:=str_op+' and v_op_bscard_all.委托编号 like '+''''+'%'+Edit15.text+'%'+''''; if Edit34.text<>''then str_op:=str_op+' and v_op_bscard_all.主提单号 like '+''''+'%'+Edit34.text+'%'+''''; if Edit16.text<>''then str_op:=str_op+' and (v_op_bscard_all.订舱单号 like '+''''+'%'+Edit16.text+'%'+''' or v_op_bscard_all.主提单号 like '+''''+'%'+Edit16.text+'%'+''' or v_op_bscard_all.分提单号 like '+''''+'%'+Edit16.text+'%'+''' or v_op_bscard_all.业务编号 like '+''''+'%'+Edit16.text+'%'+''' or v_op_bscard_all.委托编号 like '+''''+'%'+Edit16.text+'%'+''')'; if Edit17.text<>''then str_op:=str_op+' and v_op_bscard_all.分提单号 like '+''''+'%'+Edit17.text+'%'+''''; if Edit18.text<>''then str_op:=str_op+' and (v_op_bscard_all.报检单号 like '+''''+'%'+Edit18.text+'%'+''' or v_op_bscard_all.报关单号 like '+''''+'%'+Edit18.text+'%'+''')'; if Edit33.text<>''then str_op:=str_op+' and v_op_bscard_all.核销单号 like '+''''+'%'+Edit33.text+'%'+''''; if wwDBComboBox46.text<>''then str_op:=str_op+' and v_op_bscard_all.业务类型='+''''+wwDBComboBox46.text+''''; if wwDBLookupCombo49.text<>''then str_op:=str_op+' and v_op_bscard_all.船名 like '+''''+'%'+wwDBLookupCombo49.text+'%'+''''; if Edit30.text<>''then str_op:=str_op+' and v_op_bscard_all.航次 like '+''''+'%'+Edit30.text+'%'+''''; if aCuster<>'' then str_op:=str_op+' and v_op_bscard_all.委托单位 like '+''''+'%'+aCuster+'%'+''''; if ComboBox1.text<>''then str_op:=str_op+' and v_op_bscard_all.'+bsSkinComboBox1.text+'='+''''+ComboBox1.text+''''; { if Edit18.text<>''then str_op:=str_op+' and v_op_bscard.'+Label2.Caption+' like '+''''+'%'+Edit18.text+'%'+''''; } case bsSkinComboBox2.ItemIndex of 0: begin if wwDBDateTimePicker17.text<>''then str_op:=str_op+' and v_op_bscard_all.开船日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_op:=str_op+' and v_op_bscard_all.开船日期<='+''''+wwDBDateTimePicker19.text+''''; end; 1: begin if wwDBDateTimePicker17.text<>''then str_op:=str_op+' and v_op_bscard_all.报关日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_op:=str_op+' and v_op_bscard_all.报关日期<='+''''+wwDBDateTimePicker19.text+''''; end; 2: begin if wwDBDateTimePicker17.text<>''then str_op:=str_op+' and v_op_bscard_all.装箱日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_op:=str_op+' and v_op_bscard_all.装箱日期<='+''''+wwDBDateTimePicker19.text+''''; end; 3: begin if wwDBDateTimePicker17.text<>''then str_op:=str_op+' and v_op_bscard_all.送货日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_op:=str_op+' and v_op_bscard_all.送货日期<='+''''+wwDBDateTimePicker19.text+''''; end; end; if wwDBDateTimePicker18.text<>''then str_op:=str_op+' and v_op_bscard_all.会计期间>='+''''+wwDBDateTimePicker18.text+''''; if wwDBDateTimePicker20.text<>''then str_op:=str_op+' and v_op_bscard_all.会计期间<='+''''+wwDBDateTimePicker20.text+''''; if wwDBComboBox5.text='是' then str_op:=str_op+' and v_op_bscard_all.是否退舱=1 '; if wwDBComboBox5.text='否' then str_op:=str_op+' and (v_op_bscard_all.是否退舱=0 OR v_op_bscard_all.是否退舱 IS NULL) '; if Trim(Edit19.Text)<>'' then begin str_op:=str_op+' and v_op_bscard_all.编号 in (select distinct 编号 from v_dui_fee where 对帐编号='''+Trim(Edit19.Text)+''')'; end; if Trim(Edit36.Text)<>'' then begin str_op:=str_op+' and v_op_bscard_all.编号 in (select distinct 业务编号 from t_ch_fee_do where 工作编号='''+Trim(Edit36.Text)+''')'; end; //ShowMessage(str_op); if Trim(Edit35.Text)<>'' then begin str_op:=str_op+' and v_op_bscard_all.编号 in (select distinct 业务编号 from t_ch_fee_do where 类型=1 and 工作编号 in ( select 申请编号 from t_ch_invoice where (是否收费=0 or 是否收费 is null) and (是否废除=0 or 是否废除 is null ) and 发票号码 ='''+Trim(Edit35.Text)+'''))'; end; if (strtoint(bs_text.text)=2) and strtobool(get_parameters_value(152,'true')) then begin str_op:=str_op+' and ((v_op_bscard_all.费用状态=''费用封帐'' and v_op_bscard_all.业务类型=''海运出口'') or v_op_bscard_all.业务类型<>''海运出口'')'; end; if strtoint(bs_text.text)=8 then str_op:='where v_op_bscard_all.编号=主编号 and v_op_bscard_all.编号 in (select distinct 编号 from v_ch_fee '+str_fee+')'+str_op else begin str_op:='where v_op_bscard_all.编号 in (select distinct 编号 from v_ch_fee '+str_fee+')'+str_op; end; case strtoint(bs_text.text) of 1,7: begin str_op:=str_op+' and (v_op_bscard_all.香港付费=0 OR v_op_bscard_all.香港付费 IS NULL) '; end; end; case strtoint(bs_text.text) of 1,7: begin str_op:=str_op+' and '+open_data('1002','揽货人','操作员','客服员','报关操作','报检操作'); end; 2,6: begin str_op:=str_op+' and '+open_data('1004','揽货人','操作员','客服员','报关操作','报检操作'); end; 3,4: begin str_op:=str_op+' and '+open_data('1003','揽货人','操作员','客服员','报关操作','报检操作'); end; end; case strtoint(bs_text.text) of 3,6: begin //3 应收费用结算 op_str:='select v_op_bscard_all.编号,v_op_bscard_all.业务类型,v_op_bscard_all.业务状态,v_op_bscard_all.业务种类,v_op_bscard_all.费用状态' +',v_op_bscard_all.业务编号,v_op_bscard_all.委托编号,v_op_bscard_all.主提单号,v_op_bscard_all.分提单号,v_op_bscard_all.报关单号' +',v_op_bscard_all.报检单号,v_op_bscard_all.订舱单号' +',v_op_bscard_all.委托单位,v_op_bscard_all.经营单位' +',v_op_bscard_all.开船日期,v_op_bscard_all.会计期间,v_op_bscard_all.装运方式,v_op_bscard_all.船名,v_op_bscard_all.航次,v_op_bscard_all.装货港,v_op_bscard_all.卸货港' +',v_op_bscard_all.集装箱,v_op_bscard_all.件数,v_op_bscard_all.重量,v_op_bscard_all.尺码,v_op_bscard_all.操作员,v_op_bscard_all.揽货人' +',v_op_bscard_all.客服员,v_op_bscard_all.箱型10,' +'SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END ) as 未收USD ' +',' +'SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 未收RMB ' +',' +'SUM(CASE t_ch_fee.类型 WHEN ''付'' THEN (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END ) as 未付USD ' +',' +'SUM( CASE t_ch_fee.类型 WHEN ''付'' THEN (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END ) as 未付RMB ' +' from v_op_bscard_all v_op_bscard_all '; if acust<>'' then op_str:=op_str+' Left Join t_ch_fee t_ch_fee on v_op_bscard_all.编号=t_ch_fee.编号 and t_ch_fee.费用状态 in(''审核通过'',''部分结算'') and t_ch_fee.金额<>t_ch_fee.结算金额 and 客户名称='+''''+acust+'''' else op_str:=op_str+' Left Join t_ch_fee t_ch_fee on v_op_bscard_all.编号=t_ch_fee.编号 and t_ch_fee.费用状态 in(''审核通过'',''部分结算'') and t_ch_fee.金额<>t_ch_fee.结算金额 '; op_str:=op_str +str_op +' group by v_op_bscard_all.编号,v_op_bscard_all.业务类型,v_op_bscard_all.业务状态,v_op_bscard_all.业务种类,v_op_bscard_all.费用状态' +',v_op_bscard_all.业务编号,v_op_bscard_all.委托编号,v_op_bscard_all.主提单号,v_op_bscard_all.分提单号,v_op_bscard_all.报关单号' +',v_op_bscard_all.报检单号,v_op_bscard_all.订舱单号' +',v_op_bscard_all.委托单位,v_op_bscard_all.经营单位' +',v_op_bscard_all.开船日期,v_op_bscard_all.会计期间,v_op_bscard_all.装运方式,v_op_bscard_all.船名,v_op_bscard_all.航次,v_op_bscard_all.装货港,v_op_bscard_all.卸货港' +',v_op_bscard_all.集装箱,v_op_bscard_all.件数,v_op_bscard_all.重量,v_op_bscard_all.尺码,v_op_bscard_all.操作员,v_op_bscard_all.揽货人' +',v_op_bscard_all.客服员,v_op_bscard_all.箱型10' +default_sort(53,'v_op_bscard_all','','desc'); end; 2,4: begin //2 付费申请 op_str:='select v_op_bscard_all.编号,v_op_bscard_all.业务类型,v_op_bscard_all.业务状态,v_op_bscard_all.业务种类,v_op_bscard_all.费用状态' +',v_op_bscard_all.业务编号,v_op_bscard_all.委托编号,v_op_bscard_all.主提单号,v_op_bscard_all.分提单号,v_op_bscard_all.报关单号' +',v_op_bscard_all.报检单号,v_op_bscard_all.订舱单号' +',v_op_bscard_all.委托单位,v_op_bscard_all.经营单位' +',v_op_bscard_all.开船日期,v_op_bscard_all.会计期间,v_op_bscard_all.装运方式,v_op_bscard_all.船名,v_op_bscard_all.航次,v_op_bscard_all.装货港,v_op_bscard_all.卸货港' +',v_op_bscard_all.集装箱,v_op_bscard_all.件数,v_op_bscard_all.重量,v_op_bscard_all.尺码,v_op_bscard_all.操作员,v_op_bscard_all.揽货人' +',v_op_bscard_all.客服员,v_op_bscard_all.箱型10,' +'t_op_gain.应收USD-t_op_gain.已收USD as 未收USD ' +',' +'t_op_gain.应收RMB-t_op_gain.已收RMB as 未收RMB ' +',' +'SUM(CASE t_ch_fee.类型 WHEN ''付'' THEN (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END ) as 未付USD ' +',' +'SUM( CASE t_ch_fee.类型 WHEN ''付'' THEN (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END ) as 未付RMB ' +' from v_op_bscard_all v_op_bscard_all ' +' Left Join t_op_gain on v_op_bscard_all.编号=t_op_gain.编号'; if acust<>'' then op_str:=op_str+' Left Join t_ch_fee t_ch_fee on v_op_bscard_all.编号=t_ch_fee.编号 and t_ch_fee.费用状态 in(''审核通过'',''部分结算'') and t_ch_fee.金额<>t_ch_fee.结算金额 and 客户名称='+''''+acust+'''' else op_str:=op_str+' Left Join t_ch_fee t_ch_fee on v_op_bscard_all.编号=t_ch_fee.编号 and t_ch_fee.费用状态 in(''审核通过'',''部分结算'') and t_ch_fee.金额<>t_ch_fee.结算金额 '; op_str:=op_str +str_op +' group by v_op_bscard_all.编号,v_op_bscard_all.业务类型,v_op_bscard_all.业务状态,v_op_bscard_all.业务种类,v_op_bscard_all.费用状态' +',v_op_bscard_all.业务编号,v_op_bscard_all.委托编号,v_op_bscard_all.主提单号,v_op_bscard_all.分提单号,v_op_bscard_all.报关单号' +',v_op_bscard_all.报检单号,v_op_bscard_all.订舱单号' +',v_op_bscard_all.委托单位,v_op_bscard_all.经营单位' +',v_op_bscard_all.开船日期,v_op_bscard_all.会计期间,v_op_bscard_all.装运方式,v_op_bscard_all.船名,v_op_bscard_all.航次,v_op_bscard_all.装货港,v_op_bscard_all.卸货港' +',v_op_bscard_all.集装箱,v_op_bscard_all.件数,v_op_bscard_all.重量,v_op_bscard_all.尺码,v_op_bscard_all.操作员,v_op_bscard_all.揽货人' +',v_op_bscard_all.客服员,v_op_bscard_all.箱型10,t_op_gain.应收USD-t_op_gain.已收USD,t_op_gain.应收RMB-t_op_gain.已收RMB ' +default_sort(53,'v_op_bscard_all','','desc'); end; else begin op_str:='select v_op_bscard_all.编号,v_op_bscard_all.业务类型,v_op_bscard_all.业务状态,v_op_bscard_all.业务种类,v_op_bscard_all.费用状态' +',v_op_bscard_all.业务编号,v_op_bscard_all.委托编号,v_op_bscard_all.主提单号,v_op_bscard_all.分提单号,v_op_bscard_all.报关单号' +',v_op_bscard_all.报检单号,v_op_bscard_all.订舱单号' +',v_op_bscard_all.委托单位,v_op_bscard_all.经营单位' +',v_op_bscard_all.开船日期,v_op_bscard_all.会计期间,v_op_bscard_all.装运方式,v_op_bscard_all.船名,v_op_bscard_all.航次,v_op_bscard_all.装货港,v_op_bscard_all.卸货港' +',v_op_bscard_all.集装箱,v_op_bscard_all.件数,v_op_bscard_all.重量,v_op_bscard_all.尺码,v_op_bscard_all.操作员,v_op_bscard_all.揽货人' +',v_op_bscard_all.客服员,v_op_bscard_all.箱型10,' +'0 AS未收USD ' +',' +'0 未收RMB ' +',' +'0 as 未付USD ' +',' +'0 as 未付RMB ' +' from v_op_bscard_all v_op_bscard_all '+str_op +default_sort(53,'v_op_bscard_all','','desc'); end; end; { op_str:='select * from v_op_bscard_all '+str_op +default_sort(53,'v_op_bscard_all','','desc'); } case strtoint(bs_text.text) of 1: //发票 begin if Trim(Edit36.Text)<>'' then begin fee_str:='select t_ch_fee.类型,t_ch_fee.CH_ID,t_ch_fee.编号,t_ch_fee.费用名称,t_ch_fee.客户名称' +',t_ch_fee.币别,t_ch_fee.汇率, t_ch_fee.税率,备注,t_ch_fee.财务税率,t_ch_fee.开票金额,t_ch_fee.金额,(t_ch_fee_do.原始金额) as 未开金额 ' +' from t_ch_fee_do ' +' left join t_ch_fee on t_ch_fee_do.ch_id=t_ch_fee.ch_id ' +str_fee_i+' and t_ch_fee.编号=:编号'; if Trim(Edit36.Text)<>'' then begin fee_str:=fee_str+' and t_ch_fee_do.工作编号='''+Trim(Edit36.Text)+''''; end; fee_str:=fee_str+' order by t_ch_fee.CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end else begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,备注,税率,财务税率,开票金额,金额,(金额-开票金额-申请开票) as 未开金额 from t_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit19.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit19.Text)+''')'; end; if Trim(Edit35.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select ch_id from t_ch_fee_do where 类型=1 and 工作编号 in ( select 申请编号 from t_ch_invoice where (是否收费=0 or 是否收费 is null) and (是否废除=0 or 是否废除 is null ) and 发票号码 ='''+Trim(Edit35.Text)+'''))'; end; if Trim(Edit36.Text)<>'' then begin // fee_str:=fee_str+' and CH_ID in (select CH_ID from t_ch_fee_do where 工作编号='''+Trim(Edit36.Text)+''')'; fee_str:=fee_str+' and EXISTS (select 1 from t_ch_fee_do where t_ch_fee_do.CH_ID=t_ch_fee.CH_ID AND t_ch_fee_do.工作编号='''+Trim(Edit36.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; end; 7: //发票申请 begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,备注,汇率,税率,财务税率,t_ch_fee.开票金额,金额,(金额-开票金额-申请开票) as 未开金额 from t_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit19.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit19.Text)+''')'; end; if Trim(Edit35.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select ch_id from t_ch_fee_do where 类型=1 and 工作编号 in ( select 申请编号 from t_ch_invoice where (是否收费=0 or 是否收费 is null) and (是否废除=0 or 是否废除 is null ) and 发票号码 ='''+Trim(Edit35.Text)+'''))'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 2: //业务支付申请 begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,备注,税率,财务税率,开票金额,金额, 未开金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit19.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit19.Text)+''')'; end; if Trim(Edit35.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select ch_id from t_ch_fee_do where 类型=1 and 工作编号 in ( select 申请编号 from t_ch_invoice where (是否收费=0 or 是否收费 is null) and (是否废除=0 or 是否废除 is null ) and 发票号码 ='''+Trim(Edit35.Text)+'''))'; end; fee_str:=fee_str+' order by CH_ID'; // showmessage(fee_str); sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; { 历史 fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,金额, 未开金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit19.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit19.Text)+''')'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; } 3: //3 应收费用结算 begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,备注,税率,财务税率,开票金额,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit19.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit19.Text)+''')'; end; if Trim(Edit35.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select ch_id from t_ch_fee_do where 类型=1 and 工作编号 in ( select 申请编号 from t_ch_invoice where (是否收费=0 or 是否收费 is null) and (是否废除=0 or 是否废除 is null ) and 发票号码 ='''+Trim(Edit35.Text)+'''))'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 4: // 应付费用结算 begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,税率,备注,财务税率,开票金额,金额, 未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit19.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit19.Text)+''')'; end; if Trim(Edit35.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select ch_id from t_ch_fee_do where 类型=1 and 工作编号 in ( select 申请编号 from t_ch_invoice where (是否收费=0 or 是否收费 is null) and (是否废除=0 or 是否废除 is null ) and 发票号码 ='''+Trim(Edit35.Text)+'''))'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 6: //业务收费申请 begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,备注,汇率,税率,财务税率,开票金额,金额, 未开金额= ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号=:编号'; if Trim(Edit19.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select CH_ID from v_dui_fee where 对帐编号='''+Trim(Edit19.Text)+''')'; end; if Trim(Edit35.Text)<>'' then begin fee_str:=fee_str+' and CH_ID in (select ch_id from t_ch_fee_do where 类型=1 and 工作编号 in ( select 申请编号 from t_ch_invoice where (是否收费=0 or 是否收费 is null) and (是否废除=0 or 是否废除 is null ) and 发票号码 ='''+Trim(Edit35.Text)+'''))'; end; fee_str:=fee_str+' order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号=:编号 group by 类型,币别 order by 类型,币别'; end; 8: // 应收费用结算 begin fee_str:='select 类型,CH_ID,编号,费用名称,客户名称,币别,汇率,税率,备注,财务税率,开票金额,金额,未结金额= ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) from v_ch_fee ' +str_fee+' and 编号 in (select 编号 from v_op_bscard_all where 主编号=:编号) order by CH_ID'; sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号 in (select 编号 from v_op_bscard_all where 主编号=:编号) group by 类型,币别 order by 类型,币别'; end; end; t_ch_fee.Close; t_ch_fee_sum.close; v_op_bscard.close; v_op_bscard.sql.clear; v_op_bscard.sql.add(op_str); v_op_bscard.open; // v_op_bscard.LoadFromDataSet(v_op_bscard,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]); t_ch_fee.sql.clear; t_ch_fee.sql.add(fee_str); // ShowMessage(fee_str); t_ch_fee.open; old_sum_str:=sum_str; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; // ShowMessage(sum_str); // v_op_bscard.BeforeScroll:=v_op_bscardBeforeScroll; end; procedure Tfra_ch_add_do.ComboBoxObjBsCardEnter(Sender: TObject); var str_fee,str_op:widestring; aQuery:TADOQuery; begin //列客户名称 case strtoint(bs_text.text) of 1: begin if (strtobool(get_parameters_value(87,'false'))=true) then begin str_fee:=' and c.金额<>(c.申请开票+c.开票金额) and c.不开发票<>1' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+')'; end else begin str_fee:=' and c.金额<>(c.申请开票+c.开票金额) and c.不开发票<>1' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; str_fee:=str_fee+' and c.类型='+''''+wwDBComboBox31.Text+''''; 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 (c.机密=0 or c.机密 is null)'; end; end; end; 7: begin if (strtobool(get_parameters_value(87,'false'))=true) then begin str_fee:=' and c.金额<>(c.申请开票+c.开票金额) and c.不开发票<>1' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+')'; end else begin str_fee:=' and c.金额<>(c.申请开票+c.开票金额) and c.不开发票<>1' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; str_fee:=str_fee+' and c.类型='+''''+wwDBComboBox31.Text+''''; 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 (c.机密=0 or c.机密 is null)'; end; end; end; 2: begin if strtobool(get_parameters_value(323,'false')) then begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and c.类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; 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 (c.机密=0 or c.机密 is null)'; end; end; if strtobool(get_parameters_value(175,'false')) then str_fee:=str_fee+ ' and '+ open_data('7000','c.录入人','no','no','no','no'); end; 3,8: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'收'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and c.类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; 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 (c.机密=0 or c.机密 is null)'; end; end; end; 4: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 and ((c.金额>0 and c.金额>=c.结算金额) or (c.金额<0 and c.金额<=c.结算金额))' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and c.类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; 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 (c.机密=0 or c.机密 is null)'; end; end; end; 6: begin if strtobool(get_parameters_value(323,'false')) then begin str_fee:=' and ' +'(case c.类型 when '+''''+'收'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额-c.冲抵金额) THEN (c.金额-c.申请金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额-c.冲抵金额) end) end) ' +'end)<>0 and ((c.金额>0 and c.金额>=c.结算金额) or (c.金额<0 and c.金额<=c.结算金额)) ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:=' and ' +'(case c.类型 when '+''''+'收'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额-c.冲抵金额) THEN (c.金额-c.申请金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额-c.冲抵金额) end) end) ' +'end)<>0 and ((c.金额>0 and c.金额>=c.结算金额) or (c.金额<0 and c.金额<=c.结算金额)) ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'收'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and c.类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; 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 (c.机密=0 or c.机密 is null)'; end; end; end; end; if RxDBLookupCombo15.DisplayValues[1]<>''then str_fee:=str_fee+' and c.币别='+''''+RxDBLookupCombo15.DisplayValues[0]+''''; if RxDBLookupCombo16.DisplayValues[1]<>''then str_fee:=str_fee+' and c.费用名称='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; if Edit15.text<>''then str_fee:=str_fee+' and b.委托编号 like '+''''+'%'+Edit15.text+'%'+''''; if Edit34.text<>''then str_fee:=str_fee+' and b.主提单号 like '+''''+'%'+Edit34.text+'%'+''''; if Edit16.text<>''then str_fee:=str_fee+' and (b.主提单号 like '+''''+'%'+Edit16.text+'%'+''' or b.分提单号 like '+''''+'%'+Edit16.text+'%'+''' or b.业务编号 like '+''''+'%'+Edit16.text+'%'+''' or b.委托编号 like '+''''+'%'+Edit16.text+'%'+''')'; if Edit17.text<>''then str_fee:=str_fee+' and b.报检单号 like '+''''+'%'+Edit17.text+'%'+''''; if wwDBComboBox46.text<>''then str_fee:=str_fee+' and b.业务类型='+''''+wwDBComboBox46.text+''''; if Edit18.text<>''then str_fee:=str_fee+' and b.'+Label2.Caption+' like '+''''+'%'+Edit18.text+'%'+''''; if wwDBLookupCombo49.text<>''then str_fee:=str_fee+' and b.船名 like '+''''+'%'+wwDBLookupCombo49.text+'%'+''''; if Edit30.text<>''then str_fee:=str_fee+' and b.航次 like '+''''+'%'+Edit30.text+'%'+''''; case bsSkinComboBox2.ItemIndex of 0: begin if wwDBDateTimePicker17.text<>''then str_fee:=str_fee+' and b.开船日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_fee:=str_fee+' and b.开船日期<='+''''+wwDBDateTimePicker19.text+''''; end; 1:begin if wwDBDateTimePicker17.text<>''then str_fee:=str_fee+' and b.报关日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_fee:=str_fee+' and b.报关日期<='+''''+wwDBDateTimePicker19.text+''''; end; end; if wwDBDateTimePicker18.text<>''then str_fee:=str_fee+' and b.会计期间>='+''''+wwDBDateTimePicker18.text+''''; if wwDBDateTimePicker20.text<>''then str_fee:=str_fee+' and b.会计期间<='+''''+wwDBDateTimePicker20.text+''''; ComboBoxObjBsCard.Items.Clear; aQuery:=CreateAdoQuery; with aQuery do try Close;SQL.Clear; SQL.Add('Select distinct u.代码, u.客户简称'); SQL.Add('from t_ch_fee c'); SQL.Add('Left Join t_crm_client u on (u.客户简称=c.客户名称)'); SQL.Add(' Left Join v_op_bscard_all b on b.编号=c.编号 '); SQL.Add('where not u.客户简称 is null '); SQL.Add(str_fee); SQL.Add(' order by u.代码'); Open;First; while not Eof do begin ComboBoxObjBsCard.Items.Add(FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString); Next; end; finally Close; FreeAndNil(aQuery); end; { Close;SQL.Clear; SQL.Add('Select distinct u.代码, u.客户简称'); SQL.Add('from t_ch_fee c'); SQL.Add('Left Join t_crm_client u on (u.客户简称=c.客户名称)'); SQL.Add(', v_op_bscard_all b'); SQL.Add('where b.编号=c.编号 and not u.客户简称 is null '); SQL.Add(str_fee); SQL.Add(' order by u.代码'); } end; procedure Tfra_ch_add_do.bsSkinButton9Click(Sender: TObject); begin ComboBoxObjBsCard.text:=''; ComboBoxObjBs.text:=''; Edit15.text:=''; Edit16.Text:=''; Edit17.text:=''; Edit18.text:=''; Edit19.text:=''; Edit35.text:=''; wwDBDateTimePicker17.Clear; wwDBDateTimePicker18.clear; wwDBDateTimePicker19.clear; wwDBDateTimePicker20.clear; RxDBLookupCombo15.ClearValue; RxDBLookupCombo16.ClearValue; wwDBLookupCombo49.Text:=''; Edit30.Text:=''; Edit33.Text:=''; wwDBComboBox46.Text:=''; wwDBComboBox31.Text:=''; ComboBox1.Text:=''; end; procedure Tfra_ch_add_do.ComboBoxObjairiEnter(Sender: TObject); var str_fee:widestring; aQuery:TADOQuery; begin //列客户名称 case strtoint(bs_text.text) of 1: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 7: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 2: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 3: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'收'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 4: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 6: begin str_fee:=' and ' +'(case c.类型 when '+''''+'收'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; // if not strtobool(get_parameters_value(46,'true')) then // str_fee:=str_fee+' and 类型='+''''+'收'+''''; end; end; if Edit7.text<>''then str_fee:=str_fee+' and b.委托编号 like '+''''+'%'+Edit7.text+'%'+''''; if Edit11.text<>''then str_fee:=str_fee+' and b.主运单号 like '+''''+'%'+Edit11.text+'%'+''''; if Edit12.text<>''then str_fee:=str_fee+' and b.分运单号 like '+''''+'%'+Edit12.text+'%'+''''; if wwDBDateTimePicker13.text<>''then str_fee:=str_fee+' and b.进口日期>='+''''+wwDBDateTimePicker13.text+''''; if wwDBDateTimePicker15.text<>''then str_fee:=str_fee+' and b.进口日期<='+''''+wwDBDateTimePicker15.text+''''; if wwDBDateTimePicker14.text<>''then str_fee:=str_fee+' and b.会计期间>='+''''+wwDBDateTimePicker14.text+''''; if wwDBDateTimePicker16.text<>''then str_fee:=str_fee+' and b.会计期间<='+''''+wwDBDateTimePicker16.text+''''; ComboBoxObjairi.Items.Clear; aQuery:=CreateAdoQuery; with aQuery do try Close;SQL.Clear; SQL.Add('Select distinct u.代码, u.客户简称'); SQL.Add('from t_ch_fee c'); SQL.Add('Left Join t_crm_client u on (u.客户简称=c.客户名称)'); SQL.Add(', t_op_airi b'); SQL.Add('where b.编号=c.编号 '); SQL.Add(str_fee); SQL.Add(' order by u.代码'); Open; First; while not Eof do begin ComboBoxObjairi.Items.Add(FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString); Next; end; finally Close; FreeAndNil(aQuery); end; end; procedure Tfra_ch_add_do.ComboBoxObjAireEnter(Sender: TObject); var str_fee:widestring; aQuery:TADOQuery; begin //列客户名称 case strtoint(bs_text.text) of 1: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 7: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 2: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 3: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'收'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 4: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 6: begin str_fee:=' and ' +'(case c.类型 when '+''''+'收'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; // if not strtobool(get_parameters_value(46,'true')) then // str_fee:=str_fee+' and 类型='+''''+'收'+''''; end; end; if Edit8.text<>''then str_fee:=str_fee+' and b.委托编号 like '+''''+'%'+Edit8.text+'%'+''''; if Edit9.text<>''then str_fee:=str_fee+' and b.主运单号 like '+''''+'%'+Edit9.text+'%'+''''; if Edit10.text<>''then str_fee:=str_fee+' and b.分运单号 like '+''''+'%'+Edit10.text+'%'+''''; if wwDBDateTimePicker9.text<>''then str_fee:=str_fee+' and b.一程开航日期>='+''''+wwDBDateTimePicker9.text+''''; if wwDBDateTimePicker11.text<>''then str_fee:=str_fee+' and b.一程开航日期<='+''''+wwDBDateTimePicker11.text+''''; if wwDBDateTimePicker10.text<>''then str_fee:=str_fee+' and b.会计期间>='+''''+wwDBDateTimePicker10.text+''''; if wwDBDateTimePicker12.text<>''then str_fee:=str_fee+' and b.会计期间<='+''''+wwDBDateTimePicker12.text+''''; ComboBoxObjaire.Items.Clear; aQuery:=CreateAdoQuery; with aQuery do try Close;SQL.Clear; SQL.Add('Select distinct u.代码, u.客户简称'); SQL.Add('from t_ch_fee c'); SQL.Add('Left Join t_crm_client u on (u.客户简称=c.客户名称)'); SQL.Add(', t_op_aire b'); SQL.Add('where b.编号=c.编号 '); SQL.Add(str_fee); SQL.Add(' order by u.代码'); Open; First; while not Eof do begin ComboBoxObjaire.Items.Add(FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString); Next; end; finally Close; FreeAndNil(aQuery); end; end; procedure Tfra_ch_add_do.ComboBoxObjSeaiEnter(Sender: TObject); var str_fee:widestring; aQuery:TAdoQuery; begin //列客户名称 case strtoint(bs_text.text) of 1: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 7: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 2: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 3: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'收'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 4: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 6: begin str_fee:=' and ' +'(case c.类型 when '+''''+'收'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; // str_fee:=str_fee+' and 类型='+''''+'收'+''''; end; end; if Edit1.text<>''then str_fee:=str_fee+' and b.委托编号 like '+''''+'%'+Edit1.text+'%'+''''; if Edit5.text<>''then str_fee:=str_fee+' and b.主提单号 like '+''''+'%'+Edit5.text+'%'+''''; if Edit14.text<>''then str_fee:=str_fee+' and b.报检单号 like '+''''+'%'+Edit14.text+'%'+''''; if Edit6.text<>''then str_fee:=str_fee+' and b.'+Label6.Caption+' like '+''''+'%'+Edit6.text+'%'+''''; if wwDBDateTimePicker5.text<>''then str_fee:=str_fee+' and b.进口日期>='+''''+wwDBDateTimePicker5.text+''''; if wwDBDateTimePicker7.text<>''then str_fee:=str_fee+' and b.进口日期<='+''''+wwDBDateTimePicker7.text+''''; if wwDBDateTimePicker6.text<>''then str_fee:=str_fee+' and b.会计期间>='+''''+wwDBDateTimePicker6.text+''''; if wwDBDateTimePicker8.text<>''then str_fee:=str_fee+' and b.会计期间<='+''''+wwDBDateTimePicker8.text+''''; ComboBoxObjseai.Items.Clear; aQuery:=CreateAdoQuery; with aQuery do try Close;SQL.Clear; SQL.Add('Select distinct u.代码, u.客户简称'); SQL.Add('from t_ch_fee c'); SQL.Add('Left Join t_crm_client u on (u.客户简称=c.客户名称)'); SQL.Add(', t_op_seai b'); SQL.Add('where b.编号=c.编号 '); SQL.Add(str_fee); SQL.Add(' order by u.代码'); Open; First; while not Eof do begin ComboBoxObjseai.Items.Add(FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString); Next; end; finally Close; FreeAndNil(aQuery); end; end; procedure Tfra_ch_add_do.ComboBoxObjSeaeEnter(Sender: TObject); var str_fee:widestring; aQuery:TAdoQuery; begin //列客户名称 case strtoint(bs_text.text) of 1: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 7: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 2: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 3,8: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'收'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 4: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 6: begin str_fee:=' and ' +'(case c.类型 when '+''''+'收'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; // if not strtobool(get_parameters_value(46,'true')) then // str_fee:=str_fee+' and 类型='+''''+'收'+''''; end; end; if Edit4.text<>''then str_fee:=str_fee+' and b.委托编号 like '+''''+'%'+Edit4.text+'%'+''''; if Edit2.text<>''then str_fee:=str_fee+' and b.主提单号 like '+''''+'%'+Edit2.text+'%'+''''; if Edit13.text<>''then str_fee:=str_fee+' and b.报检单号 like '+''''+'%'+Edit13.text+'%'+''''; if Edit3.text<>''then str_fee:=str_fee+' and b.'+Label2.Caption+' like '+''''+'%'+Edit3.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+''''; ComboBoxObjseae.Items.Clear; aQuery:=CreateAdoQuery; with aQuery do try Close;SQL.Clear; SQL.Add('Select distinct u.代码, u.客户简称'); SQL.Add('from t_ch_fee c'); SQL.Add('Left Join t_crm_client u on (u.客户简称=c.客户名称)'); SQL.Add(', t_op_seae b'); SQL.Add('where b.编号=c.编号 '); SQL.Add(str_fee); SQL.Add(' order by u.代码'); Open; First; while not Eof do begin ComboBoxObjseae.Items.Add(FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString); Next; end; finally Close; FreeAndNil(aQuery); end; end; procedure Tfra_ch_add_do.dxDBGrid19DblClick(Sender: TObject); begin if EmpProfit then fee_view(v_op_bscard.fieldbyname('编号').asstring); end; procedure Tfra_ch_add_do.bsSkinCheckRadioBox5Click(Sender: TObject); begin bsSkinPanel13.Visible:=bsSkinCheckRadioBox6.Checked; end; procedure Tfra_ch_add_do.wwDBLookupCombo49KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinButton8Click(Sender); end; end; procedure Tfra_ch_add_do.dxDBGrid19Column22CustomDraw(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[dxDBGrid19Column22.Index])='更改单' then AColor:=clred; AFont.Color:=clblack; end; procedure Tfra_ch_add_do.RxDBLookupCombo14Enter(Sender: TObject); var str_fee,str_op:widestring; aQuery:TADOQuery; begin //列客户名称 case strtoint(bs_text.text) of 1: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 7: begin str_fee:=' and c.金额<>(c.开票金额+c.申请开票) and c.类型='+''''+'收'+'''' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 2: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 3,8: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'收'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 4: begin str_fee:=' and ' +'(case c.类型 when '+''''+'付'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) THEN (c.金额-c.开票金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.开票金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.开票金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and c.类型='+''''+'付'+''''; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; 6: begin str_fee:=' and ' +'(case c.类型 when '+''''+'收'+''''+' then (case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) THEN (c.金额-c.申请金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.申请金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.申请金额) end) end) ' +'else(case when c.金额>0 then ' +'(CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) THEN (c.金额-c.冲抵金额) ' +'ELSE (c.金额-c.结算金额) end) else (CASE WHEN (c.金额-c.结算金额)>(c.金额-c.冲抵金额) ' +'THEN (c.金额-c.结算金额) ELSE (c.金额-c.冲抵金额) end) end) ' +'end)<>0 ' +' and c.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and c.是否垫付<>1 '; end; end; if RxDBLookupCombo15.DisplayValues[1]<>''then str_fee:=str_fee+' and c.币别='+''''+RxDBLookupCombo15.DisplayValues[0]+''''; if RxDBLookupCombo16.DisplayValues[1]<>''then str_fee:=str_fee+' and c.费用名称='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; if Edit15.text<>''then str_fee:=str_fee+' and b.委托编号 like '+''''+'%'+Edit15.text+'%'+''''; if Edit16.text<>''then str_fee:=str_fee+' and b.主提单号 like '+''''+'%'+Edit16.text+'%'+''''; if Edit17.text<>''then str_fee:=str_fee+' and b.报检单号 like '+''''+'%'+Edit17.text+'%'+''''; if wwDBComboBox46.text<>''then str_fee:=str_fee+' and b.业务类型='+''''+wwDBComboBox46.text+''''; if Edit18.text<>''then str_fee:=str_fee+' and b.'+Label2.Caption+' like '+''''+'%'+Edit18.text+'%'+''''; case bsSkinComboBox2.ItemIndex of 0: begin if wwDBDateTimePicker17.text<>''then str_fee:=str_fee+' and b.开船日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_fee:=str_fee+' and b.开船日期<='+''''+wwDBDateTimePicker19.text+''''; end; 1: begin if wwDBDateTimePicker17.text<>''then str_fee:=str_fee+' and b.报关日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_fee:=str_fee+' and b.报关日期<='+''''+wwDBDateTimePicker19.text+''''; end; end; if wwDBDateTimePicker18.text<>''then str_fee:=str_fee+' and b.会计期间>='+''''+wwDBDateTimePicker18.text+''''; if wwDBDateTimePicker20.text<>''then str_fee:=str_fee+' and b.会计期间<='+''''+wwDBDateTimePicker20.text+''''; with t_ch_cust do begin Close;SQL.Clear; SQL.Add('Select distinct u.代码, u.客户简称'); SQL.Add('from t_ch_fee c'); 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 Tfra_ch_add_do.dxDBGrid19Column24CustomDraw(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[dxDBGrid19Column21.Index],ANode.Strings[dxDBGrid19Column24.Index]); AFont.Color:=clblack; end; procedure Tfra_ch_add_do.v_op_bscardBeforeScroll(DataSet: TDataSet); var amtDr,usdamtDr,amtcr,usdamtcr:Double; begin { if v_op_bscard.FieldByName('箱型10').AsInteger=1 then begin amtDr:=amtDr+v_op_bscard.FieldByName('未收RMB').AsFloat; usdamtDr:=usdamtDr+v_op_bscard.FieldByName('未收USD').AsFloat; amtcr:=amtcr+v_op_bscard.FieldByName('未付RMB').AsFloat; usdamtcr:=usdamtcr+v_op_bscard.FieldByName('未付USD').AsFloat; end else begin amtDr:=amtDr-v_op_bscard.FieldByName('未收RMB').AsFloat; usdamtDr:=usdamtDr-v_op_bscard.FieldByName('未收USD').AsFloat; amtcr:=amtcr-v_op_bscard.FieldByName('未付RMB').AsFloat; usdamtcr:=usdamtcr-v_op_bscard.FieldByName('未付USD').AsFloat; end; Label81.Caption:='未收RMB:'+FormatFloat('0.00;-0.00;0',amtDr)+'未收USD:'+FormatFloat('0.00;-0.00;0',usdamtDr); } end; procedure Tfra_ch_add_do.Edit34KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; v_op_bscard.Locate('主提单号',Trim(Edit34.text),[]); end; end; procedure Tfra_ch_add_do.bsSkinButton12Click(Sender: TObject); begin if v_op_bscard.RecordCount>0 then v_op_bscard.Locate('主提单号',Trim(Edit34.text),[]); end; procedure Tfra_ch_add_do.ComboBoxObjBsEnter(Sender: TObject); var aQuery:TADOQuery; begin ComboBoxObjBs.Items.Clear; aQuery:=CreateAdoQuery; with aQuery do try Close;SQL.Clear; SQL.Add('Select 代码,客户简称'); SQL.Add('From t_crm_client'); SQL.Add('where 客户性质<>''目标'' and 委托单位=1'); SQL.Add(' order by 代码'); Open; First; while not Eof do begin ComboBoxObjBs.Items.Add(FixLenStr(FieldByName('代码').AsString,10) +' '+FieldByName('客户简称').AsString); Next; end; finally Close; FreeAndNil(aQuery); end; end; procedure Tfra_ch_add_do.ComboBoxObjBsKeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinButton8Click(Sender); end; end; procedure Tfra_ch_add_do.N13Click(Sender: TObject); begin grid_save_xls(dxdbgrid19); end; procedure Tfra_ch_add_do.ComboBox1Enter(Sender: TObject); var AdoQuery1:TAdoQuery; begin ComboBox1.items.clear; AdoQuery1:=CreateAdoQuery; with AdoQuery1 do try Close;sql.Clear; SQL.Add('select * from t_sys_employee where 状态=''在职'''); SQL.Add('Order by 姓名'); Open;first; while not Eof do begin ComboBox1.Items.Add(AdoQuery1.fieldbyname('姓名').AsString); Next; end; finally Free; end; end; procedure Tfra_ch_add_do.dxDBGrid19SelectedCountChange(Sender: TObject); var i:Integer; str_fee,str_fee_I,fee_str:widestring; aAdoQuery:TAdoQuery; aAdoQuery1:TDataSource; absnos:string; begin if v_op_bscard.IsEmpty then exit; // if not GetCustID(acust) then exit; absnos:=''; if dxDBGrid19.SelectedCount>=1 then begin for i:=0 to dxDBGrid19.SelectedCount-1 do begin v_op_bscard.GotoBookmark(pointer(dxDBGrid19.selectedrows[i])); if absnos='' then absnos:=''''+v_op_bscard.fieldbyname('编号').AsString+'''' else absnos:=absnos+','+''''+v_op_bscard.fieldbyname('编号').AsString+''''; end; end else begin absnos:=''''+v_op_bscard.fieldbyname('编号').AsString+'''' end; // dxDBGrid19.ClearSelection; case strtoint(bs_text.text) of 1: //发票 begin if (strtobool(get_parameters_value(87,'false'))=true) then begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+')'; if Trim(Edit36.Text)<>'' then begin // fee_str:=fee_str+' and CH_ID in (select CH_ID from t_ch_fee_do where 工作编号='''+Trim(Edit36.Text)+''')'; fee_str:=fee_str+' and EXISTS (select 1 from t_ch_fee_do where t_ch_fee_do.CH_ID=t_ch_fee.CH_ID AND t_ch_fee_do.工作编号='''+Trim(Edit36.Text)+''')'; end; str_fee_I:='where t_ch_fee.金额<>(t_ch_fee.申请开票+t_ch_fee.开票金额) and t_ch_fee.不开发票<>1' +' and t_ch_fee.费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+')'; end else begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if Trim(Edit36.Text)<>'' then begin // fee_str:=fee_str+' and CH_ID in (select CH_ID from t_ch_fee_do where 工作编号='''+Trim(Edit36.Text)+''')'; fee_str:=fee_str+' and EXISTS (select 1 from t_ch_fee_do where t_ch_fee_do.CH_ID=t_ch_fee.CH_ID AND t_ch_fee_do.工作编号='''+Trim(Edit36.Text)+''')'; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; str_fee_I:=str_fee_I+' and t_ch_fee.类型='+''''+wwDBComboBox31.Text+''''; 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 (机密=0 or 机密 is null)'; str_fee_I:=str_fee_I+' and (t_ch_fee.机密=0 or t_ch_fee.机密 is null) '; end; end; end; 7: //发票申请 begin if (strtobool(get_parameters_value(87,'false'))=true) then begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+','+''''+'提交审核'+''''+','+''''+'提交复核'+''''+')'; end else begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; 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 (机密=0 or 机密 is null)'; end; end; end; 2: //业务支付申请 begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; 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 (机密=0 or 机密 is null)'; end; end; if strtobool(get_parameters_value(175,'false')) then str_fee:=str_fee+ ' and '+ open_data('7000','录入人','no','no','no','no'); end; 3,8: //3 应收费用结算 begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; 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 (机密=0 or 机密 is null)'; end; end; end; 4: //应付费用结算 begin str_fee:='where ' +'(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额))' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'付'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; 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 (机密=0 or 机密 is null)'; end; end; end; 6: //业务收费申请 2123 begin str_fee:='where ' +'(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额-冲抵金额) THEN (金额-申请金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额-冲抵金额) end) end) ' +'end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not strtobool(get_parameters_value(46,'true')) then str_fee:=str_fee+' and 类型='+''''+'收'+'''' else begin if (wwDBComboBox31.Text<>'') and (wwDBComboBox31.text<>'全部') then begin str_fee:=str_fee+' and 类型='+''''+wwDBComboBox31.Text+''''; end; end; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; 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 (机密=0 or 机密 is null)'; end; end; end; end; if acust_sum<>'' then begin str_fee:=str_fee+' and 客户名称='+''''+acust_sum+''''; str_fee_i:=str_fee_i+' and t_ch_fee.客户名称='+''''+acust_sum+''''; end; if RxDBLookupCombo15.DisplayValues[1]<>''then begin str_fee:=str_fee+' and 币别='+''''+RxDBLookupCombo15.DisplayValues[0]+''''; str_fee_i:=str_fee_i+' and t_ch_fee.币别='+''''+RxDBLookupCombo15.DisplayValues[0]+''''; end; if RxDBLookupCombo16.DisplayValues[1]<>''then begin str_fee:=str_fee+' and 费用名称='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; str_fee_I:=str_fee_I+' and t_ch_fee.费用名称='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; end; // showmessage(acust); // showmessage(str_fee); case strtoint(bs_text.text) of 1: //发票 begin if Trim(Edit36.Text)<>'' then begin if 1=1 then begin sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号 in ('+absnos+') group by 类型,币别 order by 类型,币别'; end else begin sum_str:=old_sum_str; end; end else begin if 1=1 then begin sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号 in ('+absnos+') group by 类型,币别 order by 类型,币别'; end else begin sum_str:=old_sum_str end; end; end; 7: //发票申请 begin if 1=1 then begin sum_str:='select 类型,币别,sum(金额) as 金额,sum(金额-开票金额-申请开票) as 未开金额 from v_ch_fee ' +str_fee+' and 编号 in ('+absnos+') group by 类型,币别 order by 类型,币别' end else begin sum_str:=old_sum_str; end; end; 2: //业务支付申请 begin if 1=1 then begin sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号 in ('+absnos+') group by 类型,币别 order by 类型,币别'; end else begin sum_str:=old_sum_str; end; end; 3: //3 应收费用结算 begin if 1=1 then begin sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号 in ('+absnos+') group by 类型,币别 order by 类型,币别'; end else begin sum_str:=old_sum_str; end; end; 4: // 应付费用结算 begin if 1=1 then begin sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号 in ('+absnos+') group by 类型,币别 order by 类型,币别'; end else begin sum_str:=old_sum_str; end; end; 6: //业务收费申请 begin if 1=1 then begin sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'收'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) ' +'THEN (金额-结算金额) ELSE (金额-申请金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未开金额 from v_ch_fee ' +str_fee+' and 编号 in ('+absnos+') group by 类型,币别 order by 类型,币别'; end else begin sum_str:=old_sum_str; end; end; 8: // 应收费用结算 begin if 1=1 then begin sum_str:='select 类型,币别,sum(金额) as 金额,sum(case 类型 when '+''''+'付'+''''+' then (case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) ' +'THEN (金额-结算金额) ELSE (金额-开票金额) end) end) ' +'else(case when 金额>0 then ' +'(CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) ' +'ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) ' +'THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) ' +'end) as 未结金额 from v_ch_fee ' +str_fee+' and 编号 in (select 编号 from v_op_bscard_all where 编号 in ('+absnos+')) group by 类型,币别 order by 类型,币别'; end else begin sum_str:=old_sum_str; end; end; end; if dxDBGrid19.SelectedCount>1 then begin t_ch_fee_sum_ttl.close; t_ch_fee_sum_ttl.sql.clear; t_ch_fee_sum_ttl.sql.add(sum_str); t_ch_fee_sum_ttl.open;t_ch_fee_sum_ttl.First; dxDBGrid20.DataSource:=t_ch_fee_sum_ttl1; end else begin dxDBGrid20.DataSource:=t_ch_fee_sum1; end; end; end.