unit u_op_seae_vessel_change; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, wwdbdatetimepicker, Mask, DBCtrls, StdCtrls, wwdblook, bsdbctrls; type Tfrm_op_seae_vessel_change = class(TForm) Panel2: TPanel; bsSkinButton7: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; Notebook1: TNotebook; dxDBGrid1: TdxDBGrid; t_op_seae_vessel: TADOQuery; t_op_seae_vessel1: TDataSource; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridDateColumn; dxDBGrid1Column4: TdxDBGridDateColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridDateColumn; dxDBGrid1Column8: TdxDBGridDateColumn; dxDBGrid1Column9: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridDateColumn; v_vessel_change: TADOQuery; v_vessel_change1: TDataSource; bsSkinPanel1: TbsSkinPanel; Label125: TLabel; wwDBLookupCombo49: TwwDBLookupCombo; Button1: TButton; Label126: TLabel; DBEdit63: TDBEdit; Label15: TLabel; wwDBDateTimePicker2: TwwDBDateTimePicker; Label25: TLabel; wwDBDateTimePicker6: TwwDBDateTimePicker; Label1: TLabel; wwDBLookupCombo1: TwwDBLookupCombo; Button2: TButton; Label2: TLabel; DBEdit1: TDBEdit; Label3: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; Label4: TLabel; wwDBDateTimePicker3: TwwDBDateTimePicker; Label5: TLabel; DBEdit2: TDBEdit; Label6: TLabel; DBEdit3: TDBEdit; bsSkinButton8: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton12: TbsSkinButton; Label7: TLabel; DBMemo1: TDBMemo; dxDBGrid2: TdxDBGrid; dxDBGrid2Column3: TdxDBGridMaskColumn; dxDBGrid2Column4: TdxDBGridDateColumn; dxDBGrid2Column5: TdxDBGridMaskColumn; dxDBGrid2Column6: TdxDBGridMaskColumn; dxDBGrid2Column7: TdxDBGridMaskColumn; dxDBGrid2Column8: TdxDBGridMaskColumn; dxDBGrid2Column10: TdxDBGridMaskColumn; dxDBGrid2Column11: TdxDBGridMaskColumn; dxDBGrid2Column12: TdxDBGridMaskColumn; dxDBGrid2Column13: TdxDBGridDateColumn; dxDBGrid2Column14: TdxDBGridDateColumn; dxDBGrid2Column15: TdxDBGridMaskColumn; dxDBGrid2Column16: TdxDBGridMaskColumn; dxDBGrid2Column17: TdxDBGridMaskColumn; dxDBGrid2Column18: TdxDBGridMaskColumn; dxDBGrid2Column19: TdxDBGridMaskColumn; dxDBGrid2Column20: TdxDBGridMaskColumn; t_op_seae: TADOQuery; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; t_op_seae_vessel_bill: TADOQuery; p_update: TADOStoredProc; procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure t_op_seae_vesselBeforeEdit(DataSet: TDataSet); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure t_op_seae_vesselAfterInsert(DataSet: TDataSet); procedure t_op_seae_vesselBeforePost(DataSet: TDataSet); procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure t_op_seae_vesselAfterScroll(DataSet: TDataSet); procedure FormShow(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure Panel2Resize(Sender: TObject); procedure dxDBGrid2ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); private { Private declarations } public { Public declarations } end; var frm_op_seae_vessel_change: Tfrm_op_seae_vessel_change; implementation uses u_main, u_op_seae_vessel, my_sys_function; {$R *.dfm} procedure Tfrm_op_seae_vessel_change.bsSkinButton7Click(Sender: TObject); begin table_Prior(t_op_seae_vessel); end; procedure Tfrm_op_seae_vessel_change.bsSkinButton6Click(Sender: TObject); begin table_next(t_op_seae_vessel); end; procedure Tfrm_op_seae_vessel_change.bsSkinButton2Click(Sender: TObject); begin table_post(t_op_seae_vessel); end; procedure Tfrm_op_seae_vessel_change.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_seae_vessel); end; procedure Tfrm_op_seae_vessel_change.bsSkinButton4Click(Sender: TObject); begin if t_op_seae_vessel.IsEmpty then exit; if t_op_seae_vessel.FieldByName('是否修改').asboolean then begin showmessage('船期已经进行了批量修改,不能删除!!'); exit; end; table_delete(t_op_seae_vessel); end; procedure Tfrm_op_seae_vessel_change.bsSkinButton11Click(Sender: TObject); begin if bsSkinButton11.Caption='详细内容' then begin Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; end else begin Notebook1.PageIndex:=0; bsSkinButton11.Caption:='详细内容'; end; end; procedure Tfrm_op_seae_vessel_change.bsSkinButton1Click(Sender: TObject); begin t_op_seae_vessel.insert; Notebook1.PageIndex:=1; end; procedure Tfrm_op_seae_vessel_change.t_op_seae_vesselBeforeEdit( DataSet: TDataSet); begin if not modify_all then begin if t_op_seae_vessel.FieldByName('是否修改').asboolean then begin showmessage('船期已经进行了批量修改,不能修改!!'); abort; end; end; end; procedure Tfrm_op_seae_vessel_change.Button1Click(Sender: TObject); begin if t_op_seae_vessel.IsEmpty then exit; if t_op_seae_vessel.FieldByName('是否修改').asboolean then exit; try frm_op_seae_vessel:=tfrm_op_seae_vessel.Create (self); frm_op_seae_vessel.v_vessel_voyage.open; frm_op_seae_vessel.wwIncrementalSearch1.Text:=wwDBLookupCombo49.text; op_seae_vessel_num:=2; frm_op_seae_vessel.ShowModal; finally frm_op_seae_vessel.Free; frm_op_seae_vessel:=nil; end; end; procedure Tfrm_op_seae_vessel_change.Button2Click(Sender: TObject); begin if t_op_seae_vessel.IsEmpty then exit; if t_op_seae_vessel.FieldByName('是否修改').asboolean then exit; try frm_op_seae_vessel:=tfrm_op_seae_vessel.Create (self); frm_op_seae_vessel.v_vessel_voyage.open; frm_op_seae_vessel.wwIncrementalSearch1.Text:=wwDBLookupCombo1.text; op_seae_vessel_num:=3; frm_op_seae_vessel.ShowModal; finally frm_op_seae_vessel.Free; frm_op_seae_vessel:=nil; end; end; procedure Tfrm_op_seae_vessel_change.t_op_seae_vesselAfterInsert( DataSet: TDataSet); begin t_op_seae_vessel['修改人']:=employee; t_op_seae_vessel['修改日期']:=date; t_op_seae_vessel['是否修改']:=0; end; procedure Tfrm_op_seae_vessel_change.t_op_seae_vesselBeforePost( DataSet: TDataSet); begin table_before_post(t_op_seae_vessel,'旧船名'); table_before_post(t_op_seae_vessel,'旧航次'); table_before_post(t_op_seae_vessel,'旧开船日期'); table_before_post(t_op_seae_vessel,'新船名'); table_before_post(t_op_seae_vessel,'新航次'); table_before_post(t_op_seae_vessel,'新开船日期'); end; procedure Tfrm_op_seae_vessel_change.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_vessel_change.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_op_seae_vessel_change.Hide; frm_op_seae_vessel_change.ManualFloat(frm_op_seae_vessel_change.BoundsRect ); frm_main.freeTabs('frm_op_seae_vessel_change'); action:=cafree; frm_op_seae_vessel_change:=nil; end; procedure Tfrm_op_seae_vessel_change.t_op_seae_vesselAfterScroll( DataSet: TDataSet); begin if t_op_seae_vessel.FieldByName('是否修改').asboolean then begin v_vessel_change1.Enabled:=false; v_vessel_change1.DataSet:=v_vessel_change; v_vessel_change1.Enabled:=true; bsSkinButton8.Enabled:=false; bsSkinButton9.Enabled:=false; bsSkinButton12.Enabled:=true; end else begin t_op_seae.close; v_vessel_change1.Enabled:=false; v_vessel_change1.DataSet:=t_op_seae; v_vessel_change1.Enabled:=true; bsSkinButton8.Enabled:=true; bsSkinButton9.Enabled:=true; bsSkinButton12.Enabled:=false; end; end; procedure Tfrm_op_seae_vessel_change.FormShow(Sender: TObject); begin t_op_seae_vessel.open; v_vessel_change.open; t_op_seae_vessel_bill.open; end; procedure Tfrm_op_seae_vessel_change.bsSkinButton8Click(Sender: TObject); begin if t_op_seae_vessel.IsEmpty then exit; if (t_op_seae_vessel.State=dsinsert)or(t_op_seae_vessel.State=dsedit)then t_op_seae_vessel.post; t_op_seae.close; t_op_seae.Parameters.ParamByName('船名').value:=wwDBLookupCombo49.text; t_op_seae.Parameters.ParamByName('航次').value:=DBEdit63.text; t_op_seae.Parameters.ParamByName('开船日期').value:=wwDBDateTimePicker2.Date; t_op_seae.open; end; procedure Tfrm_op_seae_vessel_change.bsSkinButton9Click(Sender: TObject); begin if not t_op_seae.Active then exit; if t_op_seae.IsEmpty then exit; if t_op_seae_vessel.IsEmpty then exit; if (t_op_seae_vessel.State=dsinsert)or(t_op_seae_vessel.State=dsedit)then t_op_seae_vessel.post; t_op_seae.first; while not t_op_seae.eof do begin t_op_seae.edit; t_op_seae['船名']:=t_op_seae_vessel['新船名']; t_op_seae['航次']:=t_op_seae_vessel['新航次']; t_op_seae['开船日期']:=t_op_seae_vessel['新开船日期']; t_op_seae['截港日期']:=t_op_seae_vessel['新截港日期']; t_op_seae.post; t_op_seae_vessel_bill.insert; t_op_seae_vessel_bill['VC_ID']:=t_op_seae_vessel['VC_ID']; t_op_seae_vessel_bill['编号']:=t_op_seae['编号']; t_op_seae_vessel_bill.post; t_op_seae.next; end; t_op_seae_vessel.edit; t_op_seae_vessel['是否修改']:=1; t_op_seae_vessel.post; v_vessel_change.Requery(); v_vessel_change1.Enabled:=false; v_vessel_change1.DataSet:=v_vessel_change; v_vessel_change1.Enabled:=true; bsSkinButton8.Enabled:=false; bsSkinButton9.Enabled:=false; bsSkinButton12.Enabled:=true; end; procedure Tfrm_op_seae_vessel_change.bsSkinButton12Click(Sender: TObject); var str:widestring; begin if t_op_seae_vessel.IsEmpty then exit; try str:='declare @vessel varchar(60),@voyage varchar(20),@kaichuan smalldatetime,@jiegang smalldatetime ' +' select @vessel=t_op_seae_vessel.旧船名,@voyage=t_op_seae_vessel.旧航次, ' +' @kaichuan=t_op_seae_vessel.旧开船日期,@jiegang=t_op_seae_vessel.旧截港日期 ' +' from t_op_seae_vessel where t_op_seae_vessel.VC_ID='+t_op_seae_vessel.fieldbyname('VC_ID').asstring +' update t_op_seae set 船名=@vessel,航次=@voyage,开船日期=@kaichuan,截港日期=@jiegang ' +' where 编号 in (select 编号 from t_op_seae_vessel_bill where VC_ID=' +t_op_seae_vessel.fieldbyname('VC_ID').asstring+')' +' delete t_op_seae_vessel_bill where VC_ID='+t_op_seae_vessel.fieldbyname('VC_ID').asstring; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; modify_all:=true; t_op_seae_vessel.edit; t_op_seae_vessel['是否修改']:=0; t_op_seae_vessel.Post; t_op_seae.close; v_vessel_change1.Enabled:=false; v_vessel_change1.DataSet:=t_op_seae; v_vessel_change1.Enabled:=true; bsSkinButton8.Enabled:=true; bsSkinButton9.Enabled:=true; bsSkinButton12.Enabled:=false; finally modify_all:=false; end; end; procedure Tfrm_op_seae_vessel_change.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/9); bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton10.Width:=i; bsSkinButton1.Width:=i; bsSkinButton11.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; end; procedure Tfrm_op_seae_vessel_change.dxDBGrid2ColumnSorting( Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,v_vessel_change,'业务编号'); end; end.