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,ComObj,Variants; 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; dxDBGrid18: TdxDBGrid; dxDBGridColumn113: TdxDBGridColumn; dxDBGridMaskColumn45: TdxDBGridMaskColumn; dxDBGridColumn114: TdxDBGridColumn; dxDBGridColumn115: TdxDBGridColumn; dxDBGrid19: TdxDBGrid; dxDBGridMaskColumn47: TdxDBGridMaskColumn; dxDBGridMaskColumn50: TdxDBGridMaskColumn; dxDBGridDateColumn7: TdxDBGridDateColumn; dxDBGridColumn118: TdxDBGridColumn; dxDBGridMaskColumn52: TdxDBGridMaskColumn; dxDBGridMaskColumn56: TdxDBGridMaskColumn; dxDBGridMaskColumn57: TdxDBGridMaskColumn; v_op_bscard: TADOQuery; v_op_bscard1: TDataSource; 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; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinCheckRadioBox3: TbsSkinCheckRadioBox; bsSkinCheckRadioBox4: TbsSkinCheckRadioBox; bsSkinPanel12: TbsSkinPanel; bsSkinCheckRadioBox5: TbsSkinCheckRadioBox; bsSkinCheckRadioBox6: TbsSkinCheckRadioBox; bsSkinPanel13: TbsSkinPanel; Label77: TLabel; ComboBoxCurry: TComboBox; Label78: TLabel; Edit34: TEdit; 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; Label80: TLabel; Edit35: TEdit; Splitter1: TSplitter; dxDBGrid19Column26: TdxDBGridColumn; dxDBGrid19Column27: TdxDBGridColumn; dxDBGrid19Column28: TdxDBGridColumn; dxDBGrid19Column29: TdxDBGridColumn; dxDBGrid19Column30: TdxDBGridCheckColumn; kbmMemTable1: TkbmMemTable; bsSkinButton11: TbsSkinButton; bsSkinCheckRadioBox7: TbsSkinCheckRadioBox; bsSkinButton12: TbsSkinButton; dxDBGrid19Column31: TdxDBGridMaskColumn; Label81: TLabel; ComboBoxObjBs: TComboBox; N12: TMenuItem; N13: TMenuItem; Label82: TLabel; DBComboBoxEh2: TDBComboBoxEh; Label83: TLabel; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; bsSkinButton15: TbsSkinButton; bsSkinButton16: TbsSkinButton; dxDBGrid19Column14: TdxDBGridColumn; dxDBGrid19Column15: TdxDBGridColumn; lblSum: TLabel; lblSum1: TLabel; wwDBDateTimePicker21: TwwDBDateTimePicker; wwDBDateTimePicker22: TwwDBDateTimePicker; bsSkinLabel1: TbsSkinLabel; dxDBGrid19Column16: TdxDBGridColumn; bsSkinButton17: TbsSkinButton; OpenDialog1: TOpenDialog; kbmtblbs: TkbmMemTable; kbmtblbsOrdNo: TIntegerField; kbmtblbsMBLNO: TStringField; kbmtblbsAMT: TStringField; bsSkinButton18: TbsSkinButton; kbmbscard: TkbmMemTable; IntegerField1: TIntegerField; StringField1: TStringField; StringField2: TStringField; kbmbscardETD: TStringField; kbmbscardFeeName: TStringField; kbmbscardCURRENCY: TStringField; kbmbscardISOK: TBooleanField; SaveDialog1: TSaveDialog; PopupMenu3: TPopupMenu; N14: TMenuItem; N15: TMenuItem; N16: TMenuItem; kbmbscardUSDAMT: TStringField; kbmbscardFeeNames: TStringField; kbmbscardFee: TkbmMemTable; IntegerField2: TIntegerField; StringField3: TStringField; StringField9: TStringField; kbmbscardCTN: TStringField; kbmbscardDIFFAMT: TStringField; kbmbscardDIFFUSDAMT: TStringField; kbmbscardttl: TkbmMemTable; IntegerField3: TIntegerField; StringField4: TStringField; StringField8: TStringField; StringField11: TStringField; BooleanField1: TBooleanField; StringField13: TStringField; StringField14: TStringField; kbmbscardSALE: TStringField; kbmbscardOP: TStringField; kbmbscardttlOP: TStringField; kbmbscardttlSALE: TStringField; dxDBGrid19Column17: TdxDBGridColumn; dxDBGrid19Column18: TdxDBGridColumn; N17: TMenuItem; N18: TMenuItem; kbmVsl: TkbmMemTable; StringField5: TStringField; StringField6: TStringField; StringField20: TStringField; StringField21: TStringField; kbmVslVESSEL: TStringField; kbmVslVOY: TStringField; kbmVslFEESTATUS: TStringField; dxDBGrid19Column19: TdxDBGridColumn; dxDBGrid19Column20: TdxDBGridColumn; dxDBGrid17Column7: TdxDBGridColumn; Edit36: TEdit; Label84: TLabel; 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 bsSkinButton11Click(Sender: TObject); procedure bsSkinCheckRadioBox7Click(Sender: TObject); 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 DBComboBoxEh2DropDown(Sender: TObject); procedure dxDBGrid19Column30Change(Sender: TObject); procedure kbmMemTable1Field10Change(Sender: TField); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure dxDBGrid17SelectedCountChange(Sender: TObject); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinButton18Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure v_op_bscard1DataChange(Sender: TObject; Field: TField); procedure N18Click(Sender: TObject); private function GetCustID(var aCustID : String) : Boolean; //获取客户名称 function _GetCustID(var aCustID : String) : Boolean; //获取客户名称 Procedure ExportExcelFile(FileName: string; bWriteTitle: Boolean; aDataSet: TDataSet); { Private declarations } public { Public declarations } amtDr,usdDr,amtcr,usdcr:Double; mblNos,mblNosOK:WideString; Procedure balance_dms; Procedure balance_haier; Procedure expvsl; procedure update_tablesb(bs_text,sno:string;do_ban1:TDataSource;table:TADOQuery); end; var arXlsBegin: array[0..5] of Word = ($809, 8, 0, $10, 0,0); arXlsEnd: array[0..1] of Word = ($0A, 00); arXlsString: array[0..5] of Word = ($204, 0, 0, 0, 0, 0); arXlsNumber: array[0..4] of Word = ($203, 14, 0, 0, 0); arXlsInteger: array[0..4] of Word = ($27E, 10, 0, 0, 0); arXlsBlank: array[0..4] of Word = ($201, 6, 0, 0, $17); implementation uses u_main, my_sys_function, u_data_share, FindListu; {$R *.dfm} Procedure Tfra_ch_add_do.ExportExcelFile(FileName: string; bWriteTitle: Boolean; aDataSet: TDataSet); var i,j: integer; Col , row: word; ABookMark: TBookMark; aFileStream: TFileStream; procedure incColRow; //增加行列号 begin if Col = ADataSet.FieldCount - 1 then begin Inc(Row); Col :=0; end else Inc(Col); end; procedure WriteStringCell(AValue: string);//写字符串数据 var L: Word; begin L := Length(AValue); arXlsString[1] := 8 + L; arXlsString[2] := Row; arXlsString[3] := Col; arXlsString[5] := L; aFileStream.WriteBuffer(arXlsString, SizeOf (arXlsString)); aFileStream.WriteBuffer(Pointer(AValue)^, L); IncColRow; end; procedure WriteIntegerCell(AValue: integer);//写整数 var V: Integer; begin arXlsInteger[2] := Row; arXlsInteger[3] := Col; aFileStream.WriteBuffer(arXlsInteger, SizeOf(arXlsInteger)); V := (AValue shl 2) or 2; aFileStream.WriteBuffer(V, 4); IncColRow; end; procedure WriteFloatCell(AValue: double );//写浮点数 begin arXlsNumber[2] := Row; arXlsNumber[3] := Col; aFileStream.WriteBuffer(arXlsNumber, SizeOf(arXlsNumber)); aFileStream.WriteBuffer(AValue, 8); IncColRow; end; begin if FileExists(FileName) then DeleteFile(FileName); //文件存在,先删除 aFileStream := TFileStream.Create(FileName, fmCreate); Try //写文件头  aFileStream.WriteBuffer(arXlsBegin, SizeOf(arXlsBegin)); //写列头   Col := 0; Row := 0; if bWriteTitle then begin for i := 0 to aDataSet.FieldCount - 1 do WriteStringCell(aDataSet.Fields[i].FieldName); end; //写数据集中的数据    aDataSet.DisableControls; //ABookMark := aDataSet.GetBookmark; aDataSet.First ; while not aDataSet.Eof do begin for i := 0 to aDataSet.FieldCount - 1 do case ADataSet.Fields[i].DataType of ftSmallint, ftInteger, ftWord, ftAutoInc, ftBytes: WriteIntegerCell(aDataSet.Fields[i].AsInteger); ftFloat, ftCurrency, ftBCD: WriteFloatCell(StrToFloat(FormatFloat('0.00;-0.00;0',aDataSet.Fields[i].AsFloat))) else WriteStringCell(aDataSet.Fields[i].AsString); end; aDataSet.Next; Application.ProcessMessages; end; //写文件尾   AFileStream.WriteBuffer(arXlsEnd, SizeOf(arXlsEnd)); //if ADataSet.BookmarkValid(ABookMark) then aDataSet.GotoBookmark(ABookMark); Finally AFileStream.Free; ADataSet.EnableControls; 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)); 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 ComboBoxObjBsCard.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 ComboBoxObjBsCard.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; 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)+''')'; 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; begin Label83.Caption:=''; amtDr:=0; usdDr:=0; amtcr:=0; usdcr:=0; //业务列表加入 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 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,Edit19.text) else shen_yewwu(t_op_seae,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid2,i,j,Edit19.text); 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,Edit19.text) else shen_yewwu(t_op_seai,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid4,i,j,Edit19.text); 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,Edit19.text) else shen_yewwu(t_op_aire,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid7,i,j,Edit19.text); 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,Edit19.text) else shen_yewwu(t_op_airi,bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid10,i,j,Edit19.text); 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; // kbmMemTable1.DisableControls; try if dxDBGrid19.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 dxDBGrid19.SelectedCount-1 do begin kbmMemTable1.GotoBookmark(pointer(dxDBGrid19.selectedrows[f])); // v_op_bscard.GotoBookmark(pointer(dxDBGrid19.selectedrows[f])); if str='' then str:='编号='+''''+kbmMemTable1.fieldbyname('编号').AsString+'''' else str:=str+' or 编号='+''''+kbmMemTable1.fieldbyname('编号').AsString+'''' end; dxDBGrid19.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')) then // if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(TADOQuery(kbmMemTable1),bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,c,ComboBoxCurry.text,Edit19.text) //v_op_bscard else shen_yewwu(TADOQuery(kbmMemTable1),bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,Edit19.text); t_ch_fee_detail.close; v_op_bscard.close; v_op_bscard.open; kbmMemTable1.LoadFromDataSet(v_op_bscard,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]); end else begin if strtobool(get_parameters_value(83,'false')) then // if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(TADOQuery(kbmMemTable1),bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,c,ComboBoxCurry.text,Edit19.text) else shen_yewwu(TADOQuery(kbmMemTable1),bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,Edit19.text); t_ch_fee_detail.close; v_op_bscard.close; v_op_bscard.open; kbmMemTable1.LoadFromDataSet(v_op_bscard,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]); end; finally // kbmMemTable1.EnableControls; t_ch_fee.DataSource:=v_op_bscard1; t_ch_fee_sum.DataSource:=v_op_bscard1; end; end; t_rate.close; finally t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; Edit34.SetFocus; end; end; procedure Tfra_ch_add_do.MenuItem1Click(Sender: TObject); var i,j,c:integer; RE:boolean; begin Label83.Caption:=''; amtDr:=0; usdDr:=0; amtcr:=0; usdcr:=0; //费用列表加入 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 bsSkinPanel9.Visible then begin 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,Edit19.text) 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,Edit19.text); 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,Edit19.text) 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,Edit19.text); 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,Edit19.text) 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,Edit19.text); 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,Edit19.text) 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,Edit19.text); end; if bsSkinTabSheet5.Showing then begin delete_do_type_num:=5; if strtobool(get_parameters_value(83,'false')) then // 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,TADOQuery(kbmMemTable1),t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid17,i,j,c,ComboBoxCurry.text,Edit19.text) end else begin shen_fee_select(bs_text.text,TADOQuery(kbmMemTable1),t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,dxDBGrid17,i,j,Edit19.text); end; end; finally t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; Edit34.SetFocus; 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; } //Edit35.SetFocus; 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 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 7: begin str_fee:='where 金额<>(开票金额+申请开票) 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 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; if not bsSkinCheckRadioBox4.Checked then str_fee:=str_fee+' and 是否垫付<>1 '; end; 7: begin str_fee:='where 金额<>(开票金额+申请开票) 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 类型='+''''+'收'+'''' +' 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 类型='+''''+'收'+'''' +' 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; begin Label83.Caption:=''; amtDr:=0; usdDr:=0; amtcr:=0; usdcr:=0; //费用部分加入 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 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_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,Edit19.text) 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,Edit19.text); 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,Edit19.text) 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,Edit19.text); 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,Edit19.text) 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,Edit19.text); 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,Edit19.text) 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,Edit19.text); end; if bsSkinTabSheet5.Showing then begin delete_do_type_num:=5; if strtobool(get_parameters_value(83,'false')) then // 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,TADOQuery(kbmMemTable1),t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,c,ComboBoxCurry.text,Edit19.text) else shen_fee_select_fee_fen(bs_text.text,TADOQuery(kbmMemTable1),t_ch_fee,t_ch_fee_sum,t_ch_fee_do,t_rate,do_ban1,i,Edit19.text); end; finally t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; Edit34.SetFocus; end; end; procedure Tfra_ch_add_do.bsSkinButton8Click(Sender: TObject); var str_fee,str_op:widestring; op_str,fee_str,sum_str,Str_bill:widestring; Str,aCust,aCuster,sDate:String; nyear:Integer; begin Label83.Caption:=''; amtDr:=0; usdDr:=0; amtcr:=0; usdcr:=0; if (Edit34.Text<>'') or (Edit19.Text<>'') then begin kbmbscard.EmptyTable; kbmbscard.Open; kbmbscardFee.EmptyTable; kbmbscardFee.Open; end; // kbmMemTable1.FieldByName('箱型10').OnChange:=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; // if (bs_text.Text='') then bs_text.text:='1'; case strtoint(bs_text.text) of 1: //发票 begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' // str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1 and 类型='+''''+'收'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; 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 机密<>1 '; end; end; end; 7: //发票申请 begin str_fee:='where 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; 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 机密<>1 '; 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 机密<>1 '; end; end; { 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 ((金额>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 机密<>1 '; 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 机密<>1 '; end; end; 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:='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 机密<>1 '; 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 str_fee:=str_fee+' and 客户名称='+''''+acust+''''; if RxDBLookupCombo15.DisplayValues[1]<>''then str_fee:=str_fee+' and 币别='+''''+RxDBLookupCombo15.DisplayValues[0]+''''; if RxDBLookupCombo16.DisplayValues[1]<>''then str_fee:=str_fee+' and 费用名称='+''''+RxDBLookupCombo16.DisplayValues[1]+''''; if wwDBDateTimePicker21.text<>''then str_fee:=str_fee+' and 录入日期>='+''''+wwDBDateTimePicker21.text+''''; if wwDBDateTimePicker22.text<>''then str_fee:=str_fee+' and 录入日期<='+''''+wwDBDateTimePicker22.text+''''; if Trim(Edit36.Text)<>'' then begin str_fee:=str_fee+' and EXISTS (select 1 from t_ch_fee_do d left join t_ch_invoice i on (i.申请编号=d.工作编号) where t_ch_fee.CH_ID=d.CH_ID AND d.类型=1 and i.发票号码 ='''+Trim(Edit36.Text)+''')'; 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 DBComboBoxEh2.Text<>''then str_op:=str_op+' and v_op_bscard_all.来源明细='+''''+DBComboBoxEh2.Text+''''; if Mblnos<>'' then begin str_op:=str_op+' and v_op_bscard_all.主提单号 in ('+Mblnos+')'; end; 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 Edit18.text<>''then str_op:=str_op+' and v_op_bscard.'+Label2.Caption+' like '+''''+'%'+Edit18.text+'%'+''''; } 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+''''; 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(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)=7 then begin str_op:=str_op+' and v_op_bscard_all.费用状态 in(''费用封帐'',''提交财务'') '; 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 '+open_data('1002','揽货人','操作员','客服员','报关操作','报检操作'); sDate:=FormatDateTime('yyyy',Now); nyear:=StrToInt64Def(sDate,2019); nyear:=nyear+1; sDate:=inttostr(nyear)+'-'+'01'+'-'+'01'; str_op:=str_op+' and v_op_bscard_all.开船日期<'''+sDate+''''; 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,4: 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.批准文号 as 金额,v_op_bscard_all.批准文号 as USD,v_op_bscard_all.批准文号 as RMB' +',v_op_bscard_all.委托单位,v_op_bscard_all.经营单位,v_op_bscard_all.船公司,v_op_bscard_all.箱TEU' +',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 合计未收USD,t_op_gain.应收RMB-t_op_gain.已收RMB 合计未收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 ' +',' +'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 With(NoLock) '; 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+' Left Join t_op_gain t_op_gain on v_op_bscard_all.编号=t_op_gain.编号 '; 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.箱TEU' +',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' +' order by v_op_bscard_all.船名,v_op_bscard_all.航次,v_op_bscard_all.主提单号' // +default_sort(53,'v_op_bscard_all','','desc'); end; 1,7: 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.批准文号 as 金额' +',v_op_bscard_all.委托单位,v_op_bscard_all.经营单位,v_op_bscard_all.船公司,v_op_bscard_all.箱TEU' +',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 合计未收USD,t_op_gain.应收RMB-t_op_gain.已收RMB 合计未收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-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.申请开票-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.申请开票-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.申请开票-t_ch_fee.开票金额 else 0 end) ELSE 0 END ) as 未付RMB ' +' from v_op_bscard_all v_op_bscard_all With(NoLock) '; 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.申请开票+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.申请开票+t_ch_fee.开票金额) '; //金额<>(申请开票+开票金额) op_str:=op_str+' Left Join t_op_gain t_op_gain on v_op_bscard_all.编号=t_op_gain.编号 '; 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.箱TEU' +',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' +' order by v_op_bscard_all.船名,v_op_bscard_all.航次,v_op_bscard_all.主提单号' // +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.箱TEU' +',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 With(NoLock) '+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 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; 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(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'; 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: 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; kbmMemTable1.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; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; // kbmMemTable1.BeforeScroll:=kbmMemTable1BeforeScroll; kbmMemTable1.FieldByName('箱型10').OnChange:=kbmMemTable1Field10Change; try kbmMemTable1.DisableControls; if (kbmtblbs.Active) and (kbmtblbs.RecordCount>0) then begin kbmtblbs.First; while not kbmtblbs.Eof do begin if kbmMemTable1.Locate('主提单号',kbmtblbs.FieldByName('MBLNO').AsString,[]) then begin kbmMemTable1.Edit; kbmMemTable1.FieldByName('金额').AsString:=kbmtblbs.FieldByName('AMT').AsString; kbmMemTable1.Post; end; kbmtblbs.Next; end; end; finally kbmMemTable1.EnableControls; end; Edit34.SetFocus; 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 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 ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) ' +' 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 ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额))' +' 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 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+'%'+''''; if wwDBDateTimePicker17.text<>''then str_fee:=str_fee+' and b.开船日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_fee:=str_fee+' and b.开船日期<='+''''+wwDBDateTimePicker19.text+''''; 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 c.客户名称 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; 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:=''; Edit34.Text:=''; wwDBComboBox46.Text:=''; wwDBComboBox31.Text:=''; DBComboBoxEh2.Text:=''; Edit34.SetFocus; 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 fee_view(kbmMemTable1.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+'%'+''''; if wwDBDateTimePicker17.text<>''then str_fee:=str_fee+' and b.开船日期>='+''''+wwDBDateTimePicker17.text+''''; if wwDBDateTimePicker19.text<>''then str_fee:=str_fee+' and b.开船日期<='+''''+wwDBDateTimePicker19.text+''''; 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.bsSkinButton11Click(Sender: TObject); var i,j,c,f:integer; RE:Boolean; str,feestr,sumstr:widestring; begin Label83.Caption:=''; amtDr:=0; usdDr:=0; amtcr:=0; usdcr:=0; 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 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 bsSkinTabSheet5.Showing then begin delete_do_type_num:=5; kbmMemTable1.DisableControls; try if kbmMemTable1.RecordCount>=1 then begin t_ch_fee.DataSource:=t_op_bscard_all1; t_ch_fee_sum.DataSource:=t_op_bscard_all1; kbmMemTable1.First; while not kbmMemTable1.Eof do begin if kbmMemTable1.fieldbyname('箱型10').AsInteger=1 then begin if str='' then str:='编号='+''''+kbmMemTable1.fieldbyname('编号').AsString+'''' else str:=str+' or 编号='+''''+kbmMemTable1.fieldbyname('编号').AsString+'''' end; kbmMemTable1.Next; end; dxDBGrid19.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')) then // if ((strtobool(get_parameters_value(83,'false'))) and (bs_text.Text<>'1') and (bs_text.Text<>'7')) then shen_yewwusb(TADOQuery(kbmMemTable1),bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,c,ComboBoxCurry.text,Edit19.text) //v_op_bscard else shen_yewwu(TADOQuery(kbmMemTable1),bs_text.Text,t_ch_fee_detail,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j,Edit19.text); t_ch_fee_detail.close; v_op_bscard.close; v_op_bscard.open; kbmMemTable1.LoadFromDataSet(v_op_bscard,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]); 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) else shen_yewwu(v_op_bscard,bs_text.Text,t_ch_fee,t_ch_fee_do,t_rate,do_ban1,dxDBGrid19,i,j); 李俊平 屏蔽 如果没有被选择的数据就 不做处理 } end; finally kbmMemTable1.EnableControls; t_ch_fee.DataSource:=v_op_bscard1; t_ch_fee_sum.DataSource:=v_op_bscard1; end; end; finally t_rate.close; t_ch_fee.Requery(); t_ch_fee_sum.Requery(); t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; Edit34.SetFocus; { t_ch_fee.EnableControls; t_ch_fee_sum.EnableControls; } end; /// end; procedure Tfra_ch_add_do.bsSkinCheckRadioBox7Click(Sender: TObject); begin if bsSkinCheckRadioBox7.Checked then begin with kbmMemTable1 do try DisableControls; First; while not Eof do begin Edit; FieldByName('箱型10').AsInteger:=1; Next; end; finally First; EnableControls; end; end else with kbmMemTable1 do try DisableControls; First; while not Eof do begin Edit; FieldByName('箱型10').AsInteger:=0; Next; end; finally First; EnableControls; end; end; procedure Tfra_ch_add_do.Edit34KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; kbmMemTable1.Locate('主提单号',Trim(Edit34.text),[]); end; end; procedure Tfra_ch_add_do.bsSkinButton12Click(Sender: TObject); var RecNoList: TStringList; begin with kbmMemTable1 do try DisableControls; //加这个语句可以明显提高循环效率,原因请自己查 First; While not Eof do begin if pos(trim(Edit34.text),FieldByName('主提单号').AsString)>0 then begin Break; end; Next; end; finally EnableControls; end; 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.DBComboBoxEh2DropDown(Sender: TObject); var AdoQuery1:TAdoQuery; begin AdoQuery1:=CreateAdoQuery; with AdoQuery1 do try Close; sql.Clear; SQL.Add('select distinct 来源明细 from v_op_bscard_ALL where 来源明细<>'''''); Open; first; DBComboBoxEh2.Items.Clear; while not AdoQuery1.Eof do begin DBComboBoxEh2.Items.Add(fieldbyname('来源明细').AsString); Next; end; finally Free; end; end; procedure Tfra_ch_add_do.dxDBGrid19Column30Change(Sender: TObject); var amtdr,usddr,amtcr,usdcr:Double; s:string; begin { try kbmMemTable1.DisableControls; with kbmMemTable1 do begin First; while not eof do begin if kbmMemTable1.FieldByName('箱型10').AsString='T' then begin amtdr:=amtdr+FieldByName('未收RMB').AsFloat; usddr:=usddr+FieldByName('未收USD').AsFloat; amtcr:=amtcr++FieldByName('未付RMB').AsFloat; usdcr:=usdcr++FieldByName('未付USD').AsFloat; end; Next; end; end; finally kbmMemTable1.EnableControls; Label83.Caption:='未收RMB:'+FormatFloat(';;',amtdr)+' 未收USD:'+FormatFloat(';;',usddr)+' 未付RMB:'+FormatFloat(';;',amtcr)+' 未付USD:'+FormatFloat(';;',usdcr); end; } end; procedure Tfra_ch_add_do.kbmMemTable1Field10Change(Sender: TField); begin if kbmMemTable1.FieldByName('箱型10').AsInteger=1 then begin amtDr:=amtDr+kbmMemTable1.FieldByName('未收RMB').AsFloat; usdDr:=usdDr+kbmMemTable1.FieldByName('未收USD').AsFloat; amtcr:=amtcr+kbmMemTable1.FieldByName('未付RMB').AsFloat; usdcr:=usdcr+kbmMemTable1.FieldByName('未付USD').AsFloat; end else begin amtDr:=amtDr-kbmMemTable1.FieldByName('未收RMB').AsFloat; usdDr:=usdDr-kbmMemTable1.FieldByName('未收USD').AsFloat; amtcr:=amtcr-kbmMemTable1.FieldByName('未付RMB').AsFloat; usdcr:=usdcr-kbmMemTable1.FieldByName('未付USD').AsFloat; end; Label83.Caption:='收RMB:'+FormatFloat('0.00;-0.00;0',amtdr)+' 收USD:'+FormatFloat('0.00;-0.00;0',usddr)+' 付RMB:'+FormatFloat('0.00;-0.00;0',amtcr)+' 付USD:'+FormatFloat('0.00;-0.00;0',usdcr); end; procedure Tfra_ch_add_do.bsSkinButton13Click(Sender: TObject); begin with kbmMemTable1 do try DisableControls; First; while not Eof do begin Edit; FieldByName('箱型10').AsInteger:=1; Next; end; finally First; EnableControls; Edit34.SetFocus; end; end; procedure Tfra_ch_add_do.bsSkinButton14Click(Sender: TObject); begin with kbmMemTable1 do try DisableControls; First; while not Eof do begin Edit; FieldByName('箱型10').AsInteger:=0; Next; end; finally First; EnableControls; Edit34.SetFocus; end; end; procedure Tfra_ch_add_do.bsSkinButton16Click(Sender: TObject); begin ComboBoxObjBsCard.SetFocus; end; procedure Tfra_ch_add_do.bsSkinButton15Click(Sender: TObject); begin Edit34.SetFocus; end; procedure Tfra_ch_add_do.dxDBGrid17SelectedCountChange(Sender: TObject); var i,k:integer; DR,CR,USDDR,USDCR,NDR,NCR,NUSDDR,NUSDCR,OTDR,OTCR,NOTDR,NOTCR:Double; begin case strtoint(bs_text.text) of 3,4 : begin DR:=0; CR:=0; USDDR:=0; USDCR:=0; NDR:=0; NCR:=0; NUSDDR:=0; NUSDCR:=0; OTDR:=0; OTCR:=0; NOTDR:=0; NOTCR:=0; if t_ch_fee.IsEmpty then exit; if dxDBGrid17.SelectedCount>=1 then begin for i:=0 to dxDBGrid17.SelectedCount-1 do begin t_ch_fee.GotoBookmark(pointer(dxDBGrid17.selectedrows[i])); if t_ch_fee.FieldByName('币别').AsString='USD' then begin if t_ch_fee.FieldByName('类型').AsString='收' then begin USDDR:=USDDR+t_ch_fee.fieldByName('金额').AsFloat; NUSDDR:=NUSDDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin USDCR:=USDCR+t_ch_fee.fieldByName('金额').AsFloat; NUSDCR:=NUSDCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end else if t_ch_fee.FieldByName('币别').AsString='RMB' then begin if t_ch_fee.FieldByName('类型').AsString='收' then begin DR:=DR+t_ch_fee.fieldByName('金额').AsFloat; NDR:=NDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin CR:=CR+t_ch_fee.fieldByName('金额').AsFloat; NCR:=NCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end else begin if t_ch_fee.FieldByName('类型').AsString='收' then begin OTDR:=OTDR+t_ch_fee.fieldByName('金额').AsFloat; NOTDR:=NOTDR+t_ch_fee.fieldByName('未结金额').AsFloat; end else begin OTCR:=OTCR+t_ch_fee.fieldByName('金额').AsFloat; NOTCR:=NOTCR+t_ch_fee.fieldByName('未结金额').AsFloat; end; end; end; end; lblSum.Caption:='收USD:'+FormatFloat('#,##,0.00;-0.00',NUSDDR)+';付USD:'+FormatFloat('#,##,0.00;-0.00',NUSDCR); lblSum1.Caption:='收RMB:'+FormatFloat('#,##,0.00;-0.00',NDR)+';付RMB:'+FormatFloat('#,##,0.00;-0.00',NCR); end; end; end; procedure Tfra_ch_add_do.bsSkinButton17Click(Sender: TObject); var Ext,adate,bsno,corp,vslvoy:String; ExcelTemplet:Variant; i,j:integer; M,D,Y:Word; imp:boolean; begin kbmtblbs.EmptyTable; kbmtblbs.Open; if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); try kbmtblbs.DisableControls; ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); imp:=true; if imp then begin I:=2; while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)<>'' do begin if Mblnos='' then Mblnos:=''''+VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)+'''' else Mblnos:=Mblnos+','+''''+VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)+''''; kbmtblbs.Insert; kbmtblbs.FieldByName('OrdNo').AsInteger:=i; kbmtblbs.FieldByName('MBLNO').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value); kbmtblbs.FieldByName('AMT').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value); kbmtblbs.Post; i:=i+1; end; end; finally kbmtblbs.EnableControls; ExcelTemplet.DisplayAlerts := false;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 end; end; end; try if Mblnos<>'' then bsSkinButton8Click(Sender); finally Mblnos:=''; kbmtblbs.EmptyTable; end; end; procedure Tfra_ch_add_do.update_tablesb(bs_text,sno:string;do_ban1:TDataSource;table:TADOQuery); var aQuery:TAdoQuery; sumnum,sumnumusd:real; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 金额,类型,收付类型,币别 from v_fee_do_dc where 工作编号='''+sno+''''); Open; if Recordset.RecordCount=0 then begin case strtoint(bs_text) of 1,7: begin do_ban1.DataSet.edit; do_ban1.DataSet.fieldbyname('实际金额').AsFloat:=0; if 1=1 then begin if do_ban1.DataSet['币别']='USD' then do_ban1.DataSet.fieldbyname('费用列表').asstring:=get_parameters_value(7,'代理海运费') else do_ban1.DataSet.fieldbyname('费用列表').asstring:=get_parameters_value(147,'代理运杂费'); do_ban1.DataSet.fieldbyname('金额列表').asstring:=floattostr(do_ban1.DataSet['实际金额']); end; if 1=1 then begin try do_ban1.DataSet.fieldbyname('提单号').asstring:=table.fieldbyname('主提单号').asstring; do_ban1.DataSet.fieldbyname('委托编号').asstring:=table.fieldbyname('委托编号').asstring; do_ban1.DataSet.fieldbyname('开船日期').asstring:=table.fieldbyname('开船日期').asstring; do_ban1.DataSet.fieldbyname('启运港').asstring:=table.fieldbyname('装货港').asstring; do_ban1.DataSet.fieldbyname('卸货港').asstring:=table.fieldbyname('卸货港').asstring; do_ban1.DataSet.fieldbyname('目的港').asstring:=table.fieldbyname('卸货港').asstring; do_ban1.DataSet.fieldbyname('船名航次').asstring:=table.fieldbyname('船名').asstring+' '+table.fieldbyname('航次').asstring; except ; end; end; do_ban1.DataSet.post; end; end; end else begin sumnum:=0; sumnumusd:=0; first; while not eof do begin sumnum:=sumnum+fieldbyname('金额').asfloat; Next; end; case strtoint(bs_text) of 1,7: begin do_ban1.DataSet.edit; do_ban1.DataSet.fieldbyname('实际金额').asFloat:=sumnum; if 1=1 then begin if do_ban1.DataSet.fieldbyname('币别').asstring='USD' then do_ban1.DataSet.fieldbyname('费用列表').asstring:=get_parameters_value(7,'代理海运费') else do_ban1.DataSet.fieldbyname('费用列表').asstring:=get_parameters_value(147,'代理运杂费'); do_ban1.DataSet.fieldbyname('金额列表').asstring:=floattostr(do_ban1.DataSet['实际金额']); end; if 1=1 then begin try do_ban1.DataSet.fieldbyname('提单号').asstring:=table.fieldbyname('主提单号').asstring; do_ban1.DataSet.fieldbyname('委托编号').asstring:=table.fieldbyname('委托编号').asstring; do_ban1.DataSet.fieldbyname('开船日期').asstring:=table.fieldbyname('开船日期').asstring; do_ban1.DataSet.fieldbyname('启运港').asstring:=table.fieldbyname('装货港').asstring; do_ban1.DataSet.fieldbyname('卸货港').asstring:=table.fieldbyname('卸货港').asstring; do_ban1.DataSet.fieldbyname('目的港').asstring:=table.fieldbyname('卸货港').asstring; do_ban1.DataSet.fieldbyname('船名航次').asstring:=table.fieldbyname('船名').asstring+' '+table.fieldbyname('航次').asstring; except ; end; end; do_ban1.DataSet.post; end; end; end; end; finally FreeAndNil(aQuery); end; end; Procedure Tfra_ch_add_do.balance_dms; var Ext,adate,bsno,corp,vslvoy,s:String; ExcelTemplet:Variant; i,j:integer; M,D,Y:Word; imp:boolean; aAdoQuery,aAdoQueryInsert:TAdoQuery; book1:Tbookmark; begin kbmbscard.EmptyTable; kbmbscard.Open; kbmbscardFee.EmptyTable; kbmbscardFee.Open; if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); try kbmbscard.DisableControls; ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); imp:=true; if imp then begin I:=2; while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)<>'' do begin if Mblnos='' then Mblnos:=''''+VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)+'''' else Mblnos:=Mblnos+','+''''+VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)+''''; kbmbscard.Insert; kbmbscard.FieldByName('OrdNo').AsInteger:=i; kbmbscard.FieldByName('MBLNO').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value); if not kbmbscardFee.Locate('MBLNO',VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value),[]) then begin kbmbscardFee.Insert; kbmbscardFee.FieldByName('MBLNO').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value); kbmbscardFee.Post; end; // showmessage(kbmbscard.FieldByName('MBLNO').AsString); kbmbscard.FieldByName('Etd').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value); kbmbscard.FieldByName('FeeName').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,5].Value); kbmbscard.FieldByName('AMT').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,6].Value); if VartoStr(ExcelTemplet.ActiveSheet.Cells[I,7].Value)='CNY' then kbmbscard.FieldByName('CURRENCY').AsString:='RMB' else kbmbscard.FieldByName('CURRENCY').AsString:=VartoStr(ExcelTemplet.ActiveSheet.Cells[I,7].Value); kbmbscard.FieldByName('ISOK').AsBoolean:=False; kbmbscard.Post; i:=i+1; end; end; finally kbmbscard.EnableControls; ExcelTemplet.DisplayAlerts := true;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 end; end; end; S:=do_ban1.DataSet.FieldByName('客户名称').asstring; aAdoQuery:=CreateAdoQuery; aAdoQueryInsert:=CreateAdoQuery; aAdoQueryInsert.Close; aAdoQueryInsert.SQL.Clear; aAdoQueryInsert.SQL.Add(' Insert Into t_ch_fee_do ( 工作编号 ,业务编号 ,CH_ID ,币别 ,金额,原始金额,类型)'); aAdoQueryInsert.SQL.Add(' values ( :工作编号 ,:业务编号,:CH_ID,:币别,:金额,:原始金额,:类型)'); with aAdoQuery do try Close;sql.clear; sql.add('Select t_op_seae.编号,t_op_seae.主提单号,委托编号,装货港,卸货港,船名,航次,t_op_seae.开船日期'); sql.add(', t_ch_fee.CH_ID,t_ch_fee.客户名称,(t_ch_fee.金额-t_ch_fee.开票金额-t_ch_fee.申请开票) 金额,t_ch_fee.币别,'); sql.add('case'); sql.add('when t_ch_fee.费用名称 in (''美国舱单费'',''欧洲反恐入境摘要舱单费'',''欧盟反恐入境摘要仓单费'',''船公司舱单费'') then ''舱单费'''); sql.add('else case when t_ch_fee.费用名称=''CFS费'' then ''场站费'''); sql.add(' else t_ch_fee.费用名称'); sql.add(' end'); sql.add('end 费用名称'); sql.add('from t_op_seae '); sql.add('Left Join t_ch_fee on t_op_seae.编号=t_ch_fee.编号'); sql.add('where 主提单号 in('+Mblnos+')'); sql.add('and t_ch_fee.客户名称='+''''+s+''''); sql.add('and 业务类型=''普通货'''); case strtoint(bs_text.text) of 7: begin sql.add('and t_ch_fee.金额<>(t_ch_fee.申请开票+t_ch_fee.开票金额)'); sql.add(' and t_ch_fee.费用状态 in (''审核通过'',''部分结算'',''结算完毕'',''禁止删除'',''禁止修改'') and t_ch_fee.类型=''收'' '); { sDate:=FormatDateTime('YYYY',Now); nyear:=StrToInt64(sDate); nyear:=nyear+1; sDate:=inttostr(nyear)+'-'+'01'+'01'; str_op:=str_op+' and v_op_bscard_all.开船日期<'''+sDate+''''; sql.add(' and t_ch_fee.金额<>(t_ch_fee.申请开票+t_ch_fee.开票金额)'); } end; 3: begin sql.add('and '); sql.add('(case 类型 when ''付'' then (case when 金额>0 then '); sql.add('(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) '); sql.add(' ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) '); sql.add(' THEN (金额-结算金额) ELSE (金额-开票金额) end) end) '); sql.add(' else(case when 金额>0 then '); sql.add(' (CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) '); sql.add(' ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) '); sql.add(' THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) '); sql.add('end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) '); sql.add(' and t_ch_fee.费用状态 in (''审核通过'',''部分结算'',''结算完毕'',''禁止删除'',''禁止修改'') and t_ch_fee.类型=''收'' '); end; 4: begin sql.add('and '); sql.add('(case 类型 when ''付'' then (case when 金额>0 then '); sql.add('(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) '); sql.add(' ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) '); sql.add(' THEN (金额-结算金额) ELSE (金额-开票金额) end) end) '); sql.add(' else(case when 金额>0 then '); sql.add(' (CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) '); sql.add(' ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) '); sql.add(' THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) '); sql.add('end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) '); sql.add(' and t_ch_fee.费用状态 in (''审核通过'',''部分结算'',''结算完毕'',''禁止删除'',''禁止修改'') and t_ch_fee.类型=''付'' '); end end; open;First; while not Eof do begin if kbmbscard.Locate('MBLNO;FeeName;AMT;CURRENCY;ISOK',vararrayof([trim(FieldByName('主提单号').AsString),FieldByName('费用名称').AsString,FieldByName('金额').AsString,FieldByName('币别').AsString,false]),[]) then begin kbmbscard.Edit; kbmbscard.FieldByName('ISOK').AsBoolean:=true; kbmbscard.Post; aAdoQueryInsert.Close; aAdoQueryInsert.Parameters.ParamByName('工作编号').Value:=do_ban1.DataSet.FieldByName('申请编号').asstring; aAdoQueryInsert.Parameters.ParamByName('业务编号').Value:=FieldByName('编号').AsString; aAdoQueryInsert.Parameters.ParamByName('CH_ID').Value:=FieldByName('CH_ID').AsInteger; aAdoQueryInsert.Parameters.ParamByName('币别').Value:=FieldByName('币别').AsString; aAdoQueryInsert.Parameters.ParamByName('金额').Value:=FieldByName('金额').AsFloat; aAdoQueryInsert.Parameters.ParamByName('原始金额').Value:=FieldByName('金额').AsFloat; aAdoQueryInsert.Parameters.ParamByName('类型').Value:=7; aAdoQueryInsert.ExecSQL; update_tablesb('7',do_ban1.DataSet.FieldByName('申请编号').asstring,do_ban1,aAdoQuery); end; Next; end; finally Free; end; SaveDialog1.FileName:='balance_dms'; if SaveDialog1.Execute then begin ExportExcelFile(SaveDialog1.FileName+'.xls',true,TDataSet(kbmbscard)); end else begin end; Mblnos:=''; Mblnos:=MblnosOk; try // if Mblnos<>'' then // bsSkinButton8Click(bsSkinButton8); finally Mblnos:=''; kbmbscard.EmptyTable; do_ban1.DataSet.ReFresh; book1:=do_ban1.DataSet.GetBookmark; TADOQuery(do_ban1.DataSet).Requery; do_ban1.DataSet.GotoBookmark(book1); end; end; Procedure Tfra_ch_add_do.balance_haier; var Ext,adate,bsno,corp,vslvoy,s:String; ExcelTemplet:Variant; i,j:integer; M,D,Y:Word; imp:boolean; aAdoQuery:TAdoQuery; begin if Trim(ComboBoxObjBsCard.Text)='' then begin ShowMessage('请先选择客户名称'); exit; end; kbmbscardttl.EmptyTable; kbmbscardttl.Open; if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); try kbmbscardttl.DisableControls; ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); imp:=true; if imp then begin I:=2; while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)<>'' do begin if Mblnos='' then Mblnos:=''''+Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value))+'''' else Mblnos:=Mblnos+','+''''+Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value))+''''; kbmbscardttl.Insert; kbmbscardttl.FieldByName('OrdNo').AsInteger:=i; kbmbscardttl.FieldByName('MBLNO').AsString:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)); if VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value)<>'' then kbmbscardttl.FieldByName('AMT').AsString:=FormatFloat('0.00;-0.00;0.00',StrtoFloat(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,3].Value))) else kbmbscardttl.FieldByName('AMT').AsString:='0.00'; if VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)<>'' then kbmbscardttl.FieldByName('USDAMT').AsString:=FormatFloat('0.00;-0.00;0.00',StrtoFloat(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value))) else kbmbscardttl.FieldByName('USDAMT').AsString:='0.00'; kbmbscardttl.FieldByName('ISOK').AsBoolean:=False; kbmbscardttl.Post; i:=i+1; end; end; finally kbmbscardttl.EnableControls; ExcelTemplet.DisplayAlerts := true;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 end; end; end; S:=Trim(ComboBoxObjBsCard.Text); if (S<>'') and (length(S)>10) then s:=Trim(Copy(S,11,length(S)-10)); aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;sql.clear; sql.add('Select t_op_seae.主提单号,t_op_seae.操作员,t_op_seae.揽货人'); case strtoint(bs_text.text) of 7: begin sql.add(', SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.开票金额-t_ch_fee.申请开票 else 0 end) ELSE 0 END ) as 金额 '); sql.add(','); sql.add('SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.开票金额-t_ch_fee.申请开票 else 0 end) ELSE 0 END) as 美元金额 '); end; 3: begin sql.add(', 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 金额 '); sql.add(','); sql.add('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 美元金额 '); end; 4: begin sql.add(', 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 金额 '); sql.add(','); sql.add('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 美元金额 '); end; end; sql.add('from t_op_seae '); sql.add('Left Join t_ch_fee on t_op_seae.编号=t_ch_fee.编号'); sql.add('where 主提单号 in('+Mblnos+')'); sql.add('and t_ch_fee.客户名称='+''''+s+''''); case strtoint(bs_text.text) of 7: begin sql.add('and t_ch_fee.金额<>(t_ch_fee.申请开票+t_ch_fee.开票金额)'); sql.add(' and t_ch_fee.费用状态 in (''审核通过'',''部分结算'',''结算完毕'',''禁止删除'',''禁止修改'') and t_ch_fee.类型=''收'' '); end; 3: begin sql.add('and '); sql.add('(case 类型 when ''付'' then (case when 金额>0 then '); sql.add('(CASE WHEN (金额-结算金额)>(金额-开票金额) THEN (金额-开票金额) '); sql.add(' ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-开票金额) '); sql.add(' THEN (金额-结算金额) ELSE (金额-开票金额) end) end) '); sql.add(' else(case when 金额>0 then '); sql.add(' (CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) '); sql.add(' ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) '); sql.add(' THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) '); sql.add('end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) '); sql.add(' and t_ch_fee.费用状态 in (''审核通过'',''部分结算'',''结算完毕'',''禁止删除'',''禁止修改'') and t_ch_fee.类型=''收'' '); end; 4: begin sql.add('and '); sql.add('(case 类型 when ''付'' then (case when 金额>0 then '); sql.add('(CASE WHEN (金额-结算金额)>(金额-申请金额) THEN (金额-申请金额) '); sql.add(' ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-申请金额) '); sql.add(' THEN (金额-结算金额) ELSE (金额-申请金额) end) end) '); sql.add(' else(case when 金额>0 then '); sql.add(' (CASE WHEN (金额-结算金额)>(金额-冲抵金额) THEN (金额-冲抵金额) '); sql.add(' ELSE (金额-结算金额) end) else (CASE WHEN (金额-结算金额)>(金额-冲抵金额) '); sql.add(' THEN (金额-结算金额) ELSE (金额-冲抵金额) end) end) '); sql.add('end)<>0 and ((金额>0 and 金额>=结算金额) or (金额<0 and 金额<=结算金额)) '); sql.add(' and t_ch_fee.费用状态 in (''审核通过'',''部分结算'',''结算完毕'',''禁止删除'',''禁止修改'') and t_ch_fee.类型=''付'' '); end end; sql.add('Group by t_op_seae.主提单号,t_op_seae.操作员,t_op_seae.揽货人'); // showmessage(SQL.Text); open;First; while not Eof do begin if kbmbscardttl.Locate('MBLNO;AMT;USDAMT',vararrayof([FieldByName('主提单号').AsString,FormatFloat('0.00;-0.00;0.00',FieldByName('金额').AsFloat),FormatFloat('0.00;-0.00;0.00',FieldByName('美元金额').AsFloat)]),[]) then begin if MblnosOk='' then MblnosOk:=''''+FieldByName('主提单号').AsString+'''' else MblnosOk:=MblnosOk+','+''''+FieldByName('主提单号').AsString+''''; kbmbscardttl.Edit; kbmbscardttl.FieldByName('ISOK').AsBoolean:=true; kbmbscardttl.FieldByName('OP').AsString:=FieldByName('操作员').AsString; kbmbscardttl.FieldByName('SALE').AsString:=FieldByName('揽货人').AsString; kbmbscardttl.Post; end else if kbmbscardttl.Locate('MBLNO',FieldByName('主提单号').AsString,[]) then begin kbmbscardttl.Edit; kbmbscardttl.FieldByName('DIFFAMT').AsString:=FormatFloat('0.00;-0.00;0.00',FieldByName('金额').AsFloat); kbmbscardttl.FieldByName('DIFFUSDAMT').AsString:=FormatFloat('0.00;-0.00;0.00',FieldByName('美元金额').AsFloat); kbmbscardttl.FieldByName('OP').AsString:=FieldByName('操作员').AsString; kbmbscardttl.FieldByName('SALE').AsString:=FieldByName('揽货人').AsString; kbmbscardttl.Post; end; Next; end; finally Free; end; SaveDialog1.FileName:='balance_cy'; if SaveDialog1.Execute then begin ExportExcelFile(SaveDialog1.FileName+'.xls',true,TDataSet(kbmbscardttl)); end else begin end; Mblnos:=''; Mblnos:=MblnosOk; try if Mblnos<>'' then bsSkinButton8Click(bsSkinButton8); finally Mblnos:=''; kbmbscardttl.EmptyTable; end; end; procedure Tfra_ch_add_do.bsSkinButton18Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton18.ClientToScreen(Point(0,bsSkinButton18.Height)); PopupMenu3.Popup(Pnt.x,Pnt.y); end; procedure Tfra_ch_add_do.N14Click(Sender: TObject); begin if bs_text.text<>'7' then begin ShowMessage('只有发票申请 才可以使用该功能'); exit; end; if bs_text.text='7' then begin if do_ban1.DataSet.FieldByName('客户名称').asstring='' then begin ShowMessage('请先选择客户名称'); end; if do_ban1.DataSet.FieldByName('申请编号').asstring='' then begin ShowMessage('请先保存申请'); end; end; balance_dms; end; procedure Tfra_ch_add_do.N16Click(Sender: TObject); begin balance_haier; end; procedure Tfra_ch_add_do.v_op_bscard1DataChange(Sender: TObject;Field: TField); var fee_str,str_fee,sum_str:string; begin { //showmessage(v_op_bscard1.DataSet.FieldByName('主提单号').AsString); if bs_text.text='7' then begin t_ch_fee.DataSource:=nil; // t_ch_fee_sum.DataSource:=nil; try if kbmbscardFee.Active then begin if kbmbscardFee.Locate('MBLNO',v_op_bscard1.DataSet.FieldByName('主提单号').AsString,[]) then 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 ' +' where 编号='+''''+v_op_bscard1.DataSet.FieldByName('编号').AsString+'''' +'and 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')' +' and 类型='+''''+'收'+'''' ; if kbmbscardFee.FieldByName('FeeNames').AsString<>'' then begin fee_str:=fee_str+' and 费用名称 in ('+kbmbscardFee.FieldByName('FeeNames').AsString+')'; 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 ' +' where 编号='+''''+v_op_bscard1.DataSet.FieldByName('编号').AsString+'''' +'and 金额<>(申请开票+开票金额) and 不开发票<>1' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')' +' and 类型='+''''+'收'+'''' ; if kbmbscardFee.FieldByName('FeeNames').AsString<>'' then begin sum_str:=sum_str+' and 费用名称 in ('+kbmbscardFee.FieldByName('FeeNames').AsString+')'; end; sum_str:=sum_str+' group by 类型,币别 order by 类型,币别'; t_ch_fee.Close; t_ch_fee.sql.clear; t_ch_fee.sql.add(fee_str); t_ch_fee.open; { t_ch_fee_sum.Close; t_ch_fee_sum.sql.clear; t_ch_fee_sum.sql.add(sum_str); t_ch_fee_sum.open; end; end; finally t_ch_fee.DataSource:=v_op_bscard1; // t_ch_fee_sum.DataSource:=v_op_bscard1; end; end; } end; procedure Tfra_ch_add_do.expvsl; var Ext,adate,bsno,corp,vslvoy,s:String; ExcelTemplet:Variant; i,j:integer; M,D,Y:Word; imp:boolean; aAdoQuery:TAdoQuery; begin kbmVsl.EmptyTable; kbmVsl.Open; if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); aAdoQuery:=CreateAdoQuery; try kbmVsl.DisableControls; ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); imp:=true; if imp then begin I:=2; while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)<>'' do begin if Mblnos='' then Mblnos:=''''+Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value))+'''' else Mblnos:=Mblnos+','+''''+Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value))+''''; kbmVsl.Insert; kbmVsl.FieldByName('MBLNO').AsString:=Trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)); aAdoQuery.close; aAdoQuery.SQL.Text:='select 船名,航次,操作员,揽货人,开船日期,费用状态 from t_op_seae where 主提单号='''+kbmVsl.FieldByName('MBLNO').AsString+''' AND 业务类型=''普通货'' '; aAdoQuery.Open; if not aAdoQuery.IsEmpty then begin kbmVsl.FieldByName('VESSEL').AsString:=aAdoQuery.fieldbyname('船名').AsString; kbmVsl.FieldByName('VOY').AsString:=aAdoQuery.fieldbyname('航次').AsString; kbmVsl.FieldByName('SALE').AsString:=aAdoQuery.fieldbyname('揽货人').AsString; kbmVsl.FieldByName('OP').AsString:=aAdoQuery.fieldbyname('操作员').AsString; kbmVsl.FieldByName('ETD').AsString:=aAdoQuery.fieldbyname('开船日期').AsString; kbmVsl.FieldByName('FEESTATUS').AsString:=aAdoQuery.fieldbyname('费用状态').AsString; end; kbmVsl.Post; i:=i+1; end; end; finally FreeAndNil(aAdoQuery); kbmVsl.EnableControls; ExcelTemplet.DisplayAlerts := true;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 end; end; end; SaveDialog1.FileName:='mbl_vsl'; if SaveDialog1.Execute then begin ExportExcelFile(SaveDialog1.FileName+'.xls',true,TDataSet(kbmVsl)); end else begin end; Mblnos:=''; Mblnos:=MblnosOk; try finally Mblnos:=''; kbmbscardttl.EmptyTable; end; end; procedure Tfra_ch_add_do.N18Click(Sender: TObject); begin expvsl; end; end.