unit u_rp_dui_format; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, bsSkinCtrls, BusinessSkinForm, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, bsSkinBoxCtrls, StdCtrls, DBCtrls; type Tfrm_rp_dui_format = 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; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; 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; DBListBox1: TListBox; 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); private { Private declarations } public { Public declarations } end; var frm_rp_dui_format: Tfrm_rp_dui_format; dui_format_type:integer; implementation uses u_main, u_data_share, my_sys_function; {$R *.dfm} procedure Tfrm_rp_dui_format.bsSkinButton1Click(Sender: TObject); begin t_ch_dui_format.Insert; end; procedure Tfrm_rp_dui_format.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_dui_format); end; procedure Tfrm_rp_dui_format.bsSkinButton4Click(Sender: TObject); begin table_delete(t_ch_dui_format); end; procedure Tfrm_rp_dui_format.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_dui_format); end; procedure Tfrm_rp_dui_format.t_ch_dui_formatAfterInsert(DataSet: TDataSet); begin t_ch_dui_format['类别']:=dui_format_type; end; procedure Tfrm_rp_dui_format.t_ch_dui_formatBeforePost(DataSet: TDataSet); begin t_ch_dui_format['字段内容']:=DBListBox1.Items.Text; table_before_post(t_ch_dui_format,'模板名称'); table_before_post(t_ch_dui_format,'字段内容'); end; procedure Tfrm_rp_dui_format.t_ch_dui_formatDeleteError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); begin showmessage('帐单模板已经使用,不能删除!!'); abort; end; procedure Tfrm_rp_dui_format.t_ch_dui_format_detailBeforeInsert( DataSet: TDataSet); begin table_post(t_ch_dui_format); end; procedure Tfrm_rp_dui_format.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_dui_format.FormShow(Sender: TObject); var aQuery:TADOQuery; begin Memo1.Lines.Clear; aQuery:=CreateAdoQuery; with aQuery do begin Close; SQL.Clear; SQL.Add('select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME=''t_op_seae'''); Open; end; aQuery.First; while not aQuery.Eof do begin Memo1.Lines.Add(aQuery.fieldbyname('COLUMN_NAME').AsString); aQuery.Next; end; FreeAndNil(aQuery); t_ch_dui_format.Parameters[0].value:=dui_format_type; t_ch_dui_format.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; end; end; procedure Tfrm_rp_dui_format.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_format.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; end; procedure Tfrm_rp_dui_format.bsSkinButton11Click(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)=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_format.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_format.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_format.t_ch_dui_formatAfterScroll(DataSet: TDataSet); begin DBListBox1.Items.Text:=t_ch_dui_format.fieldbyname('字段内容').asstring; end; end.