unit u_op_letter_his; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, dxExEdtr, dxDBTLCl, dxGrClms, dxTL, dxDBCtrl, dxDBGrid, dxCntner, wwdbdatetimepicker, RxLookup, StdCtrls, ExtCtrls, BusinessSkinForm, DB, ADODB, XPMenu, Menus, DBCtrls, Mask; type Tfrm_op_letter_his = class(TForm) bsSkinPanel1: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton3: TbsSkinButton; Panel1: TPanel; bsSkinPanel3: TbsSkinPanel; Label6: TLabel; Label1: TLabel; Label9: TLabel; Label3: TLabel; Label2: TLabel; Label10: TLabel; Edit1: TEdit; Edit2: TEdit; RxDBLookupCombo2: TRxDBLookupCombo; Edit4: TEdit; Edit3: TEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn5: TdxDBGridMaskColumn; dxDBGridMaskColumn6: TdxDBGridMaskColumn; dxDBGridMaskColumn7: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridDateColumn; dxDBGrid1Column17: TdxDBGridDateColumn; dxDBGrid1Column18: TdxDBGridDateColumn; dxDBGrid1Column19: TdxDBGridMaskColumn; dxDBGrid1Column20: TdxDBGridMaskColumn; dxDBGrid1Column22: TdxDBGridDateColumn; dxDBGrid1Column63: TdxDBGridMaskColumn; dxDBGrid1Column64: TdxDBGridMaskColumn; dxDBGrid1Column65: TdxDBGridDateColumn; dxDBGrid1Column66: TdxDBGridMaskColumn; dxDBGrid1Column67: TdxDBGridMaskColumn; t_bill1: TDataSource; bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinPanel2: TbsSkinPanel; bsSkinPanel5: TbsSkinPanel; Label4: TLabel; Label5: TLabel; DBEdit1: TDBEdit; DBEdit2: TDBEdit; bsSkinNotebook1: TbsSkinNotebook; Label7: TLabel; Label8: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; DBMemo1: TDBMemo; DBMemo2: TDBMemo; DBMemo3: TDBMemo; DBMemo4: TDBMemo; DBMemo5: TDBMemo; Label14: TLabel; Label15: TLabel; DBEdit4: TDBEdit; DBMemo6: TDBMemo; Label16: TLabel; Label17: TLabel; Label18: TLabel; Label19: TLabel; DBEdit5: TDBEdit; DBEdit6: TDBEdit; DBEdit7: TDBEdit; DBMemo7: TDBMemo; Label20: TLabel; Label21: TLabel; DBEdit8: TDBEdit; DBMemo8: TDBMemo; Label22: TLabel; Label23: TLabel; Label24: TLabel; DBMemo9: TDBMemo; DBMemo10: TDBMemo; DBMemo11: TDBMemo; Label25: TLabel; Label26: TLabel; Label27: TLabel; Label28: TLabel; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; Label33: TLabel; DBEdit9: TDBEdit; DBEdit10: TDBEdit; DBEdit12: TDBEdit; DBEdit13: TDBEdit; DBEdit15: TDBEdit; DBEdit16: TDBEdit; DBMemo12: TDBMemo; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; Label34: TLabel; Label35: TLabel; Label36: TLabel; Label37: TLabel; Label38: TLabel; Label39: TLabel; Label40: TLabel; Label41: TLabel; Label42: TLabel; Label43: TLabel; Label44: TLabel; Label45: TLabel; Label49: TLabel; Label50: TLabel; DBEdit14: TDBEdit; DBEdit17: TDBEdit; DBEdit18: TDBEdit; DBEdit19: TDBEdit; DBEdit20: TDBEdit; DBEdit11: TDBEdit; DBEdit21: TDBEdit; DBEdit22: TDBEdit; DBEdit23: TDBEdit; DBEdit24: TDBEdit; DBEdit25: TDBEdit; DBMemo13: TDBMemo; DBEdit31: TDBEdit; DBEdit32: TDBEdit; Label46: TLabel; Label47: TLabel; Label48: TLabel; Label51: TLabel; Label52: TLabel; DBEdit26: TDBEdit; DBEdit27: TDBEdit; DBEdit28: TDBEdit; DBEdit29: TDBEdit; DBMemo14: TDBMemo; Label53: TLabel; Label54: TLabel; DBEdit30: TDBEdit; DBMemo15: TDBMemo; Label55: TLabel; Label56: TLabel; DBMemo16: TDBMemo; DBMemo17: TDBMemo; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; t_op_letter_old1: TDataSource; t_op_letter_cq_old: TADOQuery; t_op_letter_cq_old1: TDataSource; t_op_letter_cz_old: TADOQuery; t_op_letter_cz_old1: TDataSource; t_op_letter_df_old: TADOQuery; t_op_letter_df_old1: TDataSource; t_op_letter_dq_old: TADOQuery; t_op_letter_dq_old1: TDataSource; t_op_letter_gg_old: TADOQuery; t_op_letter_gg_old1: TDataSource; t_op_letter_hc_old: TADOQuery; t_op_letter_hc_old1: TDataSource; t_op_letter_pc_old: TADOQuery; t_op_letter_pc_old1: TDataSource; t_op_letter_rh_old: TADOQuery; t_op_letter_rh_old1: TDataSource; t_op_letter_yj_old1: TDataSource; t_op_letter_yj_old: TADOQuery; PopupMenu2: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N21: TMenuItem; N22: TMenuItem; N20: TMenuItem; t_op_letter_old: TADOQuery; t_op_letter_hd_old: TADOQuery; t_op_letter_hd_old1: TDataSource; DBEdit3: TDBEdit; dxDBGrid1Column2: TdxDBGridColumn; t_bill: TADOStoredProc; procedure DBEdit3Change(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure add_letter(old_letter,new_letter:Tadoquery); procedure bsSkinButton1Click(Sender: TObject); procedure Edit1KeyPress(Sender: TObject; var Key: Char); private { Private declarations } public { Public declarations } end; var frm_op_letter_his: Tfrm_op_letter_his; implementation uses u_op_letter, u_main, my_sys_function; {$R *.dfm} procedure Tfrm_op_letter_his.add_letter(old_letter,new_letter:Tadoquery); var j:integer; begin if not old_letter.IsEmpty then begin new_letter.insert; for j:=0 to (old_letter.fieldcount-1) do begin if (old_letter.fields[j].FieldName<>'LE_ID') then new_letter[old_letter.fields[j].FieldName]:= old_letter.fields[j].value; end; new_letter.post; end; end; procedure Tfrm_op_letter_his.DBEdit3Change(Sender: TObject); begin if t_op_letter_old.IsEmpty then begin bsSkinNotebook1.PageIndex:=9; end else if DBEdit3.Text='重签保函' then begin bsSkinNotebook1.PageIndex:=0; end else if DBEdit3.Text='超重保函' then begin bsSkinNotebook1.PageIndex:=1; end else if DBEdit3.Text='电放保函' then begin bsSkinNotebook1.PageIndex:=2; end else if DBEdit3.Text='倒签保函' then begin bsSkinNotebook1.PageIndex:=3; end else if DBEdit3.Text='更改通知' then begin bsSkinNotebook1.PageIndex:=4; end else if DBEdit3.Text='换船通知' then begin bsSkinNotebook1.PageIndex:=5; end else if DBEdit3.Text='派车通知' then begin bsSkinNotebook1.PageIndex:=6; end else if DBEdit3.Text='入货通知' then begin bsSkinNotebook1.PageIndex:=7; end else if DBEdit3.Text='预借保函' then begin bsSkinNotebook1.PageIndex:=8; end else if DBEdit3.Text='业务函电' then begin bsSkinNotebook1.PageIndex:=10; end; end; procedure Tfrm_op_letter_his.bsSkinButton10Click(Sender: TObject); begin Edit1.text:=''; Edit4.text:=''; RxDBLookupCombo2.ClearValue; Edit2.text:=''; Edit3.text:=''; wwDBDateTimePicker1.text:=''; end; procedure Tfrm_op_letter_his.bsSkinButton5Click(Sender: TObject); begin CLOSE; end; procedure Tfrm_op_letter_his.bsSkinButton2Click(Sender: TObject); var str:widestring; begin if Edit1.text<>''then str:=' where 业务编号 like '+''''+'%'+Edit1.text+'%'+''''; if Edit4.text<>''then begin if str=''then str:=' where 委托编号 like '+''''+'%'+Edit4.text+'%'+'''' else str:=str+' and 委托编号 like '+''''+'%'+Edit4.text+'%'+''''; end; if Edit2.text<>''then begin if str=''then str:=' where 主提单号 like '+''''+'%'+Edit2.text+'%'+'''' else str:=str+' and 主提单号 like '+''''+'%'+Edit2.text+'%'+''''; end; if Edit3.text<>''then begin if str=''then str:=' where 分提单号 like '+''''+'%'+Edit3.text+'%'+'''' else str:=str+' and 分提单号 like '+''''+'%'+Edit3.text+'%'+''''; end; if RxDBLookupCombo2.DisplayValue<>''then begin if str=''then str:=' where 委托单位='+''''+RxDBLookupCombo2.DisplayValues[1]+'''' else str:=str+' and 委托单位='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; end; if wwDBDateTimePicker1.text<>''then begin if str=''then str:=' where 开船日期='+''''+wwDBDateTimePicker1.text+'''' else str:=str+' and 开船日期='+''''+wwDBDateTimePicker1.text+''''; end; str:='select * from t_op_seae '+str+default_sort(53,'t_op_seae','',''); t_bill.close; t_bill.Parameters.ParamByName('SQLStr').value:=str; t_bill.open; t_op_letter_old.Open; t_op_letter_cq_old.Open; t_op_letter_cz_old.Open; t_op_letter_df_old.Open; t_op_letter_dq_old.Open; t_op_letter_gg_old.Open; t_op_letter_hc_old.Open; t_op_letter_pc_old.Open; t_op_letter_rh_old.Open; t_op_letter_yj_old.Open; t_op_letter_hd_old.Open; end; procedure Tfrm_op_letter_his.bsSkinButton3Click(Sender: TObject); var i,j:integer; begin if t_op_letter_old.IsEmpty then exit; if dxDBGrid1.SelectedCount>=1 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_letter_old.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); frm_op_letter_insert:=true; frm_op_letter.t_op_letter.append; for j:=0 to (t_op_letter_old.fieldcount-1) do begin if (t_op_letter_old.fields[j].FieldName<>'LE_ID') and(t_op_letter_old.fields[j].FieldName<>'编号') then frm_op_letter.t_op_letter[t_op_letter_old.fields[j].FieldName]:= t_op_letter_old.fields[j].value; end; frm_op_letter.t_op_letter['签发人']:=employee; frm_op_letter.t_op_letter['签发日期']:=date; frm_op_letter.t_op_letter.post; if t_op_letter_old.fieldbyname('函电名称').asstring='重签保函' then begin add_letter(t_op_letter_cq_old,frm_op_letter.t_op_letter_cq); end; if t_op_letter_old.fieldbyname('函电名称').asstring='超重保函' then begin add_letter(t_op_letter_cz_old,frm_op_letter.t_op_letter_cz); end; if t_op_letter_old.fieldbyname('函电名称').asstring='电放保函' then begin add_letter(t_op_letter_df_old,frm_op_letter.t_op_letter_df); end; if t_op_letter_old.fieldbyname('函电名称').asstring='倒签保函' then begin add_letter(t_op_letter_dq_old,frm_op_letter.t_op_letter_dq); end; if t_op_letter_old.fieldbyname('函电名称').asstring='更改通知' then begin add_letter(t_op_letter_gg_old,frm_op_letter.t_op_letter_gg); end; if t_op_letter_old.fieldbyname('函电名称').asstring='换船通知' then begin add_letter(t_op_letter_hc_old,frm_op_letter.t_op_letter_hc); end; if t_op_letter_old.fieldbyname('函电名称').asstring='派车通知' then begin add_letter(t_op_letter_pc_old,frm_op_letter.t_op_letter_pc); end; if t_op_letter_old.fieldbyname('函电名称').asstring='入货通知' then begin add_letter(t_op_letter_rh_old,frm_op_letter.t_op_letter_rh); end; if t_op_letter_old.fieldbyname('函电名称').asstring='预借保函' then begin add_letter(t_op_letter_yj_old,frm_op_letter.t_op_letter_yj); end; if t_op_letter_old.fieldbyname('函电名称').asstring='业务函电' then begin add_letter(t_op_letter_hd_old,frm_op_letter.t_op_letter_hd); end; end; end else begin frm_op_letter_insert:=true; frm_op_letter.t_op_letter.append; for j:=0 to (t_op_letter_old.fieldcount-1) do begin if (t_op_letter_old.fields[j].FieldName<>'LE_ID') and(t_op_letter_old.fields[j].FieldName<>'编号') then frm_op_letter.t_op_letter[t_op_letter_old.fields[j].FieldName]:= t_op_letter_old.fields[j].value; end; frm_op_letter.t_op_letter['签发人']:=employee; frm_op_letter.t_op_letter['签发日期']:=date; frm_op_letter.t_op_letter.post; if t_op_letter_old.fieldbyname('函电名称').asstring='重签保函' then begin add_letter(t_op_letter_cq_old,frm_op_letter.t_op_letter_cq); end; if t_op_letter_old.fieldbyname('函电名称').asstring='超重保函' then begin add_letter(t_op_letter_cz_old,frm_op_letter.t_op_letter_cz); end; if t_op_letter_old.fieldbyname('函电名称').asstring='电放保函' then begin add_letter(t_op_letter_df_old,frm_op_letter.t_op_letter_df); end; if t_op_letter_old.fieldbyname('函电名称').asstring='倒签保函' then begin add_letter(t_op_letter_dq_old,frm_op_letter.t_op_letter_dq); end; if t_op_letter_old.fieldbyname('函电名称').asstring='更改通知' then begin add_letter(t_op_letter_gg_old,frm_op_letter.t_op_letter_gg); end; if t_op_letter_old.fieldbyname('函电名称').asstring='换船通知' then begin add_letter(t_op_letter_hc_old,frm_op_letter.t_op_letter_hc); end; if t_op_letter_old.fieldbyname('函电名称').asstring='派车通知' then begin add_letter(t_op_letter_pc_old,frm_op_letter.t_op_letter_pc); end; if t_op_letter_old.fieldbyname('函电名称').asstring='入货通知' then begin add_letter(t_op_letter_rh_old,frm_op_letter.t_op_letter_rh); end; if t_op_letter_old.fieldbyname('函电名称').asstring='预借保函' then begin add_letter(t_op_letter_yj_old,frm_op_letter.t_op_letter_yj); end; if t_op_letter_old.fieldbyname('函电名称').asstring='业务函电' then begin add_letter(t_op_letter_hd_old,frm_op_letter.t_op_letter_hd); end; end; close; end; procedure Tfrm_op_letter_his.bsSkinButton1Click(Sender: TObject); var j:integer; begin if t_op_letter_old.IsEmpty then exit; t_op_letter_old.first; while not t_op_letter_old.eof do begin frm_op_letter_insert:=true; frm_op_letter.t_op_letter.append; for j:=0 to (t_op_letter_old.fieldcount-1) do begin if (t_op_letter_old.fields[j].FieldName<>'LE_ID') and(t_op_letter_old.fields[j].FieldName<>'编号') then frm_op_letter.t_op_letter[t_op_letter_old.fields[j].FieldName]:= t_op_letter_old.fields[j].value; end; frm_op_letter.t_op_letter['签发人']:=employee; frm_op_letter.t_op_letter['签发日期']:=date; frm_op_letter.t_op_letter.post; if t_op_letter_old.fieldbyname('函电名称').asstring='重签保函' then begin add_letter(t_op_letter_cq_old,frm_op_letter.t_op_letter_cq); end; if t_op_letter_old.fieldbyname('函电名称').asstring='超重保函' then begin add_letter(t_op_letter_cz_old,frm_op_letter.t_op_letter_cz); end; if t_op_letter_old.fieldbyname('函电名称').asstring='电放保函' then begin add_letter(t_op_letter_df_old,frm_op_letter.t_op_letter_df); end; if t_op_letter_old.fieldbyname('函电名称').asstring='倒签保函' then begin add_letter(t_op_letter_dq_old,frm_op_letter.t_op_letter_dq); end; if t_op_letter_old.fieldbyname('函电名称').asstring='更改通知' then begin add_letter(t_op_letter_gg_old,frm_op_letter.t_op_letter_gg); end; if t_op_letter_old.fieldbyname('函电名称').asstring='换船通知' then begin add_letter(t_op_letter_hc_old,frm_op_letter.t_op_letter_hc); end; if t_op_letter_old.fieldbyname('函电名称').asstring='派车通知' then begin add_letter(t_op_letter_pc_old,frm_op_letter.t_op_letter_pc); end; if t_op_letter_old.fieldbyname('函电名称').asstring='入货通知' then begin add_letter(t_op_letter_rh_old,frm_op_letter.t_op_letter_rh); end; if t_op_letter_old.fieldbyname('函电名称').asstring='预借保函' then begin add_letter(t_op_letter_yj_old,frm_op_letter.t_op_letter_yj); end; if t_op_letter_old.fieldbyname('函电名称').asstring='业务函电' then begin add_letter(t_op_letter_hd_old,frm_op_letter.t_op_letter_hd); end; t_op_letter_old.next; end; close; end; procedure Tfrm_op_letter_his.Edit1KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; frm_op_letter_his.bsSkinButton2Click(Sender); end; end; end.