unit u_op_seae_paper_print; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, bsSkinCtrls, DB, ADODB, ExtCtrls, RxLookup, StdCtrls, wwdbdatetimepicker, wwdblook, Menus, Mask, bsSkinBoxCtrls, bsdbctrls,DateUtils, kbmMemTable, DBCtrlsEh,ShellAPI, ComCtrls, bsSkinTabs, dxDBTLCl, dxGrClms, cxDBLabel, cxControls, cxContainer, cxEdit, cxLabel, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxDBEdit, OleCtrls, iWebPDFEditorLib_TLB, cxCheckBox, cxProgressBar,IniFiles, AcroPDFLib_TLB; type Tfrm_op_seae_paper_print = class(TForm) qry_paper_detail: TADOQuery; ds2_detail: TDataSource; PopupMenu1: TPopupMenu; N1: TMenuItem; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bskntbsht2_detail: TbsSkinTabSheet; bsSkinPanel3: TbsSkinPanel; bsSkinButton4: TbsSkinButton; btn6_exit: TbsSkinButton; btn_seach2: TbsSkinButton; bsSkinButton14: TbsSkinButton; bsSkinPanel4: TbsSkinPanel; Label13: TLabel; Label14: TLabel; wwDBDateTimePicker5: TwwDBDateTimePicker; wwDBDateTimePicker6: TwwDBDateTimePicker; PopupMenu2: TPopupMenu; MenuItem1: TMenuItem; Edit6_searchtdh: TEdit; Label8: TLabel; bsknpnl1: TbsSkinPanel; bsknpnl2: TbsSkinPanel; qry1_paper_printlist: TADOQuery; Edit1_tdzbh: TEdit; lbl14: TLabel; bsknpnl4_NewQDT: TbsSkinPanel; lbl15_searchqdthm: TLabel; ds1: TDataSource; qry_crm_client: TADOQuery; ds_crm_client: TDataSource; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column1: TdxDBGridColumn; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column2: TdxDBGridColumn; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column3: TdxDBGridColumn; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column4: TdxDBGridColumn; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column5: TdxDBGridColumn; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column6: TdxDBGridColumn; grp1: TGroupBox; lbl4: TLabel; wdbdtmpckr1_kc: TwwDBDateTimePicker; lbl5: TLabel; wdbdtmpckr2_kc: TwwDBDateTimePicker; pnl1: TPanel; btn4_exit: TbsSkinButton; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column7: TdxDBGridColumn; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column8: TdxDBGridColumn; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column9: TdxDBGridColumn; dxdbgrdclmndxdbgrid1dxdbgrdclmnDBGrid1Column10: TdxDBGridColumn; dxdbgrd1_S: TdxDBGrid; dxdbgrdclmns: TdxDBGridColumn; dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column2: TdxDBGridColumn; dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column4: TdxDBGridColumn; dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column5: TdxDBGridColumn; dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column3: TdxDBGridColumn; dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column6: TdxDBGridColumn; dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column19: TdxDBGridColumn; dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column13: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn9: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn10: TdxDBGridColumn; lbl6: TLabel; cbb1_cgsh: TRxDBLookupCombo; btn4_searchNew: TbsSkinButton; lbl1: TLabel; Edit1_tdh: TEdit; lbl13: TLabel; cbb3_qdfsh: TRxDBLookupCombo; lbl2: TLabel; cbb4_dyzht: TbsSkinComboBox; dxdbgrdclmndxdbgrd1_SColumn11: TdxDBGridColumn; btn3_cancelPrint: TbsSkinButton; btn4_rescindPrint: TbsSkinButton; btn1_printbat: TbsSkinButton; dxdbgrd1_detail: TdxDBGrid; dxdbgrdclmndxdbgrd1Column11: TdxDBGridColumn; dxdbgrdclmndxdbgrd1Column12: TdxDBGridColumn; iwbpdfdtr1: TiWebPDFEditor; lbl3: TLabel; cbb1_printstate: TbsSkinComboBox; dxdbgrdchckclmndxdbgrd1Column13: TdxDBGridCheckColumn; dxdbgrdchckclmndxdbgrd1_SColumn12: TdxDBGridCheckColumn; cxchckbx1_shfhq: TcxCheckBox; dxdbgrdmclmndxdbgrdclmndxdbgrd1_detailColumn14: TdxDBGridMemoColumn; dxdbgrdmclmndxdbgrdclmndxdbgrd1_SColumn13: TdxDBGridMemoColumn; btn5_submit: TbsSkinButton; btn7Recivice: TbsSkinButton; dxdbgrdclmndxdbgrd1_SColumn14: TdxDBGridColumn; sp_sign_batin_id: TADOStoredProc; dxdbgrdclmndxdbgrd1_SColumn15: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn16: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn17: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn18: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn19: TdxDBGridColumn; ds2_print: TDataSource; bskntbsht1: TbsSkinTabSheet; bsknpnl3: TbsSkinPanel; btn6_notify_exit: TbsSkinButton; btn1_notify_search: TbsSkinButton; btn2_notify_clear: TbsSkinButton; btn1: TbsSkinButton; btn2: TbsSkinButton; bsknpnl4: TbsSkinPanel; lbl7: TLabel; lbl8: TLabel; lbl9: TLabel; lbl10: TLabel; wdbdtmpckr1: TwwDBDateTimePicker; wdbdtmpckr2: TwwDBDateTimePicker; edt1_tdh: TEdit; dxdbgrd3_notify: TdxDBGrid; dxdbgrdclmndxdbgrd3_notifyColumn15: TdxDBGridColumn; dxdbgrdclmn1: TdxDBGridColumn; dxdbgrdclmn2: TdxDBGridColumn; dxdbgrdclmn3: TdxDBGridColumn; dxdbgrdclmn4: TdxDBGridColumn; dxdbgrdclmn5: TdxDBGridColumn; dxdbgrdclmn6: TdxDBGridColumn; dxdbgrdclmn7: TdxDBGridColumn; dxdbgrdclmn8: TdxDBGridColumn; dxdbgrdclmn9: TdxDBGridColumn; dxdbgrdclmn10: TdxDBGridColumn; dxdbgrdclmn11: TdxDBGridColumn; dxdbgrdchckclmn1: TdxDBGridCheckColumn; dxdbgrdmclmn1: TdxDBGridMemoColumn; dxdbgrdclmn12: TdxDBGridColumn; qry2_paper_printlist: TADOQuery; ds2_paper_printlist: TDataSource; lbl11: TLabel; cbb2_submitstate: TbsSkinComboBox; qry1_print: TADOQuery; dxdbgrdclmndxdbgrd3_notifyColumn16: TdxDBGridColumn; dxdbgrdclmndxdbgrd3_notifyColumn17: TdxDBGridColumn; dxdbgrdclmndxdbgrd3_notifyColumn18: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn20: TdxDBGridColumn; btn3: TbsSkinButton; ds2_crm_client_paper: TDataSource; qry2_crm_client_paper: TADOQuery; lbl12: TLabel; cbb2_shipinc_paper: TRxDBLookupCombo; cxprgrsbr1: TcxProgressBar; dxdbgrdclmndxdbgrd1_SColumn21: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn22: TdxDBGridColumn; bskntbsht2: TbsSkinTabSheet; bsknpnl5: TbsSkinPanel; btn4: TbsSkinButton; btn5: TbsSkinButton; btn6: TbsSkinButton; btn7: TbsSkinButton; btn8: TbsSkinButton; dxdbgrd3_notiffyTask: TdxDBGrid; dxdbgrdclmn14: TdxDBGridColumn; dxdbgrdclmn15: TdxDBGridColumn; dxdbgrdclmn16: TdxDBGridColumn; dxdbgrdclmn17: TdxDBGridColumn; dxdbgrdclmn25: TdxDBGridColumn; dxdbgrdclmn26: TdxDBGridColumn; dxdbgrdclmn27: TdxDBGridColumn; dxdbgrdchckclmn2: TdxDBGridCheckColumn; dxdbgrdclmn28: TdxDBGridColumn; btn3_1_tasksubmit: TbsSkinButton; btn3_2printDesign: TbsSkinButton; btn1_RefreshTask: TbsSkinButton; ds3_notifytask: TDataSource; qry3_notifyTask: TADOQuery; dxdbgrdclmndxdbgrd1_SColumn23: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn24: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn26: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn27: TdxDBGridColumn; dxdbgrdclmndxdbgrd3_notifyColumn19: TdxDBGridColumn; dxdbgrdclmndxdbgrd3_notifyColumn20: TdxDBGridColumn; dxdbgrdclmndxdbgrd3_notifyColumn21: TdxDBGridColumn; dxdbgrdclmndxdbgrd1_SColumn28: TdxDBGridColumn; txtSelPages: TStaticText; procedure btn4_exitClick(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure btn3_clearConditonClick(Sender: TObject); procedure btn4_searchNewClick(Sender: TObject); procedure N1Click(Sender: TObject); procedure Edit3_ztdhKeyPress(Sender: TObject; var Key: Char); procedure dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column13CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure dxDBGrid2Column14CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure MenuItem1Click(Sender: TObject); procedure btn6_exitClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure btn11Click(Sender: TObject); procedure FormResize(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure Edit1_paperCountKeyPress(Sender: TObject; var Key: Char); procedure btn_seach2Click(Sender: TObject); procedure btn2_fxpageClick(Sender: TObject); procedure btn3_cancelPrintClick(Sender: TObject); procedure btn4_rescindPrintClick(Sender: TObject); procedure btn1_printbatClick(Sender: TObject); procedure dxdbgrd1_SColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure btn5_submitClick(Sender: TObject); procedure btn6_cancelSubmitClick(Sender: TObject); procedure btn1_notify_searchClick(Sender: TObject); procedure btn6_notify_exitClick(Sender: TObject); procedure btn2_notify_clearClick(Sender: TObject); procedure btn3Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure btn1_RefreshTaskClick(Sender: TObject); procedure btn3_2printDesignClick(Sender: TObject); procedure btn3_1_tasksubmitClick(Sender: TObject); procedure cxchckbx1_shfhqClick(Sender: TObject); procedure dxdbgrd1_SChangeNode(Sender: TObject; OldNode, Node: TdxTreeListNode); procedure dxdbgrd1_SSelectedCountChange(Sender: TObject); private { Private declarations } employeePhone:string; m_infomation:string; m_strNo_pre,m_strNo_start,m_strNo_end:string;//记录生成提单页号时的初始值 m_printTotalPages:integer; //打印总页数统计 procedure bindPaperIn(); function genPaperno():Boolean; procedure seachPrintList(); procedure ToOpenFile(strpath:string); function GetPDFPages(strpath:string):Integer; procedure DeleteChangedPrintList(); procedure DealDeletePrintFile(); function CheckBilldue():Boolean; function PrintBilldue():Boolean; function get_sign_batin_id:integer; function Checksubmit():Boolean; //提交已打印 未提交 已签回 function print_submit(bid:string):Boolean; procedure seachSubmitList(); procedure seachtaskList(); public { Public declarations } op:integer; end; var frm_op_seae_paper_print: Tfrm_op_seae_paper_print; implementation uses u_main,my_sys_function, u_sys_progress; {$R *.dfm} /// /// 临时目录 /// function GetWinTempPath: string; var TempDir: array[0..255] of char; begin GetTempPath(255, @TempDir); Result := strPas(TempDir); end; function Tfrm_op_seae_paper_print.get_sign_batin_id:integer; var str:string; aQuery:TADOQuery; begin Result:=0; aQuery:=CreateAdoQuery(); str:= 'insert into t_sys_sign_batin_id ([mainorderno]) values(''1'');'; aQuery.SQL.Add(str) ; aQuery.ExecSQL(); aQuery.sql.Clear(); str:= 'select max(signid) as sid from t_sys_sign_batin_id; '; aQuery.sql.add(str); aQuery.Open; aQuery.First; result :=aQuery.FieldByName('sid').AsInteger; end; procedure Tfrm_op_seae_paper_print.bindPaperIn(); var str:string; aQuery:TADOQuery; begin aQuery:=CreateAdoQuery(); with aQuery do begin str:= 'DECLARE @RC int ' + 'EXECUTE @RC = [p_insert_seae_paperprint_list];' ; Close; SQL.Clear; SQL.Add(str); ExecSQL(); end; end; procedure Tfrm_op_seae_paper_print.btn4_exitClick(Sender: TObject); begin Close; end; procedure Tfrm_op_seae_paper_print.FormShow(Sender: TObject); begin bsSkinPageControl1.ActivePageIndex:=0; dxdbgrd1_S.Width:=self.ClientWidth; bsknpnl1.Height :=34; self.WindowState:= wsMaximized; wwDBDateTimePicker5.Date:=Date-7; wwDBDateTimePicker6.Date:=Date; btn3_cancelPrint.Enabled:= if_open('443'); btn4_rescindPrint.Enabled:=if_open('444'); loadreggrid(dxdbgrd1_S,false,caption+'1'); loadreggrid(dxdbgrd1_detail,false,caption+'2'); loadreggrid(dxdbgrd3_notify,false,caption+'3'); qry_crm_client.Close(); qry_crm_client.Open; qry2_crm_client_paper.Active:=False; qry2_crm_client_paper.Active:=True; seachPrintList(); seachSubmitList(); end; procedure Tfrm_op_seae_paper_print.FormClose(Sender: TObject; var Action: TCloseAction); begin // pdfctvx1. FPDF_ExitAppActiveX (); savereggrid(dxdbgrd1_S,caption+'1'); savereggrid(dxdbgrd1_detail,caption+'2'); savereggrid(dxdbgrd3_notify,caption+'3'); frm_op_seae_paper_print.Hide; frm_op_seae_paper_print.ManualFloat(frm_op_seae_paper_print.BoundsRect ); frm_main.freeTabs('frm_op_seae_paper_print'); action:=cafree; frm_op_seae_paper_print:=nil; end; procedure Tfrm_op_seae_paper_print.btn3_clearConditonClick(Sender: TObject); begin //Edit1_ywbh.text:=''; //Edit2_wtbh.text:=''; end; function replaceSQuotes(txt: string):string; begin result:=stringreplace(txt,'''','''''',[rfReplaceAll]); end; procedure Tfrm_op_seae_paper_print.btn4_searchNewClick(Sender: TObject); begin // try if ((cbb4_dyzht.Text='<无>') or (cbb4_dyzht.Text='未打印') ) then begin //处理台账信息发生变化 DeleteChangedPrintList(); //处理已删除的公司挂单文件 DealDeletePrintFile(); //生成台账 bindPaperIn(); //计算页数 genPaperno(); end; //显示列表 seachPrintList(); except on ex:exception do begin errorlog(ex.Message) ; Application.MessageBox(PChar('异常提醒:'+EX.Message),'',MB_ICONWARNING); end; end; end; procedure Tfrm_op_seae_paper_print.btn1_printbatClick(Sender: TObject); begin try qry1_paper_printlist.DisableControls; qry_crm_client.DisableControls; iwbpdfdtr1.IsOpenVerify:=false; iwbpdfdtr1.VerifySigner:=False; try if CheckBilldue() then begin cxprgrsbr1.Visible:=True; cxprgrsbr1.Position:=0; //打印 PrintBilldue(); qry_crm_client.Active:=false; qry_crm_client.Active:=true; seachPrintList(); end; except ON ex:Exception do begin // errorlog(ex.Message) ; Application.MessageBox(PChar('异常提醒:'+EX.Message),'',MB_ICONWARNING); end; end; finally iwbpdfdtr1.IsOpenVerify:=true; cxprgrsbr1.Visible:=False; qry_crm_client.EnableControls; qry1_paper_printlist.EnableControls; end; end; /// /// 船公司 / 提单份数 / 签单方式/ 换签 发生变化清理 /// procedure Tfrm_op_seae_paper_print.DeleteChangedPrintList(); var str:string; begin str:='DECLARE @return_value int' +#13 +' EXEC @return_value = [dbo].[p_delete_seae_paper_printlist_onchange] ' +'SELECT ''Return Value'' = @return_value '; try frm_main.db.Execute(str); except on ex:Exception do errorlog(ex.message); end; end; /// /// 上传文件删除的进行标记 /// procedure Tfrm_op_seae_paper_print.DealDeletePrintFile(); var str:string; begin // try str:='update t_op_seae_paper_print_list set 打印状态=''文件异常'',备注=''文件已被删除''' +' where 打印状态 in (''未打印'',''取消打印'') and exists (' +'SELECT [序号]FROM [v_op_seaep_paper_print_errfile] v where v.序号=t_op_seae_paper_print_list.序号 ' +' )' ; frm_main.db.Execute(str); except on ex:Exception do begin errorlog(ex.Message) ; end; end; end; /// /// 检查一致性 /// function Tfrm_op_seae_paper_print.CheckBilldue():Boolean; var strxhs,strMainOrder,cgsh1,cgsh2,printState,strfilename,str,strInfo,strtmp,strPagechangeInfo:string; i,itmp,i_tdpages,i_fxpages,iSelcount :integer; blNeedAnalyze:Boolean; aQuery:TADOQuery; begin { //测试顺序 str:=''; for i:=0 to dxdbgrd1_S.SelectedCount-1 do begin qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i])); str:= str+#13+ qry1_paper_printlist.FieldByName('主提单号').AsString; end; ShowMessage(str); } str:=''; //1.判断船公司是否一致 //2.选择的是是否都是可以打印的提单 //3.判断文件是否存在 //4.校验打印份数是否一致:正本和副本 doing blNeedAnalyze:=False;//是否需要重新分析 Result:=true; m_printTotalPages:=0; strxhs:='-54321'; iSelcount:= dxdbgrd1_S.SelectedCount; for i:=0 to dxdbgrd1_S.SelectedCount-1 do begin qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i])); itmp:= qry1_paper_printlist.FieldByName('需要提单纸张数').AsInteger; strfilename:= qry1_paper_printlist.FieldByName('名称').AsString; strMainOrder:= qry1_paper_printlist.FieldByName('主提单号').AsString; // m_printTotalPages:=m_printTotalPages+itmp; if i=0 then begin cgsh1 := qry1_paper_printlist.FieldByName('船公司').AsString; cgsh2:=cgsh1; end else begin cgsh2 := qry1_paper_printlist.FieldByName('船公司').AsString; end; // if cgsh1<>cgsh2 then begin showmessage('船公司不唯一!'); Result:=false; Exit; end; printState:=qry1_paper_printlist.FieldByName('打印状态').AsString; if (printState<>'未打印') and (printState<>'取消打印') then begin showmessage('批量打印中必须全部是未打印(或取消打印)的提单!'); Result:=false; Exit; end; //校验文件页数是否发生编号 if(blNeedAnalyze=false) then begin i_tdpages:= qry1_paper_printlist.FieldByName('提单页数').AsInteger; i_fxpages:= GetPDFPages(strfilename); if(i_tdpages<>i_fxpages) then begin blNeedAnalyze:=true; strPagechangeInfo:='提单[' +strmainorder+']的提单页数已经发生变化:' +inttostr(i_tdpages)+'>>' + IntToStr(i_fxpages) +',需要重新分析!' ; end; end; strtmp:= qry1_paper_printlist.FieldByName('序号').AsString; if(not FileExists(strfilename)) then begin Result:=false; strInfo:='提单['+ strMainOrder +']的船公司挂单文件'+strfilename +'已不存在或者暂时不可访问!不能打印!' +#13+'是否标记该台账"文件异常"?' + #13 +'标记文件提单异常后,当前提单记录将不能打印!' +'如需打印请删除原来的记录,重新用不同的文件名上传后再进行打印'; IF Application.MessageBox(PChar(strInfo),'信息提示',MB_ICONQUESTION+MB_YESNO)=ID_YES then begin str:='update t_op_seae_paper_print_list set 打印状态=''文件异常'',备注=''文件不存在或者不可访问'' ' +'where 序号= ' + strtmp +';' ; frm_main.db.Execute(str); seachPrintList(); END; Result:=false; Exit; end; strxhs:= strxhs+',' +strtmp; end; //页数变化提醒 if ( blNeedAnalyze) then begin // strPagechangeInfo Result:=false; Application.MessageBox(PChar(strPagechangeInfo),'信息提示',MB_ICONINFORMATION+MB_OK); str:='update t_op_seae_paper_print_list set [是否已分析]=0 where 序号 in ('+ strxhs + ' ); ' ; frm_main.db.Execute(str); genPaperno(); seachPrintList(); Exit; end; //提单号已打印提醒 str:='select 序号,编号,主提单号,打印日期 from t_op_seae_paper_print_list p where p.打印状态=''已打印'' ' +' and 主提单号 in ( select 主提单号 from t_op_seae_paper_print_list p0 where 序号 in ('+ strxhs + ') ) ' ; aQuery:=CreateAdoQuery(); aQuery.Close; aQuery.SQL.Clear; aQuery.SQL.Add(str); aQuery.Open; if not aQuery.IsEmpty then begin strInfo:=''; aQuery.First; while not aQuery.Eof do begin strInfo := strInfo+ '提单号:'+ aQuery.fieldbyname('主提单号').AsString +',打印日期:' + aQuery.fieldbyname('打印日期').AsString +#13; aQuery.Next; end; if( iSelcount>1) then begin result:=false; strInfo:= '批量打印中含有已打印的提单,请确认后再进行批量打印:'+#13#10 + strinfo; Application.MessageBox(PChar(strInfo),'信息提示',MB_ICONINFORMATION); end else begin strInfo:= '选择提单号已打印,您确实要打印该提单吗:'+#13#10 + strinfo; IF Application.MessageBox(PChar(strInfo),'信息提示',MB_ICONQUESTION+MB_YESNO) <>ID_YES then begin Result:=false; END; end; end; exit; //sql strtmp:='select * from ' +'( SELECT [序号],p.[编号],p.[主提单号],p.[船公司]' +' ,p.[签单方式],p.[份数],p.[提单份数],p.[副本提单份数],p.[名称],' +' case when p.[船公司]=sea.[船公司] then 0 else 1 end as 船公司err,' +' case p.提单份数-' +' case sea.[提单份数] when ''ONE'' then 1 when ''TWO'' then 2 when ''THREE'' then 3' +' when ''FOUR'' then 4 when ''FIVE'' then 5 when ''SIX'' then 6 when ''SEVEN'' then 7' +' when ''EIGHT'' then 8 when ''NINE'' then 9 when ''TEN'' then 10 else 0 end ' +' when 0 then 0 else 1 end as [提单份数err] ,' +' case p.[副本提单份数]-' +' case sea.[副本提单份数] when ''ONE'' then 1 when ''TWO'' then 2 when ''THREE'' then 3' +' when ''FOUR'' then 4 when ''FIVE'' then 5 when ''SIX'' then 6 when ''SEVEN'' then 7' +' when ''EIGHT'' then 8 when ''NINE'' then 9 when ''TEN'' then 10 else 0 end' +' when 0 then 0 else 1 end as [副本提单份数err] , ' +' case when isnull(p.[是否换签],0)=isnull(sea.[是否换签],0) then 0 else 1 end as 是否换签err ,' +' case when p.签单方式=sea.签单方式 then 0 else 1 end as 签单方式err' +' FROM ( select * from [t_op_seae_paper_print_list] where 序号 in('+ strxhs +') ) ' +' left join t_op_seae sea on p.编号=sea.编号' +' ) v where (v.副本提单份数err+v.提单份数err+v.是否换签err+v.签单方式err+v.船公司err)>0' +'' +'' +''; aQuery:=CreateAdoQuery(); with aQuery do begin Close(); SQL.Clear; SQL.Add(strtmp); Open; First; if (not IsEmpty) then begin strInfo:=''; while not Eof do begin // //strInfo:= strInfo+'提单号为[' +fieldbyname('主提单号')+ end; end; end; end; //end CheckBilldue /// /// 批量打印 /// function Tfrm_op_seae_paper_print.PrintBilldue():boolean; var str,cgsh1,cgsh2,strtmp,strtdbh,strdyxh,strtdh2,strinoTmp:string; ipages,itmp,i,j,im,icount:Integer; m_infomation,strfile,printState,strerr,xhs:string; aQuery,aQueryUpdate:TADOQuery; lcfile:string; // inifile1:Tinifile; inifile_name:string; rederpath: string; hasreader:Boolean; paperStartNo:string; //提单:提单纸开始号码 paperEndNo:string;// 提单:提单纸结束号码 begin strinoTmp:='';//debug aQuery:=CreateAdoQuery(); aQueryUpdate:=CreateAdoQuery(); m_infomation:=''; ipages:=0; itmp:=0; strinoTmp:=''; icount:= dxdbgrd1_S.SelectedCount; // inifile_name:=ExtractFilePath(application.ExeName)+'pdfread.ini'; hasreader:=false; if(FileExists(inifile_name ) ) then begin inifile1:=Tinifile.Create(inifile_name); rederpath:= inifile1.ReadString('pdf','pdfreaderpath',''); if( FileExists(PChar(rederpath)) ) then hasreader:=True else begin ShowMessage('请配置"'+inifile_name+'"文件中的foxit read 路径!'); Exit; end; end; for i:=0 to dxdbgrd1_S.SelectedCount-1 do begin qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i])); itmp:= qry1_paper_printlist.FieldByName('需要提单纸张数').AsInteger; //1 记录明细 strtdbh :=qry1_paper_printlist.FieldByName('编号').AsString; strtdh2 := qry1_paper_printlist.FieldByName('主提单号').AsString; strfile:= qry1_paper_printlist.fieldbyname('名称').AsString; //strinoTmp:=strinoTmp+':'+ strtdh2+':'+ strtdbh +':'+ strfile +#13#10; // ipages:=ipages+itmp; if i=0 then begin cgsh1 := qry1_paper_printlist.FieldByName('船公司').AsString; cgsh2:=cgsh1; end else begin cgsh2 := qry1_paper_printlist.FieldByName('船公司').AsString; end; // if cgsh1<>cgsh2 then begin showmessage('船公司不唯一!'); Exit; end; printState:=qry1_paper_printlist.FieldByName('打印状态').AsString; if (printState<>'未打印') and (printState<>'取消打印') and (printState<>'已作废') then begin showmessage('批量打印中必须全部是未打印提单!'); Exit; end; //qry1_paper_printlist.Next; end; //判断纸张数量 ,用locate if( qry_crm_client.Locate('船公司简称',cgsh1,[loCaseInsensitive])) then strtmp:= qry_crm_client.FieldByName('船公司简称').AsString else with qry_crm_client DO begin First; While Not EOF Do {对表中全部记录进行其他处理} begin strtmp:= FieldByName('船公司简称').AsString; if(strtmp=cgsh1) then begin break; end; Next; end; // ShowMessage(strinoTmp); // end; if(strtmp<>cgsh1) then begin Application.MessageBox( PChar('只能选择一家公司的的提单!'),'信息提示',MB_ICONINFORMATION) ; Exit; end; itmp:= qry_crm_client.fieldbyname('提单纸剩余数量').AsInteger; if(itmp ID_YES) then Exit; //msk end; //BBBBBBBBBBBBBBB aQuery.Close; aQuery.SQL.Clear; if(qry_crm_client.fieldbyname('纸张使用是否降序').AsBoolean) then str:='SELECT TOP ' + IntToStr(ipages) + ' * FROM [t_op_seae_paper_detail] ' +' where 船公司简称=''' +cgsh1+ ''' and 使用状态 is null order by 入库序号 , 提单纸号 desc ' else str:='SELECT TOP ' + IntToStr(ipages) + ' * FROM [t_op_seae_paper_detail] ' +' where 船公司简称=''' +cgsh1+ ''' and 使用状态 is null order by 入库序号 , 提单纸号 '; aQuery.SQL.Add(str); aQuery.Open; aQuery.First; strinoTmp:=''; xhs:='-1234'; for i:=0 to dxdbgrd1_S.SelectedCount-1 do //提单循环 begin //for begin // 改变状态更新库存 qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i])); itmp:= qry1_paper_printlist.FieldByName('需要提单纸张数').AsInteger; xhs:=xhs+','+ qry1_paper_printlist.fieldbyname('序号').AsString; //1 记录明细 strdyxh:=qry1_paper_printlist.FieldByName('序号').AsString; strtdbh :=qry1_paper_printlist.FieldByName('编号').AsString; strtdh2 := qry1_paper_printlist.FieldByName('主提单号').AsString; strfile:= qry1_paper_printlist.fieldbyname('名称').AsString; // strinoTmp:=strinoTmp+':'+ strtdh2+':'+ strtdbh +':'+ strfile +#13#10; if(itmp<1) then begin // Continue; end; try frm_main.db.BeginTrans; for j:=1 to itmp do begin aQuery.Edit;//编辑明细 if(j=1) then begin paperStartNo:=aQuery.fieldbyname('提单纸号').AsString; paperEndNo:= aQuery.fieldbyname('提单纸号').AsString; end else paperEndNo:= aQuery.fieldbyname('提单纸号').AsString; aQuery.fieldbyname('提单编号').AsString :=strtdbh; aQuery.fieldbyname('提单号').AsString := strtdh2; aQuery.fieldbyname('页号').asinteger :=j; aQuery.fieldbyname('总页数').asinteger := itmp; aQuery.fieldbyname('使用状态').AsString :='已打印'; aQuery.fieldbyname('操作人').AsString := employee; aQuery.fieldbyname('操作时间').AsDateTime :=GetDbDatetime; aQuery.fieldbyname('打印台账序号').asinteger :=qry1_paper_printlist.FieldByName('序号').asinteger; aQuery.next ; end; //3b修改总数 //2.改变状态 str:='update t_op_seae_paper_print_list set ' +' 打印状态=''已打印'',打印人='''+employee + ''',打印日期='''+ FormatDateTime('yyyy-mm-dd hh:mm:ss',GetDbDatetime) +''' ,提单纸开始号='''+paperstartno + ''',提单纸结束号='''+paperendno+''' ' +'where 序号 =' +strdyxh+' '; aQueryUpdate.Close; aQueryUpdate.SQL.Clear; aQueryUpdate.SQL.Add(str); aQueryUpdate.ExecSQL; aQueryUpdate.Close; aQueryUpdate.SQL.Clear; aQueryUpdate.SQL.Add('UPDATE [t_op_seae_paper_shipinc] ' + ' SET [提单纸剩余数量] = 提单纸剩余数量- '+inttostr(itmp ) + ' WHERE [船公司简称] = ''' + cgsh1 +''''); aQueryUpdate.ExecSQL; frm_main.db.CommitTrans; except on ex:Exception do begin frm_main.db.RollbackTrans; m_infomation:='打印提单发生异常:'+ex.Message +'!'; Application.MessageBox(PChar(m_infomation),'信息提示',MB_ICONINFORMATION); end; end;//edn try // /.按份打印 try for im:=1 to qry1_paper_printlist.fieldbyname('份数').asinteger do begin lcfile:= GetWinTempPath()+ trim(strdyxh) + '.PDF'; CopyFile(pChar(strfile),pChar(lcfile),false); // ShowMessage(lcfile); { AcroPDF1.src:=strfile; AcroPDF1.LoadFile(strfile); AcroPDF1.Print; } // lcfile:=strfile; if(hasreader) then ShellExecute(Self.Handle,'open',PChar( rederpath) ,PChar(' -p '+lcfile ) , nil, SW_HIDE) else ShellExecute(Self.Handle,'print',PChar(lcfile),nil, nil, SW_HIDE) ; sleep(2000); end; except on ex:Exception do begin errorlog(ex.Message) ; m_infomation:='打印提单发生异常:'+ex.Message +'!'; Application.MessageBox(PChar(m_infomation),'信息提示',MB_ICONINFORMATION); Break; end; end; cxprgrsbr1.Position:= Round(100*((i+1)/icount) ) ; cxprgrsbr1.Refresh; sleep(2000); //EEEEEEEEEEEEEEEEEEE end; //for end qry_crm_client.close(); qry_crm_client.open; exit; //提单纸有编号的处理 end ; //其他船公司 没有纸张编号的的 m_infomation:='请将'+ IntToStr(ipages)+'张空白'+cgsh1 +'提单纸放入打印机,是否现在进行打印?'; if(Application.MessageBox(PChar(m_infomation),'信息提示',MB_ICONQUESTION+MB_YESNO) <> ID_YES) then Exit; //BBBBBBBBBBBBBBB 222222 for i:=0 to dxdbgrd1_S.SelectedCount-1 do //提单循环 begin xhs:=xhs+','+ qry1_paper_printlist.fieldbyname('序号').AsString; qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i])); itmp:= qry1_paper_printlist.FieldByName('需要提单纸张数').AsInteger; xhs:=xhs+','+ qry1_paper_printlist.fieldbyname('序号').AsString; //1 记录无 //aQuery.post; //2.改变状态 strdyxh:=qry1_paper_printlist.FieldByName('序号').AsString; strtdbh:=qry1_paper_printlist.fieldbyname('编号').AsString; strfile:= qry1_paper_printlist.fieldbyname('名称').AsString; lcfile:= GetWinTempPath()+trim(strtdbh)+'_'+ IntToStr(Random(20))+ '.PDF'; CopyFile(pChar(strfile),pChar(lcfile),false); // lcfile:=strfile; ///////////////////////////// strtdbh :=qry1_paper_printlist.FieldByName('编号').AsString; strtdh2 := qry1_paper_printlist.FieldByName('主提单号').AsString; strfile:= qry1_paper_printlist.fieldbyname('名称').AsString; // strinoTmp:=strinoTmp+':'+ strtdh2+':'+ strtdbh +':'+ strfile +#13#10; // /.按份打印 if(itmp<1 ) then begin // Continue; end; try // 改变状态更新库存 frm_main.db.BeginTrans; xhs:='-1234'; //2.改变状态 str:='update t_op_seae_paper_print_list set ' +' 打印状态=''已打印'',打印人='''+employee + ''',打印日期='''+ FormatDateTime('yyyy-mm-dd hh:mm:ss',GetDbDatetime) +''' where 序号 = ' +strdyxh+' '; aQueryUpdate.Close; aQueryUpdate.SQL.Clear; aQueryUpdate.SQL.Add(str); aQueryUpdate.ExecSQL; //3b修改总数 aQuery.Close; aQuery.SQL.Clear; aQuery.SQL.Add('UPDATE [t_op_seae_paper_shipinc] ' + ' SET [提单纸剩余数量] = 提单纸剩余数量- '+inttostr(itmp ) + ' WHERE [船公司简称] = ''' + cgsh1 +''''); aQuery.ExecSQL; frm_main.db.CommitTrans; except on ex:Exception do begin m_infomation:='打印提单发生异常:'+ex.Message +'!'; Application.MessageBox(PChar(m_infomation),'信息提示',MB_ICONINFORMATION); frm_main.db.RollbackTrans; end; end;//edn try // ShowMessage(lcfile); for im:=1 to qry1_paper_printlist.fieldbyname('份数').asinteger do begin try { AcroPDF1.src:=lcfile; AcroPDF1.LoadFile(lcfile); AcroPDF1.Print; } if(hasreader) then ShellExecute(Self.Handle,'open',PChar( rederpath) ,PChar(' -p '+lcfile ) , nil, SW_HIDE) else ShellExecute(Self.Handle,'print',PChar(lcfile),nil, nil, SW_HIDE); Sleep(2000); except on ex: Exception do begin m_infomation:='打印提单发生异常:'+ex.Message +'!'; Application.MessageBox(PChar(m_infomation),'信息提示',MB_ICONINFORMATION); break; end; end; cxprgrsbr1.Position:= Round(100*((i+1)/icount) ) ; cxprgrsbr1.Refresh; Sleep(3000); end; //EEEEEEEEEEEEEEEEEEE 2222 end; qry_crm_client.close(); qry_crm_client.open; end; procedure Tfrm_op_seae_paper_print.N1Click(Sender: TObject); begin if(bsSkinPageControl1.ActivePage=bsSkinTabSheet1 ) then //bsSkinTabSheet1 0 dxdbgrd1_S grid_save_xls(dxdbgrd1_S) else if (bsSkinPageControl1.ActivePage=bskntbsht2_detail ) then //bskntbsht2_detail 1 dxdbgrd1_detail grid_save_xls(dxdbgrd1_detail) else if(bsSkinPageControl1.ActivePage=bskntbsht1 ) then // bskntbsht1 3 dxdbgrd3_notify grid_save_xls(dxdbgrd3_notify) ; end; procedure Tfrm_op_seae_paper_print.Edit3_ztdhKeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; //bsSkinButton8Click(Sender); end; end; procedure Tfrm_op_seae_paper_print.dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column13CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin { if Trim(ANode.Strings[dxDBGrid2Column13.Index])<>'' then AColor:=clred; AFont.Color:=clblack; } end; procedure Tfrm_op_seae_paper_print.dxDBGrid2Column14CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin {if Trim(ANode.Strings[dxDBGrid2Column14.Index])<>'' then AColor:=clred; AFont.Color:=clblack; } end; procedure Tfrm_op_seae_paper_print.MenuItem1Click(Sender: TObject); begin if(bsSkinPageControl1.ActivePage=bsSkinTabSheet1 ) then //bsSkinTabSheet1 0 dxdbgrd1_S grid_save_xls(dxdbgrd1_S) else if (bsSkinPageControl1.ActivePage=bskntbsht2_detail ) then //bskntbsht2_detail 1 dxdbgrd1_detail grid_save_xls(dxdbgrd1_detail) else if(bsSkinPageControl1.ActivePage=bskntbsht1 ) then // bskntbsht1 3 dxdbgrd3_notify grid_save_xls(dxdbgrd3_notify) ; end; procedure Tfrm_op_seae_paper_print.btn6_exitClick(Sender: TObject); begin Close; end; procedure Tfrm_op_seae_paper_print.btn11Click(Sender: TObject); begin bsSkinPageControl1.Pages[0].Visible:=true; bsSkinPageControl1.Pages[1].Visible:=true; bsSkinPageControl1.ActivePageIndex:=0; end; procedure Tfrm_op_seae_paper_print.FormResize(Sender: TObject); begin // bsSkinTabSheet1.Width:=self.ClientWidth; end; procedure Tfrm_op_seae_paper_print.bsSkinButton14Click(Sender: TObject); begin Edit1_tdzbh.Text:=''; Edit6_searchtdh.Text:=''; wwDBDateTimePicker5.text:=''; wwDBDateTimePicker6.text:=''; cbb1_printstate.ItemIndex:=2; end; procedure Tfrm_op_seae_paper_print.Edit1_paperCountKeyPress(Sender: TObject; var Key: Char); begin // 回车自动查询 if key=#13 then begin btn4_searchNewClick(btn4_searchNew); end; end; procedure Tfrm_op_seae_paper_print.btn_seach2Click(Sender: TObject); var str,strChgs,strtmp,strorder:string; begin str:=''; strChgs:= cbb2_shipinc_paper.DisplayValues[1] ; if(strChgs='') then begin Application.MessageBox('请选择船公司','信息提醒',MB_ICONINFORMATION); exit; end; str:=' AND d.船公司简称= ''' +strChgs +''' '; strtmp:= StringReplace(trim(Edit1_tdzbh.text),'''','',[rfReplaceAll]); if Edit1_tdzbh.text<>'' then str:= str + ' AND d.提单纸号 like ''%' +strtmp +'%'''; strtmp:= StringReplace(trim(Edit6_searchtdh.text),'''','',[rfReplaceAll]); if strtmp<>'' then str:= str + ' AND d.提单号 like ''%' +strtmp +'%'''; //if( cbb1_printstate.ItemIndex >1) then begin if(wwDBDateTimePicker5.Text<>'') then str:= str + ' AND d.操作时间>=''' + Trim(wwDBDateTimePicker5.Text) + ''' '; // if(wwDBDateTimePicker6.Text<>'') then str:= str + ' AND d.操作时间<=''' + Trim(wwDBDateTimePicker6.Text) + ' 23:59:59'' '; end; if cbb1_printstate.ItemIndex>0 then //0 为<无> str:=str + ' AND isnull(d.[使用状态],''未打印'')='''+cbb1_printstate.Text+''' ' ; // strorder :=' order by 入库序号,提单纸号'; if(qry2_crm_client_paper.FieldByName('纸张使用是否降序').AsBoolean) then strorder:= strorder + ' desc'; str:=str+strorder; str:='SELECT d.[序号],d.[入库序号],d.[船公司简称],d.[提单纸号],d.[提单编号],' +'d.[提单号],d.[页号],d.[总页数],isnull(d.[使用状态],''未打印'') as [使用状态]' +',d.[操作人],d.[操作时间],d.[备注],d.[是否作废],d.[打印台账序号] ' +',m.录入人 as 入库人,m.录入日期 as 入库日期 FROM ' +' [t_op_seae_paper_detail] d,t_op_seae_paper_in m where d.入库序号=m.序号 ' + str; with qry_paper_detail do begin Close; SQL.Clear; SQL.Add(str); Open; end; end; procedure Tfrm_op_seae_paper_print.seachPrintList(); var str:string; begin // str:=''; if(Edit1_tdh.Text<>'') then str:= str + ' AND plst.主提单号 like ''%' + StringReplace( Trim(Edit1_tdh.Text),'''','''''',[rfReplaceAll]) + '%'' '; if(cbb1_cgsh.DisplayValues[1]<>'') then str:= str + ' AND plst.船公司 =''' + Trim(cbb1_cgsh.DisplayValues[1]) + ''' '; if(cbb3_qdfsh.DisplayValues[1]<>'') then str:= str + ' AND plst.签单方式 =''' + Trim(cbb3_qdfsh.DisplayValues[1]) + ''' '; if(cbb4_dyzht.Text<>'<无>') then str:= str + ' AND plst.打印状态 =''' + Trim(cbb4_dyzht.Text) + ''' '; if(cbb4_dyzht.ItemIndex<> 1) then begin if(wdbdtmpckr1_kc.Text<>'') then str:= str + ' AND plst.打印日期>=''' + Trim(wdbdtmpckr1_kc.Text) + ''' '; // if(wdbdtmpckr2_kc.Text<>'') then str:= str + ' AND plst.打印日期<=''' + Trim(wdbdtmpckr2_kc.Text) + ' 23:59:59'' '; end; if(cxchckbx1_shfhq.State=cbsChecked) then str:= str + ' AND isnull(plst.[是否换签],''false'')=1 ' else if(cxchckbx1_shfhq.State=cbsUnchecked) then str:= str + ' AND isnull(plst.[是否换签],''false'')=0 ' ; // 提单纸前缀号 2017-09-26 str:=' SELECT plst.*,dbo.[fn_GetPaperPreNo](plst.编号,plst.打印状态) as 提单纸前缀号 , cast(plst.提单份数 as varchar)+''正''+ CAST( plst.副本提单份数 as varchar) +''副'' as 签单要求,sea.委托单位 ,sea.操作员,sea.船名,sea.航次 ' + ' from ( SELECT p.序号,p.编号,p.主提单号,p.船公司,p.签单方式,' +' case when 船公司 in(''MAERSK'',''日本邮船'',''MCC'',''SAFMARINE'',''HAPAG'') then 1 else p.提单份数 end as 份数,p.提单份数' +' ,p.副本提单份数,p.文件类型,p.名称,p.类型,p.提单页数' + ' , p.提单页数 * case when 船公司 in( ''MAERSK'',''日本邮船'',''MCC'',''SAFMARINE'',''HAPAG'')then 1 else p.提单份数 end as 需要提单纸张数' +' ,p.是否已分析,p.打印状态,p.打印人,p.打印日期,p.备注,p.是否换签,p.是否提交,p.提交编号 ' + ' ,p.提交状态,p.提交人,p.提交日期,p.是否签入,p.签入人,p.签入日期,p.驳回人,p.驳回日期 ' + ' ,s.业务状态 as 签回状态,p.提单纸开始号,p.提单纸结束号 FROM [t_op_seae_paper_print_list] p left join ' + ' (select 编号,业务状态,录入日期 as 签回日期 from t_op_state where 业务状态=''提单签回'') s ' +' on p.编号=s.编号 ) plst,t_op_seae sea ' + ' where plst.编号=sea.编号 and plst.提交状态 in(''未提交'',''已驳回'')' + str +' order by 序号 '; with qry1_paper_printlist do begin // Close; SQL.Clear; SQL.Add(str) ; Open; end; dxdbgrd1_S.Refresh; end; function Tfrm_op_seae_paper_print.genPaperno():Boolean; var ipages :integer; info,str,strppath :string; aQuery:TAdoQuery; begin aQuery:=CreateAdoQuery(); try iwbpdfdtr1.IsOpenVerify:=False; iwbpdfdtr1.VerifySigner:=False; str:=' select 序号,编号,主提单号,船公司,份数,名称,类型,提单页数,提单份数,' +' 需要提单纸张数,是否已分析 from t_op_seae_paper_print_list plst where plst.是否已分析=0'; with aQuery do begin // Close; SQL.Clear; SQL.Add(str) ; Open; first; if(not Eof) then begin while not Eof do begin strppath:=fieldbyname('名称').AsString; ipages:= GetPDFPages(strppath); if(ipages>-1) then begin Edit; FieldByName('提单页数').asinteger:=ipages; if ipages<=0 then ipages:=0; if(fieldbyname('船公司').AsString='MAERSK') or (fieldbyname('船公司').AsString='日本邮船') or (fieldbyname('船公司').AsString='MCC') or (fieldbyname('船公司').AsString='SAFMARINE' ) //2018-7-30增加HAPAG公司 or (fieldbyname('船公司').AsString='HAPAG') then FieldByName('需要提单纸张数').asinteger:=ipages else begin // 如果是HAPAG船公司,只打印pdf有多少页打印多少页,其他按照以前来正本数*页数 2018-7-31 if(fieldbyname('船公司').AsString='MAERSK') or (fieldbyname('船公司').AsString='日本邮船') or (fieldbyname('船公司').AsString='MCC') or (fieldbyname('船公司').AsString='SAFMARINE' ) then FieldByName('需要提单纸张数').asinteger:=ipages*FieldByName('提单份数').asinteger; if (fieldbyname('船公司').AsString='HAPAG') then FieldByName('需要提单纸张数').asinteger:=ipages; end; FieldByName('是否已分析').AsBoolean:=true; end else showmessage(fieldbyname('主提单号').AsString +'提单获取页数失败!'); Next; end; if State in [dsedit,dsinsert] then Post; end; end; finally ///frm_u_op_seae_paper_getpages.Close; //FreeAndNil(frm_u_op_seae_paper_getpages); iwbpdfdtr1.IsOpenVerify:=False; freeandnil(aQuery); end; end; procedure Tfrm_op_seae_paper_print.ToOpenFile(strpath:string); var lcfile:string; begin lcfile:= GetWinTempPath()+ ExtractFileName(strpath); if(FileExists(lcfile)) then DeleteFile(lcfile); CopyFile(pChar(strpath),pChar(lcfile),false); iwbpdfdtr1.LoadFromFile(lcfile); end; function Tfrm_op_seae_paper_print.GetPDFPages(strpath:string):Integer; begin Result:=- 1 ; try if(FileExists(strpath) ) then begin ToOpenFile(strpath); Result:= iwbpdfdtr1.PageCount; iwbpdfdtr1.CloseRead; //pdfctvx1.FPDF_CloseFile (); if(Result<=0) then showmessage(strpath+'获取页数失败!'); end else showmessage(strpath+'不存在或者不可访问!'); except end; end; procedure Tfrm_op_seae_paper_print.btn2_fxpageClick(Sender: TObject); begin // try bindPaperIn(); genPaperno(); seachPrintList(); ShowMessage('分析完成!'); except on ex:exception do begin Application.MessageBox(PChar('分析PDF页码失败:'+EX.Message),'',MB_ICONWARNING); end; end; end; procedure Tfrm_op_seae_paper_print.btn3_cancelPrintClick(Sender: TObject); var str,cgsh1,cgsh2,strtmp:string; ipages,itmp,j:Integer; m_infomation,printState:string; aQuery:TADOQuery; //blbh:Boolean; begin // m_infomation:=''; ipages:=0; itmp:=0; if( dxdbgrd1_S.SelectedCount>1) then begin Application.MessageBox(PChar('不能多选,请选择一个已打印的提单'),'信息提示',MB_ICONWARNING); exit; end; printState:=qry1_paper_printlist.FieldByName('打印状态').AsString; if printState<>'已打印' then begin showmessage('必须是已打印提单才能取消!'); Exit; end; if qry1_paper_printlist.FieldByName('签回状态').AsString='提单签回' then begin showmessage('已签回的提单不能取消!'); Exit; end; m_infomation:='您要取消提单号为' +qry1_paper_printlist.FieldByName('主提单号').AsString + '的提单的打印状态吗? 取消打印,打印纸将会回收重新使用,将要回收提单纸' + inttostr(qry1_paper_printlist.FieldByName('需要提单纸张数').AsInteger) +'张,你确实要取消打印吗?'; if(Application.MessageBox(pchar(m_infomation),'信息提示', MB_ICONQUESTION+MB_YESNO) <> ID_YES) then Exit; // 打印台账序号 try //单选 qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[0])); itmp:= qry1_paper_printlist.FieldByName('序号').AsInteger; aQuery:=CreateAdoQuery(); frm_main.db.BeginTrans; with aQuery do begin close; sql.clear; SQL.Add('UPDATE [t_op_seae_paper_shipinc] ' + 'SET [提单纸剩余数量]= [提单纸剩余数量] + v.需要提单纸张数 ' + 'from ( SELECT [船公司] ,[需要提单纸张数],序号 FROM [t_op_seae_paper_print_list] ' +'where [打印状态]=''已打印'' and 序号='+ IntToStr(itmp) + ') v where [t_op_seae_paper_shipinc].船公司简称=v.船公司;' ) ; SQL.Add('UPDATE [t_op_seae_paper_detail] ' + 'SET [提单编号] = null,[提单号] = null,[页号] =0,[总页数] = 0,[使用状态] = null ' +' ,[操作人] = null ,[操作时间] = null,[备注] =null,[打印台账序号] = null ' +' where [打印台账序号]='+ IntToStr(itmp) + ' ; ' ) ; SQL.Add('UPDATE [t_op_seae_paper_print_list] ' + ' SET [打印状态] = ''取消打印'' ,[备注] = ''' +employee +':'+FormatDateTime('yyyy-mm-dd hh:mm:ss',GetDbDatetime) +''' WHERE [序号]=' + IntToStr(itmp) ); ExecSQL(); end; frm_main.db.CommitTrans; bindPaperIn(); seachPrintList(); except on ex:Exception do begin frm_main.db.RollbackTrans; errorlog(ex.Message) ; ShowMessage(ex.Message); end; end; end; procedure Tfrm_op_seae_paper_print.btn4_rescindPrintClick(Sender: TObject); var str,cgsh1 :string; ipages,itmp:Integer; m_infomation ,printState :string; aQuery:TADOQuery; reasons:string; blshfzftz:string;// 作废无效台账 begin // m_infomation:=''; ipages:=0; itmp:=0; if( dxdbgrd1_S.SelectedCount>1) then begin Application.MessageBox(PChar('不能多选,请选择一个已打印的提单'),'信息提示',MB_ICONWARNING); exit; end; printState:=qry1_paper_printlist.FieldByName('打印状态').AsString; if printState<>'已打印' then begin showmessage('必须是已打印提单才能作废!'); Exit; end; m_infomation:='您要对提单号为' +qry1_paper_printlist.FieldByName('主提单号').AsString + '的提单的变更为作废状态吗? 作废打印时打印纸不回收,要作废' +#13#10 + inttostr(qry1_paper_printlist.FieldByName('需要提单纸张数').AsInteger) +'张,你确实要作废打印吗?'; if(Application.MessageBox(pchar(m_infomation),'信息提示', MB_ICONQUESTION+MB_YESNO) <> ID_YES) then Exit; reasons:=trim(InputBox('作废打印原因', '原因', '')); if reasons=''then begin showmessage('原因不能为空!!'); reasons:=trim(InputBox('作废打印原因', '原因', '')); end; if reasons='' then exit; //作废无效台账:作废后不再生成新的打印任务 m_infomation:='是否同时作废此票打印台账?'; blshfzftz:='0'; if(Application.MessageBox(pchar(m_infomation),'信息提示', MB_ICONQUESTION+MB_YESNO) <> ID_NO) then blshfzftz:='1'; try //单选 qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[0])); itmp:= qry1_paper_printlist.FieldByName('序号').AsInteger; aQuery:=CreateAdoQuery(); frm_main.db.BeginTrans; with aQuery do begin close; sql.clear; SQL.Add('UPDATE [t_op_seae_paper_detail] ' + 'SET 使用状态 = ''已作废'' ' +' ,[备注] =''打印作废:' + employee +':'+FormatDateTime('yyyy-mm-dd hh:mm:ss',GetDbDatetime) +''',[打印台账序号] = null ' +' where [打印台账序号]='+ IntToStr(itmp) + ' ; ' ); SQL.Add('UPDATE [t_op_seae_paper_print_list] ' + ' SET [打印状态] = ''已作废'' ,作废无效台账='+ blshfzftz + ',[备注] = ''' + stringreplace(reasons,'''','''''',[rfReplaceAll]) +employee +':'+FormatDateTime('yyyy-mm-dd hh:mm:ss',GetDbDatetime) +''' WHERE [序号]=' + IntToStr(itmp) ); ExecSQL(); end; frm_main.db.CommitTrans; bindPaperIn(); seachPrintList(); except frm_main.db.RollbackTrans; end; // end; procedure Tfrm_op_seae_paper_print.dxdbgrd1_SColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,qry1_paper_printlist,'序号'); end; procedure Tfrm_op_seae_paper_print.btn5_submitClick(Sender: TObject); var str,xhs:string; bid,i:Integer; aQuery:TADOQuery; begin if(not Checksubmit) then exit; // 获取提交的批ID bid:=get_sign_batin_id(); xhs:='-234'; aQuery:=CreateAdoQuery; try frm_main.db.BeginTrans; for i:=0 to dxdbgrd1_S.SelectedCount-1 do begin qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i])); xhs:=xhs+','+ qry1_paper_printlist.fieldbyname('序号').AsString; end; str:='update t_op_seae_paper_print_list set 是否提交=1 ' +', 提交编号=' +inttostr(bid)+',提交状态=''已提交'',提交人='''+employee + ''',提交日期= GETDATE() where 序号 in(' +xhs+');'; frm_main.db.Execute(str); //通知财务签入 str:='INSERT INTO [dbo].[t_op_state]([编号],[业务状态],[录入人] ,[录入日期] ) ' +' select 编号 ,''通知签入'' as 业务状态,'''+ employee +''' as 录入人 ,GETDATE() 录入日期 from ' +' (select 编号 from t_op_seae_paper_print_list d where 序号 in (' +xhs+')' +' and not exists (select 编号 from [t_op_state] where 业务状态=''通知签入'' and 编号= d.编号)) v;'; frm_main.db.Execute(str); frm_main.db.CommitTrans; print_submit(IntToStr(bid)); seachPrintList(); btn1_notify_searchClick(btn1_notify_search); except on ex: Exception do begin qry1_paper_printlist.Cancel; frm_main.db.RollbackTrans; Application.messagebox(pchar('提交发生异常:'+ex.Message),'信息提醒',MB_ICONWARNING ); end; end; end; function Tfrm_op_seae_paper_print.print_submit(bid:string):Boolean; var str,strinfo:string; i,icount:Integer; aQuery:TADOQuery; begin result:=True; // 获取提交的批ID icount:=0; // str:='SELECT plst.*,dbo.[fn_GetPaperPreNo](plst.编号,plst.打印状态) as 提单纸前缀号,sea.委托单位, sea.操作员, sea.船名, sea.航次 FROM [t_op_seae_paper_print_list] plst , t_op_seae sea ' +' where plst.编号=sea.编号 and plst.提交编号=' + bid +' ;'; with qry1_print do begin Close; SQL.Clear; SQL.Add(str); open; end; sys_print('提单签入通知',1,ds2_print,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; function Tfrm_op_seae_paper_print.Checksubmit():Boolean; //提交已打印 未提交 已签回 var i,itmp :integer; aQuery:TADOQuery; blchk:Boolean; strtmp,tdh,info:string; begin Result:=true; for i:=0 to dxdbgrd1_S.SelectedCount-1 do begin qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i])); tdh:= qry1_paper_printlist.FieldByName('签回状态').AsString; //是否已打印 if( qry1_paper_printlist.FieldByName('打印状态').AsString<>'已打印') then begin Application.MessageBox(PChar('含有未打印的提单' +tdh + '不能提交'),'',MB_ICOninformation); result:=false; exit; end; if(qry1_paper_printlist.FieldByName('签回状态').IsNull) then begin Application.MessageBox(PChar('含有未签回的提单' +tdh + '不能提交'),'',MB_ICOninformation); result:=false; exit; end; //已提交,提交状态为被驳回的可以重新提交 if(qry1_paper_printlist.FieldByName('是否提交').AsBoolean) and (qry1_paper_printlist.FieldByName('提交状态').AsString<>'已驳回') then begin Application.MessageBox(PChar('含有已提交的提单' +tdh + '不能提交'),'',MB_ICOninformation); result:=false; exit; end; // end; end; procedure Tfrm_op_seae_paper_print.btn6_cancelSubmitClick(Sender: TObject); var str,bid,strinfo:string; i,icount:Integer; aQuery:TADOQuery; begin // 获取提交的批ID if(qry2_paper_printlist.Recordset.RecordCount<1) then begin Application.messagebox(pchar('请选择要取消的提单'),'信息提醒',MB_ICONINFORMATION ); Exit; end; if( qry2_paper_printlist.FieldByName('提交状态').AsString<>'已提交') then begin Application.MessageBox(PChar('只能取消已提交的提单!'),'',MB_ICOninformation); exit; end; // aQuery:=CreateAdoQuery; icount:=0; // bid:= qry2_paper_printlist.fieldbyname('提交编号').AsString; str:='SELECT [编号],[序号],[主提单号] FROM [t_op_seae_paper_print_list] ' +' where 提交编号=' + bid +' ;'; with aQuery do begin Close; SQL.Clear; SQL.Add(str); open; icount:=Recordset.RecordCount; end; strinfo:='是否要批量取消所选提交编号为'+ bid+ '的'+inttostr(icount)+'票提单'; if(Application.MessageBox(pchar(strinfo),'信息提示', MB_ICONQUESTION+MB_YESNO) <> ID_YES) then Exit; try frm_main.db.BeginTrans; // aQuery.close; aQuery.sql.Clear; str:='UPDATE [t_op_seae_paper_print_list] ' + 'SET 是否提交=0, 提交人=null,提交日期=null,[提交状态]=''未提交'' WHERE [提交编号] = ' + bid ; aQuery.SQL.Add(str); aQuery.ExecSQL; str:='delete from [t_op_state] where 业务状态=''通知签入'' and exists ' +' (select 编号 from t_op_seae_paper_print_list d where ' +' 提交编号=' + bid + ' and 编号=[t_op_state].编号)' ; frm_main.db.Execute(str); frm_main.db.CommitTrans; btn1_notify_searchClick( btn1_notify_search); seachPrintList(); except on ex: Exception do begin frm_main.db.RollbackTrans; Application.messagebox(pchar('驳回发生异常:'+ex.Message),'信息提醒',MB_ICONWARNING ); end; end; // end; procedure Tfrm_op_seae_paper_print.btn1_notify_searchClick( Sender: TObject); begin seachSubmitList(); end; procedure Tfrm_op_seae_paper_print.seachSubmitList(); var str:string; begin // str:=''; if(edt1_tdh.Text<>'') then str:= str + ' AND 主提单号 like ''%' + Trim(edt1_tdh.Text) + '%'' '; if(wdbdtmpckr1.Text<>'') then str:= str + ' AND 提交日期>=''' + Trim(wdbdtmpckr1.Text) + ''' '; // if(wdbdtmpckr2.Text<>'') then str:= str + ' AND 提交日期<=''' + Trim(wdbdtmpckr2.Text) + ' 23:59:59'' '; if(cbb2_submitstate.ItemIndex>0) then str:= str + ' AND 提交状态 =''' + Trim(cbb2_submitstate.Text) + ''' '; str:='select *, cast(提单份数 as varchar)+''正''+ CAST( 副本提单份数 as varchar) +''副'' as 签单要求 ' + ' from ( SELECT p.序号,p.编号,p.主提单号,p.船公司,p.签单方式,' // case when 船公司=''MAERSK'' then 1 else p.提单份数 end as +' 份数,p.提单份数' +' ,p.副本提单份数,p.文件类型,p.名称,p.类型,p.提单页数' + ' , p.提单页数 * case when 船公司=''MAERSK'' then 1 else p.提单份数 end as 需要提单纸张数' +' ,p.是否已分析,p.打印状态,p.打印人,p.打印日期,p.备注,p.是否换签,p.是否提交,p.提交编号 ' + ' ,p.提交状态,p.提交人,p.提交日期,p.是否签入,p.签入人,p.签入日期,p.驳回人,p.驳回日期 ' + ' ,s.业务状态 as 签回状态 FROM [t_op_seae_paper_print_list] p left join ' + ' (select 编号,业务状态,录入日期 as 签回日期 from t_op_state where 业务状态=''提单签回'') s ' +' on p.编号=s.编号 ) plst ' + ' where 提交状态 not in(''未提交'',''已驳回'')' + str +' order by 序号 '; with qry2_paper_printlist do begin // Close; SQL.Clear; SQL.Add(str) ; Open; end; end; procedure Tfrm_op_seae_paper_print.btn6_notify_exitClick(Sender: TObject); begin Close(); end; procedure Tfrm_op_seae_paper_print.btn2_notify_clearClick(Sender: TObject); begin // wdbdtmpckr1.text:=''; wdbdtmpckr2.text:=''; edt1_tdh.text:=''; cbb2_submitstate.ItemIndex:=0; end; procedure Tfrm_op_seae_paper_print.btn3Click(Sender: TObject); var str,xhs:string; bid,i:Integer; aQuery:TADOQuery; begin xhs:='-234'; aQuery:=CreateAdoQuery; if(dxdbgrd1_S.SelectedCount>0) then for i:=0 to dxdbgrd1_S.SelectedCount-1 do begin qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i])); xhs:=xhs+','+ qry1_paper_printlist.fieldbyname('序号').AsString; end ; str:=' SELECT plst.*,dbo.[fn_GetPaperPreNo](plst.编号,plst.打印状态) as 提单纸前缀号,sea.委托单位, sea.操作员,sea.船名,sea.航次 FROM [t_op_seae_paper_print_list] plst , t_op_seae sea ' +' where plst.编号=sea.编号 and plst.序号 in (' + xhs +' );'; with qry1_print do begin Close; SQL.Clear; SQL.Add(str); open; end; sys_print('提单签入通知',2,ds2_print,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; /// /// 调整页数 /// procedure Tfrm_op_seae_paper_print.bsSkinButton4Click(Sender: TObject); var strNum,cgsh1,cgsh2,strxhs,str:string; i,inum:integer; aQuery:TADOQuery; begin if(dxdbgrd1_detail.SelectedCount<1) then Exit; strxhs:='-123'; for i:=0 to dxdbgrd1_detail.SelectedCount do begin if i=0 then begin cgsh1 := qry_paper_detail.FieldByName('船公司简称').AsString; cgsh2:=cgsh1; end else begin cgsh2 := qry_paper_detail.FieldByName('船公司简称').AsString; end; // if cgsh1<>cgsh2 then begin showmessage('船公司不唯一!'); Exit; end; strxhs:=strxhs+','+ qry_paper_detail.FieldByName('序号').AsString; end; //qry_paper_detail strNum:=trim(InputBox('需向后调整的页数', '输入的页数', '')); if strNum='' then begin showmessage('调整的页数不能为空!!'); Exit; end; try inum:= StrToInt(Trim(strnum)); if( inum <1) then begin showmessage('输入的调整的页数格式错误,必须大于0!'); exit; end; except showmessage('输入的调整的页数格式错误!!'); exit; end; //校验选择的页数是否是被占用..... str:=' select top ' + IntToStr(inum)+ ' 序号,提单号 from t_op_seae_paper_detail ' +' where 船公司简称='''+ cgsh1 + ''' and isnull(使用状态,'''')<>''已作废''' +' and 提单纸号> (select MAX(dt.提单纸号) from t_op_seae_paper_detail dt ' +' where dt.序号 in (' + strxhs+ ') ) and isnull(使用状态,'''')=''已打印'' '; aQuery:=CreateAdoQuery(); with aQuery do begin Close; sql.Clear; sql.Add(str); Open; First; end; if(not aQuery.IsEmpty) then begin showmessage('要调整打印记录相邻的打印纸有' + IntToStr(aQuery.Recordset.recordcount ) + '张,已经被使用,不能调整!'); exit; end; //校验选择的页数是否是够用..... str:=' select top ' + IntToStr(inum)+ ' 序号,提单号 from t_op_seae_paper_detail ' +' where 船公司简称='''+ cgsh1 + ''' and isnull(使用状态,'''')<>''已作废''' +' and 提单纸号> (select MAX(dt.提单纸号) from t_op_seae_paper_detail dt ' +' where dt.序号 in (' + strxhs+ ') ) and isnull(使用状态,'''')=''已打印'' '; aQuery:=CreateAdoQuery(); with aQuery do begin Close; sql.Clear; sql.Add(str); Open; First; end; if(not aQuery.IsEmpty) then begin showmessage('要调整打印记录相邻的打印纸有' + IntToStr(aQuery.Recordset.recordcount ) + '张,已经被使用,不能调整!'); exit; end; str:= ' select * from t_op_seae_paper_print_list where 序号 in ( '+strxhs+')'; end; procedure Tfrm_op_seae_paper_print.btn1_RefreshTaskClick(Sender: TObject); begin // end; procedure Tfrm_op_seae_paper_print.seachtaskList(); var str:string; begin // qry3_notifyTask.Active:=false; qry3_notifyTask.Active:=true; end; procedure Tfrm_op_seae_paper_print.btn3_2printDesignClick(Sender: TObject); begin sys_print('提单签入通知',2,ds3_notifytask,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_paper_print.btn3_1_tasksubmitClick(Sender: TObject); var str,strbhs:string; i:Integer; begin if(dxdbgrd3_notiffyTask.SelectedCount<1) then Exit; // %s:录入人 %s 编号 str:=' INSERT INTO [t_op_seae_signin_notify] ' +'([提交编号],[编号],[主提单号],[船公司],[委托单位],[签单方式],' +'[是否换签],[操作员],[签回人],[签回日期],[打印状态],[提交人],[提交日期]) ' +#13#10 +' select v0.编号,v0.主提单号,v0.船公司,v0.委托单位,v0.签单方式,v0.是否换签,' +'v0.操作员,v0.签回人,v0.签回日期,p.打印状态,''%s'' as 提交人,getdate() as 提交日期 ' +#13#10 +' from ' +#13#10 +' (select sea.编号,sea.主提单号,sea.船公司,sea.委托单位,sea.签单方式,' +' sea.是否换签,sea.操作员, S.签回人,S.签回日期 ' +#13#10 +' from t_op_seae sea join ( select distinct 编号,业务状态,录入人 as 签回人' +' ,录入日期 as 签回日期 from t_op_state where 业务状态=''提单签回'' ' +#13#10 +' and DATEDIFF(DAY, 录入日期,getdate())<=13 /*2日内*/ ' +#13#10 +' ) s ' +#13#10 +' on sea.编号=s.编号 where (sea.签单方式=''正本'' OR sea.签单方式=''电子提单'') ' +' and sea.编号 in(%s) and not exists (select distinct 编号,业务状态 ' +#13#10 +' from t_op_state s where s.编号= sea.编号 and s.业务状态=''提单签入'') ' +#13#10 +' )v0 left join (select pr.编号 ,pr.打印状态 from ' +' t_op_seae_paper_print_list pr where pr.打印状态=''已打印'' )p ' +' on v0.编号=p.编号 ;' ; for i:=0 to dxdbgrd3_notiffyTask.SelectedCount do begin if(i=0) then strbhs:=''''+ qry3_notifyTask.FieldByName('编号').AsString +'''' else strbhs:=strbhs+','+ qry3_notifyTask.FieldByName('编号').AsString; end; str:=Format(str,[employee,strbhs]); ShowMessage(str); try frm_main.db.Execute(str); except on ex:Exception do begin errorlog(ex.Message); ShowMessage(ex.Message); end; end; end; procedure Tfrm_op_seae_paper_print.cxchckbx1_shfhqClick(Sender: TObject); begin seachPrintList(); end; procedure Tfrm_op_seae_paper_print.dxdbgrd1_SChangeNode(Sender: TObject; OldNode, Node: TdxTreeListNode); var ipages:Integer; begin if(dxdbgrd1_S.SelectedCount<1) then txtSelPages.Caption:='0'; if(dxdbgrd1_S.SelectedCount>1) then exit; ipages:=0; ipages:= qry1_paper_printlist.FieldByName('需要提单纸张数').AsInteger; txtSelPages.Caption:='选中页数:'+IntToStr(ipages); end; procedure Tfrm_op_seae_paper_print.dxdbgrd1_SSelectedCountChange( Sender: TObject); var i,itmp,ipages:Integer; begin if(dxdbgrd1_S.SelectedCount<1) then txtSelPages.Caption:='0'; ipages:=0; for i:=0 to dxdbgrd1_S.SelectedCount-1 do begin qry1_paper_printlist.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i])); itmp:= qry1_paper_printlist.FieldByName('需要提单纸张数').AsInteger; //1 记录明细 ipages:=ipages+itmp; end; txtSelPages.Caption:='选中页数:'+IntToStr(ipages); end; end.