unit u_fee_modify; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, DB, ADODB, StdCtrls, Mask, DBCtrls, wwdblook, RxLookup; type Tfrm_fee_modify = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinGroupBox1: TbsSkinGroupBox; table_old1: TDataSource; Label1: TLabel; DBEdit1: TDBEdit; Label2: TLabel; DBEdit2: TDBEdit; Label3: TLabel; DBEdit3: TDBEdit; Label4: TLabel; DBEdit4: TDBEdit; Label5: TLabel; DBEdit5: TDBEdit; Label6: TLabel; DBEdit6: TDBEdit; Label7: TLabel; DBEdit7: TDBEdit; Label8: TLabel; DBEdit8: TDBEdit; Label9: TLabel; DBEdit9: TDBEdit; bsSkinGroupBox2: TbsSkinGroupBox; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; Label16: TLabel; Label17: TLabel; Label18: TLabel; DBEdit14: TDBEdit; DBEdit15: TDBEdit; DBEdit16: TDBEdit; DBEdit18: TDBEdit; wwDBLookupCombo5: TwwDBLookupCombo; wwDBLookupCombo4: TwwDBLookupCombo; wwDBLookupCombo3: TwwDBLookupCombo; Label19: TLabel; DBEdit10: TDBEdit; table_new1: TDataSource; table1: TDataSource; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; RxDBLookupCombo1: TRxDBLookupCombo; RxDBLookupCombo2: TRxDBLookupCombo; Label20: TLabel; DBEdit11: TDBEdit; Label21: TLabel; DBEdit12: TDBEdit; Label22: TLabel; DBEdit13: TDBEdit; Label23: TLabel; DBEdit17: TDBEdit; Label24: TLabel; DBEdit19: TDBEdit; Label25: TLabel; DBEdit20: TDBEdit; Label26: TLabel; DBEdit21: TDBEdit; Label27: TLabel; DBEdit22: TDBEdit; procedure FormCreate(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure wwDBLookupCombo5Change(Sender: TObject); procedure wwDBLookupCombo4Change(Sender: TObject); procedure DBEdit14Change(Sender: TObject); procedure RxDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo5KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo4KeyPress(Sender: TObject; var Key: Char); procedure DBEdit15KeyPress(Sender: TObject; var Key: Char); procedure DBEdit14KeyPress(Sender: TObject; var Key: Char); procedure DBEdit16KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); procedure DBEdit18KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo2Enter(Sender: TObject); procedure wwDBLookupCombo3Change(Sender: TObject); procedure DBEdit12KeyPress(Sender: TObject; var Key: Char); procedure FormShow(Sender: TObject); private procedure t_ch_acceptdjoncharge(Sender: TField);//收费金额计算 { Private declarations } public { Public declarations } end; var frm_fee_modify: Tfrm_fee_modify; frm_fee_modify_ok:boolean; implementation uses u_main, u_data_share, my_sys_function; {$R *.dfm} procedure Tfrm_fee_modify.FormCreate(Sender: TObject); begin frm_fee_modify_ok:=false; end; procedure Tfrm_fee_modify.bsSkinButton1Click(Sender: TObject); begin if DBEdit10.Text='' then begin showmessage('请输入申请修改原因!!'); exit; end; if table_new1.DataSet.State=dsedit then table_new1.DataSet.post; modify_all:=true; TRY table1.DataSet.Edit; table1.DataSet['费用状态']:='申请修改'; table1.DataSet.post; EXCEPT IF table1.DataSet.STATE=DSEDIT THEN table1.DataSet.CANCEL; END; frm_fee_modify_ok:=true; close; end; procedure Tfrm_fee_modify.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_fee_modify.FormClose(Sender: TObject; var Action: TCloseAction); begin if not frm_fee_modify_ok then begin table_new1.DataSet.delete; table_old1.DataSet.delete; end; end; procedure Tfrm_fee_modify.wwDBLookupCombo5Change(Sender: TObject); begin if (table_new1.DataSet.state=dsinsert)or(table_new1.DataSet.state=dsedit) then begin if not wwDBLookupCombo5.LookupTable.IsEmpty then if wwDBLookupCombo5.LookupTable.Locate('one',wwDBLookupCombo5.text,[])then begin table_new1.DataSet['客户名称']:=wwDBLookupCombo5.LookupTable.fieldbyname('three').asstring; end; end; end; procedure Tfrm_fee_modify.wwDBLookupCombo4Change(Sender: TObject); begin if (table_new1.DataSet.state=dsinsert)or(table_new1.DataSet.state=dsedit) then begin if not wwDBLookupCombo4.LookupTable.IsEmpty then if wwDBLookupCombo4.LookupTable.Locate('one',wwDBLookupCombo4.text,[])then begin table_new1.DataSet['数量']:=wwDBLookupCombo4.LookupTable.fieldbyname('three').asfloat; end; end; end; procedure Tfrm_fee_modify.DBEdit14Change(Sender: TObject); begin if (table_new1.DataSet.state=dsinsert)or(table_new1.DataSet.state=dsedit) then begin try if (strtofloat(DBEdit15.text)>0) and (strtofloat(DBEdit14.text)>0)then table_new1.DataSet['不含税金额']:=s_w(strtoint(get_parameters_value(65,'2')),strtofloat(DBEdit15.text)*strtofloat(DBEdit14.text)); table_new1.DataSet['税额']:=s_w(strtoint(get_parameters_value(65,'2')),strtofloat(DBEdit16.text)*strtofloat(DBEdit19.text)/100); table_new1.DataSet['金额']:=s_w(strtoint(get_parameters_value(65,'2')),strtofloat(DBEdit16.text)+strtofloat(DBEdit22.text)); except ; end; end; end; procedure Tfrm_fee_modify.RxDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo5); end; procedure Tfrm_fee_modify.wwDBLookupCombo5KeyPress(Sender: TObject; var Key: Char); begin key_RxDBLookupCombo(Key,RxDBLookupCombo2); end; procedure Tfrm_fee_modify.RxDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo4); end; procedure Tfrm_fee_modify.wwDBLookupCombo4KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit15); end; procedure Tfrm_fee_modify.DBEdit15KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit14); end; procedure Tfrm_fee_modify.DBEdit14KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit16); end; procedure Tfrm_fee_modify.DBEdit16KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo3); end; procedure Tfrm_fee_modify.wwDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit18); end; procedure Tfrm_fee_modify.DBEdit18KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit12); end; procedure Tfrm_fee_modify.RxDBLookupCombo2Enter(Sender: TObject); begin // if table_new1.DataSet.FieldByName('结算单位').asstring<>''then // client_filtered(table_new1.DataSet.FieldByName('结算单位').asstring); end; procedure Tfrm_fee_modify.wwDBLookupCombo3Change(Sender: TObject); begin if (table_new1.DataSet.State=dsedit)or(table_new1.DataSet.State=dsinsert) then begin try if frm_data_share.t_code_currency.locate('币别',table_new1.DataSet.FieldByName('币别').asstring,[]) then table_new1.DataSet['汇率']:=table_new1.DataSet.FieldByName('汇率').asfloat; except ; end; end; end; procedure Tfrm_fee_modify.DBEdit12KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit10); end; procedure Tfrm_fee_modify.t_ch_acceptdjoncharge(Sender: TField); begin //收费金额计算 if (Sender.DataSet.state=dsedit)or(Sender.DataSet.state=dsinsert)then begin try Sender.DataSet.FieldByName('单价').OnChange:=nil; Sender.DataSet.FieldByName('金额').OnChange:=nil; if (Sender.DataSet.fieldbyname('单价').asfloat<>0) and (Sender.DataSet.fieldbyname('数量').asfloat<>0)then Sender.DataSet['不含税金额']:=s_w(strtoint(apointnum),Sender.DataSet.fieldbyname('单价').asfloat*Sender.DataSet.fieldbyname('数量').asfloat); Sender.DataSet['税额']:=s_w(strtoint(apointnum),Sender.DataSet.fieldbyname('不含税金额').asfloat/100*Sender.DataSet.fieldbyname('税率').asfloat); Sender.DataSet['金额']:=s_w(strtoint(apointnum),Sender.DataSet.fieldbyname('不含税金额').asfloat+Sender.DataSet.fieldbyname('税额').asfloat); finally // Sender.DataSet.FieldByName('金额').OnChange:=DatasetAmtcharge; Sender.DataSet.FieldByName('单价').OnChange:=t_ch_acceptdjoncharge; end; end; end; procedure Tfrm_fee_modify.FormShow(Sender: TObject); begin table_new1.DataSet.FieldByName('税率').OnChange:=t_ch_acceptdjoncharge; table_new1.DataSet.FieldByName('单价').OnChange:=t_ch_acceptdjoncharge; table_new1.DataSet.FieldByName('数量').OnChange:=t_ch_acceptdjoncharge; frm_data_share.t_crm_client.Filter:=''; frm_data_share.t_crm_client.Filtered:=false; end; end.