unit U_DyePCList; 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, MovePanel, cxButtonEdit, cxCalendar, RM_System, RM_Common, RM_Class, RM_GridReport, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseList, dxScrollbarAnnotations; type TfrmDyePCList = class(TfrmBaseList) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBExport: TToolButton; TBPrint: TToolButton; TBClose: TToolButton; Panel1: TPanel; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DataSource1: TDataSource; cxGridPopupMenu1: TcxGridPopupMenu; Label3: TLabel; pcid: TEdit; CDS_Main: TClientDataSet; MovePanel2: TMovePanel; RMGridReport1: TRMGridReport; customerNoName: TEdit; Label13: TLabel; ywy: TEdit; Label17: TLabel; lbHx: TEdit; Label7: TLabel; ToolButton1: TToolButton; dbGrid1: TcxGrid; tv1: TcxGridDBTableView; tv1CraftIdx: TcxGridDBColumn; tv1mcName: TcxGridDBColumn; tv1CCQX1: TcxGridDBColumn; tv1DX1: TcxGridDBColumn; tv1DX2: TcxGridDBColumn; tv1DX3: TcxGridDBColumn; tv1DX4: TcxGridDBColumn; tv1DX5: TcxGridDBColumn; tv1DX6: TcxGridDBColumn; tv1JG1: TcxGridDBColumn; tv1JRG1: TcxGridDBColumn; tv1JRG2: TcxGridDBColumn; tv1JRG3: TcxGridDBColumn; tv1GC_BatchNo: TcxGridDBColumn; tv1CurGlideName: TcxGridDBColumn; tv1Note: TcxGridDBColumn; dbGrid1Level1: TcxGridLevel; ToolButton2: TToolButton; BegDate: TDateTimePicker; EndDate: TDateTimePicker; Label1: TLabel; Label2: TLabel; tv1PCKey: TcxGridDBColumn; BegTime: TDateTimePicker; EndTime: TDateTimePicker; 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 pcidChange(Sender: TObject); procedure PRTColorChange(Sender: TObject); procedure TBdelClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure tv1JRG1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1JRG2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure tv1CCQX1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1DX1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1DX2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1DX3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1DX4CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1DX5CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1DX6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1JG1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1JRG3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure tv1DX1StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1CCQX1StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1DX2StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1DX3StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1DX4StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1DX5StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1DX6StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1JG1StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1JRG1StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1JRG2StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); procedure tv1JRG3StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); private FLeft, FTop: Integer; procedure InitGrid(); { Private declarations } public fsyrName, canshu1: string; { Public declarations } end; var frmDyePCList: TfrmDyePCList; implementation uses U_DataLink, U_RTFun, U_ZDYHelp, U_MachTaskList; {$R *.dfm} procedure TfrmDyePCList.FormDestroy(Sender: TObject); begin inherited; frmDyePCList := nil; end; procedure TfrmDyePCList.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := caFree; end; procedure TfrmDyePCList.FormCreate(Sender: TObject); begin inherited; // EndDate.DateTime := SGetServerDateTime(ADOQueryTemp); // BegDate.DateTime := EndDate.DateTime; fsyrName := trim(DdataBase); canshu1 := trim(DParameters1); // SInitComBoxBySql(ADOQueryTemp, GlideName, false, 'select PSName as Name from Dye_Process'); end; procedure TfrmDyePCList.InitGrid(); var mBegDate, mendDate: string; mAction: string; rs: _Recordset; r: integer; begin // 任务时间 try tv1.BeginUpdate; ADOQueryMain.DisableControls; with ADOQueryMain do begin close; filtered := false; sql.Clear; SQL.Add('select * from PCAboutTime where time between :StartTime and :EndTime order By Time'); Parameters.ParamByName('StartTime').Value := Trunc(BegDate.Date) + Frac(BegTime.Time); Parameters.ParamByName('EndTime').Value := Trunc(EndDate.Date) + Frac(EndTime.Time); Open; end; SCreateCDS(ADOQueryMain, CDS_main); SInitCDSData(ADOQueryMain, CDS_main); finally ADOQueryMain.EnableControls; tv1.EndUpdate; // tv1.ApplyBestFit(); end; end; procedure TfrmDyePCList.TBRafreshClick(Sender: TObject); begin MovePanel2.Visible := True; MovePanel2.Refresh; InitGrid(); MovePanel2.Visible := False; end; procedure TfrmDyePCList.ToolButton1Click(Sender: TObject); begin WriteCxGrid(self.Caption + tv1.Name, Tv1, '排产信息'); end; procedure TfrmDyePCList.ToolButton2Click(Sender: TObject); begin // if ADOQuerymain.IsEmpty then // exit; frmMachTaskList := TfrmMachTaskList.create(self); with frmMachTaskList do begin // fcurMachId := trim(self.adoquerymain.FieldByName('mcid').AsString); // machName.text := trim(self.adoquerymain.FieldByName('mcName').AsString); showModal; free; end; initgrid(); end; procedure TfrmDyePCList.tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin // if ADOQuerymain.IsEmpty then // exit; frmMachTaskList := TfrmMachTaskList.create(self); with frmMachTaskList do begin fBegTime := Self.CDS_Main.FieldByName('time').AsString; fMCName := Self.Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName; fText := self.CDS_Main.FieldByName(fMCName).AsString; showModal; free; end; initgrid(); end; procedure TfrmDyePCList.tv1DX5CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1DX5.Index] = ARow2.Values[tv1DX5.Index]) and (ARow1.Values[tv1DX5.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1DX5StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1DX5.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.tv1DX2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1DX2.Index] = ARow2.Values[tv1DX2.Index]) and (ARow1.Values[tv1DX2.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1DX2StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1DX2.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.tv1DX3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1DX3.Index] = ARow2.Values[tv1DX3.Index]) and (ARow1.Values[tv1DX3.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1DX3StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1DX3.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.tv1DX1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1DX1.Index] = ARow2.Values[tv1DX1.Index]) and (ARow1.Values[tv1DX1.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1DX1StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1DX1.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; //procedure TfrmDyePCList.tv1DX1StylesGetContentStyle( // Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; // AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); //begin // if ARecord <> nil then // begin // if ARecord.RecordIndex mod 2 = 0 then // begin // // 偶数行:白色背景 // AStyle := TcxStyle.Create(nil); // AStyle.Color := clWhite; // AStyle.TextColor := clBlack; // end // else // begin // // 奇数行:浅灰色背景 // AStyle := TcxStyle.Create(nil); // AStyle.Color := $00FFF5E1; // 浅灰色 // AStyle.TextColor := clBlack; // end; // end; //end; procedure TfrmDyePCList.tv1CCQX1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1CCQX1.Index] = ARow2.Values[tv1CCQX1.Index]) and (ARow1.Values[tv1CCQX1.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1CCQX1StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1CCQX1.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.tv1DX4CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1DX4.Index] = ARow2.Values[tv1DX4.Index]) and (ARow1.Values[tv1DX4.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1DX4StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1DX4.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.tv1DX6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1DX6.Index] = ARow2.Values[tv1DX6.Index]) and (ARow1.Values[tv1DX6.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1DX6StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1DX6.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.tv1JG1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1JG1.Index] = ARow2.Values[tv1JG1.Index]) and (ARow1.Values[tv1JG1.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1JG1StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1JG1.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.tv1JRG1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1JRG1.Index] = ARow2.Values[tv1JRG1.Index]) and (ARow1.Values[tv1JRG1.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1JRG1StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1JRG1.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.tv1JRG2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1JRG2.Index] = ARow2.Values[tv1JRG2.Index]) and (ARow1.Values[tv1JRG2.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1JRG2StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1JRG2.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.tv1JRG3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin if (ARow1.Values[tv1JRG3.Index] = ARow2.Values[tv1JRG3.Index]) and (ARow1.Values[tv1JRG3.Index] <> NULL) then AAreEqual := True else AAreEqual := False; end; procedure TfrmDyePCList.tv1JRG3StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var GroupValue: string; ColorValue: Integer; I: Integer; begin if (ARecord <> nil) and (ARecord is TcxGridDataRow) then begin GroupValue := VarToStr(ARecord.Values[tv1JRG3.Index]); if (GroupValue <> '') and (GroupValue <> null) then begin // 基于每个字符的位置和值计算哈希 ColorValue := StrToInt(Copy(GroupValue, Length(GroupValue), 1)); AStyle := TcxStyle.Create(nil); case ColorValue mod 3 of 0: AStyle.Color := $00CCFFFF; // 淡黄色 1: AStyle.Color := $00CCFFCC; // 淡绿色 2: AStyle.Color := $00FFCCCC; // 淡蓝色 end; AStyle.TextColor := clBlack; end; end; end; procedure TfrmDyePCList.ConNoMChange(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); end; end; procedure TfrmDyePCList.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmDyePCList.FormShow(Sender: TObject); begin inherited; ReadCxGrid(self.Caption + tv1.Name, Tv1, '排产信息'); canshu1 := self.fParameters1; // BegDate.DateTime := strToDateTime(FormatDateTime('yyyy-MM-dd 00:00:00', SGetServerDate(ADOQueryTemp))) - 1; // EndDate.DateTime := strToDateTime(FormatDateTime('yyyy-MM-dd 00:00:00', SGetServerDate(ADOQueryTemp))) + 1; var ServerDate: TDateTime := SGetServerDate(ADOQueryTemp); BegDate.Date := Trunc(ServerDate) - 1; // 前一天 EndDate.Date := Trunc(ServerDate) + 1; // 后一天 BegTime.Time := EncodeTime(0, 0, 0, 0); // 早上8点 endTime.Time := EncodeTime(0, 0, 0, 0); // 晚上6点 initgrid(); end; procedure TfrmDyePCList.TBExportClick(Sender: TObject); begin if ADOQueryMain.IsEmpty then exit; // SelExportData(tv1,ADOQueryMain,self.Caption); TcxGridToExcel(self.Caption, DBGrid1); end; procedure TfrmDyePCList.TBFindClick(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, CDS_Main); SInitCDSData(ADOQueryMain, CDS_Main); end; end; procedure TfrmDyePCList.pcidChange(Sender: TObject); begin TBFind.Click; end; procedure TfrmDyePCList.PRTColorChange(Sender: TObject); begin TBFind.Click; end; procedure TfrmDyePCList.TBdelClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; try with ADOQueryCmd do begin Close; sql.Clear; sql.Add('insert into Dye_Need_Up(UType,UDataId) values(''机台刷卡'',' + quotedstr(Trim(CDS_Main.fieldbyname('GOID').AsString)) + ') '); sql.Add('delete Dye_Plan_Glide_OutPut where GOID=''' + Trim(CDS_Main.fieldbyname('GOID').AsString) + ''''); ExecSQL; end; ////////////////// 更新进度 ////////////////// with ADOQueryCmd do begin Close; sql.Clear; sql.Add('exec P_Dye_Card_upCL @PCID=' + QuotedStr(CDS_Main.fieldbyname('pcid').AsString)); execsql; end; ////////////////// 更新进度 ////////////////// CDS_Main.Delete; except application.MessageBox('删除失败!', '提示信息', 0); end; end; end.