unit U_BaoGuanListQR; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, cxCheckBox, RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, Menus, cxCalendar, cxButtonEdit, cxTextEdit, cxPC, BtnEdit, cxSplitter, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, MovePanel, comobj, Registry, dxSkinsCore, dxSkinsDefaultPainters, dxSkinscxPCPainter; type TfrmBaoGuanListQR = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBExport: TToolButton; TBClose: TToolButton; Panel1: TPanel; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DataSource1: TDataSource; cxGridPopupMenu1: TcxGridPopupMenu; BegDate: TDateTimePicker; EndDate: TDateTimePicker; CDS_Main: TClientDataSet; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; ClientDataSet1: TClientDataSet; Label6: TLabel; A4FPNO: TEdit; cxTabControl1: TcxTabControl; cxGridPopupMenu2: TcxGridPopupMenu; DataSource2: TDataSource; ClientDataSet2: TClientDataSet; Label5: TLabel; GCNAME: TEdit; Label8: TLabel; KHName: TEdit; Label3: TLabel; BGCODENAME: TEdit; TBBGZL: TToolButton; RMXLSExport1: TRMXLSExport; CDS_Print: TClientDataSet; RM1: TRMGridReport; RMDBDataSet1: TRMDBDataSet; ADOQueryPrint: TADOQuery; TBHT: TToolButton; TBFP: TToolButton; TBZXD: TToolButton; TBBGD: TToolButton; TBView: TToolButton; TBSBYS: TToolButton; TBAll: TToolButton; Label2: TLabel; C3BGNameEng: TEdit; cxGrid2: TcxGrid; TV1: TcxGridDBTableView; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; cxGridDBColumn5: TcxGridDBColumn; v1YSKeZhong: TcxGridDBColumn; cxGridDBColumn6: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridDBColumn8: TcxGridDBColumn; cxGridDBColumn9: TcxGridDBColumn; cxGridDBColumn10: TcxGridDBColumn; cxGridDBColumn11: TcxGridDBColumn; Tv1Column1: TcxGridDBColumn; cxGridDBColumn12: TcxGridDBColumn; cxGridDBColumn13: TcxGridDBColumn; Tv1Column2: TcxGridDBColumn; cxGridDBColumn14: TcxGridDBColumn; Tv1Column3: TcxGridDBColumn; Tv1Column5: TcxGridDBColumn; Tv1Column6: TcxGridDBColumn; cxGridDBColumn15: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; ToolButton1: TToolButton; tv2Column1: TcxGridDBColumn; tv2Column2: TcxGridDBColumn; tv2Column3: TcxGridDBColumn; tv2Column4: TcxGridDBColumn; tv2Column5: TcxGridDBColumn; tv2Column6: TcxGridDBColumn; TV1Column7: TcxGridDBColumn; TV1Column8: TcxGridDBColumn; TV1Column9: TcxGridDBColumn; TV1Column10: TcxGridDBColumn; TV1Column11: TcxGridDBColumn; TV1Column12: TcxGridDBColumn; TV1Column13: TcxGridDBColumn; TV1Column14: TcxGridDBColumn; Label4: TLabel; orderno: TEdit; ToolButton2: TToolButton; TV1Column15: TcxGridDBColumn; MovePanel1: TMovePanel; Label7: TLabel; Label9: TLabel; Edit2: TEdit; Label10: TLabel; Label11: TLabel; bgdate: TDateTimePicker; B7DaoHuoGang: TBtnEditA; htdate: TDateTimePicker; Label12: TLabel; chuandate: TDateTimePicker; Label13: TLabel; guixing: TEdit; Label14: TLabel; huodai: TBtnEditA; Label15: TLabel; tdno1: TEdit; Button1: TButton; Button2: TButton; Panel3: TPanel; Label19: TLabel; Panel6: TPanel; Image1: TImage; Button7: TButton; RadioGroup2: TRadioGroup; ToolButton3: TToolButton; TV1Column16: TcxGridDBColumn; cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; TV1Column17: TcxGridDBColumn; TV1Column4: TcxGridDBColumn; btn1: TToolButton; ToolButton4: TToolButton; ToolButton5: TToolButton; TV1Column18: TcxGridDBColumn; Label16: TLabel; Filler: TEdit; TV1Column19: TcxGridDBColumn; Label17: TLabel; ComboBox1: TComboBox; Label18: TLabel; ComboBox2: TComboBox; Label20: TLabel; TDNO: TEdit; ComboBox3: TComboBox; TV1Column20: TcxGridDBColumn; Label1: TLabel; A6PONO: TEdit; TV1Column21: TcxGridDBColumn; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure ConNoMChange(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBExportClick(Sender: TObject); procedure TBFindClick(Sender: TObject); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure TBDelClick(Sender: TObject); procedure TBAddClick(Sender: TObject); procedure TBEditClick(Sender: TObject); procedure FactoryNameChange(Sender: TObject); procedure cxTabControl1Change(Sender: TObject); procedure CRTypeChange(Sender: TObject); procedure A4FPNOKeyPress(Sender: TObject; var Key: Char); procedure Tv1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure GCNAMEKeyPress(Sender: TObject; var Key: Char); procedure KHNameKeyPress(Sender: TObject; var Key: Char); procedure TBCopyClick(Sender: TObject); procedure TBBGZLClick(Sender: TObject); procedure TBHTClick(Sender: TObject); procedure TBFPClick(Sender: TObject); procedure TBZXDClick(Sender: TObject); procedure TBBGDClick(Sender: TObject); procedure TBViewClick(Sender: TObject); procedure TBSBYSClick(Sender: TObject); procedure TBSSClick(Sender: TObject); procedure TBSSCXClick(Sender: TObject); procedure TBHDClick(Sender: TObject); procedure TBHDCXClick(Sender: TObject); procedure TBSHClick(Sender: TObject); procedure TBSHCXClick(Sender: TObject); procedure TBAllClick(Sender: TObject); procedure C3BGNameEngChange(Sender: TObject); procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); procedure ToolButton1Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure huodaiBtnClick(Sender: TObject); procedure B7DaoHuoGangBtnClick(Sender: TObject); procedure BtnEditA1BtnClick(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Image1Click(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure TV1DblClick(Sender: TObject); procedure btn1Click(Sender: TObject); procedure RMXLSExport1AfterExport(const aFileName: string); procedure RMXLSExport1BeforeExport(var aFileName: string; var aContinue: Boolean); procedure ToolButton4Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure ordernoChange(Sender: TObject); procedure ordernoKeyPress(Sender: TObject; var Key: Char); procedure CheckBox1Click(Sender: TObject); procedure ComboBox1Change(Sender: TObject); procedure ComboBox2Change(Sender: TObject); private canshu2: string; FDate: TDateTime; procedure InitGrid(); function DelData(): Boolean; function GetDeskeptPath: string; function GetShellFolders(strDir: string): string; procedure InitSubGrid(); procedure InitGridSql(var fsj: string); procedure InitButton(); procedure InitPrtData(); { Private declarations } public canshu1, canshu3: string; fdy: string; fImagePath2: string; { Public declarations } end; //var //frmBaoGuanList: TfrmBaoGuanList; implementation uses U_DataLink, U_RTFun, U_ZDYHelp, U_BaoGuanInPut, U_Fun; {$R *.dfm} function TfrmBaoGuanListQR.GetDeskeptPath: string; begin Result := GetShellFolders('Desktop'); //是取得桌面文件夹的路径 end; function TfrmBaoGuanListQR.GetShellFolders(strDir: string): string; const regPath = '\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'; var Reg: TRegistry; strFolders: string; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_CURRENT_USER; if Reg.OpenKey(regPath, false) then begin strFolders := Reg.ReadString(strDir); end; finally Reg.Free; end; result := strFolders; end; procedure TfrmBaoGuanListQR.FormDestroy(Sender: TObject); begin //frmBaoGuanList:=nil; end; procedure TfrmBaoGuanListQR.InitButton(); begin end; procedure TfrmBaoGuanListQR.FormClose(Sender: TObject; var Action: TCloseAction); begin Application := MainApplication; Action := caFree; end; procedure TfrmBaoGuanListQR.FormCreate(Sender: TObject); begin //cxGrid1.Align:=alClient; EndDate.DateTime := SGetServerDate10(ADOQueryTemp); BegDate.DateTime := EndDate.DateTime - 90; canshu1 := Trim(DParameters1); canshu2 := Trim(DParameters2); end; procedure TfrmBaoGuanListQR.InitGrid(); var fwhere, Pwhere: string; begin Pwhere := SGetFilters(Panel1, 1, 2); begin if trim(Pwhere) <> '' then fwhere := fwhere + ' and ' + trim(Pwhere); end; try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered := False; Close; sql.Clear; sql.Add('select A.*,B.* '); sql.Add(' from JYOrder_BaoGuan_Main A INNER JOIN JYOrder_BaoGuan_SUB B ON A.BGID=B.BGID '); sql.Add(' where A.Valid=''Y'' and B.SValid=''Y'' '); if cxTabControl1.TabIndex = 0 then begin sql.Add(' and isnull(SChker,'''')='''' '); end else if cxTabControl1.TabIndex = 1 then begin //and isnull(OKPerson,'''')<>'''' // sql.Add(' and isnull(OKPerson,'''')='''' and isnull(SChker,'''')<>'''' '); sql.Add(' and isnull(Status,'''')=''已送审'' '); end else if cxTabControl1.TabIndex = 2 then begin sql.Add(' and isnull(Status,'''')=''已审核'' '); end else begin end; if ComboBox1.text = '是' then begin sql.Add('and isnull(TDSTATUS,'''')<>'''''); end else if ComboBox1.text = '否' then begin sql.Add('and isnull(TDSTATUS,'''')='''''); end; if ComboBox2.text = '是' then begin sql.Add('and isnull(BGSTATUS,'''')<>'''''); end else if ComboBox2.text = '否' then begin sql.Add('and isnull(BGSTATUS,'''')='''''); end; if ComboBox3.Text = '出库日期' then begin sql.Add(' and htdate>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.Date)) + ''''); sql.Add(' and htdate<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.Date + 1)) + ''''); end else if ComboBox3.Text = '录入日期' then begin sql.Add(' and FILLTIME>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.Date)) + ''''); sql.Add(' and FILLTIME<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.Date + 1)) + ''''); end else if ComboBox3.Text = '船期日期' then begin sql.Add(' and chuandate>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.Date)) + ''''); sql.Add(' and chuandate<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.Date + 1)) + ''''); end; SQL.Add(fwhere); SQL.Add('ORDER BY htdate DESC'); // ShowMessage(sql.Text); Open; end; SCreateCDS20(ADOQueryMain, CDS_Main); SInitCDSData20(ADOQueryMain, CDS_Main); finally ADOQueryMain.EnableControls; end; end; procedure TfrmBaoGuanListQR.TBRafreshClick(Sender: TObject); begin BegDate.SetFocus; InitGrid(); end; procedure TfrmBaoGuanListQR.ConNoMChange(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); end; end; procedure TfrmBaoGuanListQR.TBCloseClick(Sender: TObject); begin WriteCxGrid('报关主表' + self.Caption, Tv1, '报关管理7'); // WriteCxGrid('报关明细' + self.Caption, Tv2, '报关管理8'); Close; end; procedure TfrmBaoGuanListQR.FormShow(Sender: TObject); begin ReadCxGrid('报关主表' + self.Caption, Tv1, '报关管理7'); // ReadCxGrid('报关明细' + self.Caption, Tv2, '报关管理8'); canshu1 := Trim(DParameters1); // ShowMessage(canshu1); InitButton(); InitGrid(); RM1.CanExport := true; end; procedure TfrmBaoGuanListQR.TBExportClick(Sender: TObject); begin if ADOQueryMain.IsEmpty then exit; SelExportData(Tv1, ADOQueryMain, '报关资料列表'); // TcxGridToExcel(Trim(CDS_Main.fieldbyname('A4FPNO').AsString) + Trim(CDS_Main.fieldbyname('A5ConNO').AsString), cxGrid1); end; procedure TfrmBaoGuanListQR.TBFindClick(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS20(ADOQueryMain, CDS_Main); SInitCDSData20(ADOQueryMain, CDS_Main); end; end; procedure TfrmBaoGuanListQR.N1Click(Sender: TObject); begin SelOKNo(CDS_Main, True); end; procedure TfrmBaoGuanListQR.N2Click(Sender: TObject); begin SelOKNo(CDS_Main, False); end; procedure TfrmBaoGuanListQR.InitSubGrid(); begin if CDS_Main.IsEmpty = False then begin with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JYOrder_BaoGuan_Sub where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); sql.Add(' and SValid=''Y'' '); Open; end; end else begin with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JYOrder_BaoGuan_Sub where 1=2'); Open; end; end; SCreateCDS20(ADOQueryTemp, ClientDataSet2); SInitCDSData20(ADOQueryTemp, ClientDataSet2); end; procedure TfrmBaoGuanListQR.TBDelClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if cxTabControl1.TabIndex <> 0 then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; if DelData() then begin InitGrid(); end; end; function TfrmBaoGuanListQR.DelData(): Boolean; begin try Result := false; ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while CDS_Main.Locate('SSel', True, []) do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set Valid=''N'',C7BGMoneyHZ=Null,E1BZQtyHZ=Null, E2ChiMaQtyHZ=Null,E3MaoZHZ=Null,E4JingZHZ=Null'); sql.Add(',Editer=''' + Trim(DName) + ''',EditTime=getdate()'); sql.Add(' where BGId=''' + Trim(CDS_Main.fieldbyname('BGId').AsString) + ''''); sql.Add('UPdate JYOrder_BaoGuan_Sub Set SValid=''N'',SEditer=''' + Trim(DName) + ''',SEditTime=getdate() where BGId=''' + Trim(CDS_Main.fieldbyname('BGId').AsString) + ''''); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; Result := True; except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Result := False; Application.MessageBox('数据删除异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBAddClick(Sender: TObject); begin try frmBaoGuanInPut := TfrmBaoGuanInPut.Create(Application); with frmBaoGuanInPut do begin FBCId := ''; if ShowModal = 1 then begin Self.InitGrid(); end; end; finally frmBaoGuanInPut.Free; end; end; procedure TfrmBaoGuanListQR.TBEditClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; // if cxTabControl1.TabIndex <> 0 then // Exit; try frmBaoGuanInPut := TfrmBaoGuanInPut.Create(Application); with frmBaoGuanInPut do begin FBCId := Trim(CDS_Main.fieldbyname('BGID').AsString); if (Trim(Self.Caption) = '报关管理') and (cxTabControl1.TabIndex = 1) then begin ToolButton4.Visible := True; end; //TBDel.Visible:=False; //TBAdd.Visible:=False; if ShowModal = 1 then begin Self.InitGrid(); end; end; finally frmBaoGuanInPut.Free; end; end; procedure TfrmBaoGuanListQR.FactoryNameChange(Sender: TObject); begin TBFind.Click; end; procedure TfrmBaoGuanListQR.cxTabControl1Change(Sender: TObject); begin InitButton(); InitGrid(); end; procedure TfrmBaoGuanListQR.CRTypeChange(Sender: TObject); begin TBFind.Click; end; procedure TfrmBaoGuanListQR.A4FPNOKeyPress(Sender: TObject; var Key: Char); var fsj: string; begin if Key = #13 then begin InitGrid(); end; end; procedure TfrmBaoGuanListQR.InitGridSql(var fsj: string); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered := False; Close; sql.Clear; sql.Add('select A.* '); sql.Add(' from JYOrder_BaoGuan_Main A '); sql.Add(' where 1=1 '); if Trim(canshu1) <> '高权限' then begin SQL.Add(' and FillerCode=''' + Trim(DCode) + ''''); end; if cxTabControl1.TabIndex = 0 then begin sql.Add(' and isnull(SChker,'''')='''' '); end else begin if cxTabControl1.TabIndex = 1 then begin sql.Add(' and isnull(SChker,'''')<>'''' and isnull(Chker,'''')='''' '); end else if cxTabControl1.TabIndex = 2 then begin sql.Add(' and isnull(Chker,'''')<>'''' '); end; end; sql.Add(fsj); Open; end; SCreateCDS20(ADOQueryMain, CDS_Main); SInitCDSData20(ADOQueryMain, CDS_Main); finally ADOQueryMain.EnableControls; end; end; procedure TfrmBaoGuanListQR.Tv1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin InitSubGrid(); end; procedure TfrmBaoGuanListQR.GCNAMEKeyPress(Sender: TObject; var Key: Char); var fsj: string; begin // if Key = #13 then // begin // if Trim(A6PONO.Text) = '' then // Exit; // fsj := ' and isnull(A.A6PONO,'''') like ''' + '%' + Trim(A6PONO.Text) + '%' + ''''; // InitGridSql(fsj); // end; end; procedure TfrmBaoGuanListQR.KHNameKeyPress(Sender: TObject; var Key: Char); var fsj: string; begin // if Key = #13 then // begin // if Trim(A5ConNO.Text) = '' then // Exit; // fsj := ' and isnull(A.A5ConNO,'''') like ''' + '%' + Trim(A5ConNO.Text) + '%' + ''''; // InitGridSql(fsj); // end; end; procedure TfrmBaoGuanListQR.TBCopyClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; // if cxTabControl1.TabIndex<>0 then Exit; try frmBaoGuanInPut := TfrmBaoGuanInPut.Create(Application); with frmBaoGuanInPut do begin FBCId := Trim(CDS_Main.fieldbyname('BGID').AsString); CopyStr := '99'; //TBDel.Visible:=False; //TBAdd.Visible:=False; if ShowModal = 1 then begin Self.InitGrid(); end; end; finally frmBaoGuanInPut.Free; end; end; procedure TfrmBaoGuanListQR.InitPrtData(); begin with ADOQueryPrint do begin Close; sql.Clear; sql.Add(' exec P_View_BaoGuanData :BGID '); Parameters.ParamByName('BGID').Value := Trim(CDS_Main.fieldbyname('BGId').AsString); Open; end; SCreateCDS20(ADOQueryPrint, CDS_Print); SInitCDSData20(ADOQueryPrint, CDS_Print); end; procedure TfrmBaoGuanListQR.TBBGZLClick(Sender: TObject); var fPrintFile: string; EngMoney, BZZH, FimageFile: string; begin if CDS_Main.IsEmpty then Exit; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\报关资料.rmf'; InitPrtData(); FimageFile := ExtractFilePath(Application.ExeName) + 'Image\' + Trim(CDS_Print.FieldByName('A1ChuKouShang').AsString) + '.jpg'; RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1); if FileExists(fPrintFile) then begin //RMVariables['enddate']:=enddate.DateTime; //RMVariables['printtime']:=Now; RMVariables['ImageFile'] := trim(FimageFile); RM1.LoadFromFile(fPrintFile); RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\报关资料.rmf'), '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBHTClick(Sender: TObject); var fPrintFile: string; EngMoney, BZZH, FimageFile: string; begin if CDS_Main.IsEmpty then Exit; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\报关合同.rmf'; InitPrtData(); FimageFile := ExtractFilePath(Application.ExeName) + 'Image\' + Trim(CDS_Print.FieldByName('A1ChuKouShang').AsString) + '.jpg'; RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1); if FileExists(fPrintFile) then begin //RMVariables['enddate']:=enddate.DateTime; //RMVariables['printtime']:=Now; RMVariables['ImageFile'] := trim(FimageFile); RM1.LoadFromFile(fPrintFile); RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\报关合同.rmf'), '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBFPClick(Sender: TObject); var fPrintFile: string; EngMoney, BZZH, FimageFile: string; begin if CDS_Main.IsEmpty then Exit; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\报关发票.rmf'; InitPrtData(); FimageFile := ExtractFilePath(Application.ExeName) + 'Image\' + Trim(CDS_Print.FieldByName('A1ChuKouShang').AsString) + '.jpg'; RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1); if FileExists(fPrintFile) then begin //RMVariables['enddate']:=enddate.DateTime; //RMVariables['printtime']:=Now; RMVariables['ImageFile'] := trim(FimageFile); RM1.LoadFromFile(fPrintFile); RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\报关发票.rmf'), '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBZXDClick(Sender: TObject); var fPrintFile: string; EngMoney, BZZH, FimageFile: string; begin if CDS_Main.IsEmpty then Exit; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\报关装箱单.rmf'; InitPrtData(); FimageFile := ExtractFilePath(Application.ExeName) + 'Image\' + Trim(CDS_Print.FieldByName('A1ChuKouShang').AsString) + '.jpg'; RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1); if FileExists(fPrintFile) then begin //RMVariables['enddate']:=enddate.DateTime; //RMVariables['printtime']:=Now; RMVariables['ImageFile'] := trim(FimageFile); RM1.LoadFromFile(fPrintFile); RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\报关装箱单.rmf'), '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBBGDClick(Sender: TObject); var fPrintFile: string; EngMoney, BZZH, FimageFile: string; begin if CDS_Main.IsEmpty then Exit; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\报关单.rmf'; InitPrtData(); FimageFile := ExtractFilePath(Application.ExeName) + 'Image\' + Trim(CDS_Print.FieldByName('A1ChuKouShang').AsString) + '.jpg'; RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1); if FileExists(fPrintFile) then begin //RMVariables['enddate']:=enddate.DateTime; //RMVariables['printtime']:=Now; RMVariables['ImageFile'] := trim(FimageFile); RM1.LoadFromFile(fPrintFile); RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\报关单.rmf'), '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBViewClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; //if cxTabControl1.TabIndex<>0 then Exit; try frmBaoGuanInPut := TfrmBaoGuanInPut.Create(Application); with frmBaoGuanInPut do begin FBCId := Trim(CDS_Main.fieldbyname('BGID').AsString); TBSave.Visible := False; ToolBar2.Visible := False; Panel1.Enabled := False; canshu3 := self.canshu3; Tv1.OptionsData.Editing := False; if ShowModal = 1 then begin Self.InitGrid(); end; end; finally frmBaoGuanInPut.Free; end; end; procedure TfrmBaoGuanListQR.TBSBYSClick(Sender: TObject); var fPrintFile: string; EngMoney, BZZH, FimageFile: string; begin if CDS_Main.IsEmpty then Exit; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\申报要素.rmf'; InitPrtData(); FimageFile := ExtractFilePath(Application.ExeName) + 'Image\' + Trim(CDS_Print.FieldByName('A1ChuKouShang').AsString) + '.jpg'; RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1); if FileExists(fPrintFile) then begin //RMVariables['enddate']:=enddate.DateTime; //RMVariables['printtime']:=Now; RMVariables['ImageFile'] := trim(FimageFile); RM1.LoadFromFile(fPrintFile); RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\申报要素.rmf'), '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBSSClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if cxTabControl1.TabIndex <> 0 then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要执行送审操作吗?', '提示', 32 + 4) <> IDYES then Exit; try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set Status=''已送审'',SStime=getdate(),SChker=''' + Trim(DName) + ''''); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBSSCXClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if cxTabControl1.TabIndex <> 1 then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; CDS_Main.DisableControls; with CDS_Main do begin First; while not Eof do begin if CDS_Main.FieldByName('SSel').AsBoolean = True then begin with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JYOrder_BaoGuan_Main '); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); Open; end; if Trim(ADOQueryTemp.fieldbyname('OKPerson').AsString) <> '' then begin CDS_Main.EnableControls; Application.MessageBox('已核对不能撤销!', '提示', 0); Exit; end; end; Next; end; end; CDS_Main.EnableControls; if Application.MessageBox('确定要执行送审撤销操作吗?', '提示', 32 + 4) <> IDYES then Exit; try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set Status=''待送审'',SStime=Null,SChker=Null'); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBHDClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if cxTabControl1.TabIndex <> 1 then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要执行核对操作吗?', '提示', 32 + 4) <> IDYES then Exit; try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set Status=''已核对'',OKTime=getdate(),OKPerson=''' + Trim(DName) + ''''); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBHDCXClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if cxTabControl1.TabIndex <> 2 then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; CDS_Main.DisableControls; with CDS_Main do begin First; while not Eof do begin if CDS_Main.FieldByName('SSel').AsBoolean = True then begin with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JYOrder_BaoGuan_Main '); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); Open; end; if Trim(ADOQueryTemp.fieldbyname('Chker').AsString) <> '' then begin CDS_Main.EnableControls; Application.MessageBox('已审核不能撤销!', '提示', 0); Exit; end; end; Next; end; end; CDS_Main.EnableControls; if Application.MessageBox('确定要执行核对撤销操作吗?', '提示', 32 + 4) <> IDYES then Exit; try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set Status=''已送审'',OKtime=Null,OKPerson=Null'); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBSHClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if cxTabControl1.TabIndex <> 1 then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要执行审核操作吗?', '提示', 32 + 4) <> IDYES then Exit; try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set Status=''已审核'',ChkTime=getdate(),Chker=''' + Trim(DName) + ''''); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBSHCXClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if cxTabControl1.TabIndex <> 2 then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要执行审核撤销操作吗?', '提示', 32 + 4) <> IDYES then Exit; try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set Status=''已送审'',ChkTime=Null,Chker=Null'); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.TBAllClick(Sender: TObject); var fPrintFile: string; EngMoney, BZZH, FimageFile, FZMFile: string; begin if CDS_Main.IsEmpty then Exit; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\全部报关资料.rmf'; InitPrtData(); FimageFile := ExtractFilePath(Application.ExeName) + 'Image\' + Trim(CDS_Print.FieldByName('A1ChuKouShang').AsString) + '.jpg'; //RMXLSExport1:= TRMXLSExport.Create(RMXLSExport1); if FileExists(fPrintFile) then begin if RM1.CanExport = true then begin FZMFile := 'C:\Users\Administrator\Desktop'; if not DirectoryExists(FZMFile) then begin FZMFile := 'C:\Documents and Settings\Administrator\桌面\' + trim(CDS_Main.fieldbyname('A4FPNO').AsString) + ' ' + trim(CDS_Main.fieldbyname('A5ConNO').AsString) + '.xls'; end else begin FZMFile := 'C:\Users\Administrator\Desktop\' + trim(CDS_Main.fieldbyname('A4FPNO').AsString) + ' ' + trim(CDS_Main.fieldbyname('A5ConNO').AsString) + '.XLS'; end; RM1.ExportTo(RMXLSExport1, FZMFile); end; RM1.CanExport := true; RMVariables['ImageFile'] := trim(FimageFile); RM1.LoadFromFile(fPrintFile); RM1.ShowReport; RM1.CanExport := False; end else begin Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\全部报关资料.rmf'), '提示', 0); end; end; procedure TfrmBaoGuanListQR.C3BGNameEngChange(Sender: TObject); begin TBFind.Click(); end; procedure TfrmBaoGuanListQR.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); begin InitSubGrid(); end; procedure TfrmBaoGuanListQR.ToolButton1Click(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; FDY := '0'; panel3.Visible := True; end; procedure TfrmBaoGuanListQR.ToolButton2Click(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if cxTabControl1.TabIndex <> 2 then Exit; // if CDS_Main.Locate('SSel', True, []) = False then // begin // Application.MessageBox('没有选择数据!', '提示', 0); // Exit; // end; MovePanel1.Visible := True; B7DaoHuoGang.Text := Trim(CDS_Main.fieldbyname('B7DaoHuoGang').AsString); Edit2.Text := Trim(CDS_Main.fieldbyname('A4FPNO').AsString); if CDS_Main.fieldbyname('bgdate').AsString = '' then begin bgdate.DateTime := SGetServerDateTime(ADOQueryTemp); end else begin bgdate.DateTime := CDS_Main.fieldbyname('bgdate').asdatetime; end; htdate.DateTime := CDS_Main.fieldbyname('htdate').asdatetime; chuandate.DateTime := CDS_Main.fieldbyname('chuandate').asdatetime; huodai.Text := Trim(CDS_Main.fieldbyname('huodai').AsString); guixing.Text := Trim(CDS_Main.fieldbyname('guixing').AsString); tdno1.Text := Trim(CDS_Main.fieldbyname('tdno').AsString); // if Application.MessageBox('确定要执行审核撤销操作吗?', '提示', 32 + 4) <> IDYES then // Exit; end; procedure TfrmBaoGuanListQR.Button1Click(Sender: TObject); begin try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set bgStatus=''√'''); sql.Add(',bgdate=' + quotedstr(FormatDateTime('yyyy-MM-dd', bgdate.DateTime))); sql.add(',htdate=' + quotedstr(FormatDateTime('yyyy-MM-dd', htdate.DateTime))); sql.Add(',QRREN=' + quotedstr(Trim(DNAME))); sql.Add(',A4FPNO=' + quotedstr(Trim(Edit2.Text))); sql.Add(',B7DaoHuoGang=' + quotedstr(Trim(B7DaoHuoGang.Text))); sql.add(',chuandate=' + quotedstr(FormatDateTime('yyyy-MM-dd', chuandate.DateTime))); sql.Add(',guixing=' + quotedstr(Trim(guixing.Text))); sql.Add(',huodai=' + quotedstr(Trim(huodai.Text))); sql.Add(',tdno=' + quotedstr(Trim(tdno1.Text))); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('报关确认'))); sql.Add(',' + quotedstr(trim('BGID:' + trim(CDS_Main.FieldByName('BGID').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); ExecSQL; end; with ADOQueryCmd do begin Close; sql.Clear; SQL.Add('EXEC P_Do_SCYF @BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); SQL.Add(',@DNAME=' + QUOTEDSTR(Trim(DNAME))); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; Application.MessageBox('操作成功!', '提示', 0); InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.Button2Click(Sender: TObject); begin MovePanel1.Visible := False; end; procedure TfrmBaoGuanListQR.huodaiBtnClick(Sender: TObject); var fsj: string; FWZ: Integer; begin fsj := Trim(TEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmBaoGuanListQR.B7DaoHuoGangBtnClick(Sender: TObject); var fsj: string; FWZ: Integer; begin fsj := Trim(TEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmBaoGuanListQR.BtnEditA1BtnClick(Sender: TObject); var fsj: string; FWZ: Integer; begin fsj := Trim(TEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmBaoGuanListQR.Button7Click(Sender: TObject); var fPrintFile, FTaiTou: string; EngMoney, LBName: string; ExcelApp: Variant; f1, fstr: string; begin LBName := RadioGroup2.Items.Strings[RadioGroup2.ItemIndex]; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(LBName) + '.rmf'; ExportFtErpFile(Trim(LBName) + '.rmf', ADOQueryPrint); if LBName = '开票二连打' then begin with ADOQueryPrint do begin Close; sql.Clear; sql.Add('exec P_Print_BGD5 '); SQL.ADD('@bgid=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); // ShowMessage(SQL.Text); Open; end; SCreateCDS20(ADOQueryPrint, CDS_Print); SInitCDSData20(ADOQueryPrint, CDS_Print); end else begin with ADOQueryPrint do begin Close; sql.Clear; sql.Add('exec P_Print_BGD '); SQL.ADD('@bgid=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); // ShowMessage(SQL.Text); Open; end; SCreateCDS20(ADOQueryPrint, CDS_Print); SInitCDSData20(ADOQueryPrint, CDS_Print); end; if FileExists(fPrintFile) then begin RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1); RMXLSExport1.ShowDialog := False; RMXLSExport1.ShowAfterExport := False; if FDY = '0' then begin RM1.LoadFromFile(fPrintFile); Sleep(1000); RM1.ShowReport; end else if FDY = '1' then begin RM1.LoadFromFile(fPrintFile); fImagePath2 := ExtractFilePath(Application.ExeName) + 'image\label0001.xls'; if FileExists(fImagePath2) then DeleteFile(fImagePath2); //label.xls // fImagePath2 := ExtractFilePath(Application.ExeName) + 'image\' + Trim(CDS_Main.fieldbyname('orderno').AsString) + '.xls'; // fImagePath2 := GetShellFolders('Desktop') + '\' + Trim(CDS_Main.fieldbyname('orderno').AsString) + '.xls'; fstr := (StringReplace(Trim(CDS_Main.fieldbyname('orderno').AsString), '/', ',', [rfReplaceAll])); // ShowMessage(fstr); fImagePath2 := GetShellFolders('Desktop') + '\' + fstr + '.xls'; RM1.PrepareReport; Sleep(1000); RM1.ExportTo(RMXLSExport1, fImagePath2); if RadioGroup2.ItemIndex = 1 then begin ExcelApp := CreateOleObject('Excel.Application'); ExcelApp.workBooks.Open(fImagePath2); ExcelApp.WorkSheets[1].name := '发票'; ExcelApp.WorkSheets[2].name := '箱单'; ExcelApp.WorkSheets[3].name := '报关单2'; ExcelApp.WorkSheets[4].name := '销售合同'; // if not ExcelApp.ActiveWorkBook.Saved then // ExcelApp.ActiveSheet.PrintPreview; ExcelApp.WorkBooks.Close; //关闭工作簿 if not VarIsEmpty(ExcelApp) then ExcelApp.Quit; end; end; end else begin // Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\报关单.rmf'), '提示', 0); Application.MessageBox(PChar('没有找' + trim(fPrintFile)), '提示信息', 0); Exit; end; Panel3.Visible := False; end; procedure TfrmBaoGuanListQR.Image1Click(Sender: TObject); begin panel3.Visible := false; end; procedure TfrmBaoGuanListQR.ToolButton3Click(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if cxTabControl1.TabIndex <> 2 then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set bgStatus=NULL,QRREN=NULL'); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('报关取消确认'))); sql.Add(',' + quotedstr(trim('BGID:' + trim(CDS_Main.FieldByName('BGID').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; Application.MessageBox('操作成功!', '提示', 0); InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.TV1DblClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if (cxTabControl1.TabIndex <> 0) and (cxTabControl1.TabIndex <> 1) then Exit; try frmBaoGuanInPut := TfrmBaoGuanInPut.Create(Application); with frmBaoGuanInPut do begin FBCId := Trim(CDS_Main.fieldbyname('BGID').AsString); if (Trim(Self.Caption) = '报关管理') and (cxTabControl1.TabIndex = 1) then begin ToolButton4.Visible := True; end; //TBDel.Visible:=False; //TBAdd.Visible:=False; if ShowModal = 1 then begin Self.InitGrid(); end; end; finally frmBaoGuanInPut.Free; end; end; procedure TfrmBaoGuanListQR.btn1Click(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; FDY := '1'; panel3.Visible := True; end; procedure TfrmBaoGuanListQR.RMXLSExport1AfterExport(const aFileName: string); var ExcelApp: Variant; begin // 'C:\Users\Administrator\Desktop\123.xls' ExcelApp := CreateOleObject('Excel.Application'); // ShowMessage(fImagePath2); ExcelApp.workBooks.Open(fImagePath2); // ExcelApp.Worksheets[1].activate; ExcelApp.WorkSheets[1].name := '目标3'; ExcelApp.WorkSheets[2].name := '目标33'; // ExcelApp.WorkSheets[3].name := '目标222'; // ExcelApp.WorkBooks[1].SaveAs(aFileName, 56); //fileformat:=56 -- Office Excel 97-2003 format // if not ExcelApp.ActiveWorkBook.Saved then // ExcelApp.ActiveSheet.PrintPreview; ExcelApp.WorkBooks.Close; //关闭工作簿 if not VarIsEmpty(ExcelApp) then ExcelApp.Quit; ExcelApp.Disconnect; ExcelApp := Unassigned; ExcelApp.free; end; procedure TfrmBaoGuanListQR.RMXLSExport1BeforeExport(var aFileName: string; var aContinue: Boolean); var ExcelApp: Variant; begin // 'C:\Users\Administrator\Desktop\123.xls' ExcelApp := CreateOleObject('Excel.Application'); // ShowMessage(fImagePath2); ExcelApp.workBooks.Open(fImagePath2); // ExcelApp.Worksheets[1].activate; ExcelApp.WorkSheets[1].name := '目标2'; ExcelApp.WorkSheets[2].name := '目标22'; // ExcelApp.WorkSheets[3].name := '目标222'; // ExcelApp.WorkBooks[1].SaveAs(aFileName, 56); //fileformat:=56 -- Office Excel 97-2003 format // if not ExcelApp.ActiveWorkBook.Saved then // ExcelApp.ActiveSheet.PrintPreview; ExcelApp.WorkBooks.Close; //关闭工作簿 if not VarIsEmpty(ExcelApp) then ExcelApp.Quit; ExcelApp := Unassigned; ExcelApp.free; // if not ExcelApp.ActiveWorkBook.Saved then // ExcelApp.ActiveSheet.PrintPreview; // ExcelApp.free; end; procedure TfrmBaoGuanListQR.ToolButton4Click(Sender: TObject); begin if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set TDStatus=''√'''); sql.Add(',TDdate=GETDATE()'); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; Application.MessageBox('操作成功!', '提示', 0); InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.ToolButton5Click(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; CDS_Main.DisableControls; with CDS_Main do begin First; while Locate('SSel', True, []) = True do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('UPdate JYOrder_BaoGuan_Main Set TDStatus=NULL'); SQL.Add(',TDDATE=NULL'); sql.Add(' where BGID=''' + Trim(CDS_Main.fieldbyname('BGID').AsString) + ''''); ExecSQL; end; CDS_Main.Delete; end; end; CDS_Main.EnableControls; ADOQueryCmd.Connection.CommitTrans; Application.MessageBox('操作成功!', '提示', 0); InitGrid(); except CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作异常!', '提示', 0); end; end; procedure TfrmBaoGuanListQR.ordernoChange(Sender: TObject); begin // try // ADOQueryMain.DisableControls; // with ADOQueryMain do // begin // Filtered := False; // Close; // sql.Clear; // sql.Add('select A.*,B.* '); // sql.Add(' from JYOrder_BaoGuan_Main A INNER JOIN JYOrder_BaoGuan_SUB B ON A.BGID=B.BGID '); // sql.Add(' where A.Valid=''Y'' and B.SValid=''Y'' '); // if cxTabControl1.TabIndex = 0 then // begin // sql.Add(' and isnull(SChker,'''')='''' '); // end // else if cxTabControl1.TabIndex = 1 then // begin // sql.Add(' and isnull(Status,'''')=''已送审'' '); // end // else if cxTabControl1.TabIndex = 2 then // begin // sql.Add(' and isnull(Status,'''')=''已审核'' '); // // end // else // begin // // end; // sql.Add(' and filltime>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.Date)) + ''''); // sql.Add(' and filltime<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.Date + 1)) + ''''); // SQL.Add('AND EXISTS(SELECT * FROM JYOrder_BaoGuan_SUB C WHERE ORDERNO LIKE ' + QUOTEDSTR('%' + Trim(orderno.Text) + '%')); // SQL.Add('AND C.BGID=A.BGID)'); // SQL.Add('ORDER BY FILLTIME DESC'); // Open; // end; // SCreateCDS20(ADOQueryMain, CDS_Main); // SInitCDSData20(ADOQueryMain, CDS_Main); // finally // ADOQueryMain.EnableControls; // end; end; procedure TfrmBaoGuanListQR.ordernoKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered := False; Close; sql.Clear; sql.Add('select A.*,B.* '); sql.Add(' from JYOrder_BaoGuan_Main A INNER JOIN JYOrder_BaoGuan_SUB B ON A.BGID=B.BGID '); sql.Add(' where A.Valid=''Y'' and B.SValid=''Y'' '); if cxTabControl1.TabIndex = 0 then begin sql.Add(' and isnull(SChker,'''')='''' '); end else if cxTabControl1.TabIndex = 1 then begin sql.Add(' and isnull(Status,'''')=''已送审'' '); end else if cxTabControl1.TabIndex = 2 then begin sql.Add(' and isnull(Status,'''')=''已审核'' '); end else begin end; sql.Add(' and filltime>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.Date)) + ''''); sql.Add(' and filltime<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.Date + 1)) + ''''); SQL.Add('AND EXISTS(SELECT * FROM JYOrder_BaoGuan_SUB C WHERE ORDERNO LIKE ' + QUOTEDSTR('%' + Trim(orderno.Text) + '%')); SQL.Add('AND C.BGID=A.BGID)'); SQL.Add('ORDER BY FILLTIME DESC'); // ShowMessage(sql.Text); Open; end; SCreateCDS20(ADOQueryMain, CDS_Main); SInitCDSData20(ADOQueryMain, CDS_Main); finally ADOQueryMain.EnableControls; end; end; end; procedure TfrmBaoGuanListQR.CheckBox1Click(Sender: TObject); begin InitGrid(); end; procedure TfrmBaoGuanListQR.ComboBox1Change(Sender: TObject); begin InitGrid(); end; procedure TfrmBaoGuanListQR.ComboBox2Change(Sender: TObject); begin InitGrid(); end; end.