unit u_rp_dui_seai_pay; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, ADODB, Menus, XPMenu, DB, Mask, DBCtrls, dxDBGrid, RxLookup, wwdbdatetimepicker, StdCtrls, dxDBTLCl, dxGrClms, dxTL, dxDBCtrl, dxCntner, ExtCtrls, bsSkinCtrls, ComCtrls, bsSkinTabs, bsdbctrls; type Tfrm_rp_dui_seai_pay = class(TForm) Panel1: TPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton12: TbsSkinButton; Notebook1: TNotebook; dxDBGrid1: TdxDBGrid; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column9: TdxDBGridDateColumn; bsSkinPanel3: TbsSkinPanel; bsSkinPanel4: TbsSkinPanel; Label1: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Edit4: TEdit; Edit2: TEdit; Edit3: TEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; RxDBLookupCombo2: TRxDBLookupCombo; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinPanel5: TbsSkinPanel; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridMaskColumn2: TdxDBGridMaskColumn; dxDBGridMaskColumn3: TdxDBGridMaskColumn; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn5: TdxDBGridMaskColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridDateColumn2: TdxDBGridDateColumn; dxDBGridMaskColumn6: TdxDBGridMaskColumn; dxDBGridColumn1: TdxDBGridColumn; dxDBGridMaskColumn7: TdxDBGridMaskColumn; dxDBGridMaskColumn8: TdxDBGridMaskColumn; dxDBGridMaskColumn9: TdxDBGridMaskColumn; dxDBGridMaskColumn10: TdxDBGridMaskColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGridMaskColumn11: TdxDBGridMaskColumn; dxDBGridMaskColumn12: TdxDBGridMaskColumn; dxDBGridMaskColumn13: TdxDBGridMaskColumn; Panel2: TPanel; dxDBGrid4: TdxDBGrid; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; bsSkinPanel1: TbsSkinPanel; bsSkinPanel6: TbsSkinPanel; Label2: TLabel; Label5: TLabel; Label6: TLabel; Label15: TLabel; Label3: TLabel; Label4: TLabel; DBEdit2: TDBEdit; DBEdit5: TDBEdit; RxDBLookupCombo3: TRxDBLookupCombo; DBEdit6: TDBEdit; RxDBLookupCombo1: TRxDBLookupCombo; DBEdit4: TDBEdit; t_ch_dui: TADOQuery; t_ch_dui1: TDataSource; t_bill_fee1: TDataSource; t_op_seae: TADOQuery; t_op_seae1: TDataSource; t_ch_fee: TADOQuery; t_ch_fee1: TDataSource; PopupMenu1: TPopupMenu; N1: TMenuItem; t_ch_dui_format1: TDataSource; t_ch_dui_format: TADOQuery; t_ch_dui_bill: TADOQuery; p_update: TADOStoredProc; PopupMenu3: TPopupMenu; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; v_dui_bill: TADOQuery; v_dui_bill1: TDataSource; v_dui_fee: TADOQuery; v_dui_fee1: TDataSource; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; dxDBGrid5: TdxDBGrid; dxDBGrid5Column1: TdxDBGridMaskColumn; dxDBGrid5Column2: TdxDBGridMaskColumn; dxDBGrid5Column6: TdxDBGridMaskColumn; dxDBGrid5Column7: TdxDBGridColumn; dxDBGrid5Column8: TdxDBGridColumn; dxDBGrid5Column9: TdxDBGridColumn; dxDBGrid6: TdxDBGrid; dxDBGrid6Column1: TdxDBGridMaskColumn; dxDBGrid6Column2: TdxDBGridMaskColumn; dxDBGrid6Column3: TdxDBGridMaskColumn; dxDBGrid6RMB: TdxDBGridColumn; dxDBGrid6Column20: TdxDBGridColumn; dxDBGrid6Column21: TdxDBGridColumn; dxDBGrid6USD: TdxDBGridColumn; dxDBGrid6Column23: TdxDBGridColumn; dxDBGrid6Column24: TdxDBGridColumn; dxDBGrid6Column4: TdxDBGridMaskColumn; dxDBGrid6Column5: TdxDBGridMaskColumn; dxDBGrid6Column6: TdxDBGridMaskColumn; dxDBGrid6Column7: TdxDBGridDateColumn; dxDBGrid6Column8: TdxDBGridMaskColumn; dxDBGrid6Column9: TdxDBGridMaskColumn; dxDBGrid6Column10: TdxDBGridMaskColumn; dxDBGrid6Column11: TdxDBGridMaskColumn; dxDBGrid6Column12: TdxDBGridColumn; dxDBGrid6Column14: TdxDBGridMaskColumn; dxDBGrid6Column15: TdxDBGridMaskColumn; dxDBGrid6Column16: TdxDBGridMaskColumn; dxDBGrid6Column17: TdxDBGridMaskColumn; dxDBGrid6Column18: TdxDBGridMaskColumn; bsSkinTabSheet2: TbsSkinTabSheet; dxDBGrid2: TdxDBGrid; bsSkinButton6: TbsSkinButton; PopupMenu2: TPopupMenu; N5: TMenuItem; XPMenu1: TXPMenu; Label16: TLabel; wwDBDateTimePicker5: TwwDBDateTimePicker; Label17: TLabel; wwDBDateTimePicker6: TwwDBDateTimePicker; Label7: TLabel; DBEdit7: TDBEdit; Label19: TLabel; wwDBDateTimePicker7: TwwDBDateTimePicker; Label18: TLabel; DBEdit1: TDBEdit; dxDBGrid3Column19: TdxDBGridColumn; dxDBGrid3Column20: TdxDBGridColumn; dxDBGrid6Column25: TdxDBGridColumn; dxDBGrid6Column26: TdxDBGridColumn; dxDBGrid6Column13: TdxDBGridColumn; t_bill_fee: TADOQuery; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinPanel2Resize(Sender: TObject); procedure t_ch_duiAfterInsert(DataSet: TDataSet); procedure t_ch_duiBeforePost(DataSet: TDataSet); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure t_ch_duiAfterScroll(DataSet: TDataSet); procedure RxDBLookupCombo3Change(Sender: TObject); procedure N1Click(Sender: TObject); procedure RxDBLookupCombo1Enter(Sender: TObject); procedure N2Click(Sender: TObject); procedure dxDBGrid2ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure t_ch_duiAfterPost(DataSet: TDataSet); procedure bsSkinButton9Click(Sender: TObject); procedure N4Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure t_ch_duiBeforeCancel(DataSet: TDataSet); procedure bsSkinButton6Click(Sender: TObject); procedure N5Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_rp_dui_seai_pay: Tfrm_rp_dui_seai_pay; implementation uses u_main, u_rp_dui_format, u_data_share, my_sys_function, u_rp_dui_query; {$R *.dfm} procedure Tfrm_rp_dui_seai_pay.bsSkinButton8Click(Sender: TObject); begin RxDBLookupCombo2.ClearValue; Edit4.text:=''; Edit3.Text:=''; Edit2.text:=''; wwDBDateTimePicker1.Clear; wwDBDateTimePicker2.clear; wwDBDateTimePicker3.clear; wwDBDateTimePicker4.clear; end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton7Click(Sender: TObject); var str_fee,str_op:widestring; begin if NOT strtobool(get_parameters_value(84,'false')) then begin if NOT strtobool(get_parameters_value(47,'false')) then begin str_fee:='where (是否对帐=0 OR 是否对帐 IS NULL) and 类型='+''''+'付'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:='where (是否对帐=0 OR 是否对帐 IS NULL) and 类型='+''''+'付'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+'''' +','+''''+'禁止修改'+''''+')'; end; end else begin if NOT strtobool(get_parameters_value(47,'false')) then begin str_fee:='where (是否对帐=0 OR 是否对帐 IS NULL) and 类型='+''''+'付'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'结算完毕'+''''+','+''''+'禁止删除'+''''+','+''''+'录入状态'+''''+','+''''+'提交审核'+'''' +','+''''+'禁止修改'+''''+')'; end else begin str_fee:='where (是否对帐=0 OR 是否对帐 IS NULL) and 类型='+''''+'付'+'''' +' and 费用状态 in ('+''''+'审核通过'+''''+','+''''+'部分结算'+'''' +','+''''+'禁止删除'+''''+','+''''+'录入状态'+''''+','+''''+'提交审核'+'''' +','+''''+'禁止修改'+''''+')'; end; end; if RxDBLookupCombo2.DisplayValues[1]<>''then str_fee:=str_fee+' and 客户名称='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; str_op:=''; if Edit4.text<>''then str_op:=str_op+' and 委托编号 like '+''''+'%'+Edit4.text+'%'+''''; if Edit2.text<>''then str_op:=str_op+' and 主提单号 like '+''''+'%'+Edit2.text+'%'+''''; if Edit3.text<>''then str_op:=str_op+' and 分提单号 like '+''''+'%'+Edit3.text+'%'+''''; if wwDBDateTimePicker1.text<>''then str_op:=str_op+' and 进口日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str_op:=str_op+' and 进口日期<='+''''+wwDBDateTimePicker2.text+''''; if wwDBDateTimePicker3.text<>''then str_op:=str_op+' and 会计期间>='+''''+wwDBDateTimePicker3.text+''''; if wwDBDateTimePicker4.text<>''then str_op:=str_op+' and 会计期间<='+''''+wwDBDateTimePicker4.text+''''; str_op:='where 编号 in (select distinct 编号 from t_ch_fee '+str_fee+')'+str_op; str_op:=str_op+' and '+open_data('0032','揽货人','操作员','客服员','报关操作','报检操作'); str_op:='select * from t_op_seai '+str_op+default_sort(54,'t_op_seai','','desc'); str_fee:='select * from t_ch_fee ' +str_fee+' and 编号=:编号 order by CH_ID'; t_ch_fee.Close; t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add(str_op); t_op_seae.open; t_ch_fee.sql.clear; t_ch_fee.sql.add(str_fee); t_ch_fee.open; end; procedure Tfrm_rp_dui_seai_pay.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_rp_dui_seai_pay.Hide; frm_rp_dui_seai_pay.ManualFloat(frm_rp_dui_seai_pay.BoundsRect ); frm_main.freeTabs('frm_rp_dui_seai_pay'); action:=cafree; frm_rp_dui_seai_pay:=nil; end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_dui_seai_pay.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.width/10); bsSkinButton9.width:=i; bsSkinButton12.width:=i; bsSkinButton10.width:=i; bsSkinButton1.width:=i; bsSkinButton2.width:=i; bsSkinButton4.width:=i; bsSkinButton3.width:=i; bsSkinButton11.width:=i; bsSkinButton6.width:=i; end; procedure Tfrm_rp_dui_seai_pay.t_ch_duiAfterInsert(DataSet: TDataSet); begin t_ch_dui['对帐日期']:=date; t_ch_dui['对帐人']:=employee; t_ch_dui['类别']:=4; if not t_ch_fee.IsEmpty then t_ch_dui['对帐客户']:=t_ch_fee.fieldbyname('客户名称').asstring; end; procedure Tfrm_rp_dui_seai_pay.t_ch_duiBeforePost(DataSet: TDataSet); begin table_before_post(t_ch_dui,'对帐客户'); if t_ch_dui.State=dsinsert then begin t_ch_dui['对帐编号']:=get_no(date,'D4'); end; modify_all:=true; end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton1Click(Sender: TObject); begin t_ch_dui.insert; Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_dui); end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton4Click(Sender: TObject); var aAdoQuery:TAdoQuery; str:widestring; begin if t_ch_dui.IsEmpty then exit; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)<>IDOK then exit; try aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin Close;SQL.Clear; SQL.Add('Select ch_id from t_ch_fee where 编号=:编号 and 是否对帐=1 and 对帐编号=:对帐编号'); end; v_dui_bill.first; while not v_dui_bill.eof do begin aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('编号').Value:=v_dui_bill.fieldbyname('编号').asstring; aAdoQuery.Parameters.ParamByName('对帐编号').Value:=t_ch_dui.fieldbyname('对帐编号').asstring; aAdoQuery.Open; aAdoQuery.First; while not aAdoQuery.Eof do begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+'''' +' and ch_id='+''''+aAdoQuery.fieldbyname('ch_id').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; aAdoQuery.Next; end; { str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; } str:='delete from t_ch_dui_detail' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; v_dui_bill.next; end; t_ch_dui.delete; finally aAdoQuery.Free; if t_op_seae.Active then t_op_seae.Requery(); end; end; {procedure Tfrm_rp_dui_seai_pay.bsSkinButton4Click(Sender: TObject); var str:widestring; begin if t_ch_dui.IsEmpty then exit; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)<>IDOK then exit; v_dui_bill.first; while not v_dui_bill.eof do begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; v_dui_bill.next; end; t_ch_dui.delete; if t_op_seae.Active then t_op_seae.Requery(); end; } procedure Tfrm_rp_dui_seai_pay.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_dui); end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton11Click(Sender: TObject); var answer:TModalResult; begin if bsSkinButton11.Caption='编辑修改' then begin Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; end else begin if (t_ch_dui.State=dsinsert)or(t_ch_dui.State=dsedit) then BEGIN answer:=messagedlg( '数据已经修改,是否保存?',mtWarning,mbYesNoCancel,0); if answer=mrYes then begin t_ch_dui.post; end; if answer=mrNo then begin t_ch_dui.cancel; end; if answer=mrCancel then begin exit; end; END; Notebook1.PageIndex:=0; bsSkinButton11.Caption:='编辑修改'; end; end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton12Click(Sender: TObject); begin try if not assigned(frm_rp_dui_format) then frm_rp_dui_format:=tfrm_rp_dui_format.Create (self); dui_format_type:=4; frm_rp_dui_format.showmodal; finally frm_rp_dui_format.free; frm_rp_dui_format:=nil; t_ch_dui_format.requery; end; end; procedure Tfrm_rp_dui_seai_pay.FormShow(Sender: TObject); var str:widestring; begin Notebook1.PageIndex:=0; t_ch_dui_format.Parameters[0].value:=4; t_ch_dui_format.open; str:='select top 50 * from t_ch_dui '; str:=str+' where 类别=4 and 对帐人='+''''+employee+''''+' order by 对帐日期 desc'; t_ch_dui.close; t_ch_dui.SQL.clear; t_ch_dui.sql.Add(str); modify_all:=true; t_ch_dui.open; t_ch_dui_bill.open; v_dui_bill.open; v_dui_fee.Parameters.ParamByName('对帐编号').value:=t_ch_dui.fieldbyname('对帐编号').asstring; v_dui_fee.open; modify_all:=false; frm_data_share.t_crm_client_all.requery; if t_ch_dui.fieldbyname('DM_ID').asstring<>''then if t_ch_dui_format.Locate('DM_ID',t_ch_dui.fieldbyname('DM_ID').asinteger,[])then begin dui_grid(t_ch_dui_format.fieldbyname('字段内容').asstring,dxdbgrid2); t_bill_fee.close; t_bill_fee.Sql.Clear; t_bill_fee.Sql.text:=dui_sql(t_ch_dui_format.fieldbyname('字段内容').asstring,'t_op_seai',t_ch_dui.fieldbyname('对帐编号').asstring,t_ch_dui); // t_bill_fee.Parameters.ParamByName('SQLStr').value:=dui_sql(t_ch_dui_format.fieldbyname('字段内容').asstring,'t_op_seai',t_ch_dui.fieldbyname('对帐编号').asstring); t_bill_fee.open; end; frm_data_share.t_crm_client_all.requery; end; procedure Tfrm_rp_dui_seai_pay.t_ch_duiAfterScroll(DataSet: TDataSet); begin if not modify_all then begin if t_ch_dui.fieldbyname('DM_ID').asstring<>''then if t_ch_dui_format.Locate('DM_ID',t_ch_dui.fieldbyname('DM_ID').asinteger,[])then begin dui_grid(t_ch_dui_format.fieldbyname('字段内容').asstring,dxdbgrid2); t_bill_fee.close; t_bill_fee.Sql.Clear; t_bill_fee.Sql.text:=dui_sql(t_ch_dui_format.fieldbyname('字段内容').asstring,'t_op_seai',t_ch_dui.fieldbyname('对帐编号').asstring,t_ch_dui); //t_bill_fee.Parameters.ParamByName('SQLStr').value:=dui_sql(t_ch_dui_format.fieldbyname('字段内容').asstring,'t_op_seai',t_ch_dui.fieldbyname('对帐编号').asstring); t_bill_fee.open; end else t_bill_fee.close; end; if v_dui_fee.active then begin v_dui_fee.close; v_dui_fee.Parameters.ParamByName('对帐编号').value:=t_ch_dui.fieldbyname('对帐编号').asstring; v_dui_fee.open; end; end; procedure Tfrm_rp_dui_seai_pay.RxDBLookupCombo3Change(Sender: TObject); begin if (t_ch_dui.state=dsinsert)or(t_ch_dui.state=dsedit) then if t_ch_dui.fieldbyname('DM_ID').asstring<>''then if t_ch_dui_format.Locate('DM_ID',t_ch_dui.fieldbyname('DM_ID').asinteger,[])then begin dui_grid(t_ch_dui_format.fieldbyname('字段内容').asstring,dxdbgrid2); t_bill_fee.close; t_bill_fee.Sql.Clear; t_bill_fee.Sql.text:=dui_sql(t_ch_dui_format.fieldbyname('字段内容').asstring,'t_op_seai',t_ch_dui.fieldbyname('对帐编号').asstring,t_ch_dui); // t_bill_fee.Parameters.ParamByName('SQLStr').value:=dui_sql(t_ch_dui_format.fieldbyname('字段内容').asstring,'t_op_seai',t_ch_dui.fieldbyname('对帐编号').asstring); t_bill_fee.open; end else t_bill_fee.close; end; procedure Tfrm_rp_dui_seai_pay.N1Click(Sender: TObject); var i,k:integer; begin if t_op_seae.IsEmpty then exit; if t_ch_dui.IsEmpty then exit; if t_ch_dui.FieldByName('对帐客户').asstring='' then begin t_ch_dui.edit; t_ch_dui['对帐客户']:=t_ch_fee.FieldByName('客户名称').asstring; t_ch_dui.post; end; if dxDBGrid3.SelectedCount>=1 then begin for i:=0 to dxDBGrid3.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid3.selectedrows[i])); t_ch_fee.first; while not t_ch_fee.Eof do begin if t_ch_dui.FieldByName('对帐客户').asstring<>t_ch_fee.FieldByName('客户名称').asstring then begin showmessage('当前客户名称与对帐客户名称不符,加入失败!!'); exit; end; t_ch_fee.next; end; end; end else begin t_ch_fee.first; while not t_ch_fee.Eof do begin if t_ch_dui.FieldByName('对帐客户').asstring<>t_ch_fee.FieldByName('客户名称').asstring then begin showmessage('当前客户名称与对帐客户名称不符,加入失败!!'); exit; end; t_ch_fee.next; end; end; if (t_ch_dui.state=dsinsert)or(t_ch_dui.state=dsedit) then t_ch_dui.Post; if dxDBGrid3.SelectedCount>=1 then begin for i:=0 to dxDBGrid3.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid3.selectedrows[i])); if not t_ch_fee.IsEmpty then begin if not t_ch_dui_bill.Locate('对帐编号;编号',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_op_seae.FieldByName('编号').asstring]),[]) then begin t_ch_dui_bill.insert; t_ch_dui_bill['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_bill['编号']:=t_op_seae.FieldByName('编号').asstring; t_ch_dui_bill.post; end; t_ch_fee.first; while not t_ch_fee.Eof do begin t_ch_fee.edit; t_ch_fee['是否对帐']:=1; t_ch_fee['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_fee.post; t_ch_fee.next; end; end; end; end else begin if not t_ch_fee.IsEmpty then begin if not t_ch_dui_bill.Locate('对帐编号;编号',VarArrayOf([t_ch_dui.FieldByName('对帐编号').asstring,t_op_seae.FieldByName('编号').asstring]),[]) then begin t_ch_dui_bill.insert; t_ch_dui_bill['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_dui_bill['编号']:=t_op_seae.FieldByName('编号').asstring; t_ch_dui_bill.post; end; t_ch_fee.first; while not t_ch_fee.Eof do begin t_ch_fee.edit; t_ch_fee['是否对帐']:=1; t_ch_fee['对帐编号']:=t_ch_dui.FieldByName('对帐编号').asstring; t_ch_fee.post; t_ch_fee.next; end; end; end; t_op_seae.requery; t_bill_fee.close; t_bill_fee.Sql.Clear; t_bill_fee.Sql.text:=dui_sql(t_ch_dui_format.fieldbyname('字段内容').asstring,'t_op_seai',t_ch_dui.fieldbyname('对帐编号').asstring,t_ch_dui); // t_bill_fee.Parameters.ParamByName('SQLStr').value:=dui_sql(t_ch_dui_format.fieldbyname('字段内容').asstring,'t_op_seai',t_ch_dui.fieldbyname('对帐编号').asstring); t_bill_fee.open; v_dui_bill.requery; end; procedure Tfrm_rp_dui_seai_pay.RxDBLookupCombo1Enter(Sender: TObject); begin if t_ch_dui_bill.IsEmpty then RxDBLookupCombo1.ReadOnly:=false else RxDBLookupCombo1.ReadOnly:=true; end; procedure Tfrm_rp_dui_seai_pay.N2Click(Sender: TObject); var i:integer; str:widestring; begin if t_bill_fee.IsEmpty then exit; if t_ch_dui.IsEmpty then exit; if dxDBGrid2.SelectedCount>=1 then begin for i:=0 to dxDBGrid2.SelectedCount-1 do begin t_bill_fee.GotoBookmark(pointer(dxDBGrid2.selectedrows[i])); str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+t_bill_fee.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',t_bill_fee.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; end else begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+t_bill_fee.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',t_bill_fee.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; t_bill_fee.requery; if t_op_seae.Active then t_op_seae.Requery(); v_dui_bill.Requery(); end; procedure Tfrm_rp_dui_seai_pay.dxDBGrid2ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_bill_fee,'业务编号'); end; procedure Tfrm_rp_dui_seai_pay.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_ch_dui,'对帐编号'); end; procedure Tfrm_rp_dui_seai_pay.t_ch_duiAfterPost(DataSet: TDataSet); begin modify_all:=false; end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton9Click(Sender: TObject); begin if t_ch_dui.IsEmpty then exit; if t_ch_dui.fieldbyname('DM_ID').asstring='' then exit; if t_ch_dui.fieldbyname('DM_ID').asstring='0' then exit; try modify_all:=true; t_ch_dui.DisableControls; sys_print('海运进口应付对帐'+t_ch_dui.fieldbyname('DM_ID').asstring,2,t_ch_dui1,nil,nil,nil,t_bill_fee1,NIL,NIL,NIL,nil,nil,nil); finally t_ch_dui.EnableControls; modify_all:=false; end; end; procedure Tfrm_rp_dui_seai_pay.N4Click(Sender: TObject); begin grid_save_xls(dxDBGrid2); end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton10Click(Sender: TObject); begin try if not assigned(frm_rp_dui_query) then frm_rp_dui_query:=tfrm_rp_dui_query.Create (self); dui_query_num:=4; frm_rp_dui_query.showmodal; finally frm_rp_dui_query.free; frm_rp_dui_query:=nil; end; end; procedure Tfrm_rp_dui_seai_pay.t_ch_duiBeforeCancel(DataSet: TDataSet); begin modify_all:=true; end; procedure Tfrm_rp_dui_seai_pay.bsSkinButton6Click(Sender: TObject); begin if t_ch_dui.IsEmpty then exit; try modify_all:=true; t_ch_dui.DisableControls; sys_print('海运进口应付对帐',2,t_ch_dui1,nil,nil,nil,v_dui_bill1,v_dui_fee1,NIL,NIL,nil,nil,nil); finally t_ch_dui.EnableControls; modify_all:=false; end; end; procedure Tfrm_rp_dui_seai_pay.N5Click(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; begin if v_dui_bill.IsEmpty then exit; aAdoQuery:=CreateAdoQuery; with aAdoQuery do begin Close;SQL.Clear; SQL.Add('Select ch_id from t_ch_fee where 编号=:编号 and 是否对帐=1 and 对帐编号=:对帐编号'); end; if dxDBGrid6.SelectedCount>=1 then begin for i:=0 to dxDBGrid6.SelectedCount-1 do begin v_dui_bill.GotoBookmark(pointer(dxDBGrid6.selectedrows[i])); aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('编号').Value:=v_dui_bill.fieldbyname('编号').asstring; aAdoQuery.Parameters.ParamByName('对帐编号').Value:=t_ch_dui.fieldbyname('对帐编号').asstring; aAdoQuery.Open; aAdoQuery.First; while not aAdoQuery.Eof do begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+'''' +' and ch_id='+''''+aAdoQuery.fieldbyname('ch_id').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; aAdoQuery.Next; end; { str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; } str:='delete from t_ch_dui_detail' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; end else begin aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('编号').Value:=v_dui_bill.fieldbyname('编号').asstring; aAdoQuery.Parameters.ParamByName('对帐编号').Value:=t_ch_dui.fieldbyname('对帐编号').asstring; aAdoQuery.Open; aAdoQuery.First; while not aAdoQuery.Eof do begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+'''' +' and ch_id='+''''+aAdoQuery.fieldbyname('ch_id').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; aAdoQuery.Next; end; { str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; } str:='delete from t_ch_dui_detail' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; if t_op_seae.Active then t_op_seae.Requery(); v_dui_bill.Requery(); aAdoQuery.Free; end; {procedure Tfrm_rp_dui_seai_pay.N5Click(Sender: TObject); var i:integer; str:widestring; begin if v_dui_bill.IsEmpty then exit; if dxDBGrid6.SelectedCount>=1 then begin for i:=0 to dxDBGrid6.SelectedCount-1 do begin v_dui_bill.GotoBookmark(pointer(dxDBGrid6.selectedrows[i])); str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; end else begin str:='update t_ch_fee set 是否对帐=0,对帐编号=null' +' where 编号='+''''+v_dui_bill.fieldbyname('编号').asstring+'''' +' and 对帐编号='+''''+t_ch_dui.fieldbyname('对帐编号').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; if t_ch_dui_bill.Locate('编号',v_dui_bill.fieldbyname('编号').asstring,[])then t_ch_dui_bill.delete; end; t_bill_fee.requery; if t_op_seae.Active then t_op_seae.Requery(); v_dui_bill.Requery(); end; } end.