unit u_code_fee_project_auto; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, DB, ADODB, bsSkinCtrls, ExtCtrls, Grids, Wwdbigrd, Wwdbgrid, StdCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb, wwdblook, RxMemDS, DBCtrls, ComCtrls, bsSkinTabs, dxExEdtr, dxTL, dxDBCtrl, dxDBGrid, dxCntner, wwdbdatetimepicker, dxDBTLCl, dxGrClms, bsdbctrls, RxLookup,ComObj; type Tfrm_code_fee_project_auto = class(TForm) t_ch_project: TADOQuery; t_ch_project1: TDataSource; t_ch_project_fee: TADOQuery; t_ch_project_fee1: TDataSource; t_bz_balance: TRxMemoryData; t_bz_client: TRxMemoryData; Panel3: TPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinRadioGroup1: TbsSkinRadioGroup; bsSkinPanel2: TbsSkinPanel; bsSkinPanel3: TbsSkinPanel; dxDBGrid1: TdxDBGrid; bsSkinPanel4: TbsSkinPanel; Label1: TLabel; DBEdit2: TDBEdit; Label8: TLabel; wwDBDateTimePicker2: TwwDBDateTimePicker; Label9: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; Label2: TLabel; DBEdit1: TDBEdit; Label3: TLabel; DBEdit3: TDBEdit; bsSkinGroupBox1: TbsSkinGroupBox; bsSkinPanel5: TbsSkinPanel; bsSkinButton21: TbsSkinButton; bsSkinButton20: TbsSkinButton; bsSkinButton19: TbsSkinButton; bsSkinButton17: TbsSkinButton; t_ch_project_Condition1: TDataSource; t_ch_project_Condition: TADOQuery; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; dxDBGrid1Column1: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1Column5: TdxDBGridCheckColumn; bsSkinGroupBox2: TbsSkinGroupBox; Panel2: TPanel; Panel4: TPanel; bsSkinButton5: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; wwDBGrid2: TwwDBGrid; wwDBLookupCombo2: TwwDBLookupCombo; wwDBLookupCombo3: TwwDBLookupCombo; wwDBLookupCombo1: TwwDBLookupCombo; wwDBLookupCombo6: TwwDBLookupCombo; DBEdit4: TDBEdit; wwDBLookupCombo5: TwwDBLookupCombo; wwDBLookupCombo4: TwwDBLookupCombo; bsSkinButton10: TbsSkinButton; wwDBComboBox2: TwwDBComboBox; bsSkinPanel1: TbsSkinPanel; dxDBGrid2: TdxDBGrid; dxDBGridColumn1: TdxDBGridColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; bsSkinButton9: TbsSkinButton; bsSkinPanel6: TbsSkinPanel; bsSkinButton44: TbsSkinButton; RxDBLookupCombo57: TRxDBLookupCombo; Label213: TLabel; Label17: TLabel; RxDBLookupCombo7: TRxDBLookupCombo; Label12: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; wwDBComboBox1: TwwDBComboBox; Label4: TLabel; bsSkinButton11: TbsSkinButton; Label5: TLabel; wwDBComboBox3: TwwDBComboBox; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; Label6: TLabel; DBEdit5: TDBEdit; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; Edit1: TEdit; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; Panel1: TPanel; bsSkinButton12: TbsSkinButton; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; bsSkinButton15: TbsSkinButton; bsSkinButton16: TbsSkinButton; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn2: TdxDBGridMaskColumn; RxDBLookupCombo2: TRxDBLookupCombo; Label7: TLabel; t_ch_project_Cust1: TDataSource; t_ch_project_Cust: TADOQuery; dxDBGrid3Column2: TdxDBGridColumn; dxDBGrid3Column3: TdxDBGridColumn; DBEdit6: TDBEdit; Label10: TLabel; Label11: TLabel; DBEdit7: TDBEdit; OpenDialog1: TOpenDialog; bsSkinButton18: TbsSkinButton; bsSkinButton22: TbsSkinButton; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure Panel3Resize(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure t_ch_projectAfterInsert(DataSet: TDataSet); procedure t_ch_projectBeforePost(DataSet: TDataSet); procedure t_ch_project_feeBeforePost(DataSet: TDataSet); procedure t_ch_project_feeBeforeInsert(DataSet: TDataSet); procedure t_ch_project_standardBeforeInsert(DataSet: TDataSet); procedure wwDBLookupCombo1Change(Sender: TObject); procedure t_ch_projectBeforeEdit(DataSet: TDataSet); procedure t_ch_projectPostError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); procedure wwDBLookupCombo2Enter(Sender: TObject); procedure t_ch_project_feeAfterOpen(DataSet: TDataSet); procedure bsSkinRadioGroup1Checked(Sender: TObject); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinButton19Click(Sender: TObject); procedure bsSkinButton20Click(Sender: TObject); procedure bsSkinButton21Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure t_ch_project_ConditionBeforeInsert(DataSet: TDataSet); procedure t_ch_project_ConditionBeforePost(DataSet: TDataSet); procedure bsSkinButton44Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure dxDBGrid2DblClick(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure t_ch_project_CustAfterInsert(DataSet: TDataSet); procedure RxDBLookupCombo2Enter(Sender: TObject); procedure RxDBLookupCombo2Exit(Sender: TObject); procedure bsSkinButton18Click(Sender: TObject); procedure bsSkinButton22Click(Sender: TObject); private procedure t_ch_feecurrcharge(Sender: TField); { Private declarations } public { Public declarations } end; var frm_code_fee_project_auto: Tfrm_code_fee_project_auto; implementation uses u_main, u_data_share, my_sys_function, u_code_fee_project_copy, u_code_fee_project_auto_condition; {$R *.dfm} procedure Tfrm_code_fee_project_auto.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_code_fee_project_auto.Hide; frm_code_fee_project_auto.ManualFloat(frm_code_fee_project_auto.BoundsRect ); frm_main.freeTabs('frm_code_fee_project_auto'); action:=cafree; frm_code_fee_project_auto:=nil; end; procedure Tfrm_code_fee_project_auto.FormShow(Sender: TObject); var i:integer; begin frm_data_share.t_code_fee_unit.Filtered:=false; frm_data_share.t_code_fee_unit.Filter:='海运=1'; frm_data_share.t_code_fee_unit.Filtered:=true; t_bz_balance.close; t_bz_balance.open; t_bz_balance.Append; t_bz_balance['one']:='1-单票'; t_bz_balance['two']:='单票'; t_bz_balance['three']:='单票'; t_bz_balance.post; t_bz_balance.Append; t_bz_balance['one']:='2-重量'; t_bz_balance['two']:='重量'; t_bz_balance['three']:='重量'; t_bz_balance.post; t_bz_balance.Append; t_bz_balance['one']:='3-尺码'; t_bz_balance['two']:='尺码'; t_bz_balance['three']:='尺码'; t_bz_balance.post; t_bz_balance.Append; t_bz_balance['one']:='4-计费吨'; t_bz_balance['two']:='计费吨'; t_bz_balance['three']:='计费吨'; t_bz_balance.Append; t_bz_balance['one']:='5-TEU'; t_bz_balance['two']:='TEU'; t_bz_balance['three']:='TEU'; t_bz_balance.Append; t_bz_balance['one']:='6-箱数'; t_bz_balance['two']:='箱数'; t_bz_balance['three']:='箱数'; t_bz_balance.Append; t_bz_balance['one']:='7-舱单票数'; t_bz_balance['two']:='舱单票数'; t_bz_balance['three']:='舱单票数'; t_bz_balance.Append; t_bz_balance['one']:='8-舱单分票'; t_bz_balance['two']:='舱单分票'; t_bz_balance['three']:='舱单分票'; t_bz_balance.Append; t_bz_balance['one']:='9-提箱小票数'; t_bz_balance['two']:='提箱小票数'; t_bz_balance['three']:='提箱小票数'; t_bz_balance.Append; t_bz_balance['one']:='10-超额小票数'; t_bz_balance['two']:='超额小票数'; t_bz_balance['three']:='超额小票数'; t_bz_balance.Append; t_bz_balance['one']:='11-不超额小票数'; t_bz_balance['two']:='不超额小票数'; t_bz_balance['three']:='不超额小票数'; frm_data_share.t_code_ctn.First; while not frm_data_share.t_code_ctn.eof do begin t_bz_balance.Append; t_bz_balance['one']:=frm_data_share.t_code_ctn['表现形式']; t_bz_balance['two']:=frm_data_share.t_code_ctn['表现形式']; t_bz_balance['three']:=0; t_bz_balance.post; frm_data_share.t_code_ctn.next; end; t_bz_client.close; t_bz_client.open; t_bz_client.Append; t_bz_client['one']:='0-委托单位'; t_bz_client['two']:='委托单位'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='1-船 公 司'; t_bz_client['two']:='船公司'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='2-场 站'; t_bz_client['two']:='场站'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='3-车 队'; t_bz_client['two']:='车队'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='4-报 关 行'; t_bz_client['two']:='报关行'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='5-代 理'; t_bz_client['two']:='代理'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='6-货 代'; t_bz_client['two']:='货代'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='7-船 代'; t_bz_client['two']:='船代'; t_bz_client.post; { t_bz_client.Append; t_bz_client['one']:='7-发 货 人'; t_bz_client['two']:='发货人'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='8-收 货 人'; t_bz_client['two']:='收货人'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='9-通 知 人'; t_bz_client['two']:='通知人'; t_bz_client.post; t_bz_client.Append; t_bz_client['one']:='10-其 他'; t_bz_client['two']:='其他客户'; t_bz_client.post; } frm_data_share.t_code_fee.Filtered:=false; frm_data_share.t_code_fee.Filter:='海运=1'; frm_data_share.t_code_fee.Filtered:=true; t_ch_project.SQL.clear; t_ch_project.sql.add('select * from t_ch_project_auto '); t_ch_project.SQL.Add(' where 费用类别=''场站'' and '+open_data('8005','录入人','no','no','no','no') +' order by 方案代码'); t_ch_project.open; t_ch_project_fee.open; t_ch_project_Condition.Open; frm_data_share.t_code_fee.requery; frm_data_share.t_crm_client.requery; frm_data_share.t_code_currency.requery; frm_data_share.t_code_ctn.requery; t_ch_project_Cust.Open; end; procedure Tfrm_code_fee_project_auto.Panel3Resize(Sender: TObject); var i:integer; begin i:=round(Panel3.width/7); bsSkinButton1.width:=i; bsSkinButton2.width:=i; bsSkinButton4.width:=i; bsSkinButton3.width:=i; bsSkinButton11.Width:=i; end; procedure Tfrm_code_fee_project_auto.bsSkinButton9Click(Sender: TObject); begin if not (t_ch_project_Condition.State in [dsedit]) then t_ch_project_Condition.Edit; try frm_code_fee_project_auto_condition:=tfrm_code_fee_project_auto_condition.Create (self); frm_code_fee_project_auto_condition.ShowModal; finally frm_code_fee_project_auto_condition.Free; end; end; procedure Tfrm_code_fee_project_auto.bsSkinButton1Click(Sender: TObject); begin t_ch_project.insert; end; procedure Tfrm_code_fee_project_auto.t_ch_feecurrcharge(Sender: TField); begin if (t_ch_project_fee.state=dsedit)or(t_ch_project_fee.state=dsinsert)then begin if t_ch_project_fee.FieldByName('币别').AsString='RMB' then begin t_ch_project_fee.FieldByName('汇率').Asfloat:=1; end else begin IF frm_data_share.t_code_currency.Locate('币别',t_ch_project_fee.FieldByName('币别').AsString,[])then t_ch_project_fee['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; procedure Tfrm_code_fee_project_auto.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_project); end; procedure Tfrm_code_fee_project_auto.bsSkinButton4Click(Sender: TObject); begin table_delete(t_ch_project); end; procedure Tfrm_code_fee_project_auto.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_project); end; procedure Tfrm_code_fee_project_auto.bsSkinButton5Click(Sender: TObject); begin t_ch_project_fee.insert; end; procedure Tfrm_code_fee_project_auto.bsSkinButton6Click(Sender: TObject); begin table_post(t_ch_project_fee); end; procedure Tfrm_code_fee_project_auto.bsSkinButton7Click(Sender: TObject); begin table_delete(t_ch_project_fee); end; procedure Tfrm_code_fee_project_auto.bsSkinButton8Click(Sender: TObject); begin table_cancel(t_ch_project_fee); end; procedure Tfrm_code_fee_project_auto.t_ch_projectAfterInsert(DataSet: TDataSet); var feestr:string; begin feestr:=bsSkinRadioGroup1.Items[bsSkinRadioGroup1.ItemIndex]; t_ch_project['录入人']:=employee; t_ch_project['录入日期']:=date; if (feestr<>'全部') then t_ch_project['费用类别']:=feestr; t_ch_project['默认方案']:=1; t_ch_project['优先级']:=0; t_ch_project['收付类型']:='全部'; end; procedure Tfrm_code_fee_project_auto.t_ch_projectBeforePost(DataSet: TDataSet); begin table_before_post(t_ch_project,'费用类别'); table_before_post(t_ch_project,'收付类型'); table_before_post(t_ch_project,'开始日期'); // table_before_post(t_ch_project,'结束日期'); end; procedure Tfrm_code_fee_project_auto.t_ch_project_feeBeforePost( DataSet: TDataSet); begin table_before_post(t_ch_project_fee,'费用名称'); table_before_post(t_ch_project_fee,'币别'); table_before_post(t_ch_project_fee,'汇率'); table_before_post(t_ch_project_fee,'标准'); end; procedure Tfrm_code_fee_project_auto.t_ch_project_feeBeforeInsert( DataSet: TDataSet); begin table_before_insert(t_ch_project); end; procedure Tfrm_code_fee_project_auto.t_ch_project_standardBeforeInsert( DataSet: TDataSet); begin if do_data('8005',t_ch_project.fieldbyname('录入人').asstring,'','','','','')=false then begin showmessage('对不起你无权修改此数据!!'); abort; end; table_before_insert(t_ch_project_fee); end; procedure Tfrm_code_fee_project_auto.wwDBLookupCombo1Change(Sender: TObject); begin if (t_ch_project_fee.state=dsinsert)or(t_ch_project_fee.state=dsedit) then begin t_ch_project_fee['币别']:=frm_data_share.t_code_fee.fieldbyname('默认币别').asstring; end; end; procedure Tfrm_code_fee_project_auto.t_ch_projectBeforeEdit(DataSet: TDataSet); begin if do_data('8005', t_ch_project.fieldbyname('录入人').asstring,'','','','','')=false then begin showmessage('对不起你无权修改此数据!!'); abort; end; end; procedure Tfrm_code_fee_project_auto.t_ch_projectPostError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); begin table_post_error_primary('方案代码',E); end; procedure Tfrm_code_fee_project_auto.wwDBLookupCombo2Enter(Sender: TObject); begin if t_ch_project_fee.FieldByName('结算单位').asstring<>''then begin frm_data_share.t_crm_client.Filtered:=false; frm_data_share.t_crm_client.Filter:=t_ch_project_fee.FieldByName('结算单位').asstring+'=1'; frm_data_share.t_crm_client.Filtered:=true; end; end; procedure Tfrm_code_fee_project_auto.t_ch_project_feeAfterOpen( DataSet: TDataSet); begin t_ch_project_fee.FieldByName('币别').OnChange:=t_ch_feecurrcharge; end; procedure Tfrm_code_fee_project_auto.bsSkinRadioGroup1Checked( Sender: TObject); var feestr:string; begin feestr:=bsSkinRadioGroup1.Items[bsSkinRadioGroup1.ItemIndex]; if (feestr='全部') then begin t_ch_project.Close; t_ch_project.SQL.clear; t_ch_project.sql.add('select * from t_ch_project_auto '); t_ch_project.SQL.Add(' where '+open_data('8005','录入人','no','no','no','no') +' order by 方案代码'); t_ch_project.open; end else begin t_ch_project.Close; t_ch_project.SQL.clear; t_ch_project.sql.add('select * from t_ch_project_auto '); t_ch_project.SQL.Add(' where 费用类别='''+feestr+''' and '+open_data('8005','录入人','no','no','no','no') +' order by 方案代码'); t_ch_project.open; end; end; procedure Tfrm_code_fee_project_auto.bsSkinButton17Click(Sender: TObject); begin t_ch_project_Condition.Insert; try frm_code_fee_project_auto_condition:=tfrm_code_fee_project_auto_condition.Create (self); frm_code_fee_project_auto_condition.ShowModal; finally frm_code_fee_project_auto_condition.Free; end; end; procedure Tfrm_code_fee_project_auto.bsSkinButton19Click(Sender: TObject); begin table_post(t_ch_project_Condition); end; procedure Tfrm_code_fee_project_auto.bsSkinButton20Click(Sender: TObject); begin table_delete(t_ch_project_Condition); end; procedure Tfrm_code_fee_project_auto.bsSkinButton21Click(Sender: TObject); begin table_Cancel(t_ch_project_Condition); end; procedure Tfrm_code_fee_project_auto.bsSkinButton10Click(Sender: TObject); begin close; end; procedure Tfrm_code_fee_project_auto.t_ch_project_ConditionBeforeInsert( DataSet: TDataSet); begin table_before_insert(t_ch_project); end; procedure Tfrm_code_fee_project_auto.t_ch_project_ConditionBeforePost( DataSet: TDataSet); begin table_before_post(t_ch_project_Condition,'条件名称'); table_before_post(t_ch_project_Condition,'条件关系'); table_before_post(t_ch_project_Condition,'条件值'); end; procedure Tfrm_code_fee_project_auto.bsSkinButton44Click(Sender: TObject); var feestr,str:string; begin feestr:=bsSkinRadioGroup1.Items[bsSkinRadioGroup1.ItemIndex]; str:=' 1=1 '; if RxDBLookupCombo57.Text<>'<无>' then begin str:=str+' and (条件名称=''委托单位'' and 条件值='''+RxDBLookupCombo57.DisplayValues[1]+''') '; end; if RxDBLookupCombo7.Text<>'<无>' then begin str:=str+' and (条件名称=''场站'' and 条件值='''+RxDBLookupCombo7.DisplayValues[1]+''') '; end; if RxDBLookupCombo1.Text<>'<无>' then begin str:=str+' and (条件名称=''船公司'' and 条件值='''+RxDBLookupCombo1.DisplayValues[1]+''') '; end; if (feestr='全部') then begin t_ch_project.Close; t_ch_project.SQL.clear; t_ch_project.sql.add('select * from t_ch_project_auto '); t_ch_project.SQL.Add(' where '+open_data('8005','录入人','no','no','no','no')); if (str<>' 1=1 ') then t_ch_project.SQL.Add(' and EXISTS (select 1 from t_ch_project_Condition c where c.方案代码=t_ch_project_auto.方案代码 and '+str+') '); t_ch_project.SQL.Add(' order by 方案代码'); t_ch_project.open; end else begin t_ch_project.Close; t_ch_project.SQL.clear; t_ch_project.sql.add('select * from t_ch_project_auto '); t_ch_project.SQL.Add(' where 费用类别='''+feestr+''' and '+open_data('8005','录入人','no','no','no','no')); if (str<>' 1=1 ') then t_ch_project.SQL.Add(' and EXISTS (select 1 from t_ch_project_Condition c where c.方案代码=t_ch_project_auto.方案代码 and '+str+') '); t_ch_project.SQL.Add(' order by 方案代码'); t_ch_project.open; end; end; procedure Tfrm_code_fee_project_auto.bsSkinButton11Click(Sender: TObject); var aQuery:TADOQuery; i,fadm:Integer; begin if t_ch_project.IsEmpty then exit; fadm:=t_ch_project.fieldbyname('方案代码').AsInteger; aQuery:=CreateAdoQuery; try with aQuery do begin close;SQL.Clear; SQL.Add('select * from t_ch_project_auto where 方案代码='+IntToStr(fadm)); Open; t_ch_project.Insert; t_ch_project['方案描述']:=aQuery['方案描述']; t_ch_project['费用类别']:=aQuery['费用类别']; t_ch_project['收付类型']:=aQuery['收付类型']; t_ch_project['默认方案']:=aQuery['默认方案']; t_ch_project['开始日期']:=aQuery['开始日期']; t_ch_project['结束日期']:=aQuery['结束日期']; t_ch_project.Post; close;SQL.Clear; SQL.Add('select * from t_ch_project_auto_fee where 方案代码='+IntToStr(fadm)); Open; First; while not eof do begin t_ch_project_fee.Insert; t_ch_project_fee['类型']:=aQuery['类型']; t_ch_project_fee['费用名称']:=aQuery['费用名称']; t_ch_project_fee['结算单位']:=aQuery['结算单位']; t_ch_project_fee['客户名称']:=aQuery['客户名称']; t_ch_project_fee['币别']:=aQuery['币别']; t_ch_project_fee['汇率']:=aQuery['汇率']; t_ch_project_fee['标准']:=aQuery['标准']; t_ch_project_fee['单价']:=aQuery['单价']; t_ch_project_fee['费用备注']:=aQuery['费用备注']; t_ch_project_fee['单价公式']:=aQuery['单价公式']; t_ch_project_fee['顺序']:=aQuery['顺序']; t_ch_project_fee['税率']:=aQuery['税率']; t_ch_project_fee.Post; Next; end; close;SQL.Clear; SQL.Add('select * from t_ch_project_Condition where 方案代码='+IntToStr(fadm)); Open; First; while not eof do begin t_ch_project_Condition.Insert; t_ch_project_Condition['条件名称']:=aQuery['条件名称']; t_ch_project_Condition['条件关系']:=aQuery['条件关系']; t_ch_project_Condition['条件值']:=aQuery['条件值']; t_ch_project_Condition.Post; Next; end; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_code_fee_project_auto.dxDBGrid2DblClick(Sender: TObject); begin if not (t_ch_project_Condition.State in [dsedit]) then t_ch_project_Condition.Edit; try frm_code_fee_project_auto_condition:=tfrm_code_fee_project_auto_condition.Create (self); frm_code_fee_project_auto_condition.ShowModal; finally frm_code_fee_project_auto_condition.Free; end; end; procedure Tfrm_code_fee_project_auto.bsSkinButton16Click(Sender: TObject); begin close; end; procedure Tfrm_code_fee_project_auto.bsSkinButton12Click(Sender: TObject); begin t_ch_project_Cust.Insert; end; procedure Tfrm_code_fee_project_auto.bsSkinButton13Click(Sender: TObject); begin table_post(t_ch_project_Cust); end; procedure Tfrm_code_fee_project_auto.bsSkinButton14Click(Sender: TObject); begin table_delete(t_ch_project_Cust); end; procedure Tfrm_code_fee_project_auto.bsSkinButton15Click(Sender: TObject); begin table_Cancel(t_ch_project_Cust); end; procedure Tfrm_code_fee_project_auto.t_ch_project_CustAfterInsert( DataSet: TDataSet); begin t_ch_project_Cust['录入人']:=employee; t_ch_project_Cust['录入日期']:=Now; end; procedure Tfrm_code_fee_project_auto.RxDBLookupCombo2Enter( Sender: TObject); begin RxLookupComboEnter(RxDBLookupCombo2); end; procedure Tfrm_code_fee_project_auto.RxDBLookupCombo2Exit(Sender: TObject); begin RxLookupComboExit(RxDBLookupCombo2); end; procedure Tfrm_code_fee_project_auto.bsSkinButton18Click(Sender: TObject); var Ext,adate,bsno,corp,vslvoy:String; ExcelTemplet:Variant; i,j:integer; M,D,Y:Word; imp:boolean; begin if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); try ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); imp:=true; I:=2; while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,1].Value)<>'' do begin t_ch_project_fee.insert; t_ch_project_fee['类型']:=VarTostr(ExcelTemplet.ActiveSheet.Cells[i,1].Value); t_ch_project_fee['费用名称']:=VarTostr(ExcelTemplet.ActiveSheet.Cells[i,2].Value); t_ch_project_fee['结算单位']:=VarTostr(ExcelTemplet.ActiveSheet.Cells[i,3].Value); t_ch_project_fee['客户名称']:=VarTostr(ExcelTemplet.ActiveSheet.Cells[i,4].Value); t_ch_project_fee['币别']:=VarTostr(ExcelTemplet.ActiveSheet.Cells[i,5].Value); if (VartoStr(ExcelTemplet.ActiveSheet.Cells[I,6].Value)<>'') then t_ch_project_fee['汇率']:=StrToFloat(VarTostr(ExcelTemplet.ActiveSheet.Cells[i,6].Value)); t_ch_project_fee['标准']:=VarTostr(ExcelTemplet.ActiveSheet.Cells[i,7].Value); if (VartoStr(ExcelTemplet.ActiveSheet.Cells[I,8].Value)<>'') then t_ch_project_fee['单价']:=StrToFloat(VarTostr(ExcelTemplet.ActiveSheet.Cells[i,8].Value)); t_ch_project_fee['单价公式']:=VarTostr(ExcelTemplet.ActiveSheet.Cells[i,9].Value); t_ch_project_fee['费用备注']:=VarTostr(ExcelTemplet.ActiveSheet.Cells[i,10].Value); t_ch_project_fee['费用英文名称']:=VarTostr(ExcelTemplet.ActiveSheet.Cells[i,11].Value); if (VartoStr(ExcelTemplet.ActiveSheet.Cells[I,12].Value)<>'') then t_ch_project_fee['顺序']:=StrToInt64(VarTostr(ExcelTemplet.ActiveSheet.Cells[i,12].Value)); t_ch_project_fee.post; i:=i+1; end; finally ExcelTemplet.DisplayAlerts := false;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 end; end; end; MessageDlg('导入完成!', mtConfirmation, [mbYes],0); end; procedure Tfrm_code_fee_project_auto.bsSkinButton22Click(Sender: TObject); var aQuery:TADOQuery; i:Integer; begin if wwDBGrid2.SelectedList.Count>=1 then begin aQuery:=CreateAdoQuery; aQuery.SQL.Text:='select top 1 * from t_ch_project_auto_fee '; aQuery.Open; try for i:=0 to wwDBGrid2.SelectedList.Count-1 do begin t_ch_project_fee.GotoBookmark(pointer(wwDBGrid2.SelectedList[i])); aQuery.Insert; aQuery['方案代码']:=t_ch_project_fee['方案代码']; aQuery['类型']:=t_ch_project_fee['类型']; aQuery['费用名称']:=t_ch_project_fee['费用名称']; aQuery['结算单位']:=t_ch_project_fee['结算单位']; aQuery['客户名称']:=t_ch_project_fee['客户名称']; aQuery['币别']:=t_ch_project_fee['币别']; aQuery['汇率']:=t_ch_project_fee['汇率']; aQuery['标准']:=t_ch_project_fee['标准']; aQuery['单价']:=t_ch_project_fee['单价']; aQuery['单价公式']:=t_ch_project_fee['单价公式']; aQuery['费用备注']:=t_ch_project_fee['费用备注']; aQuery['费用英文名称']:=t_ch_project_fee['费用英文名称']; aQuery['顺序']:=t_ch_project_fee['顺序']; aQuery.Post; end; finally t_ch_project_fee.Requery(); FreeAndNil(aQuery); end; end; end; end.