unit u_op_letter_free; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, dxExEdtr, dxDBGrid, dxTL, dxDBCtrl, dxCntner, bsSkinCtrls, StdCtrls, Mask, DBCtrls, ComCtrls, bsSkinTabs, Menus, XPMenu; type Tfra_op_letter_free = class(TFrame) t_op_letter: TADOQuery; t_op_letter1: TDataSource; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1HEAD_TO: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1Column5: TdxDBGridColumn; bsSkinPanel1: TbsSkinPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinPanel3: TbsSkinPanel; Label1: TLabel; Label2: TLabel; DBEdit1: TDBEdit; DBEdit2: TDBEdit; Button5: TButton; t_op_letter_free_detail: TADOQuery; t_op_letter_free1: TDataSource; bsSkinPageControl1: TbsSkinPageControl; t_op_letter_detail: TADOQuery; t_op_letter_detail1: TDataSource; PopupMenu1: TPopupMenu; N26: TMenuItem; XPMenu1: TXPMenu; op_type: TEdit; DBEdit3: TDBEdit; t_op_hd: TADOQuery; t_op_hd1: TDataSource; procedure bsSkinPanel1Resize(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure t_op_letterBeforeInsert(DataSet: TDataSet); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure add_letter(Sender:TObject); procedure t_op_letterAfterInsert(DataSet: TDataSet); procedure DBEdit3Change(Sender: TObject); procedure bsSkinPanel3Resize(Sender: TObject); procedure bsSkinPanel2Resize(Sender: TObject); procedure Button5Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure N26Click(Sender: TObject); procedure t_op_letter_detailAfterInsert(DataSet: TDataSet); procedure t_op_letter_detailBeforeInsert(DataSet: TDataSet); procedure t_op_letter_detailBeforeEdit(DataSet: TDataSet); procedure t_op_letterBeforeEdit(DataSet: TDataSet); private { Private declarations } public { Public declarations } end; implementation uses u_main, u_data_share, u_code_send_head, my_sys_function, u_op_letter_free_his; {$R *.dfm} procedure Tfra_op_letter_free.add_letter(Sender:TObject); var menu_skins:Tmenuitem; begin menu_skins:= Sender as Tmenuitem; try modify_all:=true; t_op_letter.Insert; t_op_letter['函电名称']:=menu_skins.Caption; t_op_letter['LF']:=menu_skins.Hint; t_op_letter.Post; finally modify_all:=false; end; end; procedure Tfra_op_letter_free.bsSkinPanel1Resize(Sender: TObject); begin bsSkinPageControl1.Height:=bsSkinPanel1.Height-bsSkinPanel2.Height-bsSkinPanel3.Height+18; end; procedure Tfra_op_letter_free.bsSkinButton1Click(Sender: TObject); var Pnt:Tpoint; nn:Tmenuitem; i:integer; begin if N26.Hint<>'do' then begin i:=0; N26.Hint:='do'; frm_data_share.t_op_letter_free.Filtered:=false; frm_data_share.t_op_letter_free.requery; frm_data_share.t_op_letter_free.Filter:='业务类别='+''''+op_type.text+''''; frm_data_share.t_op_letter_free.Filtered:=true; while not frm_data_share.t_op_letter_free.eof do begin i:=i+1; nn:=Tmenuitem.Create(application); with nn do begin caption:='-'; PopupMenu1.Items.Add(nn); end; nn:=Tmenuitem.Create(application); with nn do begin caption:=frm_data_share.t_op_letter_free.fieldbyname('函电名称').asstring; nn.Hint:=frm_data_share.t_op_letter_free.fieldbyname('LF').asstring; onclick:=add_letter; PopupMenu1.Items.Add(nn); end; frm_data_share.t_op_letter_free.next; end; end; Pnt:=bsSkinButton1.ClientToScreen(Point(0,bsSkinButton1.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfra_op_letter_free.t_op_letterBeforeInsert(DataSet: TDataSet); begin if (if_open('776')) then begin showmessage('此票业务不能修改!'); abort; end; if t_op_letter.DataSource.DataSet.State=dsinsert then t_op_letter.DataSource.DataSet.post; IF modify_all=false THEN ABORT; end; procedure Tfra_op_letter_free.bsSkinButton2Click(Sender: TObject); begin if (t_op_letter.State=dsinsert)or(t_op_letter.State=dsedit) then t_op_letter.post; if (t_op_letter_detail.State=dsinsert)or(t_op_letter_detail.State=dsedit) then t_op_letter_detail.post; end; procedure Tfra_op_letter_free.bsSkinButton4Click(Sender: TObject); begin if t_op_letter.IsEmpty then exit; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)=IDOK then begin if not t_op_letter_detail.IsEmpty then t_op_letter_detail.Delete; t_op_letter.delete; end; end; procedure Tfra_op_letter_free.bsSkinButton3Click(Sender: TObject); begin if (t_op_letter_detail.State=dsinsert)or(t_op_letter_detail.State=dsedit) then t_op_letter_detail.cancel; if (t_op_letter.State=dsinsert)or(t_op_letter.State=dsedit) then t_op_letter.cancel; end; procedure Tfra_op_letter_free.t_op_letterAfterInsert(DataSet: TDataSet); begin t_op_letter['编号']:=t_op_letter.DataSource.DataSet['编号']; t_op_letter['签发人']:=employee; t_op_letter['签发日期']:=date; end; procedure Tfra_op_letter_free.DBEdit3Change(Sender: TObject); var i:integer; TabSheet: TbsSkinTabSheet; lb: TLabel; ed: TDBEdit; mm: TDBMemo; begin for i:=0 to bsSkinPageControl1.PageCount -1 do begin bsSkinPageControl1.Pages[i].free; end; if t_op_letter.IsEmpty then exit; if DBEdit3.text=''then exit; TabSheet:=TbsSkinTabSheet.create(self); TabSheet.PageControl:=bsSkinPageControl1; bsSkinPageControl1.ActivePageIndex:=0; t_op_letter_detail.close; t_op_letter_detail.SQL.Clear; t_op_letter_detail.SQL.Add('select * from t_op_letter_free'+t_op_letter.fieldbyname('LF').asstring +' where LE_ID=:LE_ID'); t_op_letter_detail.Open; t_op_letter_free_detail.first; i:=0; while not t_op_letter_free_detail.eof do begin if t_op_letter_free_detail.FieldByName('数据类型').asstring='短' then begin lb:=TLabel.create(self); lb.Parent:=bsSkinPageControl1.Pages[0]; lb.Caption:=t_op_letter_free_detail.FieldByName('字段名称').asstring; lb.Transparent:=true; lb.Left:=76-lb.Width; lb.top:=26*i+7;//72 ed:=TDBEdit.create(self); ed.Parent:=bsSkinPageControl1.Pages[0]; ed.DataSource:=t_op_letter_detail1; ed.DataField:=t_op_letter_free_detail.FieldByName('字段名称').asstring; ed.Left:=78; ed.top:=26*i+4; ed.Width:=bsSkinPageControl1.Width-85; i:=i+1; end else begin lb:=TLabel.create(self); lb.Parent:=bsSkinPageControl1.Pages[0]; lb.Caption:=t_op_letter_free_detail.FieldByName('字段名称').asstring; lb.Transparent:=true; lb.Left:=76-lb.Width; lb.top:=26*i+7;//72 mm:=TDBMemo.create(self); mm.Parent:=bsSkinPageControl1.Pages[0]; mm.DataSource:=t_op_letter_detail1; mm.DataField:=t_op_letter_free_detail.FieldByName('字段名称').asstring; mm.Left:=78; mm.top:=26*i+4; mm.Width:=bsSkinPageControl1.Width-85; mm.Height:=26*3-6; i:=i+3; end; t_op_letter_free_detail.next; end; end; procedure Tfra_op_letter_free.bsSkinPanel3Resize(Sender: TObject); begin DBEdit1.Width:=bsSkinPanel3.Width-DBEdit1.left-6; DBEdit2.Width:=DBEdit1.Width-20; Button5.Left:=DBEdit2.left+DBEdit2.Width; end; procedure Tfra_op_letter_free.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.width/5); bsSkinButton1.width:=i; bsSkinButton2.width:=i; bsSkinButton4.width:=i; bsSkinButton3.width:=i; end; procedure Tfra_op_letter_free.Button5Click(Sender: TObject); begin if t_op_letter.isempty then exit; if not if_open('144') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; try frm_code_send_head:=tfrm_code_send_head.Create (self); code_send_head_num:=3; frm_code_send_head.DataSource1.Enabled:=false; frm_code_send_head.DataSource1.DataSet:=t_op_letter; frm_code_send_head.DataSource1.Enabled:=true; frm_code_send_head.ShowModal; finally frm_code_send_head.Free; frm_code_send_head:=nil; end; end; procedure Tfra_op_letter_free.bsSkinButton9Click(Sender: TObject); var book1:Tbookmark; begin if t_op_letter.IsEmpty then exit; if (t_op_letter.State=dsinsert)or(t_op_letter.State=dsedit) then t_op_letter.post; if (t_op_letter_detail.State=dsinsert)or(t_op_letter_detail.State=dsedit) then t_op_letter_detail.post; try book1:=t_op_letter.GetBookmark; t_op_letter.DisableControls; if op_type.text='海运出口'then begin t_op_hd.Close; t_op_hd.Open; sys_print(op_type.text+'函电'+t_op_letter.fieldbyname('LF').asstring,2,t_op_letter.DataSource,t_op_letter1,t_op_letter_detail1,t_op_hd1,nil,nil,nil,nil,nil,nil,nil) END else sys_print(op_type.text+'函电'+t_op_letter.fieldbyname('LF').asstring,2,t_op_letter.DataSource,t_op_letter1,t_op_letter_detail1,nil,nil,nil,nil,nil,nil,nil,nil); finally t_op_letter.GotoBookmark(book1); t_op_letter.EnableControls; end; end; procedure Tfra_op_letter_free.N26Click(Sender: TObject); begin try modify_all:=true; if not assigned(frm_op_letter_free_his) then frm_op_letter_free_his:=tfrm_op_letter_free_his.Create (self); if op_type.text='海运出口'then frm_op_letter_free_his.op_type.text:='1'; if op_type.text='海运进口'then frm_op_letter_free_his.op_type.text:='2'; if op_type.text='空运出口'then frm_op_letter_free_his.op_type.text:='3'; if op_type.text='空运进口'then frm_op_letter_free_his.op_type.text:='4'; frm_op_letter_free_his.t_do_letter.Enabled:=false; frm_op_letter_free_his.t_do_letter.DataSet:=t_op_letter; frm_op_letter_free_his.t_do_letter.Enabled:=true; frm_op_letter_free_his.t_do_letter_detail.Enabled:=false; frm_op_letter_free_his.t_do_letter_detail.DataSet:=t_op_letter_detail; frm_op_letter_free_his.t_do_letter_detail.Enabled:=true; frm_op_letter_free_his.ShowModal; finally frm_op_letter_free_his.free; frm_op_letter_free_his:=nil; modify_all:=false; end; end; procedure Tfra_op_letter_free.t_op_letter_detailAfterInsert( DataSet: TDataSet); var aQuery:TADOQuery; begin { if t_op_letter.FieldByName('函电名称').AsString='PRE-ALERT' then begin if t_op_letter_detail.FindField('费用明细描述')<>nil then begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 主提单号 from '); end; finally FreeAndNil(aQuery); end; end; end; } end; procedure Tfra_op_letter_free.t_op_letter_detailBeforeInsert( DataSet: TDataSet); begin if (if_open('776')) then begin showmessage('此票业务不能修改!'); abort; end; end; procedure Tfra_op_letter_free.t_op_letter_detailBeforeEdit( DataSet: TDataSet); begin if (if_open('776')) then begin showmessage('此票业务不能修改!'); abort; end; end; procedure Tfra_op_letter_free.t_op_letterBeforeEdit(DataSet: TDataSet); begin if (if_open('776')) then begin showmessage('此票业务不能修改!'); abort; end; end; end.