unit u_op_ctn_status; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, StdCtrls, DBCtrls, wwdbdatetimepicker, wwdbedit, Wwdotdot, Wwdbcomb, Mask, RxLookup, ComCtrls, bsSkinTabs, wwdblook, dxDBTLCl, dxGrClms, Menus; type TRecordStatus=Record StatusDate,statusCz :string; end; Tfrm_op_ctn_status = class(TForm) Panel1: TPanel; bsSkinButton7: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinPanel1: TbsSkinPanel; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinPanel2: TbsSkinPanel; bsSkinButton44: TbsSkinButton; Edit1: TEdit; Label6: TLabel; Label11: TLabel; wwDBDateTimePicker3: TwwDBDateTimePicker; Label12: TLabel; wwDBDateTimePicker4: TwwDBDateTimePicker; Label3: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; bsSkinPanel3: TbsSkinPanel; Label4: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; Label7: TLabel; wwDBDateTimePicker5: TwwDBDateTimePicker; Label15: TLabel; Edit5: TEdit; bsSkinButton2: TbsSkinButton; t_op_ctn_detail: TADOQuery; t_op_ctn_detail1: TDataSource; t_code_ctn_status1: TDataSource; t_code_ctn_status: TADOQuery; bsSkinPanel4: TbsSkinPanel; bsSkinGroupBox1: TbsSkinGroupBox; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column11: TdxDBGridColumn; Label16: TLabel; RxDBLookupCombo9: TRxDBLookupCombo; t_op_ctn_status1: TDataSource; t_op_ctn_status: TADOQuery; dxDBGrid2: TdxDBGrid; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGrid2Column3: TdxDBGridColumn; dxDBGrid2Column4: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column12: TdxDBGridCheckColumn; wwDBComboBox1: TwwDBComboBox; Label5: TLabel; Label10: TLabel; wwDBComboBox2: TwwDBComboBox; Memo1: TMemo; Label1: TLabel; Edit2: TEdit; Label13: TLabel; RxDBLookupCombo4: TRxDBLookupCombo; dxDBGrid1Column13: TdxDBGridColumn; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; wwDBLookupCombo2: TwwDBLookupCombo; Label27: TLabel; Label2: TLabel; wwDBLookupCombo3: TwwDBLookupCombo; dxDBGrid2Column5: TdxDBGridColumn; dxDBGrid2Column6: TdxDBGridColumn; Label8: TLabel; wwDBComboBox3: TwwDBComboBox; t_op_railway1: TDataSource; t_op_railway: TADOQuery; bsSkinGroupBox7: TbsSkinGroupBox; Label118: TLabel; Label119: TLabel; Label120: TLabel; Label121: TLabel; Label122: TLabel; Label123: TLabel; Label124: TLabel; Label126: TLabel; Label127: TLabel; Label128: TLabel; Label129: TLabel; Label130: TLabel; Label131: TLabel; Label132: TLabel; Label133: TLabel; Label134: TLabel; Label137: TLabel; Label138: TLabel; Label139: TLabel; Label140: TLabel; Label141: TLabel; wwDBDateTimePicker23: TwwDBDateTimePicker; wwDBDateTimePicker24: TwwDBDateTimePicker; wwDBDateTimePicker25: TwwDBDateTimePicker; wwDBDateTimePicker26: TwwDBDateTimePicker; DBEdit50: TDBEdit; wwDBDateTimePicker27: TwwDBDateTimePicker; wwDBDateTimePicker28: TwwDBDateTimePicker; RxDBLookupCombo19: TRxDBLookupCombo; RxDBLookupCombo3: TRxDBLookupCombo; wwDBDateTimePicker29: TwwDBDateTimePicker; wwDBDateTimePicker30: TwwDBDateTimePicker; DBEdit52: TDBEdit; wwDBDateTimePicker31: TwwDBDateTimePicker; wwDBDateTimePicker32: TwwDBDateTimePicker; DBEdit53: TDBEdit; wwDBDateTimePicker33: TwwDBDateTimePicker; RxDBLookupCombo20: TRxDBLookupCombo; wwDBDateTimePicker35: TwwDBDateTimePicker; wwDBDateTimePicker36: TwwDBDateTimePicker; wwDBDateTimePicker37: TwwDBDateTimePicker; RxDBLookupCombo21: TRxDBLookupCombo; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinCheckRadioBox3: TbsSkinCheckRadioBox; PopupMenu2: TPopupMenu; N16: TMenuItem; SaveDialog: TSaveDialog; RxDBLookupCombo5: TRxDBLookupCombo; Label9: TLabel; Edit3: TEdit; Label14: TLabel; dxDBGrid1Column16: TdxDBGridColumn; dxDBGrid2Column7: TdxDBGridColumn; PopupMenu1: TPopupMenu; MenuItem1: TMenuItem; dxDBGrid1Column17: TdxDBGridColumn; dxDBGrid1Column18: TdxDBGridCheckColumn; dxDBGrid1Column19: TdxDBGridCheckColumn; dxDBGrid1Column20: TdxDBGridCheckColumn; dxDBGrid1Column21: TdxDBGridCheckColumn; dxDBGrid1Column22: TdxDBGridCheckColumn; dxDBGrid1Column23: TdxDBGridCheckColumn; dxDBGrid1Column24: TdxDBGridCheckColumn; dxDBGrid1Column25: TdxDBGridColumn; dxDBGrid1Column26: TdxDBGridColumn; dxDBGrid1Column27: TdxDBGridColumn; dxDBGrid1Column28: TdxDBGridColumn; t_op_ctn_detailctnid: TAutoIncField; t_op_ctn_detailDSDesigner: TStringField; t_op_ctn_detailDSDesigner2: TStringField; t_op_ctn_detailDSDesigner3: TStringField; t_op_ctn_detailDSDesigner4: TDateTimeField; t_op_ctn_detailDSDesigner5: TStringField; t_op_ctn_detailDSDesigner6: TStringField; t_op_ctn_detailDSDesigner7: TStringField; t_op_ctn_detailDSDesigner8: TStringField; t_op_ctn_detailDSDesigner9: TBooleanField; t_op_ctn_detailDSDesigner10: TStringField; t_op_ctn_detailDSDesigner11: TStringField; t_op_ctn_detailDSDesigner12: TStringField; t_op_ctn_detailDSDesigner13: TStringField; t_op_ctn_detailaddctnid: TIntegerField; t_op_ctn_detailDSDesigner14: TDateTimeField; t_op_ctn_detailDSDesigner15: TStringField; t_op_ctn_detailDSDesigner16: TDateTimeField; t_op_ctn_detailDSDesigner17: TBooleanField; t_op_ctn_detailDSDesigner18: TStringField; t_op_ctn_detailDSDesigner19: TStringField; t_op_ctn_detailDSDesigner20: TDateTimeField; t_op_ctn_detailDSDesigner21: TStringField; t_op_ctn_detailDSDesigner22: TStringField; t_op_ctn_detailDSDesigner23: TStringField; t_op_ctn_detailDSDesigner24: TDateTimeField; t_op_ctn_detailDSDesigner25: TStringField; t_op_ctn_detailDSDesigner26: TStringField; t_op_ctn_detailDSDesigner27: TDateTimeField; t_op_ctn_detailDSDesigner28: TStringField; t_op_ctn_detailDSDesigner29: TStringField; t_op_ctn_detailDSDesigner30: TStringField; t_op_ctn_detailDSDesigner31: TStringField; t_op_ctn_detailDSDesigner32: TStringField; t_op_ctn_detailDSDesigner33: TDateTimeField; t_op_ctn_detailDSDesigner35: TStringField; t_op_ctn_detailDSDesigner36: TDateTimeField; t_op_ctn_detailDSDesigner37: TIntegerField; t_op_ctn_detailDSDesigner38: TIntegerField; t_op_ctn_detailDSDesigner39: TIntegerField; t_op_ctn_detailDSDesigner40: TIntegerField; t_op_ctn_detailDSDesigner41: TIntegerField; t_op_ctn_detailDSDesigner42: TIntegerField; t_op_ctn_detailDSDesigner43: TIntegerField; t_ctn_status: TADOQuery; dxDBGrid1Column29: TdxDBGridColumn; t_op_ctn_detailField: TStringField; t_op_ctn_detailField2: TStringField; t_op_ctn_detailField3: TStringField; dxDBGrid1Column30: TdxDBGridColumn; dxDBGrid1Column31: TdxDBGridColumn; t_op_ctn_detailDSDesigner34: TDateTimeField; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton5Click(Sender: TObject); procedure Panel1Resize(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton44Click(Sender: TObject); procedure Edit1KeyPress(Sender: TObject; var Key: Char); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure t_op_ctn_statusAfterInsert(DataSet: TDataSet); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinCheckRadioBox1Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure MenuItem1Click(Sender: TObject); procedure t_op_ctn_detailCalcFields(DataSet: TDataSet); private { Private declarations } public { Public declarations } function GetCtnStatus(ctnid:integer;ctnstatus:string):string; function GetczCtnStatus(ctnid:integer;ctnstatus:string):TRecordStatus; end; var frm_op_ctn_status: Tfrm_op_ctn_status; implementation uses u_main, my_sys_function; {$R *.dfm} function Tfrm_op_ctn_status.GetczCtnStatus(ctnid:integer;ctnstatus:string):TRecordStatus; var aAdoQuery:TAdoQuery; begin Result.StatusDate:=''; Result.Statuscz:=''; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try close;sql.Clear; sql.Add('select 动态时间,场站 from t_op_ctnmg_status'); sql.Add('where ctnid=:ctnid and 动态名称=:ctnstatus'); Parameters.ParamByName('ctnid').Value:=ctnid; Parameters.ParamByName('ctnstatus').Value:=ctnstatus; open; if not IsEmpty then begin Result.StatusDate:=FieldByName('动态时间').AsString; Result.Statuscz:=FieldByName('场站').AsString; end; finally Free; end; end; function Tfrm_op_ctn_status.GetCtnStatus(ctnid:integer;ctnstatus:string):string; var aAdoQuery:TAdoQuery; begin Result:=''; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try close;sql.Clear; sql.Add('select 动态时间 from t_op_ctnmg_status'); sql.Add('where ctnid=:ctnid and 动态名称=:ctnstatus'); Parameters.ParamByName('ctnid').Value:=ctnid; Parameters.ParamByName('ctnstatus').Value:=ctnstatus; open; if not IsEmpty then begin Result:=FieldByName('动态时间').AsString; end; finally Free; end; end; procedure Tfrm_op_ctn_status.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); frm_op_ctn_status.Hide; frm_op_ctn_status.ManualFloat(frm_op_ctn_status.BoundsRect ); frm_main.freeTabs('frm_op_ctn_status'); action:=cafree; frm_op_ctn_status:=nil; end; procedure Tfrm_op_ctn_status.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_ctn_status.Panel1Resize(Sender: TObject); var i:integer; begin i:=round(panel1.Width/8); bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; end; procedure Tfrm_op_ctn_status.FormShow(Sender: TObject); begin t_code_ctn_status.Open; loadreggrid(dxdbgrid1,true,caption); end; procedure Tfrm_op_ctn_status.bsSkinButton44Click(Sender: TObject); var ctnstr,ctn:string; i:integer; begin t_op_ctn_status.Close; t_op_ctn_detail.close; t_op_ctn_detail.SQL.clear; t_op_ctn_detail.SQL.add('select v_op_ctnmg_detail.*'); t_op_ctn_detail.SQL.add(',t_op_railway.船名,t_op_railway.配船航次,t_op_railway.发车日期,t_op_railway.到货日期,t_op_railway.到达站,t_op_railway.还箱日期'); t_op_ctn_detail.SQL.add(',status.买箱,status.卖箱,status.放箱,status.修箱,status.返箱,status.还箱,status.接受'); t_op_ctn_detail.SQL.add('from v_op_ctnmg_detail'); t_op_ctn_detail.SQL.add('left join t_op_railway on v_op_ctnmg_detail.ctnid=t_op_railway.ctnid and t_op_railway.箱源 in(''公司自备箱'',''其它租赁箱'')'); t_op_ctn_detail.SQL.add('left join '); t_op_ctn_detail.SQL.add('(select ctnid'); t_op_ctn_detail.SQL.add(',sum(case when 动态名称=''买箱'' then 1 else 0 end) 买箱'); t_op_ctn_detail.SQL.add(',sum(case when 动态名称=''卖箱'' then 1 else 0 end) 卖箱'); t_op_ctn_detail.SQL.add(',sum(case when 动态名称=''放箱'' then 1 else 0 end) 放箱'); t_op_ctn_detail.SQL.add(',sum(case when 动态名称=''修箱'' then 1 else 0 end) 修箱'); t_op_ctn_detail.SQL.add(',sum(case when 动态名称=''返箱'' then 1 else 0 end) 返箱'); t_op_ctn_detail.SQL.add(',sum(case when 动态名称=''还箱'' then 1 else 0 end) 还箱'); t_op_ctn_detail.SQL.add(',sum(case when 动态名称=''接受'' then 1 else 0 end) 接受'); t_op_ctn_detail.SQL.add('from t_op_ctnmg_status'); t_op_ctn_detail.SQL.add('group by ctnid) as status on v_op_ctnmg_detail.ctnid=status.ctnid'); t_op_ctn_detail.SQL.add('where 1=1 and '+open_data('0008','v_op_ctnmg_detail.录入人','no','no','no','no') ); if Edit2.Text<>'' then t_op_ctn_detail.SQL.add(' and v_op_ctnmg_detail.租买箱单号='+''''+edit2.text+''''); if RxDBLookupCombo4.DisplayValues[1]<>'' then begin ctn:=RxDBLookupCombo4.DisplayValues[1]; ctn:=StringReplace(ctn,'''','?''',[rfReplaceAll]); ctn:=StringReplace(ctn,'?','''',[rfReplaceAll]); t_op_ctn_detail.SQL.add(' and v_op_ctnmg_detail.箱型='+''''+ctn+''''); end; if wwDBDateTimePicker3.text<>''then t_op_ctn_detail.SQL.add(' and v_op_ctnmg_detail.租买箱时间>='+''''+wwDBDateTimePicker3.text+''''); if wwDBDateTimePicker4.text<>''then t_op_ctn_detail.SQL.add(' and v_op_ctnmg_detail.租买箱时间<='+''''+wwDBDateTimePicker4.text+''''); if Edit1.Text<>'' then t_op_ctn_detail.SQL.add(' and v_op_ctnmg_detail.箱号='+''''+edit1.Text+''''); if RxDBLookupCombo1.DisplayValue<>'' then t_op_ctn_detail.SQL.add(' and v_op_ctnmg_detail.当前动态='+''''+RxDBLookupCombo1.DisplayValue+''''); if wwDBLookupCombo2.Text<>'' then t_op_ctn_detail.SQL.add(' and v_op_ctnmg_detail.当前地点='+''''+wwDBLookupCombo2.Text+''''); if RxDBLookupCombo5.DisplayValues[1]<>'' then t_op_ctn_detail.SQL.add(' and v_op_ctnmg_detail.当前场站='+''''+RxDBLookupCombo5.DisplayValues[1]+''''); if wwDBComboBox3.Text<>'' then t_op_ctn_detail.SQL.add(' and v_op_ctnmg_detail.租买类型='+''''+wwDBComboBox3.text+''''); if bsSkinCheckRadioBox2.checked then t_op_ctn_detail.SQL.add(' and ctnid in (select ctnid from t_op_railway where 是否卖箱=''是'' and 还箱日期 is null)'); if bsSkinCheckRadioBox3.checked then t_op_ctn_detail.SQL.add(' and ctnid in (select ctnid from t_op_railway where 是否卖箱=''否'' and 返程日期 is null and 接受日期 is null)'); if Memo1.Lines.Count<>0 then begin ctnstr:=ctnstr+'and ('; for i:=0 to Memo1.Lines.Count-1 do begin if i=0 then ctnstr:=ctnstr+'v_op_ctnmg_detail.箱号='+''''+Trim(Memo1.Lines.Strings[i])+'''' else ctnstr:=ctnstr+' or v_op_ctnmg_detail.箱号='+''''+Trim(Memo1.Lines.Strings[i])+''''; end; ctnstr:=ctnstr+') '; end else begin if Edit1.Text<>'' then ctnstr:=' and v_op_ctnmg_detail.箱号='+''''+Trim(Edit1.Text)+''''; end; if ctnstr<>'' then t_op_ctn_detail.SQL.add(ctnstr); t_op_ctn_detail.SQL.add(' order by v_op_ctnmg_detail.ctnid'); t_op_ctn_detail.open; t_op_ctn_status.Open; end; procedure Tfrm_op_ctn_status.Edit1KeyPress(Sender: TObject; var Key: Char); begin if Key<>#13 then exit; if (Trim(Edit1.Text)<>'') then begin Memo1.Lines.Add(Trim(Edit1.Text)); Edit1.Text:=''; end; end; procedure Tfrm_op_ctn_status.bsSkinButton2Click(Sender: TObject); var i:Integer; aQuery:TADOQuery; begin if RxDBLookupCombo2.DisplayValue='' then begin MessageDlg('动态名称不能为空',mtWarning,[mbyes],0); exit; end; if wwDBDateTimePicker5.Text='' then begin MessageDlg('动态日期不能为空',mtWarning,[mbyes],0); exit; end; if RxDBLookupCombo2.DisplayValue='接受' then begin if RxDBLookupCombo9.DisplayValue='' then begin MessageDlg('场站不能为空',mtWarning,[mbyes],0); exit; end; end; if dxdbgrid1.SelectedCount>0 then begin for i:=0 to dxdbgrid1.SelectedCount-1 do begin t_op_ctn_detail.GotoBookmark(pointer(dxdbgrid1.selectedrows[i])); if t_op_ctn_detail.FieldByName('当前动态').AsString<>'已卖箱' then begin t_op_ctn_detail.Edit; t_op_ctn_detail['当前动态']:=RxDBLookupCombo2.DisplayValue; t_op_ctn_detail['动态时间']:=wwDBDateTimePicker5.Date; if Edit5.Text<>'' then t_op_ctn_detail['主提单号']:=Edit5.Text; if wwDBComboBox1.Text<>'' then t_op_ctn_detail['当前状态']:=wwDBComboBox1.Text; if wwDBComboBox2.Text<>'' then begin if wwDBComboBox2.Text='是' then t_op_ctn_detail['重箱']:=true; if wwDBComboBox2.Text='否' then t_op_ctn_detail['重箱']:=false; end; // if wwDBLookupCombo3.Text<>'' then t_op_ctn_detail['当前地点']:=wwDBLookupCombo3.Text; if edit3.text<>'' then t_op_ctn_detail['备注']:=edit3.Text; // if RxDBLookupCombo9.DisplayValues[1]<>'' then t_op_ctn_detail['当前场站']:=RxDBLookupCombo9.DisplayValues[1]; t_op_ctn_detail.Post; t_op_ctn_status.Insert; t_op_ctn_status.Post; if (RxDBLookupCombo2.DisplayValue='还箱') or (RxDBLookupCombo2.DisplayValue='返箱') or (RxDBLookupCombo2.DisplayValue='接受') then begin aQuery:=CreateAdoQuery; try with aQuery do begin close; if RxDBLookupCombo2.DisplayValue='还箱' then begin SQL.text:='update t_op_railway set 是否还箱=''是'',还箱日期=:还箱日期 where ctnid='+t_op_ctn_status.fieldbyname('ctnid').AsString; aQuery.Parameters.ParamByName('还箱日期').Value:=wwDBDateTimePicker5.Date; ExecSQL; end; if RxDBLookupCombo2.DisplayValue='返箱' then begin SQL.text:='update t_op_railway set 返程日期=:返箱日期 where ctnid='+t_op_ctn_status.fieldbyname('ctnid').AsString; aQuery.Parameters.ParamByName('返箱日期').Value:=wwDBDateTimePicker5.Date; ExecSQL; end; if RxDBLookupCombo2.DisplayValue='接受' then begin SQL.text:='update t_op_railway set 接受日期=:接受日期,接受堆场=:接受堆场 where ctnid='+t_op_ctn_status.fieldbyname('ctnid').AsString; aQuery.Parameters.ParamByName('接受日期').Value:=wwDBDateTimePicker5.Date; aQuery.Parameters.ParamByName('接受堆场').Value:=RxDBLookupCombo9.DisplayValues[1]; ExecSQL; end; end; finally FreeAndNil(aQuery); end; end; end else begin end; end; end { t_op_ctn_detail.First; while not t_op_ctn_detail.Eof do begin if t_op_ctn_detail.FieldByName('当前动态').AsString<>'已还箱' then begin t_op_ctn_detail.Edit; t_op_ctn_detail['当前动态']:=RxDBLookupCombo2.DisplayValue; t_op_ctn_detail['动态时间']:=wwDBDateTimePicker5.Date; if Edit5.Text<>'' then t_op_ctn_detail['当前提单号']:=Edit5.Text; if wwDBLookupCombo1.Text<>'' then t_op_ctn_detail['当前船名']:=wwDBLookupCombo1.Text; if Edit4.Text<>'' then t_op_ctn_detail['当前航次']:=Edit4.Text; if RxDBLookupCombo9.DisplayValues[1]<>'' then t_op_ctn_detail['当前场站']:=RxDBLookupCombo9.DisplayValues[1]; t_op_ctn_detail.Post; t_op_ctn_status.Insert; t_op_ctn_status.Post; end else begin end; t_op_ctn_detail.Next; end; } end; procedure Tfrm_op_ctn_status.bsSkinButton4Click(Sender: TObject); var i:Integer; begin if MessageDlg('确实要确认还箱吗?',mtWarning,[mbYes,mbNo],0)<>mryes then exit; if wwDBDateTimePicker5.Text='' then begin MessageDlg('动态日期不能为空',mtWarning,[mbyes],0); exit; end; if dxdbgrid1.SelectedCount>0 then begin for i:=0 to dxdbgrid1.SelectedCount-1 do begin t_op_ctn_detail.GotoBookmark(pointer(dxdbgrid1.selectedrows[i])); t_op_ctn_detail.Edit; t_op_ctn_detail['当前动态']:='已还箱'; t_op_ctn_detail['动态时间']:=wwDBDateTimePicker5.Date; t_op_ctn_detail['是否还箱']:=1; t_op_ctn_detail['还箱时间']:=wwDBDateTimePicker5.Date; if Edit5.Text<>'' then t_op_ctn_detail['主提单号']:=Edit5.Text; if RxDBLookupCombo9.DisplayValues[1]<>'' then t_op_ctn_detail['当前场站']:=RxDBLookupCombo9.DisplayValues[1]; if edit3.text<>'' then t_op_ctn_detail['备注']:=edit3.Text; t_op_ctn_detail.Post; end; end { t_op_ctn_detail.First; while not t_op_ctn_detail.Eof do begin t_op_ctn_detail.Edit; t_op_ctn_detail['当前动态']:='已还箱'; t_op_ctn_detail['动态时间']:=wwDBDateTimePicker5.Date; t_op_ctn_detail['是否还箱']:=1; t_op_ctn_detail['还箱时间']:=wwDBDateTimePicker5.Date; if Edit5.Text<>'' then t_op_ctn_detail['当前提单号']:=Edit5.Text; if wwDBLookupCombo1.Text<>'' then t_op_ctn_detail['当前船名']:=wwDBLookupCombo1.Text; if Edit4.Text<>'' then t_op_ctn_detail['当前航次']:=Edit4.Text; if RxDBLookupCombo9.DisplayValues[1]<>'' then t_op_ctn_detail['当前场站']:=RxDBLookupCombo9.DisplayValues[1]; t_op_ctn_detail.Post; t_op_ctn_detail.Next; end; } end; procedure Tfrm_op_ctn_status.t_op_ctn_statusAfterInsert(DataSet: TDataSet); function getmaxno:Integer; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('select MAx(stno) stno from t_op_ctn_status where ctnid='+t_op_ctn_detail.fieldbyname('ctnid').AsString); open; if IsEmpty then result:=1 else Result:=fieldbyname('stno').AsInteger+1; end; finally FreeAndNil(aQuery); end; end; begin t_op_ctn_status['ctnid']:=t_op_ctn_detail['ctnid']; // t_op_ctn_status['stno']:=getmaxno; t_op_ctn_status['动态名称']:=t_op_ctn_detail['当前动态']; t_op_ctn_status['动态时间']:=t_op_ctn_detail['动态时间']; t_op_ctn_status['状态']:=t_op_ctn_detail['当前状态']; t_op_ctn_status['重箱']:=t_op_ctn_detail['重箱']; t_op_ctn_status['操作员']:=employee; t_op_ctn_status['操作时间']:=now; t_op_ctn_status['提单号']:=t_op_ctn_detail['主提单号']; t_op_ctn_status['地点']:=t_op_ctn_detail['当前地点']; t_op_ctn_status['场站']:=t_op_ctn_detail['当前场站']; t_op_ctn_status['备注']:=t_op_ctn_detail['备注']; end; procedure Tfrm_op_ctn_status.bsSkinButton3Click(Sender: TObject); var aQuery:TADOQuery; i:Integer; begin if MessageDlg('确实要取消还箱吗?',mtWarning,[mbYes,mbNo],0)<>mryes then exit; aQuery:=CreateAdoQuery; TRY if dxdbgrid1.SelectedCount>0 then begin for i:=0 to dxdbgrid1.SelectedCount-1 do begin t_op_ctn_detail.GotoBookmark(pointer(dxdbgrid1.selectedrows[i])); if t_op_ctn_detail.FieldByName('当前动态').AsString='已还箱' then begin aQuery.SQL.Text:='select * from t_op_ctn_status where 动态名称<>''已还箱'' and ctnid='+t_op_ctn_detail.fieldbyname('ctnid').AsString+' order by stid desc'; aQuery.Open; t_op_ctn_detail.Edit; t_op_ctn_detail['当前动态']:=aQuery.fieldbyname('动态名称').AsString; t_op_ctn_detail['动态时间']:=aQuery['动态时间']; t_op_ctn_detail['是否还箱']:=0; t_op_ctn_detail['还箱时间']:=null; t_op_ctn_detail['当前提单号']:=aQuery.fieldbyname('提单号').AsString; t_op_ctn_detail['当前船名']:=aQuery.fieldbyname('船名').AsString; t_op_ctn_detail['当前航次']:=aQuery.fieldbyname('航次').AsString; t_op_ctn_detail['当前场站']:=aQuery.fieldbyname('场站').AsString; t_op_ctn_detail.Post; end; end; end { t_op_ctn_detail.First; while not t_op_ctn_detail.Eof do begin if t_op_ctn_detail.FieldByName('当前动态').AsString='已还箱' then begin aQuery.SQL.Text:='select * from t_op_ctn_status where 动态名称<>''已还箱'' and ctnid='+t_op_ctn_detail.fieldbyname('ctnid').AsString+' order by stid desc'; aQuery.Open; t_op_ctn_detail.Edit; t_op_ctn_detail['当前动态']:=aQuery.fieldbyname('动态名称').AsString; t_op_ctn_detail['动态时间']:=aQuery['动态时间']; t_op_ctn_detail['是否还箱']:=0; t_op_ctn_detail['还箱时间']:=null; t_op_ctn_detail['当前提单号']:=aQuery.fieldbyname('提单号').AsString; t_op_ctn_detail['当前船名']:=aQuery.fieldbyname('船名').AsString; t_op_ctn_detail['当前航次']:=aQuery.fieldbyname('航次').AsString; t_op_ctn_detail['当前场站']:=aQuery.fieldbyname('场站').AsString; t_op_ctn_detail.Post; end; t_op_ctn_detail.Next; end; } finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_ctn_status.bsSkinCheckRadioBox1Click(Sender: TObject); begin if bsSkinCheckRadioBox1.Checked then begin t_op_railway.Close; t_op_railway.Open; bsSkinGroupBox7.Visible:=True; end else begin t_op_railway.Close; bsSkinGroupBox7.Visible:=false; end; end; procedure Tfrm_op_ctn_status.N16Click(Sender: TObject); begin with SaveDialog do begin DefaultExt :='xls'; Filter := '(*.xls)|*.xls'; if Execute then begin dxDBGrid1.SaveToXLS(FileName,true); end; end; end; procedure Tfrm_op_ctn_status.MenuItem1Click(Sender: TObject); begin if MessageDlg('确实要删除此条记录吗?',mtWarning,[mbYes,mbNo],0)<>mryes then exit; t_op_ctn_status.delete; end; procedure Tfrm_op_ctn_status.t_op_ctn_detailCalcFields(DataSet: TDataSet); var RecordStatus:TRecordStatus; begin t_op_ctn_detail.FieldByName('卖箱日期').AsString:=GetCtnStatus(t_op_ctn_detail.FieldByName('ctnid').AsInteger,'卖箱'); RecordStatus:=GetczCtnStatus(t_op_ctn_detail.FieldByName('ctnid').AsInteger,'返箱'); t_op_ctn_detail.FieldByName('返箱日期').AsString:=RecordStatus.StatusDate; t_op_ctn_detail.FieldByName('返箱场站').AsString:=RecordStatus.statusCz; end; end.