unit u_rp_dui_formatrpt; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, bsSkinCtrls, BusinessSkinForm, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, bsSkinBoxCtrls, StdCtrls, DBCtrls, Grids, Wwdbigrd, Wwdbgrid, dxDBTLCl, dxGrClms; type Tfrm_rp_dui_formatrpt = class(TForm) t_ch_dui_format: TADOQuery; t_ch_dui_format1: TDataSource; bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinPanel1: TbsSkinPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinPanel5: TbsSkinPanel; bsSkinPanel6: TbsSkinPanel; bsSkinButton6: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton12: TbsSkinButton; bsSkinPanel7: TbsSkinPanel; bsSkinGroupBox1: TbsSkinGroupBox; bsSkinListBox1: TbsSkinListBox; bsSkinGroupBox2: TbsSkinGroupBox; dxDBGrid3: TdxDBGrid; dxDBGrid3Column1: TdxDBGridMaskColumn; bsSkinButton5: TbsSkinButton; Memo1: TMemo; Memo2: TMemo; Memo3: TMemo; Memo4: TMemo; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; Memo5: TMemo; bsSkinPanel3: TbsSkinPanel; bsSkinPanel4: TbsSkinPanel; DBListBox1: TListBox; bsSkinPanel8: TbsSkinPanel; bsSkinPanel9: TbsSkinPanel; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; t_ch_dui_feefield: TADOQuery; t_ch_dui_feefield1: TDataSource; t_ch_dui_feename: TADOQuery; t_ch_dui_feename1: TDataSource; bsSkinPanel10: TbsSkinPanel; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; Label1: TLabel; bsSkinPanel11: TbsSkinPanel; Label2: TLabel; wwDBGrid1: TwwDBGrid; bsSkinButton9: TbsSkinButton; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; dxDBGrid1Column3: TdxDBGridCheckColumn; dxDBGrid1Column4: TdxDBGridCheckColumn; dxDBGrid1Column5: TdxDBGridCheckColumn; dxDBGrid1Column6: TdxDBGridCheckColumn; dxDBGrid1Column7: TdxDBGridCheckColumn; dxDBGrid1Column8: TdxDBGridCheckColumn; dxDBGrid1Column9: TdxDBGridCheckColumn; dxDBGrid1Column10: TdxDBGridCheckColumn; dxDBGrid1Column12: TdxDBGridCheckColumn; dxDBGrid1Column13: TdxDBGridCheckColumn; dxDBGrid1Column14: TdxDBGridCheckColumn; dxDBGrid1Column15: TdxDBGridCheckColumn; bsSkinPanel12: TbsSkinPanel; dxDBGrid1Column16: TdxDBGridCheckColumn; dxDBGrid1Column17: TdxDBGridCheckColumn; ListBox1: TListBox; bsSkinButton15: TbsSkinButton; bsSkinButton16: TbsSkinButton; Label3: TLabel; dxDBGrid1Column19: TdxDBGridCheckColumn; dxDBGrid1Column18: TdxDBGridCheckColumn; dxDBGrid1Column20: TdxDBGridCheckColumn; dxDBGrid1Column21: TdxDBGridCheckColumn; dxDBGrid1Column22: TdxDBGridCheckColumn; procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure t_ch_dui_formatAfterInsert(DataSet: TDataSet); procedure t_ch_dui_formatBeforePost(DataSet: TDataSet); procedure t_ch_dui_formatDeleteError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); procedure t_ch_dui_format_detailBeforeInsert(DataSet: TDataSet); procedure bsSkinButton5Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure t_ch_dui_formatAfterScroll(DataSet: TDataSet); procedure t_ch_dui_feefieldAfterInsert(DataSet: TDataSet); procedure t_ch_dui_feenameAfterInsert(DataSet: TDataSet); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure t_ch_dui_feefieldBeforeInsert(DataSet: TDataSet); procedure t_ch_dui_feenameBeforeInsert(DataSet: TDataSet); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure t_ch_dui_feefieldBeforeDelete(DataSet: TDataSet); private { Private declarations } public { Public declarations } end; var frm_rp_dui_formatrpt: Tfrm_rp_dui_formatrpt; dui_format_type:integer; implementation uses u_main, u_data_share, my_sys_function; {$R *.dfm} procedure Tfrm_rp_dui_formatrpt.bsSkinButton1Click(Sender: TObject); begin t_ch_dui_format.Insert; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_dui_format); end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton4Click(Sender: TObject); var aQuery:TAdoQuery; begin if MessageDlg('确实要删除此对帐模板吗?',mtWarning,[mbyes,mbNo],0)=mryes then begin aQuery:=CreateAdoQuery; try with aQuery do begin close; sql.Text:='delete from t_ch_dui_feefield where DM_ID='+t_ch_dui_format.fieldbyname('DM_ID').AsString; ExecSQL; close; sql.Text:='delete from t_ch_dui_feename where DM_ID='+t_ch_dui_format.fieldbyname('DM_ID').AsString; ExecSQL; end; finally freeandnil(aQuery); end; table_delete(t_ch_dui_format); end; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_dui_format); end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_formatAfterInsert(DataSet: TDataSet); begin t_ch_dui_format['类别']:=dui_format_type; t_ch_dui_format['是否按费用客户合计']:=1; t_ch_dui_format['应收USD其他费用']:=1; t_ch_dui_format['应收RMB其他费用']:=1; t_ch_dui_format['应收合计USD']:=1; t_ch_dui_format['应收合计RMB']:=1; t_ch_dui_format['应付USD其他费用']:=1; t_ch_dui_format['应付RMB其他费用']:=1; t_ch_dui_format['应付合计USD']:=1; t_ch_dui_format['应付合计RMB']:=1; t_ch_dui_format['应收合计']:=1; t_ch_dui_format['应付合计']:=1; t_ch_dui_format['USD差额']:=1; t_ch_dui_format['RMB差额']:=1; t_ch_dui_format['差额合计']:=1; t_ch_dui_format['应收OT其他费用']:=1; t_ch_dui_format['应收合计OT']:=1; t_ch_dui_format['应付OT其他费用']:=1; t_ch_dui_format['应付合计OT']:=1; t_ch_dui_format['OT差额']:=1; end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_formatBeforePost(DataSet: TDataSet); begin t_ch_dui_format['字段内容']:=DBListBox1.Items.Text; t_ch_dui_format['排序字段']:=ListBox1.Items.Text; table_before_post(t_ch_dui_format,'模板名称'); table_before_post(t_ch_dui_format,'字段内容'); end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_formatDeleteError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); begin showmessage('帐单模板已经使用,不能删除!!'); abort; end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_format_detailBeforeInsert( DataSet: TDataSet); begin table_post(t_ch_dui_format); end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_dui_formatrpt.FormShow(Sender: TObject); begin t_ch_dui_format.Parameters[0].value:=dui_format_type; t_ch_dui_format.open; t_ch_dui_feefield.Open; t_ch_dui_feename.Open; case dui_format_type of 1,2,3,4: begin frm_data_share.t_code_fee.Requery(); frm_data_share.t_code_fee.Filtered:=false; frm_data_share.t_code_fee.Filter:='海运=1'; frm_data_share.t_code_fee.Filtered:=true; end; 5,6,7,8: begin frm_data_share.t_code_fee.Requery(); frm_data_share.t_code_fee.Filtered:=false; frm_data_share.t_code_fee.Filter:='空运=1'; frm_data_share.t_code_fee.Filtered:=true; end; end; case dui_format_type of 1,2: begin bsSkinListBox1.Items.Text:=memo1.text; end; 3,4: begin bsSkinListBox1.Items.Text:=memo2.text; end; 5,6: begin bsSkinListBox1.Items.Text:=memo3.text; end; 7,8: begin bsSkinListBox1.Items.Text:=memo4.text; end; 9,12: begin bsSkinListBox1.Items.Text:=memo5.text; end; end; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton6Click(Sender: TObject); var if_find:boolean; i:integer; begin if t_ch_dui_format.IsEmpty then exit; if bsSkinListBox1.ItemIndex=-1 then exit; for i:=0 to DBListBox1.Items.Count-1 do begin if copy(DBListBox1.Items[i],2,length(DBListBox1.Items[i])-1)=bsSkinListBox1.Items[bsSkinListBox1.ItemIndex] then exit; end; t_ch_dui_format.edit; DBListBox1.Items.Add('0'+bsSkinListBox1.Items[bsSkinListBox1.ItemIndex]); t_ch_dui_format.post; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton10Click(Sender: TObject); begin if DBListBox1.ItemIndex=-1 then exit; t_ch_dui_format.edit; DBListBox1.Items.Delete(DBListBox1.ItemIndex); t_ch_dui_format.post; // t_ch_dui_feename.Post; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton11Click(Sender: TObject); var if_find:boolean; i:integer; aQuery:TADOQuery; begin if t_ch_dui_feefield.State in [dsedit,dsinsert] then t_ch_dui_feefield.Post; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 费用名称 from t_ch_dui_feename where 费用名称='''+frm_data_share.t_code_fee.fieldbyname('中文名').asstring+''' and DM_ID='+inttostr(t_ch_dui_format['DM_ID'])); Open; if IsEmpty then begin t_ch_dui_feename.Insert; t_ch_dui_feename['费用名称']:=frm_data_share.t_code_fee.fieldbyname('中文名').asstring; t_ch_dui_feename.Post; end; end; finally FreeAndNil(aQuery); end; { if t_ch_dui_format.IsEmpty then exit; if bsSkinListBox1.ItemIndex=-1 then exit; for i:=0 to DBListBox1.Items.Count-1 do begin if copy(DBListBox1.Items[i],2,length(DBListBox1.Items[i])-1)=frm_data_share.t_code_fee.fieldbyname('中文名').asstring then exit; end; t_ch_dui_format.edit; DBListBox1.Items.Add('1'+frm_data_share.t_code_fee.fieldbyname('中文名').asstring); t_ch_dui_format.post; } end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton7Click(Sender: TObject); var i:integer; begin if t_ch_dui_format.IsEmpty then exit; if DBListBox1.ItemIndex=-1 then exit; if DBListBox1.ItemIndex=0 then exit; t_ch_dui_format.edit; i:=DBListBox1.ItemIndex-1; DBListBox1.Items.Move(DBListBox1.ItemIndex,DBListBox1.ItemIndex-1); t_ch_dui_format.post; DBListBox1.ItemIndex:=i; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton8Click(Sender: TObject); var i:integer; begin if t_ch_dui_format.IsEmpty then exit; if DBListBox1.ItemIndex=-1 then exit; if DBListBox1.ItemIndex=DBListBox1.Items.Count-1 then exit; t_ch_dui_format.edit; i:=DBListBox1.ItemIndex+1; DBListBox1.Items.Move(DBListBox1.ItemIndex,DBListBox1.ItemIndex+1); t_ch_dui_format.post; DBListBox1.ItemIndex:=i; end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_formatAfterScroll(DataSet: TDataSet); begin DBListBox1.Items.Text:=t_ch_dui_format.fieldbyname('字段内容').asstring; ListBox1.Items.Text:=t_ch_dui_format.fieldbyname('排序字段').asstring; end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_feefieldAfterInsert( DataSet: TDataSet); begin t_ch_dui_feefield['DM_ID']:=t_ch_dui_format['DM_ID']; t_ch_dui_feefield['应收USD']:=1; t_ch_dui_feefield['应收RMB']:=1; t_ch_dui_feefield['应付USD']:=1; t_ch_dui_feefield['应付RMB']:=1; t_ch_dui_feefield['应收合计']:=1; t_ch_dui_feefield['应付合计']:=1; t_ch_dui_feefield['利润合计']:=1; t_ch_dui_feefield['应收USD显示']:=''; t_ch_dui_feefield['应收RMB显示']:=''; t_ch_dui_feefield['应付USD显示']:=''; t_ch_dui_feefield['应付RMB显示']:=''; t_ch_dui_feefield['应收合计显示']:=''; t_ch_dui_feefield['应付合计显示']:=''; t_ch_dui_feefield['利润合计显示']:=''; t_ch_dui_feefield['应收OT']:=1; t_ch_dui_feefield['应付OT']:=1; t_ch_dui_feefield['应收OT显示']:=''; t_ch_dui_feefield['应付OT显示']:=''; end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_feenameAfterInsert( DataSet: TDataSet); begin t_ch_dui_feename['FF_ID']:=t_ch_dui_feefield['FF_ID']; t_ch_dui_feename['DM_ID']:=t_ch_dui_feefield['DM_ID']; t_ch_dui_feename['费用字段']:=t_ch_dui_feefield['费用字段']; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton9Click(Sender: TObject); begin if t_ch_dui_format.State in [dsedit,dsinsert] then t_ch_dui_format.Post; t_ch_dui_feefield.Insert; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton13Click(Sender: TObject); begin t_ch_dui_feefield.Delete; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton14Click(Sender: TObject); begin t_ch_dui_feefield.Post; end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_feefieldBeforeInsert( DataSet: TDataSet); begin if t_ch_dui_format.IsEmpty then exit; end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_feenameBeforeInsert( DataSet: TDataSet); begin if t_ch_dui_feefield.IsEmpty then exit; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton12Click(Sender: TObject); begin if t_ch_dui_feename.IsEmpty then Exit; t_ch_dui_feename.Delete; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton15Click(Sender: TObject); var if_find:boolean; i:integer; begin if t_ch_dui_format.IsEmpty then exit; if DBListBox1.ItemIndex=-1 then exit; for i:=0 to ListBox1.Items.Count-1 do begin if ListBox1.Items[i]=DBListBox1.Items[DBListBox1.ItemIndex] then exit; end; t_ch_dui_format.edit; ListBox1.Items.Add(copy(DBListBox1.Items[DBListBox1.ItemIndex],2,length(DBListBox1.Items[DBListBox1.ItemIndex])-1)); t_ch_dui_format.post; end; procedure Tfrm_rp_dui_formatrpt.bsSkinButton16Click(Sender: TObject); begin if ListBox1.ItemIndex=-1 then exit; t_ch_dui_format.edit; ListBox1.Items.Delete(ListBox1.ItemIndex); t_ch_dui_format.post; end; procedure Tfrm_rp_dui_formatrpt.t_ch_dui_feefieldBeforeDelete( DataSet: TDataSet); begin { if not t_ch_dui_feename.IsEmpty then begin MessageDlg('此费用分组包含费用明细,请先删除费用明细在删除或修改分组!',mtWarning,[mbOk],0); abort; end; } end; end.