unit U_MGFYBBMXGL; 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, cxCalc; type TfrmMGFYBBMXGL = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBClose: TToolButton; Panel1: TPanel; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DataSource1: TDataSource; cxGridPopupMenu1: TcxGridPopupMenu; Label1: TLabel; BegDate: TDateTimePicker; EndDate: TDateTimePicker; CDS_Main: TClientDataSet; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; ClientDataSet1: TClientDataSet; cxGridPopupMenu2: TcxGridPopupMenu; DataSource2: TDataSource; ClientDataSet2: TClientDataSet; Label5: TLabel; G_ZBFACTORYNAME: TEdit; RMXLSExport1: TRMXLSExport; CDS_Print: TClientDataSet; RM1: TRMGridReport; RMDBDataSet1: TRMDBDataSet; ADOQueryPrint: TADOQuery; cxGrid2: TcxGrid; TV1: TcxGridDBTableView; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridDBColumn9: TcxGridDBColumn; Tv1Column1: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; tv2Column1: TcxGridDBColumn; tv2Column2: TcxGridDBColumn; tv2Column6: TcxGridDBColumn; TV1Column11: TcxGridDBColumn; TV1Column12: TcxGridDBColumn; TV1Column15: TcxGridDBColumn; ToolButton1: TToolButton; TV1Column2: TcxGridDBColumn; TV1Column3: TcxGridDBColumn; TV1Column4: TcxGridDBColumn; TV1Column6: TcxGridDBColumn; TV1Column7: TcxGridDBColumn; TV1Column8: TcxGridDBColumn; TV1Column5: TcxGridDBColumn; TV1Column9: TcxGridDBColumn; TV1Column10: TcxGridDBColumn; TV1Column13: TcxGridDBColumn; TV1Column14: TcxGridDBColumn; chkMGF: TCheckBox; chKXKPF: TCheckBox; chkFXPWWC: TCheckBox; chkslt: TCheckBox; ToolBar2: TToolBar; ToolButton11: TToolButton; ToolButton12: TToolButton; ToolButton13: TToolButton; ToolButton14: TToolButton; ToolButton15: TToolButton; ToolButton16: TToolButton; ToolButton17: TToolButton; TV1Column16: TcxGridDBColumn; TV1Column17: TcxGridDBColumn; TV1Column18: TcxGridDBColumn; TV1Column19: TcxGridDBColumn; TV1Column20: TcxGridDBColumn; TV1Column21: TcxGridDBColumn; TV1Column22: TcxGridDBColumn; TV1Column23: TcxGridDBColumn; TV1Column24: TcxGridDBColumn; TV1Column25: TcxGridDBColumn; TV1Column26: TcxGridDBColumn; TV1Column27: TcxGridDBColumn; ToolBar3: TToolBar; ToolButton2: TToolButton; ToolButton3: TToolButton; ToolButton4: TToolButton; ToolButton5: TToolButton; ToolButton6: TToolButton; ToolButton7: TToolButton; ToolButton8: TToolButton; TV1Column28: 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 FactoryNameChange(Sender: TObject); procedure cxTabControl1Change(Sender: TObject); procedure CRTypeChange(Sender: TObject); procedure Tv1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure G_ZBFACTORYNAMEKeyPress(Sender: TObject; var Key: Char); procedure KHNameKeyPress(Sender: TObject; var Key: Char); procedure TBBGZLClick(Sender: TObject); procedure TBHTClick(Sender: TObject); procedure TBFPClick(Sender: TObject); procedure TBZXDClick(Sender: TObject); procedure TBBGDClick(Sender: TObject); procedure TBSBYSClick(Sender: TObject); procedure TBAllClick(Sender: TObject); procedure YWYChange(Sender: TObject); procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); procedure huodaiBtnClick(Sender: TObject); procedure B7DaoHuoGangBtnClick(Sender: TObject); procedure BtnEditA1BtnClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure chkMGFClick(Sender: TObject); procedure ToolButton11Click(Sender: TObject); procedure ToolButton12Click(Sender: TObject); procedure ToolButton13Click(Sender: TObject); procedure ToolButton14Click(Sender: TObject); procedure ToolButton15Click(Sender: TObject); procedure ToolButton16Click(Sender: TObject); procedure ToolButton17Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); procedure ToolButton7Click(Sender: TObject); procedure ToolButton8Click(Sender: TObject); private canshu2: string; FDate: TDateTime; procedure InitGrid(); function DelData(): Boolean; procedure InitSubGrid(); procedure InitGridSql(var fsj: string); procedure InitPrtData(); { Private declarations } public canshu1: string; { Public declarations } end; var frmMGFYBBMXGL: TfrmMGFYBBMXGL; implementation uses U_DataLink, U_RTFun, U_ZDYHelp, U_Fun; {$R *.dfm} procedure TfrmMGFYBBMXGL.FormDestroy(Sender: TObject); begin //frmBaoGuanList:=nil; end; procedure TfrmMGFYBBMXGL.FormClose(Sender: TObject; var Action: TCloseAction); begin Application := MainApplication; Action := caFree; end; procedure TfrmMGFYBBMXGL.FormCreate(Sender: TObject); begin //cxGrid1.Align:=alClient; EndDate.DateTime := SGetServerDate10(ADOQueryTemp); BegDate.DateTime := SGetServerDateMBeg(ADOQueryTemp); canshu1 := Trim(DParameters1); canshu2 := Trim(DParameters2); end; procedure TfrmMGFYBBMXGL.InitGrid(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered := False; Close; sql.Clear; SQL.Add('SELECT * '); SQL.Add(',YF_MGF1=CAST( YF_MGF AS BIT)'); SQL.Add(',YF_DYF1=CAST( YF_DYF AS BIT)'); SQL.Add(',YF_XPKPF1=CAST( YF_XPKPF AS BIT)'); SQL.Add(',YF_DPKPF1=CAST( YF_DPKPF AS BIT)'); SQL.Add(',YF_DWZPF1=CAST( YF_DWZPF AS BIT)'); SQL.Add(',YF_MGQTF1=CAST( YF_MGQTF AS BIT)'); SQL.Add(',YF_DYQTF1=CAST( YF_DYQTF AS BIT)'); SQL.Add(',ismg=(case when G_YMG=1 then ''已描稿'' else ''未描稿'' end)'); SQL.Add(',DPKPS=(SELECT COUNT(*) FROM Sketch_XMAP B WHERE A.MGID=B.MGID AND B.XMNAME=''大片'' and b.xmkp=1)'); SQL.Add(',XPKPS=(SELECT COUNT(*) FROM Sketch_XMAP B WHERE A.MGID=B.MGID AND B.XMNAME=''小片'' and b.xmkp=1)'); SQL.Add(',isjg=(case when G_NG=1 then ''非简稿'' else ''简稿'' end)'); SQL.Add(',ISYP=(case when G_yyp=1 then ''有'' else ''无'' end)'); sql.Add('FROM Sketch_main A'); sql.Add('where A.G_ZBDATE>=''' + formatdateTime('yyyy-MM-dd', begdate.Date) + ''' '); sql.Add('and A.G_ZBDATE<''' + formatdateTime('yyyy-MM-dd', enddate.Date + 1) + ''' '); if chkMGF.Checked then begin SQL.Add('AND YF_MGF=0'); end; if chKXKPF.Checked then begin SQL.Add('AND YF_XPKPF=0'); end; if chkFXPWWC.Checked then begin SQL.Add('AND YF_DPKPF=0'); end; if chkslt.Checked then begin SQL.Add('AND YF_MGQTF=0'); end; Open; end; SCreateCDS20(ADOQueryMain, CDS_Main); SInitCDSData20(ADOQueryMain, CDS_Main); finally ADOQueryMain.EnableControls; end; end; procedure TfrmMGFYBBMXGL.TBRafreshClick(Sender: TObject); begin ToolBar1.SetFocus; InitGrid(); end; procedure TfrmMGFYBBMXGL.ConNoMChange(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); end; end; procedure TfrmMGFYBBMXGL.TBCloseClick(Sender: TObject); begin WriteCxGrid('报关主表' + self.Caption, Tv1, '描稿费用明细报表'); // WriteCxGrid('报关明细' + self.Caption, Tv2, '报关管理8'); Close; end; procedure TfrmMGFYBBMXGL.FormShow(Sender: TObject); begin ReadCxGrid('报关主表' + self.Caption, Tv1, '描稿费用明细报表'); // ReadCxGrid('报关明细' + self.Caption, Tv2, '报关管理8'); canshu1 := Trim(DParameters1); // ShowMessage(canshu1); InitGrid(); TBFind.Click(); RM1.CanExport := true; end; procedure TfrmMGFYBBMXGL.TBExportClick(Sender: TObject); begin if ADOQueryMain.IsEmpty then exit; // TcxGridToExcel(Trim(CDS_Main.fieldbyname('A4FPNO').AsString) + Trim(CDS_Main.fieldbyname('A5ConNO').AsString), cxGrid1); end; procedure TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.N1Click(Sender: TObject); begin SelOKNo(CDS_Main, True); end; procedure TfrmMGFYBBMXGL.N2Click(Sender: TObject); begin SelOKNo(CDS_Main, False); end; procedure TfrmMGFYBBMXGL.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; function TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.FactoryNameChange(Sender: TObject); begin TBFind.Click; end; procedure TfrmMGFYBBMXGL.cxTabControl1Change(Sender: TObject); begin InitGrid(); end; procedure TfrmMGFYBBMXGL.CRTypeChange(Sender: TObject); begin TBFind.Click; end; procedure TfrmMGFYBBMXGL.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; sql.Add(fsj); Open; end; SCreateCDS20(ADOQueryMain, CDS_Main); SInitCDSData20(ADOQueryMain, CDS_Main); finally ADOQueryMain.EnableControls; end; end; procedure TfrmMGFYBBMXGL.Tv1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin InitSubGrid(); end; procedure TfrmMGFYBBMXGL.G_ZBFACTORYNAMEKeyPress(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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.YWYChange(Sender: TObject); begin SDofilter(ADOQueryTemp, SGetFilters(Panel1, 3, 1)); SCreateCDS20(ADOQueryTemp, ClientDataSet2); SInitCDSData20(ADOQueryTemp, ClientDataSet2); end; procedure TfrmMGFYBBMXGL.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); begin InitSubGrid(); end; procedure TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.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 TfrmMGFYBBMXGL.ToolButton1Click(Sender: TObject); begin if ADOQueryMain.IsEmpty then exit; // SelExportData(Tv1, ADOQueryMain, '出货清单'); TcxGridToExcel(self.Caption, cxGrid2); end; procedure TfrmMGFYBBMXGL.chkMGFClick(Sender: TObject); begin InitGrid(); end; procedure TfrmMGFYBBMXGL.ToolButton11Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_MGF=''1'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_MGF1').Value := True; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton12Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_XPKPF=''1'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_XPKPF1').Value := True; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton13Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_DYF=''1'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_DYF1').Value := True; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton14Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_DPKPF=''1'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_DPKPF1').Value := True; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton15Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_DWZPF=''1'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_DWZPF1').Value := True; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton16Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_MGQTF=''1'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_MGQTF1').Value := True; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton17Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_DYQTF=''1'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_DYQTF1').Value := True; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton2Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_MGF=''0'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; edit; CDS_Main.fieldbyname('YF_MGF1').Value := False; end; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton3Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_XPKPF=''0'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_XPKPF1').Value := False; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton4Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_DYF=''0'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_DYF1').Value := False; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_DPKPF=''0'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_DPKPF1').Value := False; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton6Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_DWZPF=''0'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_DWZPF1').Value := False; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton7Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_MGQTF=''0'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_MGQTF1').Value := False; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmMGFYBBMXGL.ToolButton8Click(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; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Sketch_Main SET YF_DYQTF=''0'' '); sql.Add('where MGID =' + quotedstr(trim(CDS_Main.fieldbyname('MGID').AsString))); execsql; end; edit; CDS_Main.fieldbyname('YF_DYQTF1').Value := False; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息', 0); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; end.