unit U_DyeProcessDefinKaika;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
  cxEdit, DB, cxDBData, ADODB, DBClient, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
  cxGrid, ComCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, cxTextEdit,
  cxButtonEdit, StdCtrls, ExtCtrls, cxCurrencyEdit, BtnEdit, U_BaseList,
  cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters,
  cxNavigator, dxDateRanges, dxBarBuiltInMenu, cxCheckBox, cxDropDownEdit,
  dxSkinBasic, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel,
  dxSkinCoffee, dxSkinDarkroom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
  dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
  dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinOffice2016Colorful,
  dxSkinOffice2016Dark, dxSkinOffice2019Black, dxSkinOffice2019Colorful,
  dxSkinOffice2019DarkGray, dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven,
  dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
  dxSkinSpringtime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
  dxSkinTheBezier, dxSkinValentine, dxSkinVisualStudio2013Blue,
  dxSkinVisualStudio2013Dark, dxSkinVisualStudio2013Light, dxSkinVS2010,
  dxSkinWhiteprint, dxSkinWXI, dxSkinXmas2008Blue, cxContainer, cxLabel, cxPC,
  dxScrollbarAnnotations, cxMaskEdit, Vcl.Menus, cxButtons;

type
  TfrmDyeProcessDefinKaika = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    ADOQueryCmd: TADOQuery;
    ADOQueryTemp: TADOQuery;
    CDS_1: TClientDataSet;
    DS_1: TDataSource;
    GPM_1: TcxGridPopupMenu;
    cxPageControl1: TcxPageControl;
    cxTabSheet2: TcxTabSheet;
    DX: TcxTabSheet;
    cxTabSheet4: TcxTabSheet;
    cxTabSheet5: TcxTabSheet;
    cxTabSheet6: TcxTabSheet;
    Panel2: TPanel;
    cxLabel10: TcxLabel;
    cxLabel11: TcxLabel;
    cxLabel12: TcxLabel;
    cxLabel13: TcxLabel;
    cxLabel14: TcxLabel;
    cxLabel15: TcxLabel;
    cxLabel16: TcxLabel;
    cxLabel17: TcxLabel;
    cxLabel18: TcxLabel;
    cxLabel19: TcxLabel;
    cxLabel20: TcxLabel;
    cxLabel7: TcxLabel;
    cxLabel8: TcxLabel;
    cxLabel9: TcxLabel;
    qx_WaterContentDQ: TcxTextEdit;
    qx_Add_NameDQ: TcxTextEdit;
    qx_speedDQ: TcxTextEdit;
    qx_ReduceAmplitudeDQ: TcxTextEdit;
    Panel_dx: TPanel;
    cxLabel2: TcxLabel;
    cxLabel21: TcxLabel;
    cxLabel22: TcxLabel;
    cxLabel23: TcxLabel;
    cxLabel24: TcxLabel;
    cxLabel25: TcxLabel;
    cxLabel3: TcxLabel;
    cxLabel4: TcxLabel;
    cxLabel5: TcxLabel;
    cxLabel55: TcxLabel;
    cxLabel56: TcxLabel;
    cxLabel57: TcxLabel;
    cxLabel58: TcxLabel;
    cxLabel6: TcxLabel;
    cxLabel60: TcxLabel;
    cxLabel61: TcxLabel;
    cxLabel62: TcxLabel;
    cxLabel63: TcxLabel;
    cxLabel64: TcxLabel;
    cxLabel65: TcxLabel;
    dx_temperature1: TcxTextEdit;
    dx_temperature5: TcxTextEdit;
    dx_temperature9: TcxTextEdit;
    dx_RosePower: TcxTextEdit;
    dx_upperNeedle: TcxTextEdit;
    dx_Precautions: TcxTextEdit;
    dx_UpSuperRate: TcxTextEdit;
    dx_speed: TcxTextEdit;
    dx_TubePress: TcxTextEdit;
    dx_temperature6: TcxTextEdit;
    dx_DownSuperRate: TcxTextEdit;
    dx_temperature3: TcxTextEdit;
    dx_temperature4: TcxTextEdit;
    dx_temperature7: TcxTextEdit;
    dx_temperature8: TcxTextEdit;
    dx_temperature10: TcxTextEdit;
    dx_temperature2: TcxTextEdit;
    Panel4: TPanel;
    cxLabel100: TcxLabel;
    cxLabel101: TcxLabel;
    cxLabel102: TcxLabel;
    cxLabel103: TcxLabel;
    cxLabel104: TcxLabel;
    cxLabel105: TcxLabel;
    cxLabel106: TcxLabel;
    cxLabel109: TcxLabel;
    cxLabel110: TcxLabel;
    cxLabel111: TcxLabel;
    cxLabel82: TcxLabel;
    cxLabel83: TcxLabel;
    cxLabel84: TcxLabel;
    cxLabel85: TcxLabel;
    cxLabel86: TcxLabel;
    cxLabel87: TcxLabel;
    cxLabel88: TcxLabel;
    cxLabel89: TcxLabel;
    cxLabel90: TcxLabel;
    cxLabel91: TcxLabel;
    cxLabel92: TcxLabel;
    cxLabel93: TcxLabel;
    cxLabel94: TcxLabel;
    cxLabel95: TcxLabel;
    cxLabel96: TcxLabel;
    cxLabel97: TcxLabel;
    cxLabel98: TcxLabel;
    cxLabel99: TcxLabel;
    fs_OutFanSpeedDQ: TcxTextEdit;
    fs_WidthAmplitudeDQ: TcxTextEdit;
    fs_RosePowerDQ: TcxTextEdit;
    fs_BrushSuperRateDQ: TcxTextEdit;
    fs_UpSuperRateDQ: TcxTextEdit;
    fs_speedDQ: TcxTextEdit;
    fs_TubePressDQ: TcxTextEdit;
    fs_CycleFanSpeedDQ: TcxTextEdit;
    fs_DownSuperRateDQ: TcxTextEdit;
    fs_CarPressDQ: TcxTextEdit;
    fs_PressWaterContentDQ: TcxTextEdit;
    Panel5: TPanel;
    cxLabel107: TcxLabel;
    cxLabel108: TcxLabel;
    cxLabel112: TcxLabel;
    cxLabel29: TcxLabel;
    cxLabel30: TcxLabel;
    cxLabel31: TcxLabel;
    cxLabel32: TcxLabel;
    cxLabel33: TcxLabel;
    cxLabel34: TcxLabel;
    cxLabel35: TcxLabel;
    cxLabel36: TcxLabel;
    cxLabel49: TcxLabel;
    cxLabel50: TcxLabel;
    cxLabel51: TcxLabel;
    cxLabel52: TcxLabel;
    cxLabel53: TcxLabel;
    cxLabel54: TcxLabel;
    cxLabel66: TcxLabel;
    cxLabel67: TcxLabel;
    cxLabel68: TcxLabel;
    cxLabel69: TcxLabel;
    cxLabel70: TcxLabel;
    cxLabel71: TcxLabel;
    cxLabel72: TcxLabel;
    cxLabel73: TcxLabel;
    cxLabel74: TcxLabel;
    cxLabel75: TcxLabel;
    cxLabel76: TcxLabel;
    cxLabel77: TcxLabel;
    cxLabel78: TcxLabel;
    cxLabel79: TcxLabel;
    cxLabel80: TcxLabel;
    cxLabel81: TcxLabel;
    fp_OutFanSpeedDQ: TcxTextEdit;
    fp_WidthAmplitudeDQ: TcxTextEdit;
    fp_RosePowerDQ: TcxTextEdit;
    fp_BrushSuperRateDQ: TcxTextEdit;
    fp_UpSuperRateDQ: TcxTextEdit;
    fp_speedDQ: TcxTextEdit;
    fp_TubePressDQ: TcxTextEdit;
    fp_CycleFanSpeedDQ: TcxTextEdit;
    fp_DownSuperRateDQ: TcxTextEdit;
    fp_LeftHeightDQ: TcxTextEdit;
    fp_RightHeightDQ: TcxTextEdit;
    fp_PumbMixElectricFrequency: TcxTextEdit;
    fp_SystemPress: TcxTextEdit;
    fp_MixElectricFrequency: TcxTextEdit;
    fp_GasFlow: TcxTextEdit;
    Panel6: TPanel;
    cxLabel116: TcxLabel;
    cxLabel117: TcxLabel;
    cxLabel118: TcxLabel;
    cxLabel119: TcxLabel;
    cxLabel120: TcxLabel;
    cxLabel121: TcxLabel;
    cxLabel122: TcxLabel;
    cxLabel123: TcxLabel;
    cxLabel124: TcxLabel;
    cxLabel125: TcxLabel;
    cxLabel126: TcxLabel;
    cxLabel127: TcxLabel;
    cxLabel128: TcxLabel;
    cxLabel129: TcxLabel;
    cxLabel130: TcxLabel;
    cxLabel131: TcxLabel;
    cxLabel132: TcxLabel;
    cxLabel133: TcxLabel;
    cxLabel134: TcxLabel;
    cxLabel135: TcxLabel;
    cxLabel136: TcxLabel;
    cxLabel137: TcxLabel;
    cxLabel138: TcxLabel;
    cxLabel139: TcxLabel;
    cxLabel140: TcxLabel;
    cxLabel141: TcxLabel;
    cxLabel142: TcxLabel;
    cxLabel143: TcxLabel;
    gj_WidthAmplitudeDQ: TcxTextEdit;
    gj_RosePowerDQ: TcxTextEdit;
    gj_BrushSuperRateDQ: TcxTextEdit;
    gj_UpSuperRateDQ: TcxTextEdit;
    gj_speedDQ: TcxTextEdit;
    gj_TubePressDQ: TcxTextEdit;
    gj_CycleFanSpeedDQ: TcxTextEdit;
    gj_DownSuperRateDQ: TcxTextEdit;
    gj_LeftHeightDQ: TcxTextEdit;
    gj_RightHeightDQ: TcxTextEdit;
    gj_OutFanSpeedDQ: TcxTextEdit;
    cxtabsheet7: TcxTabSheet;
    panel7: TPanel;
    cxLabel115: TcxLabel;
    cxLabel144: TcxLabel;
    cxLabel145: TcxLabel;
    cxLabel146: TcxLabel;
    cxLabel147: TcxLabel;
    cxLabel154: TcxLabel;
    cxLabel155: TcxLabel;
    cxLabel156: TcxLabel;
    zm_inoutSpeedDQ: TcxTextEdit;
    zm_needleDQ: TcxTextEdit;
    zm_PrecautionsDQ: TcxTextEdit;
    zm_frequencyDQ: TcxTextEdit;
    zm_WidthAmplitudeDQ: TcxTextEdit;
    cxLabel148: TcxLabel;
    qx_Add_NumberDQ: TcxTextEdit;
    cxLabel149: TcxLabel;
    GPM_2: TcxGridPopupMenu;
    DS_2: TDataSource;
    cds_2: TClientDataSet;
    GPM_3: TcxGridPopupMenu;
    DS_3: TDataSource;
    CDS_3: TClientDataSet;
    GPM_4: TcxGridPopupMenu;
    dx_RollMethod: TcxComboBox;
    fs_UnpackingMethodDQ: TcxComboBox;
    fs_OpenAmplitudeDQ: TcxComboBox;
    fs_RollMethodDQ: TcxComboBox;
    zm_UnpackingMethodDQ: TcxComboBox;
    zm_RollMethodDQ: TcxComboBox;
    cxLabel151: TcxLabel;
    cxLabel152: TcxLabel;
    cxLabel153: TcxLabel;
    cxLabel157: TcxLabel;
    cxLabel158: TcxLabel;
    fs_meterDQ: TcxTextEdit;
    fs_useGlubDQ: TcxTextEdit;
    fs_waterDistributionDQ: TcxTextEdit;
    fs_useOneGlubDQ: TcxTextEdit;
    fs_useOneMeterDQ: TcxTextEdit;
    cxLabel159: TcxLabel;
    fp_useOneMeterDQ: TcxTextEdit;
    cxLabel160: TcxLabel;
    fp_useOneGlubDQ: TcxTextEdit;
    cxLabel161: TcxLabel;
    gj_useOneMeterDQ: TcxTextEdit;
    cxLabel162: TcxLabel;
    gj_useOneGlubDQ: TcxTextEdit;
    qx_UnpackingMethodDQ: TcxComboBox;
    qx_RollMethodDQ: TcxComboBox;
    zm_wagClothDQ: TcxTextEdit;
    fp_RollMethodDQ: TcxComboBox;
    fp_UnpackingMethodDQ: TcxComboBox;
    gj_RollMethodDQ: TcxComboBox;
    gj_UnpackingMethodDQ: TcxComboBox;
    fp_OpenAmplitudeDQ: TcxComboBox;
    gj_OpenAmplitudeDQ: TcxComboBox;
    TbDXReplace2: TcxButton;
    TbDXClear2: TcxButton;
    Panel1: TPanel;
    GYNAME: TcxTextEdit;
    cxLabel43: TcxLabel;
    CDS_HZ: TClientDataSet;
    DS_HZ: TDataSource;
    Label5: TLabel;
    WorkHour: TEdit;
    Label2: TLabel;
    MachineName: TEdit;
    Label1: TLabel;
    note: TEdit;
    CCQX: TcxTabSheet;
    RGQX: TcxTabSheet;
    cxLabel174: TcxLabel;
    dx_tubeTemper: TcxTextEdit;
    cxLabel1: TcxLabel;
    cxLabel28: TcxLabel;
    cxLabel59: TcxLabel;
    cxLabel175: TcxLabel;
    cxLabel176: TcxLabel;
    cxLabel177: TcxLabel;
    cxLabel178: TcxLabel;
    cxLabel179: TcxLabel;
    cxLabel180: TcxLabel;
    cxLabel181: TcxLabel;
    cxLabel182: TcxLabel;
    dx_hotWind1: TcxTextEdit;
    dx_hotWind5: TcxTextEdit;
    dx_hotWind9: TcxTextEdit;
    dx_hotWind6: TcxTextEdit;
    dx_hotWind3: TcxTextEdit;
    dx_hotWind4: TcxTextEdit;
    dx_hotWind7: TcxTextEdit;
    dx_hotWind8: TcxTextEdit;
    dx_hotWind10: TcxTextEdit;
    dx_hotWind2: TcxTextEdit;
    TbDXReplace1: TcxButton;
    TbDXClear1: TcxButton;
    cxLabel183: TcxLabel;
    cxLabel184: TcxLabel;
    cxLabel185: TcxLabel;
    cxLabel186: TcxLabel;
    cxLabel187: TcxLabel;
    dx_rowWind1: TcxTextEdit;
    dx_rowWind3: TcxTextEdit;
    dx_rowWind4: TcxTextEdit;
    dx_rowWind2: TcxTextEdit;
    cxLabel188: TcxLabel;
    dx_hotWind11: TcxTextEdit;
    cxLabel189: TcxLabel;
    dx_temperature11: TcxTextEdit;
    FS: TcxTabSheet;
    FP: TcxTabSheet;
    GJ: TcxTabSheet;
    JGQX: TcxTabSheet;
    ZM: TcxTabSheet;
    Panel_FP: TPanel;
    TbFPReplace2: TcxButton;
    TbFPClear2: TcxButton;
    TbFPReplace1: TcxButton;
    TbFPClear1: TcxButton;
    cxLabel283: TcxLabel;
    cxLabel284: TcxLabel;
    cxLabel285: TcxLabel;
    cxLabel286: TcxLabel;
    cxLabel287: TcxLabel;
    cxLabel288: TcxLabel;
    cxLabel290: TcxLabel;
    cxLabel291: TcxLabel;
    cxLabel292: TcxLabel;
    cxLabel293: TcxLabel;
    cxLabel294: TcxLabel;
    cxLabel295: TcxLabel;
    cxLabel296: TcxLabel;
    cxLabel297: TcxLabel;
    cxLabel298: TcxLabel;
    cxLabel299: TcxLabel;
    cxLabel300: TcxLabel;
    cxLabel301: TcxLabel;
    cxLabel302: TcxLabel;
    cxLabel303: TcxLabel;
    cxLabel304: TcxLabel;
    cxLabel305: TcxLabel;
    cxLabel306: TcxLabel;
    cxLabel307: TcxLabel;
    cxLabel308: TcxLabel;
    cxLabel309: TcxLabel;
    cxLabel310: TcxLabel;
    cxLabel311: TcxLabel;
    cxLabel312: TcxLabel;
    cxLabel313: TcxLabel;
    cxLabel314: TcxLabel;
    cxLabel315: TcxLabel;
    cxLabel316: TcxLabel;
    cxLabel317: TcxLabel;
    cxLabel318: TcxLabel;
    cxLabel319: TcxLabel;
    cxLabel320: TcxLabel;
    cxLabel321: TcxLabel;
    cxLabel322: TcxLabel;
    cxLabel323: TcxLabel;
    cxLabel324: TcxLabel;
    cxLabel325: TcxLabel;
    cxLabel326: TcxLabel;
    cxLabel327: TcxLabel;
    fp_CarPress: TcxTextEdit;
    fp_DownSuperRate: TcxTextEdit;
    fp_fallCloth: TcxTextEdit;
    fp_hotWind1: TcxTextEdit;
    fp_hotWind10: TcxTextEdit;
    fp_hotWind11: TcxTextEdit;
    fp_hotWind2: TcxTextEdit;
    fp_hotWind3: TcxTextEdit;
    fp_hotWind4: TcxTextEdit;
    fp_hotWind5: TcxTextEdit;
    fp_hotWind6: TcxTextEdit;
    fp_hotWind7: TcxTextEdit;
    fp_hotWind8: TcxTextEdit;
    fp_hotWind9: TcxTextEdit;
    fp_leftGap: TcxTextEdit;
    fp_Precautions: TcxTextEdit;
    fp_rightGap: TcxTextEdit;
    fp_Rolling: TcxTextEdit;
    fp_RollMethod: TcxComboBox;
    fp_RosePower: TcxTextEdit;
    fp_rowWind1: TcxTextEdit;
    fp_rowWind2: TcxTextEdit;
    fp_rowWind3: TcxTextEdit;
    fp_rowWind4: TcxTextEdit;
    fp_speed: TcxTextEdit;
    fp_temperature1: TcxTextEdit;
    fp_temperature10: TcxTextEdit;
    fp_temperature11: TcxTextEdit;
    fp_temperature2: TcxTextEdit;
    fp_temperature3: TcxTextEdit;
    fp_temperature4: TcxTextEdit;
    fp_temperature5: TcxTextEdit;
    fp_temperature6: TcxTextEdit;
    fp_temperature7: TcxTextEdit;
    fp_temperature8: TcxTextEdit;
    fp_temperature9: TcxTextEdit;
    fp_TubePress: TcxTextEdit;
    fp_tubeTemper: TcxTextEdit;
    fp_upperNeedle: TcxTextEdit;
    fp_UpSuperRate: TcxTextEdit;
    Panel_gj: TPanel;
    TbGJReplace1: TcxButton;
    TbGjClear1: TcxButton;
    cxLabel233: TcxLabel;
    cxLabel241: TcxLabel;
    cxLabel242: TcxLabel;
    cxLabel243: TcxLabel;
    cxLabel244: TcxLabel;
    cxLabel245: TcxLabel;
    cxLabel246: TcxLabel;
    cxLabel248: TcxLabel;
    cxLabel254: TcxLabel;
    cxLabel255: TcxLabel;
    cxLabel256: TcxLabel;
    cxLabel257: TcxLabel;
    cxLabel258: TcxLabel;
    cxLabel259: TcxLabel;
    cxLabel260: TcxLabel;
    cxLabel261: TcxLabel;
    cxLabel262: TcxLabel;
    cxLabel263: TcxLabel;
    cxLabel264: TcxLabel;
    cxLabel265: TcxLabel;
    cxLabel266: TcxLabel;
    cxLabel267: TcxLabel;
    cxLabel268: TcxLabel;
    cxLabel269: TcxLabel;
    cxLabel270: TcxLabel;
    cxLabel271: TcxLabel;
    cxLabel272: TcxLabel;
    cxLabel274: TcxLabel;
    cxLabel275: TcxLabel;
    cxLabel276: TcxLabel;
    cxLabel277: TcxLabel;
    gj_CarPress: TcxTextEdit;
    gj_DownSuperRate: TcxTextEdit;
    gj_fallCloth: TcxTextEdit;
    gj_hotWind1: TcxTextEdit;
    gj_hotWind10: TcxTextEdit;
    gj_hotWind11: TcxTextEdit;
    gj_hotWind2: TcxTextEdit;
    gj_hotWind3: TcxTextEdit;
    gj_hotWind4: TcxTextEdit;
    gj_hotWind5: TcxTextEdit;
    gj_hotWind6: TcxTextEdit;
    gj_hotWind7: TcxTextEdit;
    gj_hotWind8: TcxTextEdit;
    gj_hotWind9: TcxTextEdit;
    gj_leftGap: TcxTextEdit;
    gj_Precautions: TcxTextEdit;
    gj_rightGap: TcxTextEdit;
    gj_Rolling: TcxTextEdit;
    gj_RollMethod: TcxComboBox;
    gj_RosePower: TcxTextEdit;
    gj_rowWind1: TcxTextEdit;
    gj_rowWind2: TcxTextEdit;
    gj_rowWind3: TcxTextEdit;
    gj_rowWind4: TcxTextEdit;
    gj_TubePress: TcxTextEdit;
    gj_tubeTemper: TcxTextEdit;
    gj_upperNeedle: TcxTextEdit;
    gj_UpSuperRate: TcxTextEdit;
    Panel_fs: TPanel;
    TbFSReplace1: TcxButton;
    TbFSClear1: TcxButton;
    TbFSReplace2: TcxButton;
    TBFScLEAR2: TcxButton;
    cxLabel191: TcxLabel;
    cxLabel192: TcxLabel;
    cxLabel193: TcxLabel;
    cxLabel194: TcxLabel;
    cxLabel195: TcxLabel;
    cxLabel196: TcxLabel;
    cxLabel198: TcxLabel;
    cxLabel199: TcxLabel;
    cxLabel200: TcxLabel;
    cxLabel201: TcxLabel;
    cxLabel202: TcxLabel;
    cxLabel203: TcxLabel;
    cxLabel204: TcxLabel;
    cxLabel205: TcxLabel;
    cxLabel206: TcxLabel;
    cxLabel207: TcxLabel;
    cxLabel208: TcxLabel;
    cxLabel209: TcxLabel;
    cxLabel210: TcxLabel;
    cxLabel211: TcxLabel;
    cxLabel212: TcxLabel;
    cxLabel213: TcxLabel;
    cxLabel214: TcxLabel;
    cxLabel215: TcxLabel;
    cxLabel216: TcxLabel;
    cxLabel217: TcxLabel;
    cxLabel218: TcxLabel;
    cxLabel219: TcxLabel;
    cxLabel220: TcxLabel;
    cxLabel221: TcxLabel;
    cxLabel222: TcxLabel;
    cxLabel223: TcxLabel;
    cxLabel224: TcxLabel;
    cxLabel225: TcxLabel;
    cxLabel226: TcxLabel;
    cxLabel227: TcxLabel;
    cxLabel228: TcxLabel;
    cxLabel229: TcxLabel;
    cxLabel230: TcxLabel;
    cxLabel231: TcxLabel;
    fs_CarPress: TcxTextEdit;
    fs_DownSuperRate: TcxTextEdit;
    fs_hotWind1: TcxTextEdit;
    fs_hotWind10: TcxTextEdit;
    fs_hotWind11: TcxTextEdit;
    fs_hotWind2: TcxTextEdit;
    fs_hotWind3: TcxTextEdit;
    fs_hotWind4: TcxTextEdit;
    fs_hotWind5: TcxTextEdit;
    fs_hotWind6: TcxTextEdit;
    fs_hotWind7: TcxTextEdit;
    fs_hotWind8: TcxTextEdit;
    fs_hotWind9: TcxTextEdit;
    fs_Precautions: TcxTextEdit;
    fs_RollMethod: TcxComboBox;
    fs_RosePower: TcxTextEdit;
    fs_rowWind1: TcxTextEdit;
    fs_rowWind2: TcxTextEdit;
    fs_rowWind3: TcxTextEdit;
    fs_rowWind4: TcxTextEdit;
    fs_speed: TcxTextEdit;
    fs_temperature1: TcxTextEdit;
    fs_temperature10: TcxTextEdit;
    fs_temperature11: TcxTextEdit;
    fs_temperature2: TcxTextEdit;
    fs_temperature3: TcxTextEdit;
    fs_temperature4: TcxTextEdit;
    fs_temperature5: TcxTextEdit;
    fs_temperature6: TcxTextEdit;
    fs_temperature7: TcxTextEdit;
    fs_temperature8: TcxTextEdit;
    fs_temperature9: TcxTextEdit;
    fs_TubePress: TcxTextEdit;
    fs_tubeTemper: TcxTextEdit;
    fs_upperNeedle: TcxTextEdit;
    fs_UpSuperRate: TcxTextEdit;
    Panel_jgqx: TPanel;
    cxLabel340: TcxLabel;
    cxLabel343: TcxLabel;
    cxLabel347: TcxLabel;
    cxLabel348: TcxLabel;
    cxLabel350: TcxLabel;
    cxLabel351: TcxLabel;
    jgqx_keepTemper: TcxTextEdit;
    jgqx_keepTime: TcxTextEdit;
    jgqx_note: TcxTextEdit;
    jgqx_reagentRatio: TcxTextEdit;
    jgqx_reagentUse: TcxTextEdit;
    Panel_rgqx: TPanel;
    cxLabel114: TcxLabel;
    cxLabel150: TcxLabel;
    cxLabel163: TcxLabel;
    cxLabel165: TcxLabel;
    cxLabel166: TcxLabel;
    rgqx_daoSet: TcxTextEdit;
    rgqx_note: TcxTextEdit;
    rgqx_speed: TcxTextEdit;
    rgqx_waterTemper: TcxTextEdit;
    Panel_zm: TPanel;
    cxLabel336: TcxLabel;
    cxLabel337: TcxLabel;
    cxLabel339: TcxLabel;
    cxLabel342: TcxLabel;
    cxLabel344: TcxLabel;
    cxLabel345: TcxLabel;
    zm_inout: TcxTextEdit;
    zm_mainElec: TcxTextEdit;
    zm_needleHigh: TcxTextEdit;
    zm_Precautions: TcxTextEdit;
    zm_style: TcxComboBox;
    Panel_ccqx: TPanel;
    ccqx_note: TcxTextEdit;
    ccqx_speed: TcxTextEdit;
    ccqx_temperature1: TcxTextEdit;
    ccqx_temperature2: TcxTextEdit;
    ccqx_temperature3: TcxTextEdit;
    ccqx_temperature4: TcxTextEdit;
    ccqx_temperature5: TcxTextEdit;
    ccqx_temperature6: TcxTextEdit;
    TbCCQXReplace: TcxButton;
    TbccqxClear: TcxButton;
    cxLabel113: TcxLabel;
    cxLabel38: TcxLabel;
    cxLabel40: TcxLabel;
    cxLabel41: TcxLabel;
    cxLabel42: TcxLabel;
    cxLabel44: TcxLabel;
    cxLabel45: TcxLabel;
    cxLabel46: TcxLabel;
    cxLabel47: TcxLabel;
    cxLabel48: TcxLabel;
    cxLabel37: TcxLabel;
    cxLabel167: TcxLabel;
    cxLabel169: TcxLabel;
    cxLabel170: TcxLabel;
    cxLabel171: TcxLabel;
    cxLabel172: TcxLabel;
    jgqx_leftMouthPress: TcxTextEdit;
    jgqx_rightMouthPress: TcxTextEdit;
    jgqx_mainGangPress: TcxTextEdit;
    jgqx_mainBengSpeed: TcxTextEdit;
    jgqx_rightWheelSpeed: TcxTextEdit;
    jgqx_leftWheelSpeed: TcxTextEdit;
    cxLabel173: TcxLabel;
    cxLabel334: TcxLabel;
    jgqx_upperSpeed: TcxTextEdit;
    jgqx_downSpeed: TcxTextEdit;
    cxLabel338: TcxLabel;
    cxLabel26: TcxLabel;
    cxLabel352: TcxLabel;
    FS_Style: TcxComboBox;
    cxLabel354: TcxLabel;
    fs_isVacuun: TcxComboBox;
    TbFSReplace3: TcxButton;
    TbFSClear3: TcxButton;
    cxLabel27: TcxLabel;
    cxLabel39: TcxLabel;
    cxLabel164: TcxLabel;
    fp_Flow: TcxTextEdit;
    fp_Gas: TcxTextEdit;
    cxLabel168: TcxLabel;
    fp_mixSpeed: TcxTextEdit;
    TbDXReplace3: TcxButton;
    TbDXClear3: TcxButton;
    TbFPReplace3: TcxButton;
    TbFPClear3: TcxButton;
    TbGJReplace3: TcxButton;
    TbGJClear3: TcxButton;
    ToolBar4: TToolBar;
    TbfsAdd: TToolButton;
    TbfsDel: TToolButton;
    cxGrid2: TcxGrid;
    Tv4: TcxGridDBTableView;
    Tv4Column1: TcxGridDBColumn;
    Tv41fs_Name: TcxGridDBColumn;
    Tv41fs_spel: TcxGridDBColumn;
    Tv4fs_unit: TcxGridDBColumn;
    Tv41fs_rate: TcxGridDBColumn;
    Tv41fs_precautions: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    cxGrid3: TcxGrid;
    Tv5: TcxGridDBTableView;
    Tv5Column1: TcxGridDBColumn;
    Tv5gj_Name: TcxGridDBColumn;
    Tv5gj_spel: TcxGridDBColumn;
    Tv5gj_unit: TcxGridDBColumn;
    Tv5gj_rate: TcxGridDBColumn;
    Tv5gj_precautions: TcxGridDBColumn;
    cxGridDBColumn26: TcxGridDBColumn;
    cxGridDBColumn27: TcxGridDBColumn;
    cxGridDBColumn28: TcxGridDBColumn;
    cxGridLevel3: TcxGridLevel;
    ToolBar5: TToolBar;
    TbgjAdd: TToolButton;
    TbgjDel: TToolButton;
    cxGrid1: TcxGrid;
    Tv6: TcxGridDBTableView;
    Tv6Column1: TcxGridDBColumn;
    Tv6fp_Name: TcxGridDBColumn;
    Tv6fp_spel: TcxGridDBColumn;
    Tv6fp_unit: TcxGridDBColumn;
    Tv6fp_rate: TcxGridDBColumn;
    Tv6fp_precautions: TcxGridDBColumn;
    cxGridDBColumn16: TcxGridDBColumn;
    cxGridDBColumn17: TcxGridDBColumn;
    cxGridDBColumn18: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    ToolBar3: TToolBar;
    TbfpAdd: TToolButton;
    TbfpDel: TToolButton;
    cxLabel190: TcxLabel;
    cxLabel197: TcxLabel;
    cxLabel232: TcxLabel;
    cxGrid4: TcxGrid;
    Tv1: TcxGridDBTableView;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridDBColumn2: TcxGridDBColumn;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridDBColumn4: TcxGridDBColumn;
    Tv1ccqx_rate: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    cxGridLevel4: TcxGridLevel;
    ToolBar2: TToolBar;
    TbccqxAdd: TToolButton;
    TbccqxDel: TToolButton;
    cxGrid5: TcxGrid;
    Tv3: TcxGridDBTableView;
    cxGridDBColumn7: TcxGridDBColumn;
    cxGridDBColumn8: TcxGridDBColumn;
    cxGridDBColumn9: TcxGridDBColumn;
    cxGridDBColumn10: TcxGridDBColumn;
    cxGridDBColumn11: TcxGridDBColumn;
    cxGridDBColumn12: TcxGridDBColumn;
    cxGridLevel5: TcxGridLevel;
    ToolBar6: TToolBar;
    TbjgqxAdd: TToolButton;
    TbjgqxDel: TToolButton;
    cxGrid6: TcxGrid;
    Tv2: TcxGridDBTableView;
    cxGridDBColumn13: TcxGridDBColumn;
    cxGridDBColumn14: TcxGridDBColumn;
    cxGridDBColumn15: TcxGridDBColumn;
    cxGridDBColumn19: TcxGridDBColumn;
    cxGridDBColumn20: TcxGridDBColumn;
    cxGridDBColumn21: TcxGridDBColumn;
    cxGridLevel6: TcxGridLevel;
    ToolBar7: TToolBar;
    TbrgqxAdd: TToolButton;
    TbrgqxDel: TToolButton;
    CDS_4: TClientDataSet;
    CDS_5: TClientDataSet;
    DS_4: TDataSource;
    DS_5: TDataSource;
    CDS_6: TClientDataSet;
    DS_6: TDataSource;
    GPM_5: TcxGridPopupMenu;
    GPM_6: TcxGridPopupMenu;
    Tv1ccqx_use: TcxGridDBColumn;
    Tv2Column1: TcxGridDBColumn;
    Tv3Column1: TcxGridDBColumn;
    Tv4fs_use: TcxGridDBColumn;
    Tv5gj_use: TcxGridDBColumn;
    Tv6Column2: TcxGridDBColumn;
    Tv2Column2: TcxGridDBColumn;
    Tv2Column3: TcxGridDBColumn;
    TbGJReplace2: TcxButton;
    TbGJClear2: TcxButton;
    cxLabel234: TcxLabel;
    cxLabel235: TcxLabel;
    cxLabel236: TcxLabel;
    cxLabel237: TcxLabel;
    cxLabel238: TcxLabel;
    cxLabel247: TcxLabel;
    cxLabel249: TcxLabel;
    cxLabel250: TcxLabel;
    cxLabel251: TcxLabel;
    cxLabel252: TcxLabel;
    cxLabel253: TcxLabel;
    cxLabel273: TcxLabel;
    gj_temperature1: TcxTextEdit;
    gj_temperature10: TcxTextEdit;
    gj_temperature11: TcxTextEdit;
    gj_temperature2: TcxTextEdit;
    gj_temperature3: TcxTextEdit;
    gj_temperature4: TcxTextEdit;
    gj_temperature5: TcxTextEdit;
    gj_temperature6: TcxTextEdit;
    gj_temperature7: TcxTextEdit;
    gj_temperature8: TcxTextEdit;
    gj_temperature9: TcxTextEdit;
    cxLabel239: TcxLabel;
    cxLabel240: TcxLabel;
    gj_speed: TcxTextEdit;
    cxLabel278: TcxLabel;
    gj_number: TcxTextEdit;
    fp_gjNumber: TcxTextEdit;
    cxLabel279: TcxLabel;
    procedure FormShow(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);

    procedure CYColorKeyPress(Sender: TObject; var Key: Char);
    procedure CYJGGYBtnDnClick(Sender: TObject);
    procedure C_WidthBtnDnClick(Sender: TObject);
    procedure C_WidthBtnUpClick(Sender: TObject);

    procedure SetXH();

    procedure fs_meterPropertiesChange(Sender: TObject);
    procedure TbfpAddClick(Sender: TObject);
    procedure TbfpDelClick(Sender: TObject);
    procedure Tv2fp_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure TbfsAddClick(Sender: TObject);
    procedure TbfsDelClick(Sender: TObject);
    procedure TbgjAddClick(Sender: TObject);
    procedure TbgjDelClick(Sender: TObject);
    procedure Tv11fs_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv3gj_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure TbCPReplaceClick(Sender: TObject);
    procedure TbDXReplace2Click(Sender: TObject);
    procedure TbFSReplace2Click(Sender: TObject);
    procedure TbFPReplaceClick(Sender: TObject);
    procedure TbGJReplaceClick(Sender: TObject);
    procedure TbFSReplace3Click(Sender: TObject);
    procedure TbFSClear3Click(Sender: TObject);
    procedure TbDXClear2Click(Sender: TObject);
    procedure cxButton4Click(Sender: TObject);
    procedure TbGJClearClick(Sender: TObject);
    procedure TBFScLEAR2Click(Sender: TObject);
    procedure TbCCQXReplaceClick(Sender: TObject);
    procedure TbccqxClearClick(Sender: TObject);
    procedure TbDXReplace1Click(Sender: TObject);
    procedure TbDXClear1Click(Sender: TObject);
    procedure TbFSReplace1Click(Sender: TObject);
    procedure TbFSClear1Click(Sender: TObject);
    procedure TbGJReplace1Click(Sender: TObject);
    procedure TbGJReplace2Click(Sender: TObject);
    procedure TbGjClear1Click(Sender: TObject);
    procedure TbGJClear2Click(Sender: TObject);
    procedure TbFPReplace1Click(Sender: TObject);
    procedure TbFPReplace2Click(Sender: TObject);
    procedure TbFPClear1Click(Sender: TObject);
    procedure TbFPClear2Click(Sender: TObject);
    procedure TbDXReplace3Click(Sender: TObject);
    procedure TbDXClear3Click(Sender: TObject);
    procedure TbFPReplace3Click(Sender: TObject);
    procedure TbFPClear3Click(Sender: TObject);
    procedure TbGJReplace3Click(Sender: TObject);
    procedure TbGJClear3Click(Sender: TObject);
    procedure TbccqxAddClick(Sender: TObject);
    procedure TbrgqxAddClick(Sender: TObject);
    procedure TbjgqxAddClick(Sender: TObject);
    procedure cxGridDBColumn2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure cxGridDBColumn14PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure cxGridDBColumn8PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv41fs_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv5gj_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv6fp_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv6fp_ratePropertiesEditValueChanged(Sender: TObject);
    procedure Tv5gj_unitPropertiesEditValueChanged(Sender: TObject);
    procedure Tv4fs_unitPropertiesEditValueChanged(Sender: TObject);
    procedure cxGridDBColumn11PropertiesEditValueChanged(Sender: TObject);
    procedure cxGridDBColumn20PropertiesEditValueChanged(Sender: TObject);
    procedure cxGridDBColumn5PropertiesEditValueChanged(Sender: TObject);

    procedure Tv1Column1PropertiesEditValueChanged(Sender: TObject);
    procedure TbccqxDelClick(Sender: TObject);
    procedure TbrgqxDelClick(Sender: TObject);
    procedure TbjgqxDelClick(Sender: TObject);
    procedure Tv2Column1PropertiesEditValueChanged(Sender: TObject);
    procedure Tv3Column1PropertiesEditValueChanged(Sender: TObject);
    procedure Tv4fs_usePropertiesEditValueChanged(Sender: TObject);
    procedure Tv5gj_usePropertiesEditValueChanged(Sender: TObject);
    procedure Tv6Column2PropertiesEditValueChanged(Sender: TObject);

  private
    canshu1: string;
    Fint: Integer;
    procedure InitGrid();
    procedure ArrangeTabsByDataset();

    function FindLastEditedTextEdit(AParent: TWinControl; const AHint: string): string;
    procedure FillAllTextEditsWithValue(AParent: TWinControl; const AHint, AValue: string; AExclude: TcxTextEdit = nil);
    procedure ClearAllTextEditsByHint(AParent: TWinControl; const AHint: string; AExclude: TcxTextEdit = nil);

    function AddPercentSuffixIfNeeded(const AText: string): string;
    { Private declarations }
  public
    BtnInt: Integer;
    FPSType: string;
    FPSID: string;

    { Public declarations }
  end;

