unit U_DyeSimpleTechnicsList; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB, cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls, cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid, cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit, cxTextEdit, cxPC, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, Menus, U_BaseList, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxScrollbarAnnotations, cxContainer, cxDropDownEdit, cxLabel, cxButtons, cxMemo, U_frameFPList, U_frameGJList, U_frameGDXList, U_frameFSList, U_frameCCQXList, U_frameJGQXList, U_frameRGQXList, U_frameYMList; //U_frameJGQXList, U_frameRGQXList, U_frameCCQXList, U_frameYMList type TfrmDyeSimpleTechnicsList = class(TfrmBaseList) ToolBar1: TToolBar; TBRafresh: TToolButton; TBDel: TToolButton; TBClose: TToolButton; ADOQueryTemp: TADOQuery; ADOQueryCmd: TADOQuery; Panel1: TPanel; ToolButton2: TToolButton; Label1: TLabel; DTMName: TEdit; ADOQueryMain: TADOQuery; Label3: TLabel; DTMNo: TEdit; GPM_2: TcxGridPopupMenu; DS_2: TDataSource; CDS_2: TClientDataSet; cxTabControl1: TcxTabControl; Tchk: TToolButton; TNochk: TToolButton; DS_PsType: TDataSource; CDS_PSType: TClientDataSet; ADOQuery1: TADOQuery; GPM_1: TcxGridPopupMenu; ToolButton3: TToolButton; ToolButton1: TToolButton; ToolButton4: TToolButton; TbSave: TToolButton; Panel2: TPanel; cxGrid2: TcxGrid; Tv2: TcxGridDBTableView; v2Ssel: TcxGridDBColumn; v2GYNO: TcxGridDBColumn; v2GYName: TcxGridDBColumn; v2GYGX: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; Splitter1: TSplitter; ScrollBox1: TScrollBox; Splitter2: TSplitter; Panel3: TPanel; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid9: TcxGrid; Tv3: TcxGridDBTableView; cxGridLevel8: TcxGridLevel; Tv1PSType: TcxGridDBColumn; CDS_GX: TClientDataSet; DS_GX: TDataSource; Tv3PSNO: TcxGridDBColumn; Tv3PSType: TcxGridDBColumn; Tv3PSName: TcxGridDBColumn; Tv3PSID: TcxGridDBColumn; Tv2DTMID: TcxGridDBColumn; ToolBar2: TToolBar; ToolButton5: TToolButton; Tv2Editer: TcxGridDBColumn; Tv2Edittime: TcxGridDBColumn; ToolButton6: TToolButton; Tv3Page: TcxGridDBColumn; GPM_3: TcxGridPopupMenu; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBCloseClick(Sender: TObject); procedure TBDelClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure DTMNoChange(Sender: TObject); procedure TchkClick(Sender: TObject); procedure TNochkClick(Sender: TObject); procedure cxTabControl1Change(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure cxGridDBColumn1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); procedure ButtonEdit(Sender: TObject; AButtonIndex: Integer); procedure Tv1DblClick(Sender: TObject); procedure TbSaveClick(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure DTMNameKeyPress(Sender: TObject; var Key: Char); procedure DTMNoKeyPress(Sender: TObject; var Key: Char); private { Private declarations } procedure InitGrid(); procedure SetStatus(); procedure InitPSTypeGrid(); procedure InitGlide(); procedure InitGXDetails(); procedure CloseAllFrames(); function SaveData(): Boolean; function GetNextFrameTop: Integer; // function SaveData(): Boolean; procedure FillAllTextEditsWithValue(AParent: TWinControl; const AHint, AValue: string; AExclude: TcxTextEdit = nil); procedure ClearAllTextEditsByHint(AParent: TWinControl; const AHint: string; AExclude: TcxTextEdit = nil); function FindLastEditedTextEdit(AParent: TWinControl; const AHint: string): string; procedure SetXH(); public fPSIDList: string; fmanage: string; end; var frmDyeSimpleTechnicsList: TfrmDyeSimpleTechnicsList; frameFPList1, frameFPList2, frameFPList3: tframeFPList; frameGJList1, frameGJList2, frameGJList3: tframeGJList; frameFSList1, frameFSList2, frameFSList3: tframeFSList; frameGDXList1, frameGDXList2, frameGDXList3: TframeGDXList; frameJGQXList1, frameJGQXList2, frameJGQXList3: TframeJGQXList; frameRGQXList1, frameRGQXList2, frameRGQXList3: TframeRGQXList; frameCCQXList1, frameCCQXList2, frameCCQXList3: TframeCCQXList; frameYMList1, frameYMList2, frameYMList3: TframeYMList; implementation uses U_DataLink, U_RTFun, U_ZDYHelp, U_DyeTechnicsinput, U_DyeProcessDefin; {$R *.dfm} procedure TfrmDyeSimpleTechnicsList.SetXH(); var i: Integer; begin with CDS_GX do begin First; i := 1; while not Eof do begin with CDS_GX do begin Edit; FieldByName('XHNoTemp').Value := i; Post; end; i := i + 1; Next; end; end; with CDS_GX do begin CDS_GX.IndexFieldNames := ''; First; i := 1; while not Eof do begin with CDS_GX do begin Edit; FieldByName('PSNO').Value := FieldByName('XHNoTemp').AsInteger; Post; end; i := i + 1; Next; end; CDS_GX.IndexFieldNames := 'PSNO'; end; end; procedure TfrmDyeSimpleTechnicsList.SetStatus(); var i: integer; begin Tchk.Visible := false; TNochk.Visible := false; TBDel.Visible := false; // Panel_zm.Visible := False; // Panel_ccqx.Visible := False; // Panel_rgqx.Visible := False; // Panel_jgqx.Visible := False; // Panel_dx.Visible := False; // Panel_FS.Visible := False; // Panel_GJ.Visible := False; // Panel_FP.Visible := False; // for i := 0 to tv2.ColumnCount - 1 do // begin // if uppercase(tv2.Columns[i].DataBinding.FieldName) <> 'SSEL' then // tv2.Columns[i].Options.Editing := false; // end; if cxTabControl1.TabIndex = 0 then begin Tchk.Visible := true; TBDel.Visible := true; end; if cxTabControl1.TabIndex = 1 then begin TNochk.Visible := true; end; if cxTabControl1.TabIndex = 2 then begin end; end; procedure TfrmDyeSimpleTechnicsList.InitGrid(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; SQL.Clear; sql.Add(' select * FROM Dye_Technics_Main'); if cxTabControl1.TabIndex < 2 then sql.Add(' where isnull(status,''0'')=''' + inttostr(cxTabControl1.TabIndex) + ''' '); // ShowMessage(SQL.Text); Open; end; SCreateCDS(ADOQueryMain, CDS_2); SInitCDSData(ADOQueryMain, CDS_2); // ShowMessage(ADOQueryMain.FieldByName('DTMID').AsString); // ShowMessage(CDS_2.FieldByName('DTMID').AsString); finally ADOQueryMain.EnableControls; //CDS_1.EmptyDataSet; end; end; function TfrmDyeSimpleTechnicsList.SaveData(): Boolean; var MaxProcessID, MaxBCPID, MaxPSID, MaxDTMID, mDTMID, DTMPSlist: string; maxsubid1, maxsubid2, maxsubid3, maxsubid4, maxsubid5, maxsubid6, mmaxgx, maxId, mPSID, mPSType: string; begin try ADOQueryCmd.Connection.BeginTrans; CDS_GX.First; while not CDS_GX.Eof do begin mPSID := CDS_GX.FieldByName('PSID').AsString; mPSType := CDS_GX.FieldByName('PSType').AsString; mDTMID := CDS_2.FieldByName('DTMID').AsString; ///////////////////////////保存主表Dye_process//////////////////////////// with ADOQueryCmd do begin Filtered := False; Close; SQL.Clear; sql.Add(' select * from Dye_Process where PSID=''' + Trim(mPSID) + ''''); Open; end; with ADOQueryCmd do begin if Trim(CDS_GX.fieldbyname('PSID').AsString) = '' then begin if GetLSNo(ADOQueryCmd, maxId, 'JP', 'Dye_Process', 4, 1) = False then begin Result := False; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!', '提示', 0); Exit; end; end else begin maxId := Trim(mPSID); end; with CDS_GX do begin Edit; FieldByName('PSID').Value := maxId; Post; end; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from Dye_Process where PSID=''' + Trim(maxId) + ''''); Open; end; with ADOQueryCmd do begin if Trim(mPSID) = '' then begin Append; FieldByName('Filler').Value := Trim(DName); end else begin Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp); end; FieldByName('PSID').Value := Trim(maxId); FieldByName('DTMID').Value := Trim(CDS_2.FieldByName('DTMID').AsString); FieldByName('PSType').Value := Trim(mPSType); FieldByName('PSName').Value := Trim(CDS_GX.FieldByName('PSName').AsString); FieldByName('DTMName').Value := Trim(CDS_2.FieldByName('DTMName').AsString); Post; end; end; ///////////////////保存主表Dye_process//////////////////////////// if mPSType = '长车清洗' then begin if CDS_GX.FieldByName('page').AsString = 'frameCCQXList1' then begin frameCCQXList1.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameCCQXList2' then begin frameCCQXList2.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameCCQXList3' then begin frameCCQXList3.SaveData(maxId); end; end else if mPSType = '卷染缸清洗' then begin if CDS_GX.FieldByName('page').AsString = 'frameRGQXList1' then begin frameRGQXList1.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameRGQXList2' then begin frameRGQXList2.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameRGQXList3' then begin frameRGQXList3.SaveData(maxId); end; end else if mPSType = '机缸清洗' then begin if CDS_GX.FieldByName('page').AsString = 'frameJGQXList1' then begin frameJGQXList1.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameJGQXList2' then begin frameJGQXList2.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameJGQXList3' then begin frameJGQXList3.SaveData(maxId); end; end else if mPSType = '干定型' then begin if CDS_GX.FieldByName('page').AsString = 'frameGDXList1' then begin frameGDXList1.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameGDXList2' then begin frameGDXList2.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameGDXList3' then begin frameGDXList3.SaveData(maxId); end; end else if mPSType = '下水定型' then begin if CDS_GX.FieldByName('page').AsString = 'frameFSList1' then begin frameFSList1.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameFSList2' then begin frameFSList2.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameFSList3' then begin frameFSList3.SaveData(maxId); end; end else if mPSType = '发泡' then begin if CDS_GX.FieldByName('page').AsString = 'frameFPList1' then begin frameFPList1.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameFPList2' then begin frameFPList2.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameFPList3' then begin frameFPList3.SaveData(maxId); end; end else if mPSType = '刮胶' then begin if CDS_GX.FieldByName('page').AsString = 'frameGJList1' then begin frameGJList1.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameGJList2' then begin frameGJList2.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameGJList3' then begin frameGJList3.SaveData(maxId); end; end else if mPSType = '轧毛' then begin if CDS_GX.FieldByName('page').AsString = 'frameYMList1' then begin frameYMList1.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameYMList2' then begin frameYMList2.SaveData(maxId); end else if CDS_GX.FieldByName('page').AsString = 'frameYMList3' then begin frameYMList3.SaveData(maxId); end; end; CDS_GX.Next; end; if Trim(mDTMID) = '' then begin if GetLSNo(ADOQueryCmd, MaxDTMID, 'GY', 'Dye_Technics_Main', 3, 1) = False then raise Exception.Create('取最大号失败!'); end else begin MaxDTMID := mDTMID; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete Dye_Technics_Sub where DTMID=' + quotedstr(trim(MaxDTMID))); execsql; end; DTMPSlist := ''; with CDS_GX do begin First; while not Eof do begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('SELECT * FROM Dye_Technics_Sub WHERE 1=2'); Open; end; with ADOQueryCmd do begin Append; FieldByName('PSNO').Value := Trim(CDS_GX.fieldbyname('PSNO').AsString); FieldByName('DTMID').Value := Trim(MaxDTMID); FieldByName('PSId').Value := Trim(CDS_GX.fieldbyname('PSId').AsString); Post; end; if DTMPSlist = '' then begin DTMPSlist := Trim(CDS_GX.fieldbyname('PSNO').AsString) + '.' + Trim(CDS_GX.fieldbyname('PSName').AsString); end else begin DTMPSlist := DTMPSlist + '→' + Trim(CDS_GX.fieldbyname('PSNO').AsString) + '.' + Trim(CDS_GX.fieldbyname('PSName').AsString); end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('SELECT * FROM Dye_Process WHERE PSID = ' + QuotedStr(Trim(CDS_GX.fieldbyname('PSId').AsString))); Open; end; with ADOQueryCmd do begin Edit; FieldByName('DTMName').Value := Trim(CDS_2.FieldByName('DTMName').AsString); FieldByName('DTMID').Value := Trim(MaxDTMID); Post; end; Next; end; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('select * from Dye_Technics_Main where DTMID =' + quotedstr(Trim(MaxDTMID))); Open; end; with ADOQueryCmd do begin if ADOQueryCmd.IsEmpty then begin Append; FieldByName('Filler').Value := Trim(DName); FieldByName('filltime').Value := SGetServerDateTime(ADOQueryTemp); FieldByName('DTMID').Value := Trim(MaxDTMID); end else begin Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp); end; FieldByName('DTMNo').Value := CDS_2.FieldByName('DTMNo').AsString; FieldByName('DTMName').Value := CDS_2.FieldByName('DTMName').AsString; FieldByName('DTMPSlist').Value := Trim(DTMPSlist); Post; end; ADOQueryCmd.Connection.CommitTrans; // FPSID := maxId; Result := True; except Result := False; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('保存失败!', '提示', 0); end; end; procedure TfrmDyeSimpleTechnicsList.InitPSTypeGrid(); begin try ADOQueryCMD.DisableControls; with ADOQueryCMD do begin // Filtered := False; Close; SQL.Clear; sql.Add(' select *,PSXH=0 from Dye_Technics '); Open; end; // SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryCMD, CDS_PSType); SInitCDSData(ADOQueryCMD, CDS_PSType); finally ADOQueryCMD.EnableControls; end; end; procedure TfrmDyeSimpleTechnicsList.InitGlide(); begin try ADOQueryTemp.DisableControls; with ADOQueryTemp do begin Close; SQL.Clear; sql.Add(' select A.* FROM V_Dye_Technics_Details A'); sql.Add(' Where A.DTMID=''' + trim(CDS_2.fieldbyname('DTMID').AsString) + ''''); SQL.Add(' ORDER BY A.PSNO'); Open; end; SCreateCDS(ADOQueryTemp, CDS_GX); SInitCDSData(ADOQueryTemp, CDS_GX); finally ADOQueryTemp.EnableControls; end; end; procedure TfrmDyeSimpleTechnicsList.InitGXDetails(); begin try ADOQueryTemp.DisableControls; CDS_GX.First; while not CDS_GX.eof do begin with ADOQueryTemp do begin Close; SQL.Clear; sql.Add(' select A.* FROM V_Dye_Technics_Details A'); sql.Add(' Where A.PSID=''' + trim(CDS_GX.fieldbyname('PSID').AsString) + ''''); // SQL.Add(' and A.PSID = ''' + trim(CDS_2.fieldbyname('PSID').AsString) + ''''); Open; end; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add(' select A.* FROM BS_Cloth_GY_Sub A'); sql.Add(' Where A.PSID=''' + trim(CDS_GX.fieldbyname('PSID').AsString) + ''''); // SQL.Add(' and A.PSID = ''' + trim(CDS_2.fieldbyname('PSID').AsString) + ''''); Open; end; // ShowMessage(IntToStr(ADOQueryCmd.RecordCount)); if CDS_GX.FieldByName('PSType').AsString = '长车清洗' then begin if self.FindComponent('frameCCQXList1') = nil then begin frameCCQXList1 := TframeCCQXList.Create(self); frameCCQXList1.Name := 'frameCCQXList1'; frameCCQXList1.Parent := self.ScrollBox1; frameCCQXList1.Top := GetNextFrameTop; frameCCQXList1.Visible := True; frameCCQXList1.LabelCCQX.Caption := CDS_GX.FieldByName('PSName').AsString; frameCCQXList1.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameCCQXList1'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameCCQXList1.Panel_ccqx, 2); frameCCQXList1.ccqx_note.Lines.Text := ADOQueryTemp.FieldByName('ccqx_note').AsString; SCreateCDS(ADOQueryCmd, frameCCQXList1.CDS_CCQX); SInitCDSData(ADOQueryCmd, frameCCQXList1.CDS_CCQX); end else if self.FindComponent('frameCCQXList2') = nil then begin frameCCQXList2 := TframeCCQXList.Create(self); frameCCQXList2.Name := 'frameCCQXList2'; frameCCQXList2.Parent := self.ScrollBox1; frameCCQXList2.Top := GetNextFrameTop; frameCCQXList2.Visible := True; frameCCQXList2.LabelCCQX.Caption := CDS_GX.FieldByName('PSName').AsString; frameCCQXList2.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameCCQXList2'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameCCQXList2.Panel_ccqx, 2); frameCCQXList2.ccqx_note.Lines.Text := ADOQueryTemp.FieldByName('ccqx_note').AsString; SCreateCDS(ADOQueryCmd, frameCCQXList2.CDS_CCQX); SInitCDSData(ADOQueryCmd, frameCCQXList2.CDS_CCQX); end else if self.FindComponent('frameCCQXList3') = nil then begin frameCCQXList3 := TframeCCQXList.Create(self); frameCCQXList3.Name := 'frameCCQXList3'; frameCCQXList3.Parent := self.ScrollBox1; frameCCQXList3.Top := GetNextFrameTop; frameCCQXList3.Visible := True; frameCCQXList3.LabelCCQX.Caption := CDS_GX.FieldByName('PSName').AsString; frameCCQXList3.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameCCQXList3'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameCCQXList3.Panel_ccqx, 2); frameCCQXList3.ccqx_note.Lines.Text := ADOQueryTemp.FieldByName('ccqx_note').AsString; SCreateCDS(ADOQueryCmd, frameCCQXList3.CDS_CCQX); SInitCDSData(ADOQueryCmd, frameCCQXList3.CDS_CCQX); end; end else if CDS_GX.FieldByName('PSType').AsString = '卷染缸清洗' then begin if self.FindComponent('frameRGQXList1') = nil then begin frameRGQXList1 := TframeRGQXList.Create(self); frameRGQXList1.Name := 'frameRGQXList1'; frameRGQXList1.Parent := self.ScrollBox1; frameRGQXList1.Top := GetNextFrameTop; frameRGQXList1.Visible := True; frameRGQXList1.LabelRGQX.Caption := CDS_GX.FieldByName('PSName').AsString; frameRGQXList1.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameRGQXList1'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameRGQXList1.Panel_rgqx, 2); frameRGQXList1.rgqx_note.Lines.Text := ADOQueryTemp.FieldByName('rgqx_note').AsString; SCreateCDS(ADOQueryCmd, frameRGQXList1.CDS_rgQX); SInitCDSData(ADOQueryCmd, frameRGQXList1.CDS_RGQX); end else if self.FindComponent('frameRGQXList2') = nil then begin frameRGQXList2 := TframeRGQXList.Create(self); frameRGQXList2.Name := 'frameRGQXList2'; frameRGQXList2.Parent := self.ScrollBox1; frameRGQXList2.Top := GetNextFrameTop; frameRGQXList2.Visible := True; frameRGQXList2.LabelRGQX.Caption := CDS_GX.FieldByName('PSName').AsString; frameRGQXList2.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameRGQXList2'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameRGQXList2.Panel_rgqx, 2); frameRGQXList2.rgqx_note.Lines.Text := ADOQueryTemp.FieldByName('rgqx_note').AsString; SCreateCDS(ADOQueryCmd, frameRGQXList2.CDS_rgQX); SInitCDSData(ADOQueryCmd, frameRGQXList2.CDS_RGQX); end else if self.FindComponent('frameRGQXList3') = nil then begin frameRGQXList3 := TframeRGQXList.Create(self); frameRGQXList3.Name := 'frameRGQXList3'; frameRGQXList3.Parent := self.ScrollBox1; frameRGQXList3.Top := GetNextFrameTop; frameRGQXList3.Visible := True; frameRGQXList3.LabelRGQX.Caption := CDS_GX.FieldByName('PSName').AsString; frameRGQXList3.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameRGQXList3'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameRGQXList3.Panel_rgqx, 2); frameRGQXList3.rgqx_note.Lines.Text := ADOQueryTemp.FieldByName('rgqx_note').AsString; SCreateCDS(ADOQueryCmd, frameRGQXList3.CDS_rgQX); SInitCDSData(ADOQueryCmd, frameRGQXList3.CDS_RGQX); end; end else if CDS_GX.FieldByName('PSType').AsString = '机缸清洗' then begin if self.FindComponent('frameJGQXList1') = nil then begin frameJGQXList1 := TframeJGQXList.Create(self); frameJGQXList1.Name := 'frameJGQXList1'; frameJGQXList1.Parent := self.ScrollBox1; frameJGQXList1.Top := GetNextFrameTop; frameJGQXList1.Visible := True; frameJGQXList1.LabelJGQX.Caption := CDS_GX.FieldByName('PSName').AsString; frameJGQXList1.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameJGQXList1'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameJGQXList1.Panel_jgqx, 2); frameJGQXList1.jgqx_note.Lines.Text := ADOQueryTemp.FieldByName('jgqx_note').AsString; SCreateCDS(ADOQueryCmd, frameJGQXList1.CDS_JGQX); SInitCDSData(ADOQueryCmd, frameJGQXList1.CDS_JGQX); end else if self.FindComponent('frameJGQXList2') = nil then begin frameJGQXList2 := TframeJGQXList.Create(self); frameJGQXList2.Name := 'frameJGQXList2'; frameJGQXList2.Parent := self.ScrollBox1; frameJGQXList2.Top := GetNextFrameTop; frameJGQXList2.Visible := True; frameJGQXList2.LabelJGQX.Caption := CDS_GX.FieldByName('PSName').AsString; frameJGQXList2.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameJGQXList2'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameJGQXList2.Panel_jgqx, 2); frameJGQXList2.jgqx_note.Lines.Text := ADOQueryTemp.FieldByName('jgqx_note').AsString; SCreateCDS(ADOQueryCmd, frameJGQXList2.CDS_JGQX); SInitCDSData(ADOQueryCmd, frameJGQXList2.CDS_JGQX); end else if self.FindComponent('frameJGQXList3') = nil then begin frameJGQXList3 := TframeJGQXList.Create(self); frameJGQXList3.Name := 'frameJGQXList3'; frameJGQXList3.Parent := self.ScrollBox1; frameJGQXList3.Top := GetNextFrameTop; frameJGQXList3.Visible := True; frameJGQXList3.LabelJGQX.Caption := CDS_GX.FieldByName('PSName').AsString; frameJGQXList3.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameJGQXList3'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameJGQXList3.Panel_jgqx, 2); frameJGQXList3.jgqx_note.Lines.Text := ADOQueryTemp.FieldByName('jgqx_note').AsString; SCreateCDS(ADOQueryCmd, frameJGQXList3.CDS_JGQX); SInitCDSData(ADOQueryCmd, frameJGQXList3.CDS_JGQX); end; end else if CDS_GX.FieldByName('PSType').AsString = '干定型' then begin if self.FindComponent('frameGDXList1') = nil then begin frameGDXList1 := TframeGDXList.Create(self); frameGDXList1.Name := 'frameGDXList1'; frameGDXList1.Parent := self.ScrollBox1; frameGDXList1.Top := GetNextFrameTop; frameGDXList1.Visible := True; frameGDXList1.LabelGDX.Caption := CDS_GX.FieldByName('PSName').AsString; frameGDXList1.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameGDXList1'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameGDXList1.Panel_dx, 2); frameGDXList1.dx_Precautions.Lines.Text := ADOQueryTemp.FieldByName('dx_Precautions').AsString; end else if self.FindComponent('frameGDXList2') = nil then begin frameGDXList2 := TframeGDXList.Create(self); frameGDXList2.Name := 'frameGDXList2'; frameGDXList2.Parent := self.ScrollBox1; frameGDXList2.Top := GetNextFrameTop; frameGDXList2.Visible := True; frameGDXList2.LabelGDX.Caption := CDS_GX.FieldByName('PSName').AsString; frameGDXList2.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameGDXList2'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameGDXList2.Panel_dx, 2); frameGDXList2.dx_Precautions.Lines.Text := ADOQueryTemp.FieldByName('dx_Precautions').AsString; end else if self.FindComponent('frameGDXList3') = nil then begin frameGDXList3 := TframeGDXList.Create(self); frameGDXList3.Name := 'frameGDXList3'; frameGDXList3.Parent := self.ScrollBox1; frameGDXList3.Top := GetNextFrameTop; frameGDXList3.Visible := True; frameGDXList3.LabelGDX.Caption := CDS_GX.FieldByName('PSName').AsString; frameGDXList3.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameGDXList3'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameGDXList3.Panel_dx, 2); frameGDXList3.dx_Precautions.Lines.Text := ADOQueryTemp.FieldByName('dx_Precautions').AsString; end; end else if CDS_GX.FieldByName('PSType').AsString = '下水定型' then begin if self.FindComponent('frameFSList1') = nil then begin frameFSList1 := tframeFSList.Create(self); frameFSList1.Name := 'frameFSList1'; frameFSList1.Parent := self.ScrollBox1; frameFSList1.Top := GetNextFrameTop; frameFSList1.Visible := True; frameFSList1.LabelFS.Caption := CDS_GX.FieldByName('PSName').AsString; frameFSList1.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameFSList1'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameFSList1.Panel_fs, 2); frameFSList1.fs_Precautions.Lines.Text := ADOQueryTemp.FieldByName('fs_Precautions').AsString; SCreateCDS(ADOQueryCmd, frameFSList1.CDS_fS); SInitCDSData(ADOQueryCmd, frameFSList1.CDS_fS); end else if self.FindComponent('frameFSList2') = nil then begin frameFSList2 := tframeFSList.Create(self); frameFSList2.Name := 'frameFSList2'; frameFSList2.Parent := self.ScrollBox1; frameFSList2.Top := GetNextFrameTop; frameFSList2.Visible := True; frameFSList2.LabelFS.Caption := CDS_GX.FieldByName('PSName').AsString; frameFSList2.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameFSList2'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameFSList2.Panel_fs, 2); frameFSList2.fs_Precautions.Lines.Text := ADOQueryTemp.FieldByName('fs_Precautions').AsString; SCreateCDS(ADOQueryCmd, frameFSList2.CDS_fS); SInitCDSData(ADOQueryCmd, frameFSList2.CDS_fS); end else if self.FindComponent('frameFSList3') = nil then begin frameFSList3 := tframeFSList.Create(self); frameFSList3.Name := 'frameFSList3'; frameFSList3.Parent := self.ScrollBox1; frameFSList3.Top := GetNextFrameTop; frameFSList3.Visible := True; frameFSList3.LabelFS.Caption := CDS_GX.FieldByName('PSName').AsString; frameFSList3.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameFSList3'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameFSList3.Panel_fs, 2); frameFSList3.fs_Precautions.Lines.Text := ADOQueryTemp.FieldByName('fs_Precautions').AsString; SCreateCDS(ADOQueryCmd, frameFSList3.CDS_fS); SInitCDSData(ADOQueryCmd, frameFSList3.CDS_fS); end end else if CDS_GX.FieldByName('PSType').AsString = '发泡' then begin if self.FindComponent('frameFPList1') = nil then begin frameFPList1 := TframeFPList.Create(self); frameFPList1.Name := 'frameFPList1'; frameFPList1.Parent := self.ScrollBox1; frameFPList1.Top := GetNextFrameTop; frameFPList1.Visible := True; frameFPList1.LabelFP.Caption := CDS_GX.FieldByName('PSName').AsString; frameFPList1.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameFPList1'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameFPList1.Panel_fp, 2); frameFPList1.fp_Precautions.Lines.Text := ADOQueryTemp.FieldByName('fp_Precautions').AsString; SCreateCDS(ADOQueryCmd, frameFPList1.CDS_FP); SInitCDSData(ADOQueryCmd, frameFPList1.CDS_FP); end else if self.FindComponent('frameFPList2') = nil then begin frameFPList2 := TframeFPList.Create(self); frameFPList2.Name := 'frameFPList2'; frameFPList2.Parent := self.ScrollBox1; frameFPList2.Top := GetNextFrameTop; frameFPList2.Visible := True; frameFPList2.LabelFP.Caption := CDS_GX.FieldByName('PSName').AsString; frameFPList2.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameFPList2'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameFPList2.Panel_fp, 2); frameFPList2.fp_Precautions.Lines.Text := ADOQueryTemp.FieldByName('fp_Precautions').AsString; SCreateCDS(ADOQueryCmd, frameFPList2.CDS_FP); SInitCDSData(ADOQueryCmd, frameFPList2.CDS_FP); end else if self.FindComponent('frameFPList3') = nil then begin frameFPList3 := TframeFPList.Create(self); frameFPList3.Name := 'frameFPList3'; frameFPList3.Parent := self.ScrollBox1; frameFPList3.Top := GetNextFrameTop; frameFPList3.Visible := True; frameFPList3.LabelFP.Caption := CDS_GX.FieldByName('PSName').AsString; frameFPList3.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameFPList3'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameFPList3.Panel_fp, 2); frameFPList3.fp_Precautions.Lines.Text := ADOQueryTemp.FieldByName('fp_Precautions').AsString; SCreateCDS(ADOQueryCmd, frameFPList3.CDS_FP); SInitCDSData(ADOQueryCmd, frameFPList3.CDS_FP); end; end else if CDS_GX.FieldByName('PSType').AsString = '刮胶' then begin if self.FindComponent('frameGJList1') = nil then begin frameGJList1 := TframeGJList.Create(self); frameGJList1.Name := 'frameGJList1'; frameGJList1.Parent := self.ScrollBox1; frameGJList1.Top := GetNextFrameTop; frameGJList1.Visible := True; frameGJList1.LabelGJ.Caption := CDS_GX.FieldByName('PSName').AsString; frameGJList1.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameGJList1'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameGJList1.Panel_gj, 2); frameGJList1.gj_Precautions.Lines.Text := ADOQueryTemp.FieldByName('gj_Precautions').AsString; SCreateCDS(ADOQueryCmd, frameGJList1.CDS_GJ); SInitCDSData(ADOQueryCmd, frameGJList1.CDS_GJ); end else if self.FindComponent('frameGJList2') = nil then begin frameGJList2 := TframeGJList.Create(self); frameGJList2.Name := 'frameGJList2'; frameGJList2.Parent := self.ScrollBox1; frameGJList2.Top := GetNextFrameTop; frameGJList2.Visible := True; frameGJList2.LabelGJ.Caption := CDS_GX.FieldByName('PSName').AsString; frameGJList2.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameGJList2'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameGJList2.Panel_gj, 2); frameGJList2.gj_Precautions.Lines.Text := ADOQueryTemp.FieldByName('gj_Precautions').AsString; SCreateCDS(ADOQueryCmd, frameGJList2.CDS_GJ); SInitCDSData(ADOQueryCmd, frameGJList2.CDS_GJ); end else if self.FindComponent('frameGJList3') = nil then begin frameGJList3 := TframeGJList.Create(self); frameGJList3.Name := 'frameGJList3'; frameGJList3.Parent := self.ScrollBox1; frameGJList3.Top := GetNextFrameTop; frameGJList3.Visible := True; frameGJList3.LabelGJ.Caption := CDS_GX.FieldByName('PSName').AsString; frameGJList3.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameGJList3'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameGJList3.Panel_gj, 2); frameGJList3.gj_Precautions.Lines.Text := ADOQueryTemp.FieldByName('gj_Precautions').AsString; SCreateCDS(ADOQueryCmd, frameGJList3.CDS_GJ); SInitCDSData(ADOQueryCmd, frameGJList3.CDS_GJ); end; end else if CDS_GX.FieldByName('PSType').AsString = '轧毛' then begin if self.FindComponent('frameYMList1') = nil then begin frameYMList1 := TframeYMList.Create(self); frameYMList1.Name := 'frameYMList1'; frameYMList1.Parent := self.ScrollBox1; frameYMList1.Top := GetNextFrameTop; frameYMList1.Visible := True; frameYMList1.LabelYM.Caption := CDS_GX.FieldByName('PSName').AsString; frameYMList1.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameYMList1'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameYMList1.Panel_zm, 2); frameYMList1.zm_Precautions.Lines.Text := ADOQueryTemp.FieldByName('zm_Precautions').AsString; end else if self.FindComponent('frameYMList2') = nil then begin frameYMList2 := TframeYMList.Create(self); frameYMList2.Name := 'frameYMList2'; frameYMList2.Parent := self.ScrollBox1; frameYMList2.Top := GetNextFrameTop; frameYMList2.Visible := True; frameYMList2.LabelYM.Caption := CDS_GX.FieldByName('PSName').AsString; frameYMList2.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameYMList2'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameYMList2.Panel_zm, 2); frameYMList2.zm_Precautions.Lines.Text := ADOQueryTemp.FieldByName('zm_Precautions').AsString; end else if self.FindComponent('frameYMList3') = nil then begin frameYMList3 := TframeYMList.Create(self); frameYMList3.Name := 'frameYMList3'; frameYMList3.Parent := self.ScrollBox1; frameYMList3.Top := GetNextFrameTop; frameYMList3.Visible := True; frameYMList3.LabelYM.Caption := CDS_GX.FieldByName('PSName').AsString; frameYMList3.InitGrid(); CDS_GX.Edit; CDS_GX.FieldByName('page').AsString := 'frameYMList3'; CDS_GX.Post; SCSHData(ADOQueryTemp, frameYMList3.Panel_zm, 2); frameYMList3.zm_Precautions.Lines.Text := ADOQueryTemp.FieldByName('zm_Precautions').AsString; end; end; CDS_GX.Next; end; finally ADOQueryTemp.EnableControls; end; end; procedure TfrmDyeSimpleTechnicsList.CloseAllFrames(); var i: Integer; Component: TComponent; begin // 关闭所有 GDXList 框架 for i := 1 to 3 do begin Component := self.FindComponent('frameGDXList' + IntToStr(i)); if Component <> nil then begin TFrame(Component).Free; end; end; // 关闭所有 FSList 框架 for i := 1 to 3 do begin Component := self.FindComponent('frameFSList' + IntToStr(i)); if Component <> nil then begin TFrame(Component).Free; end; end; // 关闭所有 FPList 框架 for i := 1 to 3 do begin Component := self.FindComponent('frameFPList' + IntToStr(i)); if Component <> nil then begin TFrame(Component).Free; end; end; // 关闭所有 GJList 框架 for i := 1 to 3 do begin Component := self.FindComponent('frameGJList' + IntToStr(i)); if Component <> nil then begin TFrame(Component).Free; end; end; for i := 1 to 3 do begin Component := self.FindComponent('frameCCQXList' + IntToStr(i)); if Component <> nil then begin TFrame(Component).Free; end; end; for i := 1 to 3 do begin Component := self.FindComponent('frameRGQXList' + IntToStr(i)); if Component <> nil then begin TFrame(Component).Free; end; end; for i := 1 to 3 do begin Component := self.FindComponent('frameJGQXList' + IntToStr(i)); if Component <> nil then begin TFrame(Component).Free; end; end; for i := 1 to 3 do begin Component := self.FindComponent('frameYMList' + IntToStr(i)); if Component <> nil then begin TFrame(Component).Free; end; end; end; procedure TfrmDyeSimpleTechnicsList.FormDestroy(Sender: TObject); begin inherited; frmDyeSimpleTechnicsList := nil; end; procedure TfrmDyeSimpleTechnicsList.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_ESCAPE then // VK_ESCAPE 是 ESC 键的常量 begin Key := 0; // 清除按键,防止继续传递 Close; // 或者 ModalResult := mrCancel; end; end; procedure TfrmDyeSimpleTechnicsList.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := caFree; end; procedure TfrmDyeSimpleTechnicsList.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmDyeSimpleTechnicsList.TBDelClick(Sender: TObject); begin if CDS_2.IsEmpty then Exit; if CDS_2.Locate('ssel', true, []) = false then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; try ADOQueryCmd.Connection.BeginTrans; with CDS_2 do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('delete Dye_Technics_Main where DTMID=''' + Trim(CDS_2.fieldbyname('DTMID').AsString) + ''''); sql.Add('delete Dye_Technics_Sub where DTMID=''' + Trim(CDS_2.fieldbyname('DTMID').AsString) + ''''); execsql; end; // CDS_1.First; // while not CDS_1.Eof do // begin // with ADOQueryCmd do // begin // close; // sql.Clear; // sql.Add('delete Dye_Process where PSID=''' + Trim(CDS_1.fieldbyname('PSID').AsString) + ''''); // sql.Add('delete BS_Cloth_GY_Sub where PSID=''' + Trim(CDS_1.fieldbyname('PSID').AsString) + ''''); // sql.Add('delete BS_Cloth_GY_Main where PSID=''' + Trim(CDS_1.fieldbyname('PSID').AsString) + ''''); // // execsql; // end; // CDS_1.Next; // end; end; next; end; First; EnableControls; end; InitGrid(); ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmDyeSimpleTechnicsList.FormShow(Sender: TObject); begin inherited; ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, '简易工艺管理'); ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, '简易工艺管理'); ReadCxGrid(trim(self.Caption) + 'Tv3', Tv3, '简易工艺管理'); SetStatus(); InitGrid(); KeyPreview := True; end; procedure TfrmDyeSimpleTechnicsList.TBRafreshClick(Sender: TObject); begin InitGrid(); end; procedure TfrmDyeSimpleTechnicsList.TbSaveClick(Sender: TObject); begin if SaveData() then begin Application.MessageBox('保存成功!', '提示', 0); end; end; procedure TfrmDyeSimpleTechnicsList.ToolButton1Click(Sender: TObject); begin CDS_2.Append; tv2.Columns[1].Options.Editing := true; tv2.Columns[2].Options.Editing := true; end; procedure TfrmDyeSimpleTechnicsList.ToolButton2Click(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, CDS_2); SInitCDSData(ADOQueryMain, CDS_2); end; end; procedure TfrmDyeSimpleTechnicsList.ToolButton3Click(Sender: TObject); begin WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, '简易工艺管理'); WriteCxGrid(trim(self.Caption) + 'Tv2', Tv2, '简易工艺管理'); WriteCxGrid(trim(self.Caption) + 'Tv3', Tv3, '简易工艺管理'); end; procedure TfrmDyeSimpleTechnicsList.ToolButton4Click(Sender: TObject); begin InitPSTypeGrid(); tv2.Columns[1].Options.Editing := true; tv2.Columns[2].Options.Editing := true; end; procedure TfrmDyeSimpleTechnicsList.ToolButton5Click(Sender: TObject); begin if CDS_GX.IsEmpty then begin Exit; end; if (CDS_GX.FieldByName('PSID').asString = '') or (CDS_GX.FieldByName('PSID').asString = null) then begin CDS_GX.Delete; // InitGXDetails(); end else begin Application.MessageBox('已保存工序不能删除!', '提示信息', MB_OK); end; SetXH(); end; procedure TfrmDyeSimpleTechnicsList.ToolButton6Click(Sender: TObject); begin CloseAllFrames(); InitGXDetails(); end; procedure TfrmDyeSimpleTechnicsList.Tv1DblClick(Sender: TObject); begin with CDS_GX do begin Append; FieldByName('PSNO').Value := CDS_GX.RecordCount + 1; FieldByName('PSType').Value := CDS_PSType.fieldbyname('PSType').AsString; FieldByName('PSId').Value := ''; post; end; // InitGXDetails(); end; procedure TfrmDyeSimpleTechnicsList.Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); begin CloseAllFrames(); SetStatus(); InitGlide(); // InitGXDetails(); // ShowMessage(CDS_2.FieldByName('DTMID').AsString); if (CDS_2.FieldByName('DTMID').AsString = '') or (CDS_2.FieldByName('DTMID').AsString = null) then begin InitPSTypeGrid(); end else begin ADOQueryCMD.DisableControls; with ADOQueryCMD do begin // Filtered := False; Close; SQL.Clear; sql.Add(' select *,PSXH=0 from Dye_Technics where 1 = 2 '); Open; end; // SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryCMD, CDS_PSType); SInitCDSData(ADOQueryCMD, CDS_PSType); end; end; procedure TfrmDyeSimpleTechnicsList.ButtonEdit(Sender: TObject; AButtonIndex: Integer); begin try frmDyeProcessDefin := TfrmDyeProcessDefin.Create(Application); with frmDyeProcessDefin do begin FPSType := self.CDS_GX.FieldByName('PSType').Value; FPSID := Self.CDS_GX.FieldByName('PSID').Value; BtnInt := 3;//查看 TbSave.visible := false; TbUpFile.Visible := False; if ShowModal = 1 then begin end; end; finally frmDyeProcessDefin.Free; end; end; procedure TfrmDyeSimpleTechnicsList.DTMNameKeyPress(Sender: TObject; var Key: Char); begin ToolButton2.Click; end; procedure TfrmDyeSimpleTechnicsList.DTMNoChange(Sender: TObject); begin ToolButton2.Click; end; procedure TfrmDyeSimpleTechnicsList.DTMNoKeyPress(Sender: TObject; var Key: Char); begin ToolButton2.Click; end; procedure TfrmDyeSimpleTechnicsList.TchkClick(Sender: TObject); begin if CDS_2.IsEmpty then exit; if CDS_2.Locate('ssel', true, []) = false then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_2 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 Dye_Technics_Main SET status=''1'' '); sql.Add('where DTMID =' + quotedstr(trim(CDS_2.fieldbyname('DTMID').AsString))); execsql; end; end; next; end; First; EnableControls; end; InitGrid(); ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmDyeSimpleTechnicsList.TNochkClick(Sender: TObject); begin if CDS_2.IsEmpty then exit; if CDS_2.Locate('ssel', true, []) = false then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_2 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 Dye_Technics_Main SET status=''0'' '); sql.Add('where DTMID =' + quotedstr(trim(CDS_2.fieldbyname('DTMID').AsString))); execsql; end; end; next; end; First; EnableControls; end; InitGrid(); ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmDyeSimpleTechnicsList.cxGridDBColumn1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmDyeProcessDefin := TfrmDyeProcessDefin.Create(Application); with frmDyeProcessDefin do begin // FPSType := self.CDS_1.FieldByName('PSType').Value; // FPSID := Self.CDS_1.FieldByName('PSID').Value; BtnInt := 3;//查看 TbSave.visible := false; TbUpFile.Visible := False; if ShowModal = 1 then begin end; end; finally frmDyeProcessDefin.Free; end; end; procedure TfrmDyeSimpleTechnicsList.cxTabControl1Change(Sender: TObject); begin SetStatus(); InitGrid(); end; procedure TfrmDyeSimpleTechnicsList.FormCreate(Sender: TObject); begin inherited; fmanage := Trim(DParameters1); end; procedure TfrmDyeSimpleTechnicsList.FillAllTextEditsWithValue(AParent: TWinControl; const AHint, AValue: string; AExclude: TcxTextEdit = nil); // 可选:排除特定控件 var i: Integer; AControl: TControl; ATextEdit: TcxTextEdit; begin for i := 0 to AParent.ControlCount - 1 do begin AControl := AParent.Controls[i]; if (AControl is TcxTextEdit) and ((AControl as TcxTextEdit).Text = '') then begin ATextEdit := AControl as TcxTextEdit; if (ATextEdit.Hint = AHint) and (ATextEdit <> AExclude) then ATextEdit.Text := AValue; end; end; end; procedure TfrmDyeSimpleTechnicsList.ClearAllTextEditsByHint(AParent: TWinControl; const AHint: string; AExclude: TcxTextEdit = nil); var i: Integer; AControl: TControl; begin for i := 0 to AParent.ControlCount - 1 do begin AControl := AParent.Controls[i]; // 检查是否是 TcxTextEdit,并且 Hint 匹配,且不是排除的控件 if (AControl is TcxTextEdit) and (TcxTextEdit(AControl).Hint = AHint) and (TcxTextEdit(AControl) <> AExclude) then begin TcxTextEdit(AControl).Text := ''; // 直接清空 end; end; end; function TfrmDyeSimpleTechnicsList.FindLastEditedTextEdit(AParent: TWinControl; const AHint: string): string; var i, j: Integer; AControl: TControl; SortedControls: TList; TempControl: TControl; begin Result := ''; // 如果没有子控件,直接返回空 if AParent.ControlCount = 0 then Exit; // 使用 TList 存储控件(兼容旧版 Delphi) SortedControls := TList.Create; try // 将所有子控件添加到列表 for i := 0 to AParent.ControlCount - 1 do SortedControls.Add(AParent.Controls[i]); // 手动排序:按 Top(Y坐标)和 Left(X坐标)升序排列 for i := 0 to SortedControls.Count - 1 do begin for j := i + 1 to SortedControls.Count - 1 do begin // 比较两个控件的 Top 和 Left if (TControl(SortedControls[i]).Top > TControl(SortedControls[j]).Top) or ((TControl(SortedControls[i]).Top = TControl(SortedControls[j]).Top) and (TControl(SortedControls[i]).Left > TControl(SortedControls[j]).Left)) then begin // 交换位置 TempControl := TControl(SortedControls[i]); SortedControls[i] := SortedControls[j]; SortedControls[j] := TempControl; end; end; end; // 遍历排序后的控件 for i := 0 to SortedControls.Count - 1 do begin AControl := TControl(SortedControls[i]); if (AControl is TcxTextEdit) and (TcxTextEdit(AControl).Hint = AHint) and (TcxTextEdit(AControl).Text <> '') then begin Result := TcxTextEdit(AControl).Text; // 最后一个符合条件的会被保留 end; end; finally SortedControls.Free; end; end; function TfrmDyeSimpleTechnicsList.GetNextFrameTop: Integer; var i: Integer; Ctrl: TControl; MaxBottom: Integer; begin MaxBottom := 0; // 如果没有任何控件,从 0 开始 if ScrollBox1.ControlCount = 1 then begin Result := 0; Exit; end; for i := 0 to ScrollBox1.ControlCount - 1 do begin Ctrl := ScrollBox1.Controls[i]; if (Ctrl is TFrame) and Ctrl.Visible then begin // 计算当前 frame 的底部位置 var BottomPos := Ctrl.Top + Ctrl.Height; if BottomPos > MaxBottom then MaxBottom := BottomPos; end; end; // 添加一些间距 Result := MaxBottom + 5; end; end.