unit u_fee_calc; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, cxTextEdit, cxControls, cxContainer, cxEdit, cxMaskEdit, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit,inifiles, cxDBLookupComboBox, bsSkinCtrls, ExtCtrls, BusinessSkinForm, DB, ADODB, Mask, DBCtrlsEh,Registry,Client_TLB,ShellApi, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxDBData, cxGridLevel, cxClasses, cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, dxExEdtr, dxTL, dxDBCtrl, dxDBGrid, dxCntner, kbmMemTable; type Tfrm_fee_calc = class(TForm) bsSkinPanel1: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; edit1: TcxTextEdit; bsBusinessSkinForm1: TbsBusinessSkinForm; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridColumn; t_ch_fee1: TDataSource; t_op_ctn_sum1: TDataSource; t_op_ctn_sum: TADOQuery; kbmMemTable1: TkbmMemTable; kbmMemTable1Field: TStringField; kbmMemTable1Field2: TIntegerField; kbmMemTable1Field3: TFloatField; dxDBGrid1Column2: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; kbmMemTable1Field4: TStringField; procedure bsSkinButton1Click(Sender: TObject); procedure edit1KeyPress(Sender: TObject; var Key: Char); procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure dxDBGrid1KeyPress(Sender: TObject; var Key: Char); private { Private declarations } public { Public declarations } end; var frm_fee_calc: Tfrm_fee_calc; implementation uses u_data_share, u_main, u_tree_main, u_dxbar_main, u_sys_close, my_sys_function; {$R *.dfm} procedure Tfrm_fee_calc.bsSkinButton1Click(Sender: TObject); var amt:Double; Fees:string; begin with kbmMemTable1 do begin First; while not eof do begin amt:=amt+kbmMemTable1.FieldByName('数量').AsFloat*kbmMemTable1.FieldByName('单价').AsFloat; if Trim(Fees)='' then begin Fees:=kbmMemTable1.FieldByName('箱型').AsString+'*'+kbmMemTable1.FieldByName('数量').AsString+'*'+kbmMemTable1.FieldByName('单价').AsString; end else begin Fees:=Fees+' '+kbmMemTable1.FieldByName('箱型').AsString+'*'+kbmMemTable1.FieldByName('数量').AsString+'*'+kbmMemTable1.FieldByName('单价').AsString; end; Next; end; end; t_ch_fee1.DataSet.Edit; t_ch_fee1.DataSet.FieldByName('金额').AsFloat:=amt; t_ch_fee1.DataSet.FieldByName('数量').AsFloat:=1; t_ch_fee1.DataSet.FieldByName('不含税价').AsFloat:=amt; t_ch_fee1.DataSet.FieldByName('标准').AsString:=Trim(t_ch_fee1.DataSet.DataSource.DataSet.FieldByName('集装箱').AsString); t_ch_fee1.DataSet.FieldByName('备注').AsString:=Trim(Fees); t_ch_fee1.DataSet.Post; close; end; procedure Tfrm_fee_calc.edit1KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; frm_fee_calc.bsSkinButton1Click(Sender); end; end; procedure Tfrm_fee_calc.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_fee_calc.FormShow(Sender: TObject); begin kbmMemTable1.EmptyTable; if not t_op_ctn_sum.IsEmpty then with t_op_ctn_sum do begin First; while not eof do begin kbmMemTable1.Insert; kbmMemTable1.FieldByName('箱型').AsString:=FieldByName('表现形式').AsString; kbmMemTable1.FieldByName('数量').AsInteger:=FieldByName('数量').AsInteger; kbmMemTable1.FieldByName('单价').AsInteger:=0; kbmMemTable1.Post; Next; end; end; end; procedure Tfrm_fee_calc.dxDBGrid1KeyPress(Sender: TObject; var Key: Char); begin if dxDBGrid1.FocusedField.FieldName='确认' then begin frm_fee_calc.bsSkinButton1Click(Sender); end; end; end.