var
  frmDyeProcessDefinKaika: TfrmDyeProcessDefinKaika;

implementation

uses
  U_DataLink, U_RTFun, U_iniParam, U_ZDYHelp, U_AttachmentUpload, U_ClothInfoSel,
  U_DyeProcessList, U_ProductInfoSel, U_DyeTechnicsinput;
//  U_ProductInfoSel;

{$R *.dfm}

procedure TfrmDyeProcessDefinKaika.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('SerialNo').Value := FieldByName('XHNoTemp').AsInteger;
//        Post;
//      end;
//      i := i + 1;
//      Next;
//    end;
//    CDS_GX.IndexFieldNames := 'SerialNo';
//  end;
end;

procedure TfrmDyeProcessDefinKaika.ArrangeTabsByDataset();
var
  I: Integer;
  TabSheet: TcxTabSheet;
  CurrentIndex: Integer;
begin


  // 初始化隐藏所有其他页面
  for I := 0 to cxPageControl1.PageCount - 1 do
    cxPageControl1.Pages[I].TabVisible := False;

  // 设置当前索引
  CurrentIndex := 0;


    // 根据工序名查找对应的页面

  for I := 0 to cxPageControl1.PageCount - 1 do
  begin
    TabSheet := cxPageControl1.Pages[I] as TcxTabSheet;
      // 匹配工序名
    if (Trim(TabSheet.Caption) = FPSType) then
    begin
      TabSheet.PageIndex := CurrentIndex;
      TabSheet.TabVisible := True;
      TabSheet.Visible := True;
      Inc(CurrentIndex);
      Break;
    end;

  end;
  // 刷新页面控件

