unit u_op_seae_teshufandan; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, XPMenu, Menus, dxDBTLCl, dxGrClms, dxDBCtrl, dxDBGrid, dxTL, dxCntner, DB, ADODB, Mask, wwdbedit, Wwdotdot, Wwdbcomb, wwdblook, RxLookup, wwdbdatetimepicker, StdCtrls, bsSkinCtrls, ExtCtrls, ComCtrls, bsSkinTabs, DBCtrls,DateUtils; type Tfrm_op_seae_teshufandan = class(TForm) Panel2: TPanel; Panel3: TPanel; bsSkinButton10: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinPanel1: TbsSkinPanel; Label6: TLabel; Label3: TLabel; Label1: TLabel; Label2: TLabel; Label10: TLabel; Label5: TLabel; Label9: TLabel; Label8: TLabel; Label11: TLabel; Label30: TLabel; Label125: TLabel; Label124: TLabel; Label16: TLabel; Edit1: TEdit; Edit4: TEdit; Edit2: TEdit; Edit3: TEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; RxDBLookupCombo2: TRxDBLookupCombo; wwDBDateTimePicker3: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; Edit7: TEdit; wwDBLookupCombo49: TwwDBLookupCombo; wwDBLookupCombo52: TwwDBLookupCombo; RxDBLookupCombo6: TRxDBLookupCombo; t_op_seae: TADOQuery; t_op_seae1: TDataSource; dxDBGrid1: TdxDBGrid; dxDBGrid1Column84: TdxDBGridCheckColumn; dxDBGrid1Column85: TdxDBGridColumn; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column78: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridDateColumn; dxDBGrid1Column17: TdxDBGridDateColumn; dxDBGrid1Column18: TdxDBGridDateColumn; dxDBGrid1Column19: TdxDBGridMaskColumn; dxDBGrid1Column20: TdxDBGridMaskColumn; dxDBGrid1Column22: TdxDBGridDateColumn; dxDBGrid1Column23: TdxDBGridMaskColumn; dxDBGrid1Column24: TdxDBGridMaskColumn; dxDBGrid1Column25: TdxDBGridMaskColumn; dxDBGrid1Column26: TdxDBGridMaskColumn; dxDBGrid1Column27: TdxDBGridMaskColumn; dxDBGrid1Column28: TdxDBGridMaskColumn; dxDBGrid1Column29: TdxDBGridMaskColumn; dxDBGrid1Column30: TdxDBGridMaskColumn; dxDBGrid1Column31: TdxDBGridDateColumn; dxDBGrid1Column32: TdxDBGridMaskColumn; dxDBGrid1Column33: TdxDBGridMaskColumn; dxDBGrid1Column34: TdxDBGridMaskColumn; dxDBGrid1Column35: TdxDBGridMaskColumn; dxDBGrid1Column36: TdxDBGridMaskColumn; dxDBGrid1Column37: TdxDBGridMaskColumn; dxDBGrid1Column38: TdxDBGridMaskColumn; dxDBGrid1Column39: TdxDBGridColumn; dxDBGrid1Column40: TdxDBGridColumn; dxDBGrid11: TdxDBGridMaskColumn; dxDBGrid12: TdxDBGridMaskColumn; dxDBGrid13: TdxDBGridMaskColumn; dxDBGrid14: TdxDBGridMaskColumn; dxDBGrid15: TdxDBGridMaskColumn; dxDBGrid16: TdxDBGridMaskColumn; dxDBGrid17: TdxDBGridMaskColumn; dxDBGrid18: TdxDBGridMaskColumn; dxDBGrid19: TdxDBGridMaskColumn; dxDBGrid110: TdxDBGridMaskColumn; dxDBGrid111: TdxDBGridMaskColumn; dxDBGrid112: TdxDBGridMaskColumn; dxDBGrid113: TdxDBGridMaskColumn; dxDBGrid114: TdxDBGridMaskColumn; dxDBGrid115: TdxDBGridMaskColumn; dxDBGrid116: TdxDBGridMaskColumn; dxDBGrid117: TdxDBGridMaskColumn; dxDBGrid118: TdxDBGridMaskColumn; dxDBGrid119: TdxDBGridMaskColumn; dxDBGrid120: TdxDBGridMaskColumn; dxDBGrid1Column61: TdxDBGridMaskColumn; dxDBGrid1TEU: TdxDBGridMaskColumn; dxDBGrid1Column63: TdxDBGridMaskColumn; dxDBGrid1Column64: TdxDBGridMaskColumn; dxDBGrid1Column65: TdxDBGridDateColumn; dxDBGrid1Column66: TdxDBGridMaskColumn; dxDBGrid1Column67: TdxDBGridMaskColumn; dxDBGrid1Column72: TdxDBGridMaskColumn; dxDBGrid1Column68: TdxDBGridMaskColumn; dxDBGrid1Column69: TdxDBGridMaskColumn; dxDBGrid1Column70: TdxDBGridMaskColumn; dxDBGrid1Column74: TdxDBGridMaskColumn; dxDBGrid1Column75: TdxDBGridMaskColumn; dxDBGrid1Column73: TdxDBGridColumn; dxDBGrid1Column76: TdxDBGridColumn; dxDBGrid1Column77: TdxDBGridCheckColumn; dxDBGrid1Column79: TdxDBGridColumn; dxDBGrid1Column80: TdxDBGridColumn; dxDBGrid1Column81: TdxDBGridColumn; dxDBGrid1Column86: TdxDBGridCheckColumn; dxDBGrid1Column87: TdxDBGridCheckColumn; dxDBGrid1Column88: TdxDBGridColumn; bsSkinButton13: TbsSkinButton; bsSkinButton1: TbsSkinButton; PopupMenu2: TPopupMenu; N16: TMenuItem; XPMenu1: TXPMenu; t_op_seaesel: TADOQuery; ds_op_seaesel1: TDataSource; pm1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; bsSkinPanel2: TbsSkinPanel; bsSkinPanel3: TbsSkinPanel; bsSkinButton2: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton12: TbsSkinButton; t_op_bill: TADOQuery; ds_op_bill1: TDataSource; bsSkinPageControl1: TbsSkinPageControl; bskntbsht1: TbsSkinTabSheet; bskntbsht2: TbsSkinTabSheet; dxDBGrid2: TdxDBGrid; dxDBGrid2Column2: TdxDBGridColumn; dxDBGrid2Column3: TdxDBGridColumn; dxDBGrid2Column4: TdxDBGridColumn; dxDBGrid2Column5: TdxDBGridColumn; dxDBGrid2Column6: TdxDBGridColumn; bsSkinPanel4: TbsSkinPanel; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn7: TdxDBGridMaskColumn; dxDBGridMaskColumn13: TdxDBGridMaskColumn; dxDBGridMaskColumn14: TdxDBGridMaskColumn; dxDBGridMaskColumn15: TdxDBGridMaskColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridMaskColumn17: TdxDBGridMaskColumn; dxDBGridMaskColumn24: TdxDBGridMaskColumn; dxDBGridMaskColumn57: TdxDBGridMaskColumn; dxDBGridMaskColumn58: TdxDBGridMaskColumn; dxDBGridMaskColumn61: TdxDBGridMaskColumn; PopupMenu1: TPopupMenu; MenuItem1: TMenuItem; RxDBLookupCombo4: TRxDBLookupCombo; Label4: TLabel; DBEdit9: TDBEdit; DBEdit10: TDBEdit; Label7: TLabel; Label12: TLabel; wwDBDateTimePicker5: TwwDBDateTimePicker; PopupMenu3: TPopupMenu; MenuItem2: TMenuItem; dxDBGrid2Column7: TdxDBGridColumn; Label13: TLabel; DBEdit1: TDBEdit; Label14: TLabel; bsSkinPanel5: TbsSkinPanel; Panel1: TPanel; bsSkinButton11: TbsSkinButton; Label17: TLabel; wwDBDateTimePicker6: TwwDBDateTimePicker; Label18: TLabel; wwDBDateTimePicker7: TwwDBDateTimePicker; Label19: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; Label20: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; dxDBGrid2Column8: TdxDBGridColumn; dxDBGrid2Column9: TdxDBGridColumn; dxDBGrid3Column12: TdxDBGridColumn; dxDBGrid3Column13: TdxDBGridColumn; dxDBGrid3Column14: TdxDBGridColumn; dxDBGrid3Column15: TdxDBGridColumn; Label21: TLabel; Label22: TLabel; wwDBDateTimePicker8: TwwDBDateTimePicker; Label23: TLabel; Label24: TLabel; RxDBLookupCombo7: TRxDBLookupCombo; wwDBDateTimePicker9: TwwDBDateTimePicker; Label15: TLabel; DBEdit2: TDBEdit; Label25: TLabel; DBEdit3: TDBEdit; Label26: TLabel; dxDBGrid2Column10: TdxDBGridColumn; dxDBGrid2Column11: TdxDBGridColumn; Label27: TLabel; RxDBLookupCombo9: TRxDBLookupCombo; bsSkinButton38: TbsSkinButton; RxDBLookupCombo8: TRxDBLookupCombo; dxDBGrid2Column12: TdxDBGridColumn; dxDBGrid2Column13: TdxDBGridColumn; dxDBGrid2Column14: TdxDBGridColumn; Label28: TLabel; DBMemo1: TDBMemo; dxDBGrid1Column89: TdxDBGridColumn; Label29: TLabel; DBMemo2: TDBMemo; RxDBLookupCombo5: TRxDBLookupCombo; Label31: TLabel; Label32: TLabel; wwDBDateTimePicker10: TwwDBDateTimePicker; RxDBLookupCombo10: TRxDBLookupCombo; dxDBGrid2Column15: TdxDBGridColumn; dxDBGrid2Column16: TdxDBGridColumn; DBMemo3: TDBMemo; DBMemo4: TDBMemo; DBMemo5: TDBMemo; RxDBLookupCombo11: TRxDBLookupCombo; Label33: TLabel; Label34: TLabel; RxDBLookupCombo12: TRxDBLookupCombo; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure N16Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure N3Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure MenuItem2Click(Sender: TObject); procedure t_op_billAfterInsert(DataSet: TDataSet); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure t_op_seaeselBeforeDelete(DataSet: TDataSet); procedure t_op_billBeforeEdit(DataSet: TDataSet); procedure t_op_billBeforeDelete(DataSet: TDataSet); procedure t_op_seaeselBeforeEdit(DataSet: TDataSet); procedure bsSkinButton38Click(Sender: TObject); procedure RxDBLookupCombo8Enter(Sender: TObject); procedure RxDBLookupCombo8Exit(Sender: TObject); procedure dxDBGrid2Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure dxDBGrid3DblClick(Sender: TObject); private { Private declarations } public { Public declarations } function InsertBillStatus(BsNo:string):Boolean; function DeleteBillStatus(BsNo,or_id:string):Boolean; end; var frm_op_seae_teshufandan: Tfrm_op_seae_teshufandan; implementation uses my_sys_function, u_main, my_sys_chat; {$R *.dfm} function Tfrm_op_seae_teshufandan.InsertBillStatus(BsNo:string):Boolean; var aAdoQuery:TAdoQuery; begin result:=False; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;Sql.Clear; SQL.Add('select count(编号) c from t_op_fangdan'); SQL.Add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=BsNo; Open; if aAdoQuery.FieldByName('c').AsInteger=0 then begin Close;Sql.Clear; SQL.Add('Insert into t_op_fangdan (编号, 放单状态,申请人,申请日期)'); SQL.Add('values (:编号,:放单状态,:申请人,:申请日期)'); Parameters.ParamByName('编号').Value:=BsNo; Parameters.ParamByName('放单状态').Value:='申请放单'; Parameters.ParamByName('申请人').Value:=employee; Parameters.ParamByName('申请日期').Value:=date; ExecSQL; end; finally aAdoQuery.Free; end; end; function Tfrm_op_seae_teshufandan.DeleteBillStatus(BsNo,or_id:string):Boolean; var aAdoQuery:TAdoQuery; begin result:=False; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try if BsNo<>'' then begin Close;Sql.Clear; SQL.Add('delete from t_op_fangdan'); SQL.Add('Where '+BsNo+''); ExecSQL; end; if or_id<>'' then begin Close;Sql.Clear; SQL.Add('delete from t_op_seae_app'); SQL.Add('Where '+or_id+''); ExecSQL; end; finally aAdoQuery.Free; end; end; procedure Tfrm_op_seae_teshufandan.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); savereggrid(dxdbgrid2,caption+'1'); frm_op_seae_teshufandan.Hide; frm_op_seae_teshufandan.ManualFloat(frm_op_seae_teshufandan.BoundsRect ); frm_main.freeTabs('frm_op_seae_teshufandan'); action:=cafree; frm_op_seae_teshufandan:=nil; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton10Click(Sender: TObject); var str:widestring; begin str:='where 业务类型=''普通货'''; if Edit1.text<>''then str:=str+' and 业务编号 like '+''''+'%'+Edit1.text+'%'+''''; if Edit4.text<>''then str:=str+' and 委托编号 like '+''''+'%'+Edit4.text+'%'+''''; if Edit2.text<>''then str:=str+' and 主提单号 like '+''''+'%'+Edit2.text+'%'+''''; if Edit3.text<>''then str:=str+' and 报关单号 like '+''''+'%'+Edit3.text+'%'+''''; if wwDBDateTimePicker1.text<>''then str:=str+' and 开船日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str:=str+' and 开船日期<='+''''+wwDBDateTimePicker2.text+''''; if wwDBDateTimePicker3.text<>''then str:=str+' and 会计期间>='+''''+wwDBDateTimePicker3.text+''''; if wwDBDateTimePicker4.text<>''then str:=str+' and 会计期间<='+''''+wwDBDateTimePicker4.text+''''; if RxDBLookupCombo2.DisplayValues[1]<>''then str:=str+' and 委托单位='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; if RxDBLookupCombo11.DisplayValue<>''then str:=str+' and 揽货人='+''''+RxDBLookupCombo11.DisplayValue+''''; // if RxDBLookupCombo6.DisplayValues[1]<>''then // str:=str+' and 操作员='+''''+RxDBLookupCombo6.DisplayValues[1]+''''; if wwDBLookupCombo49.text<>''then str:=str+' and 船名 like '+''''+'%'+wwDBLookupCombo49.text+'%'+''''; if Edit7.text<>''then str:=str+' and 航次 like '+''''+'%'+Edit7.text+'%'+''''; if wwDBLookupCombo52.text<>''then str:=str+' and 卸货港 like '+''''+'%'+wwDBLookupCombo52.text+'%'+''''; if RxDBLookupCombo12.DisplayValues[1]<>''then str:=str+' and 编号 in (select 编号 from t_ch_fee where 客户名称='+''''+RxDBLookupCombo12.DisplayValues[1]+''' and 类型=''收'')'; str:=str+'and 编号 not in (select 编号 from t_op_fangdan)'; str:=str+'and 编号 not in (select 编号 from t_op_state where 业务状态=''提单签出'')'; t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add('select * from t_op_seae '+str+default_sort(53,'t_op_seae','','desc')); t_op_seae.open; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton6Click(Sender: TObject); begin Edit1.text:=''; Edit4.text:=''; Edit2.text:=''; Edit3.text:=''; wwDBDateTimePicker1.text:=''; wwDBDateTimePicker2.text:=''; RxDBLookupCombo2.ClearValue; wwDBDateTimePicker3.text:=''; wwDBDateTimePicker4.text:=''; wwDBLookupCombo49.text:=''; Edit7.text:=''; wwDBLookupCombo52.text:=''; RxDBLookupCombo6.ClearValue; wwDBDateTimePicker5.text:=''; end; procedure Tfrm_op_seae_teshufandan.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_op_seae,'业务编号'); end; procedure Tfrm_op_seae_teshufandan.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid2); end; procedure Tfrm_op_seae_teshufandan.FormShow(Sender: TObject); begin loadreggrid(dxdbgrid1,true,caption); loadreggrid(dxdbgrid2,true,caption+'1'); RxDBLookupCombo1.Value:=employee; wwDBDateTimePicker6.Date:=Date; wwDBDateTimePicker7.Date:=Date; t_op_bill.Close; t_op_bill.Parameters.ParamByName('操作人').Value:=employee; t_op_bill.Open; t_op_seaesel.Open; end; procedure Tfrm_op_seae_teshufandan.N3Click(Sender: TObject); var i:integer; str:widestring; begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount>=0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('业务编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('业务编号').asstring+''''; end; end else begin str:='('+''''+t_op_seae.fieldbyname('业务编号').asstring+''''; end; str:=str+')'; t_op_seaesel.close; t_op_seaesel.sql.clear; t_op_seaesel.sql.add('select * from t_op_seae ' +'where 业务编号 in '+str +default_sort(53,'t_op_seae','','desc')); t_op_seaesel.open; sys_print('海运出口签单',2,nil,nil,nil,nil,ds_op_seaesel1,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_teshufandan.N1Click(Sender: TObject); var i,StlDay,qty,moduleqty:integer; aAdoQueryAmt,aAdoQuery,aAdoQuerycurAmt:TAdoQuery; AEtd:TDateTime; JFLX,FeeItems:string; StlMonth:integer; amt,usd,amt1,usd1:double; begin if t_op_bill.FieldByName('操作人').AsString<>employee then begin ShowMessage(t_op_bill.FieldByName('操作人').AsString+'的申请不能修改'); exit; end; aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin Close;Sql.Clear; SQL.Add('Select 结费金额,结费类型,结费日期,类型模式,结费期限 from t_crm_client_sales'); SQL.Add('where 客户简称=:客户简称 and 结束日期>=:aDate and 结费类型<>''现结买单'''); end; if (t_op_bill.FieldByName('状态').asstring='销售审核')then begin showmessage('当前业务操作的状态不允许添加!!'); exit; end; if t_op_bill.FieldByName('委托单位').AsString='' then begin showmessage('委托单位不能为空'); exit; end; if t_op_seae.IsEmpty then exit; if t_op_bill.IsEmpty then exit; bsSkinPageControl1.ActivePageIndex:=1; aAdoQuerycurAmt:=CreateAdoQuery; with aAdoQuerycurAmt do begin Close;SQL.Clear; SQL.Add('select'); SQL.Add('SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END ) as USD '); SQL.Add(','); SQL.Add('SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as RMB '); SQL.Add('From t_ch_fee '); SQL.Add('where t_ch_fee.编号=:编号'); end; aAdoQueryAmt:=CreateAdoQuery; with aAdoQueryAmt do begin Close;SQL.Clear; SQL.Add('select'); SQL.Add('SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END ) as USD '); SQL.Add(','); SQL.Add('SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as RMB '); SQL.Add('From t_ch_fee '); SQL.Add('Left Join t_op_seae on t_op_seae.编号=t_ch_fee.编号 '); SQL.Add('where t_op_seae.委托单位=:客户名称 and t_ch_fee.类型=''收'' and t_ch_fee.金额<>t_ch_fee.结算金额 '); SQL.Add('and t_op_seae.开船日期<=:ETD'); end; frm_main.db.BeginTrans; try if dxDBGrid1.SelectedCount>=1 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if (t_op_seae.fieldByName('委托单位').AsString=t_op_bill.fieldByName('委托单位').AsString) and (not t_op_seaesel.Locate('编号',t_op_seae.fieldByName('编号').AsString,[])) then begin t_op_seaesel.Insert; t_op_seaesel.FieldByName('签单编号').AsInteger:=t_op_bill.fieldByName('BILL_ID').AsInteger; t_op_seaesel.FieldByName('编号').AsString:=t_op_seae.fieldByName('编号').AsString; t_op_seaesel.FieldByName('主编号').AsString:=t_op_seae.fieldByName('主编号').AsString; t_op_seaesel.FieldByName('业务状态').AsString:=t_op_seae.fieldByName('业务状态').AsString; t_op_seaesel.FieldByName('费用状态').AsString:=t_op_seae.fieldByName('费用状态').AsString; t_op_seaesel.FieldByName('业务编号').AsString:=t_op_seae.fieldByName('业务编号').AsString; t_op_seaesel.FieldByName('会计期间').Value:=t_op_seae['会计期间']; t_op_seaesel.FieldByName('主提单号').AsString:=t_op_seae.fieldByName('主提单号').AsString; t_op_seaesel.FieldByName('分提单号').AsString:=t_op_seae.fieldByName('分提单号').AsString; t_op_seaesel.FieldByName('委托编号').AsString:=t_op_seae.fieldByName('委托编号').AsString; t_op_seaesel.FieldByName('委托单位').AsString:=t_op_seae.fieldByName('委托单位').AsString; t_op_seaesel.FieldByName('船名').AsString:=t_op_seae.fieldByName('船名').AsString; t_op_seaesel.FieldByName('航次').AsString:=t_op_seae.fieldByName('航次').AsString; t_op_seaesel.FieldByName('开船日期').Value:=t_op_seae['开船日期']; t_op_seaesel.FieldByName('卸货港').AsString:=t_op_seae.fieldByName('卸货港').AsString; t_op_seaesel.FieldByName('签单方式').AsString:=t_op_seae.fieldByName('签单方式').AsString; t_op_seaesel.FieldByName('操作员').AsString:=t_op_seae.fieldByName('操作员').AsString; t_op_seaesel.FieldByName('揽货人').AsString:=t_op_seae.fieldByName('揽货人').AsString; t_op_seaesel.FieldByName('船公司').AsString:=t_op_seae.fieldByName('船公司').AsString; t_op_seaesel.FieldByName('销售部门').AsString:=t_op_seae.fieldByName('销售部门').AsString; t_op_seaesel.FieldByName('提单签发状态').AsString:=t_op_seae.fieldByName('提单签发状态').AsString; t_op_seaesel.FieldByName('结费类型').AsString:=t_op_seae.fieldByName('结费类型').AsString; t_op_seaesel.FieldByName('合同帐期').Value:=t_op_seae.fieldByName('辅助字段三').AsString; aAdoQuerycurAmt.Close; aAdoQuerycurAmt.Parameters.ParamByName('编号').Value:=t_op_seae.fieldByName('编号').AsString; aAdoQuerycurAmt.open; t_op_seaesel.FieldByName('超期金额RMB').Value:=aAdoQuerycurAmt.FieldByName('RMB').Value; t_op_seaesel.FieldByName('超期金额USD').Value:=aAdoQuerycurAmt.FieldByName('USD').Value; t_op_seaesel.Post; try InsertBillStatus(t_op_seae.fieldByName('编号').AsString); InsertSeaeStatus(t_op_seae.FieldByName('编号').AsString,'申请放单',employee,FormatDateTime('YYYY-MM-DD',Now)); except on e:exception do ShowMessage(e.message); end; end else begin ShowMessage('申请客户:'+t_op_bill.fieldByName('委托单位').AsString+' 选择客户:'+t_op_seae.fieldByName('委托单位').AsString+'不相等或者已经添加,不能加入'); end; end; end; t_op_bill.Edit; t_op_bill.FieldByName('账款RMB').Value:=0; t_op_bill.FieldByName('账款USD').Value:=0; t_op_bill.Post; aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('aDate').Value:=date; aAdoQuery.Parameters.ParamByName('客户简称').Value:=t_op_seae.fieldByName('委托单位').AsString; aAdoQuery.open; if not aAdoQuery.IsEmpty then JFLX:=aAdoQuery.FieldByName('结费类型').AsString else JFLX:='现结买单'; if JFLX='现结买单' then begin { t_op_seaesel.First; while not t_op_seaesel.Eof do begin if GetCrmsales(t_op_seaesel.fieldByName('编号').AsString,t_op_bill.fieldByName('委托单位').AsString,JFLX,amt,usd) then begin amt1:=amt1+amt; usd1:=usd1+usd; end; t_op_seaesel.Next; end; } aAdoQueryAmt.Close; aAdoQueryAmt.Parameters.ParamByName('客户名称').Value:=t_op_seaesel.FieldByName('委托单位').Value; aAdoQueryAmt.Parameters.ParamByName('ETD').Value:=Date; aAdoQueryAmt.Open; t_op_bill.Edit; t_op_bill.FieldByName('账款RMB').Value:=aAdoQueryAmt.FieldByName('RMB').Value; t_op_bill.FieldByName('账款USD').Value:=aAdoQueryAmt.FieldByName('USD').Value; t_op_bill.Post; end else if GetCrmsales('',t_op_bill.fieldByName('委托单位').AsString,'约定时间',amt,usd,FeeItems) then begin t_op_bill.Edit; t_op_bill.FieldByName('账款RMB').Value:=amt; t_op_bill.FieldByName('账款USD').Value:=usd; end; if t_op_bill.state in [dsedit,dsinsert] then t_op_bill.Post; frm_main.db.CommitTrans; finally if frm_main.db.InTransaction then frm_main.db.RollbackTrans; aAdoQueryAmt.Free; aAdoQuery.Free; aAdoQuerycurAmt.Free; // t_op_bill.Requery(); t_op_seae.Requery(); t_op_seaesel.Requery(); end; end; procedure Tfrm_op_seae_teshufandan.MenuItem2Click(Sender: TObject); var i:integer; str,or_id:string; begin if t_op_bill.FieldByName('操作人').AsString<>employee then begin ShowMessage(t_op_bill.FieldByName('操作人').AsString+'的申请不能修改'); exit; end; if (t_op_bill.FieldByName('状态').asstring<>'新建签单')then begin showmessage(t_op_bill.FieldByName('状态').asstring+'通过状态不允许删除!!'); exit; end; if t_op_seaesel.IsEmpty then exit; frm_main.db.BeginTrans; try if dxDBGrid3.SelectedCount>=1 then begin for i:=0 to dxDBGrid3.SelectedCount-1 do begin t_op_seaesel.GotoBookmark(pointer(dxDBGrid3.selectedrows[i])); if str='' then str:='编号='+''''+t_op_seaesel.fieldbyname('编号').AsString+'''' else str:=str+' or 编号='+''''+t_op_seaesel.fieldbyname('编号').AsString+''''; if or_id='' then or_id:='or_id='+t_op_seaesel.fieldbyname('or_id').AsString else or_id:=or_id+' or or_id='+t_op_seaesel.fieldbyname('or_id').AsString; DelteSeaeStatus(t_op_seaesel.fieldbyname('编号').AsString,'申请放单'); end; end; if (str<>'') and (or_id<>'') then begin str:=' ('+str+')'; or_id:=' ('+or_id+')'; DeleteBillStatus(str,or_id); end; frm_main.db.CommitTrans; finally t_op_seaesel.Requery(); if frm_main.db.InTransaction then frm_main.db.RollbackTrans; end; end; procedure Tfrm_op_seae_teshufandan.t_op_billAfterInsert(DataSet: TDataSet); function GetMaxItems:Integer; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin CLose;SQL.Clear; sql.Add('Select Max(BILL_ID) from t_op_bill_fangdan'); open; if Fields[0].IsNull then Result:=1 else Result:=Fields[0].AsInteger+1; end; finally FreeAndNil(aQuery); end; end; begin DataSet.FieldByName('BILL_ID').AsInteger:=GetMaxItems; DataSet.FieldByName('状态').AsString:='新建签单'; DataSet.FieldByName('操作人').AsString:=employee; DataSet.FieldByName('操作日期').AsDateTime:=NOW; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton2Click(Sender: TObject); begin t_op_bill.Insert; bsSkinPageControl1.ActivePageIndex:=1; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton3Click(Sender: TObject); begin if t_op_bill.State in [dsedit,dsinsert] then t_op_bill.Post; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton4Click(Sender: TObject); begin if t_op_bill.IsEmpty then exit; if t_op_bill.FieldByName('状态').asstring<>'新建签单' then begin showmessage(t_op_bill.FieldByName('状态').asstring+'通过状态不允许删除!!'); exit; end; if t_op_seaesel.RecordCount>=1 then begin ShowMessage('存在放单明细不能删除,请先删除放单明细'); exit; end; t_op_bill.Delete; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton7Click(Sender: TObject); begin if t_op_bill.IsEmpty then exit; t_op_bill.Cancel; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton8Click(Sender: TObject); begin Close; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton12Click(Sender: TObject); begin sys_print('应收费用结算',2,ds_op_bill1,nil,nil,nil, ds_op_seaesel1,nil,nil,nil,ds_op_bill1,nil,nil); end; procedure Tfrm_op_seae_teshufandan.t_op_seaeselBeforeDelete( DataSet: TDataSet); begin if not t_op_bill.IsEmpty then begin if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage(t_op_bill.FieldByName('状态').AsString+'已经审核通不能修改'); abort; end; end; if t_op_bill.FieldByName('操作人').AsString<>employee then begin ShowMessage(t_op_bill.FieldByName('操作人').AsString+'的申请不能修改'); abort; end; end; procedure Tfrm_op_seae_teshufandan.t_op_billBeforeEdit(DataSet: TDataSet); begin if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage('当前状态'+t_op_bill.FieldByName('状态').AsString+'不能修改'); abort; end; if t_op_bill.FieldByName('操作人').AsString<>employee then begin ShowMessage(t_op_bill.FieldByName('操作人').AsString+'的申请不能修改'); abort; end; end; procedure Tfrm_op_seae_teshufandan.t_op_billBeforeDelete( DataSet: TDataSet); begin if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage('当前状态'+t_op_bill.FieldByName('状态').AsString+'不能修改'); abort; end; if t_op_bill.FieldByName('操作人').AsString<>employee then begin ShowMessage(t_op_bill.FieldByName('操作人').AsString+'的申请不能修改'); abort; end; end; procedure Tfrm_op_seae_teshufandan.t_op_seaeselBeforeEdit( DataSet: TDataSet); begin if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage('当前状态'+t_op_bill.FieldByName('状态').AsString+'不能修改'); abort; end; if t_op_bill.FieldByName('操作人').AsString<>employee then begin ShowMessage(t_op_bill.FieldByName('操作人').AsString+'的申请不能修改'); abort; end; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton38Click(Sender: TObject); begin t_op_bill.Refresh; end; procedure Tfrm_op_seae_teshufandan.RxDBLookupCombo8Enter(Sender: TObject); begin RxLookupComboEnter(RxDBLookupCombo8); end; procedure Tfrm_op_seae_teshufandan.RxDBLookupCombo8Exit(Sender: TObject); begin RxLookupComboExit(RxDBLookupCombo8); end; procedure Tfrm_op_seae_teshufandan.dxDBGrid2Click(Sender: TObject); begin bsSkinPageControl1.ActivePageIndex:=1; end; procedure Tfrm_op_seae_teshufandan.bsSkinButton11Click(Sender: TObject); begin with t_op_bill do begin Close; sql.Clear; sql.Add('select * from t_op_bill_fangdan'); sql.Add('where 操作日期 between :date1 and :date2 and 操作人=:操作人'); sql.Add('order by BILL_ID DESC'); Parameters.ParamByName('date1').Value:=wwDBDateTimePicker6.Date; Parameters.ParamByName('date2').Value:=wwDBDateTimePicker7.Date; Parameters.ParamByName('操作人').Value:=RxDBLookupCombo1.value; Open; end; // end; procedure Tfrm_op_seae_teshufandan.dxDBGrid3DblClick(Sender: TObject); begin fee_view(t_op_seaesel.fieldbyname('编号').asstring); end; end.