//  cxPageControl1.Invalidate;
end;

procedure TfrmDyeProcessDefinKaika.InitGrid();
var
  i: integer;
begin
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*  from Bs_Cloth_GY_sub_Kaika A ');
    sql.Add(' where gytype=''长车清洗'' and A.PSID=''' + Trim(FPSID) + '''');
    Open;
  end;
  SCreateCDS(ADOQueryTemp, CDS_1);
  SInitCDSData(ADOQueryTemp, CDS_1);

  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*  from Bs_Cloth_GY_sub_Kaika A ');
    sql.Add(' where gytype=''卷染缸清洗'' and A.PSID=''' + Trim(FPSID) + '''');
    Open;
  end;
  SCreateCDS(ADOQueryTemp, CDS_2);
  SInitCDSData(ADOQueryTemp, CDS_2);

  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*  from Bs_Cloth_GY_sub_Kaika A ');
    sql.Add(' where gytype=''机缸清洗'' and A.PSID=''' + Trim(FPSID) + '''');
    Open;
  end;
  SCreateCDS(ADOQueryTemp, CDS_3);
  SInitCDSData(ADOQueryTemp, CDS_3);

  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*  from Bs_Cloth_GY_sub_Kaika A ');
    sql.Add(' where gytype=''下水定型'' and A.PSID=''' + Trim(FPSID) + '''');
    Open;
  end;
  SCreateCDS(ADOQueryTemp, CDS_4);
  SInitCDSData(ADOQueryTemp, CDS_4);

  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*  from Bs_Cloth_GY_sub_Kaika A ');
    sql.Add(' where gytype=''发泡'' and A.PSID=''' + Trim(FPSID) + '''');
    Open;
  end;
  SCreateCDS(ADOQueryTemp, CDS_6);
  SInitCDSData(ADOQueryTemp, CDS_6);

  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*  from Bs_Cloth_GY_sub_Kaika A ');
    sql.Add(' where gytype=''刮胶'' and A.PSID=''' + Trim(FPSID) + '''');
    Open;
  end;
  SCreateCDS(ADOQueryTemp, CDS_5);
  SInitCDSData(ADOQueryTemp, CDS_5);


//  C_FromName.TxtCode := Trim(ADOQueryTemp.fieldbyname('FromBCIID').AsString);
//  C_FromName.Text := Trim(ADOQueryTemp.fieldbyname('C_FromName').AsString);

end;

procedure TfrmDyeProcessDefinKaika.FormShow(Sender: TObject);
var
  MaxPSID, MaxProcessID, MaxBCPID: string;
  Maxid1, maxid2, maxid3, maxgx: string;
begin
  InitGrid();
  ArrangeTabsByDataset();

  with ADOQueryTemp do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from Dye_Plan_Glide where PSID=''' + Trim(FPSID) + '''');
    Open;
  end;
  SCSHData(ADOQueryTemp, Panel1, 2);

  with ADOQueryTemp do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from Bs_Cloth_GY_Main_Kaika where PSID=''' + Trim(FPSID) + '''');
    Open;
  end;

  if FPSType = '长车清洗' then
  begin
    SCSHData(ADOQueryTemp, Panel_ccqx, 2);
  end
  else if FPSType = '卷染缸清洗' then
  begin
    SCSHData(ADOQueryTemp, Panel_rgqx, 2);
  end
  else if FPSType = '机缸清洗' then
  begin
    SCSHData(ADOQueryTemp, Panel_jgqx, 2);
  end
  else if FPSType = '干定型' then
  begin
    SCSHData(ADOQueryTemp, Panel_dx, 2);
  end
  else if FPSType = '下水定型' then
  begin
    SCSHData(ADOQueryTemp, Panel_fs, 2);
  end
  else if FPSType = '发泡' then
  begin
    SCSHData(ADOQueryTemp, Panel_fp, 2);
  end
  else if FPSType = '刮胶' then
  begin
    SCSHData(ADOQueryTemp, Panel_gj, 2);
  end
  else if FPSType = '轧毛' then
  begin
    SCSHData(ADOQueryTemp, Panel_zm, 2);
  end;

  if BtnInt = 3 then   //查看
  begin
//    TbSave.Visible := False;
//    TbUpFile.Visible := False;
  end;

end;

procedure TfrmDyeProcessDefinKaika.fs_meterPropertiesChange(Sender: TObject);
var
  mfs_meter, mfs_useOneMeter, mfs_useGlub: Double;
begin
  if fs_meterDQ.Text <> '' then
  begin
    mfs_meter := StrToFloat(fs_meterDQ.Text);
  end
  else
  begin
    fs_meterDQ.Text := '0';
    mfs_meter := 0;
  end;

  if fs_useOneMeterDQ.Text <> '' then
  begin
    mfs_useOneMeter := StrToFloat(fs_useOneMeterDQ.Text);
  end
  else
  begin
    fs_useOneMeterDQ.Text := '0';
    mfs_useOneMeter := 0;
  end;
  ///计算部分
  mfs_useGlub := mfs_meter * mfs_useOneMeter / 1000;
  fs_useGlubDQ.Text := FloatToStr(mfs_useGlub);
end;

procedure TfrmDyeProcessDefinKaika.TBCloseClick(Sender: TObject);
begin
  Close;
end;





procedure TfrmDyeProcessDefinKaika.CYJGGYBtnDnClick(Sender: TObject);
begin
  TBtnEditC(Sender).Text := '';
end;



procedure TfrmDyeProcessDefinKaika.TbDXReplace1Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_dx, '干定型热风', FindLastEditedTextEdit(panel_dx, '干定型热风'));
end;

procedure TfrmDyeProcessDefinKaika.TbDXReplace2Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_dx, '干定型温控', FindLastEditedTextEdit(panel_dx, '干定型温控'));
end;

procedure TfrmDyeProcessDefinKaika.TbDXReplace3Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_dx, '干定型排风', FindLastEditedTextEdit(panel_dx, '干定型排风'));
end;

procedure TfrmDyeProcessDefinKaika.TbFPClear1Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_Fp, '发泡热风');
end;

procedure TfrmDyeProcessDefinKaika.TbFPClear2Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_Fp, '发泡温控');
end;

procedure TfrmDyeProcessDefinKaika.TbFPClear3Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_Fp, '发泡排风');
end;

procedure TfrmDyeProcessDefinKaika.TbFPReplace1Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_fp, '发泡热风', FindLastEditedTextEdit(panel_fp, '发泡热风'));
end;

procedure TfrmDyeProcessDefinKaika.TbFPReplace2Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_fp, '发泡温控', FindLastEditedTextEdit(panel_fp, '发泡温控'));
end;

procedure TfrmDyeProcessDefinKaika.TbFPReplaceClick(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel5, '发泡烘箱温度', FindLastEditedTextEdit(panel5, '发泡烘箱温度'));
end;

procedure TfrmDyeProcessDefinKaika.TbFSClear1Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(Panel_fs, '防水热风');
end;

procedure TfrmDyeProcessDefinKaika.TBFScLEAR2Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_FS, '防水温控');
end;

procedure TfrmDyeProcessDefinKaika.TbGJReplace1Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_gj, '刮胶热风', FindLastEditedTextEdit(Panel_gj, '刮胶热风'));
end;

procedure TfrmDyeProcessDefinKaika.TbGJReplace2Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_gj, '刮胶温控', FindLastEditedTextEdit(panel_gj, '刮胶温控'));
end;

procedure TfrmDyeProcessDefinKaika.TbGJReplace3Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_gj, '刮胶排风', FindLastEditedTextEdit(Panel_gj, '刮胶排风'));
end;

procedure TfrmDyeProcessDefinKaika.TbGJReplaceClick(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel6, '刮胶烘箱温度', FindLastEditedTextEdit(panel6, '刮胶烘箱温度'));
end;

procedure TfrmDyeProcessDefinKaika.TbjgqxAddClick(Sender: TObject);
begin
  with CDS_3 do
  begin
    Append;
    CDS_3.FieldByName('serialno').Value := CDS_3.RecordCount + 1;
    CDS_3.FieldByName('jgqx_unit').Value := '%';
    Post;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbjgqxDelClick(Sender: TObject);
var
  i: Integer;
begin
  if not CDS_3.IsEmpty then
  begin

    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) = IDYES then
    begin
      if Trim(CDS_3.fieldbyname('BCPID').AsString) <> '' then
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('delete BS_Cloth_GY_Sub where BCPID=' + QuotedStr(Trim(CDS_3.fieldbyname('BCPID').AsString)));
          ExecSQL;
        end;
      end;
      CDS_3.Delete;
    end
    else
      exit;

    i := 0;
    CDS_3.First;
    while not CDS_3.Eof do
    begin
      i := i + 1;
      CDS_3.Edit;
      CDS_3.fieldByName('serialno').value := i;
      CDS_3.Post;
      CDS_3.Next;
    end;
  end
  else
  begin
    Application.MessageBox('无可删除数据!', '提示', 0);
    Exit;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbrgqxAddClick(Sender: TObject);
begin
  with CDS_2 do
  begin
    Append;
    CDS_2.FieldByName('serialno').Value := CDS_2.RecordCount + 1;
    CDS_2.FieldByName('rgqx_unit').Value := '%';
    Post;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbrgqxDelClick(Sender: TObject);
var
  i: Integer;
begin
  if not CDS_2.IsEmpty then
  begin

    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) = IDYES then
    begin
      if Trim(CDS_2.fieldbyname('BCPID').AsString) <> '' then
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('delete BS_Cloth_GY_Sub where BCPID=' + QuotedStr(Trim(CDS_2.fieldbyname('BCPID').AsString)));
          ExecSQL;
        end;
      end;
      CDS_2.Delete;
    end
    else
      exit;

    i := 0;
    CDS_2.First;
    while not CDS_2.Eof do
    begin
      i := i + 1;
      CDS_2.Edit;
      CDS_2.fieldByName('serialno').value := i;
      CDS_2.Post;
      CDS_2.Next;
    end;
  end
  else
  begin
    Application.MessageBox('无可删除数据!', '提示', 0);
    Exit;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbfsAddClick(Sender: TObject);
begin
  with CDS_4 do
  begin
    Append;
    CDS_4.FieldByName('serialno').Value := CDS_4.RecordCount + 1;
    CDS_4.FieldByName('fs_unit').Value := '%';
    Post;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbfpAddClick(Sender: TObject);
begin
  with CDS_6 do
  begin
    Append;
    CDS_6.FieldByName('serialno').Value := CDS_6.RecordCount + 1;
    CDS_6.FieldByName('fp_unit').Value := '%';
    Post;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbgjAddClick(Sender: TObject);
begin
  with CDS_5 do
  begin
    Append;
    CDS_5.FieldByName('serialno').Value := CDS_5.RecordCount + 1;
    CDS_5.FieldByName('gj_unit').Value := '%';
    Post;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbccqxAddClick(Sender: TObject);
begin
  with CDS_1 do
  begin
    Append;
    CDS_1.FieldByName('serialno').Value := CDS_1.RecordCount + 1;
    CDS_1.FieldByName('ccqx_unit').Value := '%';
    Post;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbccqxClearClick(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_ccqx, '长车清洗温控');
end;

procedure TfrmDyeProcessDefinKaika.TbccqxDelClick(Sender: TObject);
var
  i: Integer;
begin
  if not CDS_1.IsEmpty then
  begin

    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) = IDYES then
    begin
      if Trim(CDS_1.fieldbyname('BCPID').AsString) <> '' then
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('delete BS_Cloth_GY_Sub where BCPID=' + quotedStr(Trim(CDS_1.fieldbyname('BCPID').AsString)));
          ExecSQL;
        end;
      end;
      CDS_1.Delete;
    end
    else
      exit;

    i := 0;
    CDS_1.First;
    while not CDS_1.Eof do
    begin
      i := i + 1;
      CDS_1.Edit;
      CDS_1.fieldByName('serialno').value := i;
      CDS_1.Post;
      CDS_1.Next;
    end;
  end
  else
  begin
    Application.MessageBox('无可删除数据!', '提示', 0);
    Exit;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbfsDelClick(Sender: TObject);
var
  i: Integer;
begin
  if not CDS_4.IsEmpty then
  begin

    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) = IDYES then
    begin
      if Trim(CDS_4.fieldbyname('BCPID').AsString) <> '' then
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('delete BS_Cloth_GY_Sub where BCPID=' + QuotedStr(Trim(CDS_4.fieldbyname('BCPID').AsString)));
          ExecSQL;
        end;
      end;
      CDS_4.Delete;
    end
    else
      exit;

    i := 0;
    CDS_4.First;
    while not CDS_4.Eof do
    begin
      i := i + 1;
      CDS_4.Edit;
      CDS_4.fieldByName('serialno').value := i;
      CDS_4.Post;
      CDS_4.Next;
    end;
  end
  else
  begin
    Application.MessageBox('无可删除数据!', '提示', 0);
    Exit;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbfpDelClick(Sender: TObject);
var
  i: Integer;
begin
  if not CDS_6.IsEmpty then
  begin

    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) = IDYES then
    begin
      if Trim(CDS_6.fieldbyname('BCPID').AsString) <> '' then
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('delete BS_Cloth_GY_Sub where BCPID=' + QuotedStr((CDS_6.fieldbyname('BCPID').AsString)));
          ExecSQL;
        end;
      end;
      CDS_6.Delete;
    end
    else
      exit;

    i := 0;
    CDS_6.First;
    while not CDS_6.Eof do
    begin
      i := i + 1;
      CDS_6.Edit;
      CDS_6.fieldByName('serialno').value := i;
      CDS_6.Post;
      CDS_6.Next;
    end;
  end
  else
  begin
    Application.MessageBox('无可删除数据!', '提示', 0);
    Exit;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbgjDelClick(Sender: TObject);
var
  i: Integer;
begin
  if not CDS_5.IsEmpty then
  begin

    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) = IDYES then
    begin
      if Trim(CDS_5.fieldbyname('BCPID').AsString) <> '' then
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('delete BS_Cloth_GY_Sub where BCPID=' + QuotedStr(Trim(CDS_5.fieldbyname('BCPID').AsString)) );
          ExecSQL;
        end;
      end;
      CDS_5.Delete;
    end
    else
      exit;

    i := 0;
    CDS_5.First;
    while not CDS_5.Eof do
    begin
      i := i + 1;
      CDS_5.Edit;
      CDS_5.fieldByName('serialno').value := i;
      CDS_5.Post;
      CDS_5.Next;
    end;
  end
  else
  begin
    Application.MessageBox('无可删除数据!', '提示', 0);
    Exit;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbCPReplaceClick(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel2, '清洗水温', FindLastEditedTextEdit(panel2, '清洗水温'));
end;

function TfrmDyeProcessDefinKaika.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;

procedure TfrmDyeProcessDefinKaika.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 TfrmDyeProcessDefinKaika.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;

procedure TfrmDyeProcessDefinKaika.TbFSReplace3Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_fs, '防水排风', FindLastEditedTextEdit(panel_fs, '防水排风'));
end;

procedure TfrmDyeProcessDefinKaika.TbFSClear3Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_fs, '防水排风');
end;

procedure TfrmDyeProcessDefinKaika.TbCCQXReplaceClick(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_ccqx, '长车清洗温控', FindLastEditedTextEdit(panel_ccqx, '长车清洗温控'));
end;

procedure TfrmDyeProcessDefinKaika.TbDXClear1Click(Sender: TObject);
begin

  ClearAllTextEditsByHint(panel_DX, '干定型热风');
end;

procedure TfrmDyeProcessDefinKaika.TbDXClear2Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_DX, '干定型温控');
end;

procedure TfrmDyeProcessDefinKaika.TbDXClear3Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_DX, '干定型排风');
end;

procedure TfrmDyeProcessDefinKaika.TbFPReplace3Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_fp, '发泡排风', FindLastEditedTextEdit(panel_fp, '发泡排风'));
end;

procedure TfrmDyeProcessDefinKaika.cxButton4Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel5, '发泡烘箱温度');
end;

procedure TfrmDyeProcessDefinKaika.cxGridDBColumn11PropertiesEditValueChanged(Sender: TObject);
var
  s: string;
  fValue: Double;
begin
  s := TcxTextEdit(Sender).EditingText;

  if (s <> '') and (s[Length(s)] <> '%') then
  begin
    try
      // 尝试将字符串转换为浮点数
      fValue := StrToFloat(s);
      // 格式化为两位小数并添加百分号
      Tv3.Controller.FocusedColumn.EditValue := FormatFloat('0.00', fValue) + '%';
    except
      on E: EConvertError do
      begin
        // 如果转换失败，保持原样并添加百分号
        Tv3.Controller.FocusedColumn.EditValue := s + '%';
      end;
    end;
  end;
end;

procedure TfrmDyeProcessDefinKaika.cxGridDBColumn14PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '助剂';
      if ShowModal = 1 then
      begin
        with Self.CDS_2 do
        begin
          Edit;
          FieldByName('rgqx_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('rgqx_spel').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Type').value;

          FieldByName('rgqx_unit').Value := frmProductInfoSel.CDS_1.fieldbyname('QtyUnit').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

procedure TfrmDyeProcessDefinKaika.cxGridDBColumn20PropertiesEditValueChanged(Sender: TObject);
var
  s: string;
  fValue: Double;
begin
  s := TcxTextEdit(Sender).EditingText;

  if (s <> '') and (s[Length(s)] <> '%') then
  begin
    try
      // 尝试将字符串转换为浮点数
      fValue := StrToFloat(s);
      // 格式化为两位小数并添加百分号
      Tv2.Controller.FocusedColumn.EditValue := FormatFloat('0.00', fValue) + '%';
    except
      on E: EConvertError do
      begin
        // 如果转换失败，保持原样并添加百分号
        Tv2.Controller.FocusedColumn.EditValue := s + '%';
      end;
    end;
  end;
end;

procedure TfrmDyeProcessDefinKaika.cxGridDBColumn2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '助剂';
      if ShowModal = 1 then
      begin
        with Self.CDS_1 do
        begin
          Edit;
          FieldByName('ccqx_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('ccqx_spel').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Type').value;

          FieldByName('ccqx_unit').Value := frmProductInfoSel.CDS_1.fieldbyname('QtyUnit').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

//procedure TfrmDyeProcessDefin.cxGridDBColumn5PropertiesEditValueChanged(Sender: TObject);
//var
//  s: string;
//begin
//  s := TcxTextEdit(Sender).EditingText;
//
//  if (s <> '') and (s[Length(s)] <> '%') then
//  begin
//    Tv1.Controller.FocusedColumn.EditValue := s + '%';
//  end;
//end;

procedure TfrmDyeProcessDefinKaika.cxGridDBColumn5PropertiesEditValueChanged(Sender: TObject);
var
  s: string;
  fValue: Double;
begin
  s := TcxTextEdit(Sender).EditingText;

  if (s <> '') and (s[Length(s)] <> '%') then
  begin
    try
      // 尝试将字符串转换为浮点数
      fValue := StrToFloat(s);
      // 格式化为两位小数并添加百分号
      Tv1.Controller.FocusedColumn.EditValue := FormatFloat('0.00', fValue) + '%';
    except
      on E: EConvertError do
      begin
        // 如果转换失败，保持原样并添加百分号
        Tv1.Controller.FocusedColumn.EditValue := s + '%';
      end;
    end;
  end;
end;

function TfrmDyeProcessDefinKaika.AddPercentSuffixIfNeeded(const AText: string): string;
begin
  Result := AText;
  if (AText <> '') and (AText[Length(AText)] <> '%') then
    Result := AText + '%';
end;

procedure TfrmDyeProcessDefinKaika.cxGridDBColumn8PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '助剂';
      if ShowModal = 1 then
      begin
        with Self.CDS_3 do
        begin
          Edit;
          FieldByName('jgqx_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('jgqx_spel').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Type').value;
          FieldByName('jgqx_unit').Value := frmProductInfoSel.CDS_1.fieldbyname('QtyUnit').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

procedure TfrmDyeProcessDefinKaika.TbGjClear1Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_gj, '刮胶热风');
end;

procedure TfrmDyeProcessDefinKaika.TbGJClear2Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_gj, '刮胶温控');
end;

procedure TfrmDyeProcessDefinKaika.TbGJClear3Click(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel_gj, '刮胶排风');
end;

procedure TfrmDyeProcessDefinKaika.TbGJClearClick(Sender: TObject);
begin
  ClearAllTextEditsByHint(panel6, '刮胶烘箱温度');
end;

procedure TfrmDyeProcessDefinKaika.TbFSReplace1Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_fs, '防水热风', FindLastEditedTextEdit(panel_fs, '防水热风'));
end;

procedure TfrmDyeProcessDefinKaika.TbFSReplace2Click(Sender: TObject);
begin
  FillAllTextEditsWithValue(panel_fs, '防水温控', FindLastEditedTextEdit(panel_fs, '防水温控'));
end;

procedure TfrmDyeProcessDefinKaika.CYColorKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    Key := #0;
    SelectNext(ActiveControl as TWinControl, True, True);
  end;
end;

procedure TfrmDyeProcessDefinKaika.C_WidthBtnDnClick(Sender: TObject);
begin
  TBtnEditC(Sender).Text := '';
  TBtnEditC(Sender).TxtCode := '';
end;

procedure TfrmDyeProcessDefinKaika.C_WidthBtnUpClick(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 TfrmDyeProcessDefinKaika.Tv11fs_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '助剂';
      if ShowModal = 1 then
      begin
        with Self.CDS_1 do
        begin
          Edit;
          FieldByName('fs_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('fs_spel').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Spec').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;



procedure TfrmDyeProcessDefinKaika.Tv1Column1PropertiesEditValueChanged(Sender: TObject);
var
  TotalUse: Double;
  I: Integer;
  UseValue, RateValue: Variant;
  mvalue: string;
begin
  mvalue := TcxTextEdit(Sender).EditingText;   //获取用户输入的文本
  with CDS_1 do
  begin
    Edit;
    FieldByName('ccqx_use').Value := mvalue;
    Post;
  end;

//  CalculateUsageRates;

  // 计算所有行用量的总和
  TotalUse := 0;
  for I := 0 to Tv1.DataController.RecordCount - 1 do
  begin
    UseValue := Tv1.DataController.Values[I, Tv1ccqx_use.Index];
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
      TotalUse := TotalUse + VarAsType(UseValue, varDouble);
  end;

  // 如果总用量为0，则所有比率为0
  if TotalUse = 0 then
  begin
    for I := 0 to Tv1.DataController.RecordCount - 1 do
      Tv1.DataController.Values[I, Tv1ccqx_rate.Index] := 0;
    Exit;
  end;

  // 计算并设置每一行的比率（百分比）
  CDS_1.First;
  while not CDS_1.Eof do
  begin
    UseValue := CDS_1.FieldByName('ccqx_use').Value;
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
    begin
      RateValue := (VarAsType(UseValue, varDouble) / TotalUse) * 100;
      with CDS_1 do
      begin
        Edit;
//        FieldByName('ccqx_rate').Value := RoundFloat(RateValue,2);
        FieldByName('ccqx_rate').Value := AddPercentSuffixIfNeeded(FloatToStr(RoundFloat(RateValue,2)  ));
        Post;
      end;


    end
    else
    begin
      with CDS_1 do
      begin
        Edit;
        FieldByName('ccqx_rate').Value := 0;
        Post;
      end;
    end;

  CDS_1.Next;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv2Column1PropertiesEditValueChanged(
  Sender: TObject);
var
  TotalUse: Double;
  I: Integer;
  UseValue, RateValue: Variant;
  mvalue: string;
begin
  mvalue := TcxTextEdit(Sender).EditingText;   //获取用户输入的文本
  with CDS_2 do
  begin
    Edit;
    FieldByName('rgqx_use').Value := mvalue;
    Post;
  end;

//  CalculateUsageRates;

  // 计算所有行用量的总和
  TotalUse := 0;
  for I := 0 to Tv2.DataController.RecordCount - 1 do
  begin
    UseValue := Tv2.DataController.Values[I, Tv1ccqx_use.Index];
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
      TotalUse := TotalUse + VarAsType(UseValue, varDouble);
  end;

  // 如果总用量为0，则所有比率为0
  if TotalUse = 0 then
  begin
    for I := 0 to Tv2.DataController.RecordCount - 1 do
      Tv2.DataController.Values[I, Tv1ccqx_rate.Index] := 0;
    Exit;
  end;

  // 计算并设置每一行的比率（百分比）
  CDS_2.First;
  while not CDS_2.Eof do
  begin
    UseValue := CDS_2.FieldByName('rgqx_use').Value;
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
    begin
      RateValue := (VarAsType(UseValue, varDouble) / TotalUse) * 100;
      with CDS_2 do
      begin
        Edit;
//        FieldByName('ccqx_rate').Value := RoundFloat(RateValue,2);
        FieldByName('rgqx_rate').Value := AddPercentSuffixIfNeeded(FloatToStr(RoundFloat(RateValue,2)  ));
        Post;
      end;


    end
    else
    begin
      with CDS_2 do
      begin
        Edit;
        FieldByName('rgqx_rate').Value := 0;
        Post;
      end;
    end;

  CDS_2.Next;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv2fp_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '助剂';
      if ShowModal = 1 then
      begin
        with Self.CDS_2 do
        begin
          Edit;
          FieldByName('fp_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('fp_spel').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Spec').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv3Column1PropertiesEditValueChanged(
  Sender: TObject);
var
  TotalUse: Double;
  I: Integer;
  UseValue, RateValue: Variant;
  mvalue: string;
begin
  mvalue := TcxTextEdit(Sender).EditingText;   //获取用户输入的文本
  with CDS_3 do
  begin
    Edit;
    FieldByName('jgqx_use').Value := mvalue;
    Post;
  end;

//  CalculateUsageRates;

  // 计算所有行用量的总和
  TotalUse := 0;
  for I := 0 to Tv3.DataController.RecordCount - 1 do
  begin
    UseValue := Tv3.DataController.Values[I, Tv1ccqx_use.Index];
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
      TotalUse := TotalUse + VarAsType(UseValue, varDouble);
  end;

  // 如果总用量为0，则所有比率为0
  if TotalUse = 0 then
  begin
    for I := 0 to Tv3.DataController.RecordCount - 1 do
      Tv3.DataController.Values[I, Tv1ccqx_rate.Index] := 0;
    Exit;
  end;

  // 计算并设置每一行的比率（百分比）
  CDS_3.First;
  while not CDS_3.Eof do
  begin
    UseValue := CDS_3.FieldByName('jgqx_use').Value;
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
    begin
      RateValue := (VarAsType(UseValue, varDouble) / TotalUse) * 100;
      with CDS_3 do
      begin
        Edit;
//        FieldByName('ccqx_rate').Value := RoundFloat(RateValue,2);
        FieldByName('jgqx_rate').Value := AddPercentSuffixIfNeeded(FloatToStr(RoundFloat(RateValue,2)  ));
        Post;
      end;


    end
    else
    begin
      with CDS_3 do
      begin
        Edit;
        FieldByName('ccqx_rate').Value := 0;
        Post;
      end;
    end;

  CDS_3.Next;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv3gj_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '助剂';
      if ShowModal = 1 then
      begin
        with Self.CDS_3 do
        begin
          Edit;
          FieldByName('gj_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('gj_spel').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Spec').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv41fs_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '助剂';
      if ShowModal = 1 then
      begin
        with Self.CDS_4 do
        begin
          Edit;
          FieldByName('fs_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('fs_spel').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Type').value;
          FieldByName('fs_unit').Value := frmProductInfoSel.CDS_1.fieldbyname('QtyUnit').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv4fs_unitPropertiesEditValueChanged(Sender: TObject);
var
  s: string;
  fValue: Double;
begin
  s := TcxTextEdit(Sender).EditingText;

  if (s <> '') and (s[Length(s)] <> '%') then
  begin
    try
      // 尝试将字符串转换为浮点数
      fValue := StrToFloat(s);
      // 格式化为两位小数并添加百分号
      Tv4.Controller.FocusedColumn.EditValue := FormatFloat('0.00', fValue) + '%';
    except
      on E: EConvertError do
      begin
        // 如果转换失败，保持原样并添加百分号
        Tv4.Controller.FocusedColumn.EditValue := s + '%';
      end;
    end;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv4fs_usePropertiesEditValueChanged(
  Sender: TObject);
var
  TotalUse: Double;
  I: Integer;
  UseValue, RateValue: Variant;
  mvalue: string;
begin
  mvalue := TcxTextEdit(Sender).EditingText;   //获取用户输入的文本
  with CDS_4 do
  begin
    Edit;
    FieldByName('fs_use').Value := mvalue;
    Post;
  end;

//  CalculateUsageRates;

  // 计算所有行用量的总和
  TotalUse := 0;
  for I := 0 to Tv4.DataController.RecordCount - 1 do
  begin
    UseValue := Tv4.DataController.Values[I, Tv1ccqx_use.Index];
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
      TotalUse := TotalUse + VarAsType(UseValue, varDouble);
  end;

  // 如果总用量为0，则所有比率为0
  if TotalUse = 0 then
  begin
    for I := 0 to Tv4.DataController.RecordCount - 1 do
      Tv4.DataController.Values[I, Tv1ccqx_rate.Index] := 0;
    Exit;
  end;

  // 计算并设置每一行的比率（百分比）
  CDS_4.First;
  while not CDS_4.Eof do
  begin
    UseValue := CDS_4.FieldByName('fs_use').Value;
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
    begin
      RateValue := (VarAsType(UseValue, varDouble) / TotalUse) * 100;
      with CDS_4 do
      begin
        Edit;
//        FieldByName('ccqx_rate').Value := RoundFloat(RateValue,2);
        FieldByName('fs_rate').Value := AddPercentSuffixIfNeeded(FloatToStr(RoundFloat(RateValue,2)  ));
        Post;
      end;


    end
    else
    begin
      with CDS_4 do
      begin
        Edit;
        FieldByName('fs_rate').Value := 0;
        Post;
      end;
    end;

  CDS_4.Next;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv5gj_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '助剂';
      if ShowModal = 1 then
      begin
        with Self.CDS_5 do
        begin
          Edit;
          FieldByName('gj_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('gj_spel').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Type').value;
          FieldByName('gj_unit').Value := frmProductInfoSel.CDS_1.fieldbyname('QtyUnit').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv5gj_unitPropertiesEditValueChanged(Sender: TObject);
var
  s: string;
  fValue: Double;
begin
  s := TcxTextEdit(Sender).EditingText;

  if (s <> '') and (s[Length(s)] <> '%') then
  begin
    try
      // 尝试将字符串转换为浮点数
      fValue := StrToFloat(s);
      // 格式化为两位小数并添加百分号
      Tv5.Controller.FocusedColumn.EditValue := FormatFloat('0.00', fValue) + '%';
    except
      on E: EConvertError do
      begin
        // 如果转换失败，保持原样并添加百分号
        Tv5.Controller.FocusedColumn.EditValue := s + '%';
      end;
    end;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv5gj_usePropertiesEditValueChanged(
  Sender: TObject);
var
  TotalUse: Double;
  I: Integer;
  UseValue, RateValue: Variant;
  mvalue: string;
begin
  mvalue := TcxTextEdit(Sender).EditingText;   //获取用户输入的文本
  with CDS_5 do
  begin
    Edit;
    FieldByName('gj_use').Value := mvalue;
    Post;
  end;

//  CalculateUsageRates;

  // 计算所有行用量的总和
  TotalUse := 0;
  for I := 0 to Tv5.DataController.RecordCount - 1 do
  begin
    UseValue := Tv5.DataController.Values[I, Tv1ccqx_use.Index];
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
      TotalUse := TotalUse + VarAsType(UseValue, varDouble);
  end;

  // 如果总用量为0，则所有比率为0
  if TotalUse = 0 then
  begin
    for I := 0 to Tv5.DataController.RecordCount - 1 do
      Tv5.DataController.Values[I, Tv1ccqx_rate.Index] := 0;
    Exit;
  end;

  // 计算并设置每一行的比率（百分比）
  CDS_5.First;
  while not CDS_5.Eof do
  begin
    UseValue := CDS_5.FieldByName('gj_use').Value;
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
    begin
      RateValue := (VarAsType(UseValue, varDouble) / TotalUse) * 100;
      with CDS_5 do
      begin
        Edit;
//        FieldByName('ccqx_rate').Value := RoundFloat(RateValue,2);
        FieldByName('gj_rate').Value := AddPercentSuffixIfNeeded(FloatToStr(RoundFloat(RateValue,2)  ));
        Post;
      end;


    end
    else
    begin
      with CDS_5 do
      begin
        Edit;
        FieldByName('gj_rate').Value := 0;
        Post;
      end;
    end;

  CDS_5.Next;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv6Column2PropertiesEditValueChanged(
  Sender: TObject);
var
  TotalUse: Double;
  I: Integer;
  UseValue, RateValue: Variant;
  mvalue: string;
begin
  mvalue := TcxTextEdit(Sender).EditingText;   //获取用户输入的文本
  with CDS_6 do
  begin
    Edit;
    FieldByName('fp_use').Value := mvalue;
    Post;
  end;

//  CalculateUsageRates;

  // 计算所有行用量的总和
  TotalUse := 0;
  for I := 0 to Tv6.DataController.RecordCount - 1 do
  begin
    UseValue := Tv6.DataController.Values[I, Tv1ccqx_use.Index];
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
      TotalUse := TotalUse + VarAsType(UseValue, varDouble);
  end;

  // 如果总用量为0，则所有比率为0
  if TotalUse = 0 then
  begin
    for I := 0 to Tv6.DataController.RecordCount - 1 do
      Tv6.DataController.Values[I, Tv1ccqx_rate.Index] := 0;
    Exit;
  end;

  // 计算并设置每一行的比率（百分比）
  CDS_6.First;
  while not CDS_6.Eof do
  begin
    UseValue := CDS_6.FieldByName('fp_use').Value;
    if not VarIsNull(UseValue) and not VarIsEmpty(UseValue) then
    begin
      RateValue := (VarAsType(UseValue, varDouble) / TotalUse) * 100;
      with CDS_6 do
      begin
        Edit;
//        FieldByName('ccqx_rate').Value := RoundFloat(RateValue,2);
        FieldByName('fp_rate').Value := AddPercentSuffixIfNeeded(FloatToStr(RoundFloat(RateValue,2)  ));
        Post;
      end;


    end
    else
    begin
      with CDS_6 do
      begin
        Edit;
        FieldByName('fp_rate').Value := 0;
        Post;
      end;
    end;

  CDS_6.Next;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv6fp_NamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '助剂';
      if ShowModal = 1 then
      begin
        with Self.CDS_6 do
        begin
          Edit;
          FieldByName('fp_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('fp_spel').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Type').value;
          FieldByName('fp_unit').Value := frmProductInfoSel.CDS_1.fieldbyname('QtyUnit').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

procedure TfrmDyeProcessDefinKaika.Tv6fp_ratePropertiesEditValueChanged(Sender: TObject);
var
  s: string;
  fValue: Double;
begin
  s := TcxTextEdit(Sender).EditingText;

  if (s <> '') and (s[Length(s)] <> '%') then
  begin
    try
      // 尝试将字符串转换为浮点数
      fValue := StrToFloat(s);
      // 格式化为两位小数并添加百分号
      Tv6.Controller.FocusedColumn.EditValue := FormatFloat('0.00', fValue) + '%';
    except
      on E: EConvertError do
      begin
        // 如果转换失败，保持原样并添加百分号
        Tv6.Controller.FocusedColumn.EditValue := s + '%';
      end;
    end;
  end;
end;

end.

