unit U_YCClothRZPList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
  cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System,
  RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, MovePanel, cxTextEdit,
  cxContainer, cxCurrencyEdit, BtnEdit, RM_e_main, RM_e_htm, RM_e_Graphic,
  RM_e_Jpeg, RM_e_txt, RM_e_csv, RM_E_llPDF, Math, Clipbrd, cxPC,
  cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu;

type
  TfrmYCClothRZPList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    Label3: TLabel;
    OrderNo: TEdit;
    TBExport: TToolButton;
    Order_Main: TClientDataSet;
    conNO: TEdit;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    MJID: TEdit;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    v1Column11: TcxGridDBColumn;
    v1Column12: TcxGridDBColumn;
    Label4: TLabel;
    MJType: TComboBox;
    v1Column13: TcxGridDBColumn;
    Label5: TLabel;
    MPRTCodeName: TEdit;
    Label6: TLabel;
    MJStr2: TComboBox;
    v1Column17: TcxGridDBColumn;
    v1Column19: TcxGridDBColumn;
    Label12: TLabel;
    factoryName: TEdit;
    v1Column20: TcxGridDBColumn;
    v1Column21: TcxGridDBColumn;
    Filler: TComboBox;
    v1Column22: TcxGridDBColumn;
    v1Column23: TcxGridDBColumn;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    RM2: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    ADOQueryPrint: TADOQuery;
    v1Column24: TcxGridDBColumn;
    MovePanel2: TMovePanel;
    v1Column27: TcxGridDBColumn;
    v1Column28: TcxGridDBColumn;
    v1Column14: TcxGridDBColumn;
    CDS_CD: TClientDataSet;
    RMCD: TRMGridReport;
    RMDBCD: TRMDBDataSet;
    CDS_LS: TClientDataSet;
    v1Column15: TcxGridDBColumn;
    v1MKXS: TcxGridDBColumn;
    Mjstr4: TEdit;
    PrtColor: TEdit;
    RM3: TRMGridReport;
    v1Column31: TcxGridDBColumn;
    v1Column32: TcxGridDBColumn;
    v1Column33: TcxGridDBColumn;
    KHConNO: TEdit;
    Label19: TLabel;
    v1Column34: TcxGridDBColumn;
    v1Column36: TcxGridDBColumn;
    RMXLSExport1: TRMXLSExport;
    CDS_HZ: TClientDataSet;
    RMDBHZ: TRMDBDataSet;
    RMDBPRT: TRMDBDataSet;
    CDS_PRT: TClientDataSet;
    v1Column39: TcxGridDBColumn;
    Panel6: TPanel;
    Label31: TLabel;
    LBCPAP: TLabel;
    BTLP: TButton;
    BTNP: TButton;
    TCBNOR: TComboBox;
    IsJYTime: TCheckBox;
    v1Column42: TcxGridDBColumn;
    v1Column16: TcxGridDBColumn;
    Label1: TLabel;
    RKOrdID: TEdit;
    N3: TMenuItem;
    ToolButton4: TToolButton;
    X1: TMenuItem;
    cxTabControl1: TcxTabControl;
    v1Column18: TcxGridDBColumn;
    lbl1: TLabel;
    APID: TEdit;
    Label2: TLabel;
    RCGangNo: TEdit;
    v1Column25: TcxGridDBColumn;
    v1Column26: TcxGridDBColumn;
    v1Column29: TcxGridDBColumn;
    v1Column30: TcxGridDBColumn;
    v1Column35: TcxGridDBColumn;
    Label11: TLabel;
    lidan: TEdit;
    Label13: TLabel;
    YWY: TEdit;
    v1Column37: TcxGridDBColumn;
    v1Column38: TcxGridDBColumn;
    v1Column40: TcxGridDBColumn;
    Label14: TLabel;
    KuanHao: TEdit;
    v1Column41: TcxGridDBColumn;
    v1Column43: TcxGridDBColumn;
    v1Column44: TcxGridDBColumn;
    Label16: TLabel;
    IsOutRange: TEdit;
    v1Column45: TcxGridDBColumn;
    v1Column46: TcxGridDBColumn;
    v1Column47: TcxGridDBColumn;
    v1Column48: TcxGridDBColumn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
    procedure v1Column15PropertiesEditValueChanged(Sender: TObject);
    procedure MJIDKeyPress(Sender: TObject; var Key: Char);
    procedure BTLPClick(Sender: TObject);
    procedure BTNPClick(Sender: TObject);
    procedure TCBNORChange(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure conNOKeyPress(Sender: TObject; var Key: Char);
    procedure MJStr2Change(Sender: TObject);
    procedure MJTypeChange(Sender: TObject);
    procedure KHConNOKeyPress(Sender: TObject; var Key: Char);
    procedure RKOrdIDKeyPress(Sender: TObject; var Key: Char);
    procedure N3Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure X1Click(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
  private
    DQdate: TDateTime;
    FLeft, FTop: Integer;
    CurrentPage, RecordsNumber: Integer;
    procedure InitGrid();
    procedure InitForm();
    function Savedata(): Boolean;
    procedure GetCDSData();
    procedure SetStatus();
    procedure PrintCKMDG(MRKOrdID: string);
    { Private declarations }
  public
    FFInt: Integer;
    canshu1: string;
    { Public declarations }
  end;

implementation

uses
  U_DataLink, U_Fun, U_ZDYHelp;

{$R *.dfm}
procedure TfrmYCClothRZPList.SetStatus();
begin

end;

procedure TfrmYCClothRZPList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TfrmYCClothRZPList.FormCreate(Sender: TObject);
begin
  cxgrid1.Align := alClient;
  DQdate := SGetServerDate(ADOQueryTemp);
end;

procedure TfrmYCClothRZPList.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid(self.Caption, Tv1, '进度统计查询');
  Close;
end;

procedure TfrmYCClothRZPList.PrintCKMDG(MRKOrdID: string);
var
  fPrintFile: string;
  Txt, fImagePath: string;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if Order_Main.IsEmpty then
    Exit;
  ExportFtErpFile('仓库码单.rmf', ADOQueryTemp);
  with Order_Main do
  begin

    with ADOQueryPrint do
    begin
      Close;
      SQL.Clear;
      sql.Add(' exec P_Print_RKMDGangNo ');
      SQL.Add(' @RKOrdID=''' + Trim(MRKOrdID) + '''');
      Open;
    end;
    try
      Moudle := LoadLibrary('MakeQRBarcode.dll');
      @Makebar := GetProcAddress(Moudle, 'Make');
      @Mixtext := GetProcAddress(Moudle, 'MixText');
      Txt := Trim(ADOQueryPrint.fieldbyname('RKOrdID').AsString);
      fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
      if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
        CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
      if FileExists(fImagePath) then
        DeleteFile(fImagePath);
      Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
    except
      application.MessageBox('条形码生成失败！', '提示信息', MB_ICONERROR);
      exit;
    end;
    fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\仓库码单.rmf';
    if FileExists(fPrintFile) then
    begin
      RMVariables['QRBARCODE'] := fImagePath;
      RM2.LoadFromFile(fPrintFile);
      Rm2.DefaultCopies := 1;
      RM2.ShowReport;
    end
    else
    begin
      Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0);
      Exit;
    end;

  end;

end;

procedure TfrmYCClothRZPList.InitGrid();
var
  fwhere, Pwhere: string;
begin
  MovePanel2.Left := (self.Width - MovePanel2.Width) div 2;
  MovePanel2.Visible := True;
  MovePanel2.Refresh;
  if IsJYTime.Checked then
  begin
    fwhere := ' where Filltime>' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
    fwhere := fwhere + ' and Filltime<=' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1));
  end;

  Pwhere := SGetFilters(Panel1, 1, 2);

  if trim(Pwhere) <> '' then
  begin
    case cxTabControl1.TabIndex of
      0:
        begin
          Pwhere := Pwhere + ' and MJStr2=''未入库'' ';
        end;
      1:
        begin
          Pwhere := Pwhere + ' and MJStr2<>''未入库'' ';
        end;
      2:
        begin
          if Trim(MJStr2.Text) <> '' then
          begin
            if Trim(MJStr2.Text) = '未出库' then
            begin
              Pwhere := Pwhere + ' and MJStr2<>''已出库'' ';
            end
            else
            begin
              Pwhere := Pwhere + ' and MJStr2=' + quotedstr(Trim(MJStr2.Text));
            end;
          end;

        end;
    end;
  end
  else
  begin
    case cxTabControl1.TabIndex of
      0:
        begin
          Pwhere := ' MJStr2=''未入库'' ';
        end;
      1:
        begin
          Pwhere := ' MJStr2<>''未入库'' ';
        end;
      2:
        begin
          if Trim(MJStr2.Text) <> '' then
          begin
            if Trim(MJStr2.Text) = '未出库' then
            begin
              Pwhere := '  MJStr2<>''已出库'' ';
            end
            else
            begin
              Pwhere := '  MJStr2=' + quotedstr(Trim(MJStr2.Text));
            end;
          end
          else
          begin
            Pwhere := ' 1=1 ';
          end;
        end;
    end;
  end;

  if (canshu1 = '次品管理') or (canshu1 = '次品查询') then
  begin
    Pwhere := Pwhere + ' and MJType=''次品'' ';
  end;

  if canshu1 = '活货管理' then
  begin
    Pwhere := Pwhere + ' and MJType=''次品'' ';
    Pwhere := Pwhere + ' and ISQYCP=''活货'' ';
  end;
  if canshu1 = '死货管理' then
  begin
    Pwhere := Pwhere + ' and MJType=''次品'' ';
    Pwhere := Pwhere + ' and ISQYCP=''死货'' ';
  end;

  if trim(fwhere) <> '' then
  begin
    fwhere := fwhere + ' and ' + trim(Pwhere);
  end
  else
  begin
    fwhere := ' where ' + trim(Pwhere);
  end;

  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add('exec P_Page_ClothInfo ');
      sql.Add('@pageIndex=' + inttostr(CurrentPage));
      sql.Add(',@pageSize=' + inttostr(RecordsNumber));
      sql.Add(',@criteria= ' + quotedstr(fwhere));
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_Main);
    SInitCDSData20(ADOQueryMain, Order_Main);
    LBCPAP.Caption := inttostr(CurrentPage) + '/' + inttostr(ceil(Order_Main.FieldByName('TotalCount').AsInteger / RecordsNumber));
    MovePanel2.Visible := false;
  finally
    ADOQueryMain.EnableControls;
    MovePanel2.Visible := false;
  end;
end;

procedure TfrmYCClothRZPList.InitForm();
var
  fsj: string;
begin
  ReadCxGrid(self.Caption, Tv1, '进度统计查询');
  fsj := 'select distinct(Filler) name from WFB_MJJY   ';
  SInitComBoxBySql(ADOQueryCmd, Filler, False, fsj);

  if canshu1 = '打卷工' then
  begin
    Filler.Clear;
    Filler.Items.Add(trim(DName));
    Filler.ItemIndex := Filler.Items.IndexOf(trim(DName));
    Filler.Enabled := False;
  end;

  EndDate.DateTime := SGetServerDate10(ADOQueryTemp);
  if canshu1 = '次品查询' then
  begin
    BegDate.DateTime := EndDate.DateTime - 90;
  end
  else
  begin
    BegDate.DateTime := EndDate.DateTime - 14;
  end;
  if canshu1 = '超范围' then
  begin
    IsOutRange.Text := '超范围';
  end;
    //InitGrid();
end;

procedure TfrmYCClothRZPList.TBFindClick(Sender: TObject);
var
  fsj, fwhere: string;
begin

end;

procedure TfrmYCClothRZPList.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then
    Exit;
  SelExportData(Tv1, ADOQueryMain, '检验报告');
end;

procedure TfrmYCClothRZPList.TBRafreshClick(Sender: TObject);
begin
  OrderNo.SetFocus;

  CurrentPage := 1;
  InitGrid();

end;

procedure TfrmYCClothRZPList.FormShow(Sender: TObject);
begin
  CurrentPage := 1;
  RecordsNumber := 500;
  InitForm();
  SetStatus();
end;

procedure TfrmYCClothRZPList.Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  FLeft := X;
  FTop := Y;
end;

procedure TfrmYCClothRZPList.N1Click(Sender: TObject);
begin
  SelOKNo(Order_Main, True);
end;

procedure TfrmYCClothRZPList.N2Click(Sender: TObject);
begin
  SelOKNo(Order_Main, False);
end;

function TfrmYCClothRZPList.Savedata(): Boolean;
var
  maxno, LLID: string;
  HXPS: Integer;
  HXQty, HXMQty: Double;
begin
  HXPS := 0;
  HXQty := 0;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select Top 1 * from Contract_Cloth_LL where OrdSubId=''' + Trim(Order_Main.fieldbyname('SubId').AsString) + '''');
    sql.Add(' and FirstName=''' + Trim(Order_Main.fieldbyname('AOrddefstr4').AsString) + '''');
    Open;
  end;
  LLID := Trim(ADOQueryTemp.fieldbyname('LLID').AsString);
  if Trim(LLID) = '' then
  begin
    Result := False;
    Application.MessageBox('没有相对应的加工厂!', '提示', 0);
    Exit;
  end;
  try
    ADOQueryCmd.Connection.BeginTrans;
    if GetLSNo(ADOQueryCmd, maxno, 'HX', 'Contract_Cloth_BefChkHX', 2, 1) = False then
    begin
      Result := False;
      ADOQueryCmd.Connection.RollbackTrans;
      Application.MessageBox('取回修最大号失败!', '提示', 0);
      Exit;
    end;
    with Order_Main do
    begin
      First;
      while not Eof do
      begin
        if Order_Main.FieldByName('SSel').AsBoolean = True then
        begin
          HXPS := HXPS + 1;
          HXQty := HXQty + Order_Main.FieldByName('MJLen').Value;
        end;
        Next;
      end;
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('');
      Open;
    end;
  except
  end;
end;

procedure TfrmYCClothRZPList.OrderNoKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    if Length(OrderNo.Text) < 4 then
      Exit;
    CurrentPage := 1;
    InitGrid();
  end;
end;

procedure TfrmYCClothRZPList.GetCDSData();
begin
  CDS_CD.FieldByName('MJXH').Value := CDS_LS.fieldbyname('MJXH').Value;
  CDS_CD.FieldByName('GangNo').Value := CDS_LS.fieldbyname('Aorddefstr1').Value;
  CDS_CD.FieldByName('PRTColor').Value := CDS_LS.fieldbyname('PRTColor').Value;
  CDS_CD.FieldByName('PRTEColor').Value := CDS_LS.fieldbyname('SOrddefstr4').Value;
  CDS_CD.FieldByName('MJLen').Value := CDS_LS.fieldbyname('MJLen').Value;
  CDS_CD.FieldByName('MJJZ').Value := CDS_LS.fieldbyname('MJQty4').Value;
  CDS_CD.FieldByName('MJMZ').Value := CDS_LS.fieldbyname('MJMaoZ').Value;
  CDS_CD.FieldByName('MJFK').Value := CDS_LS.fieldbyname('MJFK').Value;
  CDS_CD.FieldByName('KFQtyHZ').Value := CDS_LS.fieldbyname('KFQtyHZ').Value;
  CDS_CD.FieldByName('DengJi').Value := CDS_LS.fieldbyname('DengJi').Value;
  CDS_CD.FieldByName('PanDing').Value := CDS_LS.fieldbyname('PanDing').Value;
  CDS_CD.FieldByName('MJID').Value := CDS_LS.fieldbyname('MJID').Value;
end;

procedure TfrmYCClothRZPList.v1Column15PropertiesEditValueChanged(Sender: TObject);
var
  mvalue: string;
begin
  mvalue := TcxTextEdit(Sender).EditingText;
  with Order_Main do
  begin
    Edit;
    FieldByName('PanDing').Value := Trim(mvalue);
    Post;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('UPdate WFB_MJJY Set PanDing=''' + Trim(mvalue) + '''');
    SQL.Add(' where MJID=''' + Trim(Order_Main.fieldbyname('MJID').AsString) + '''');
    ExecSQL;
  end;
end;

procedure TfrmYCClothRZPList.MJIDKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    if Length(MJID.Text) < 4 then
      Exit;
    CurrentPage := 1;
    InitGrid();
  end;
end;

procedure TfrmYCClothRZPList.BTLPClick(Sender: TObject);
begin
  if CurrentPage > 1 then
    CurrentPage := CurrentPage - 1;
  InitGrid();
end;

procedure TfrmYCClothRZPList.BTNPClick(Sender: TObject);
begin
  if CurrentPage < Order_Main.FieldByName('TotalCount').AsInteger / RecordsNumber then
    CurrentPage := CurrentPage + 1;
  InitGrid();
end;

procedure TfrmYCClothRZPList.TCBNORChange(Sender: TObject);
begin
  RecordsNumber := StrToInt(TCBNOR.Text);
  CurrentPage := 1;
  InitGrid();
end;

procedure TfrmYCClothRZPList.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  Clipboard.SetTextBuf(PChar(Trim(Order_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;

procedure TfrmYCClothRZPList.conNOKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    CurrentPage := 1;
    InitGrid();
  end;
end;

procedure TfrmYCClothRZPList.MJStr2Change(Sender: TObject);
begin
  CurrentPage := 1;
  InitGrid();
end;

procedure TfrmYCClothRZPList.MJTypeChange(Sender: TObject);
begin
  CurrentPage := 1;
  InitGrid();
end;

procedure TfrmYCClothRZPList.KHConNOKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    CurrentPage := 1;
    InitGrid();
  end;
end;

procedure TfrmYCClothRZPList.RKOrdIDKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    CurrentPage := 1;
    InitGrid();
  end;
end;

procedure TfrmYCClothRZPList.N3Click(Sender: TObject);
var
  SSubId, SGangNo: string;
begin

  with Order_Main do
  begin
    SSubId := trim(FieldByName('SubId').AsString);
    SGangNo := trim(FieldByName('Mjstr4').AsString);
    Order_Main.DisableControls;
    first;
    while not eof do
    begin
      if ((SSubId = trim(FieldByName('SubId').AsString)) and (SGangNo = trim(FieldByName('Mjstr4').AsString))) then
      begin
        edit;
        FieldByName('SSel').value := true;
        Post;
      end
      else
      begin
        edit;
        FieldByName('SSel').value := false;
        Post;
      end;
      Next;
    end;
    Order_Main.Locate('SubId;Mjstr4', VarArrayOf([SSubId, SGangNo]), []);
    Order_Main.EnableControls;
  end;
end;

procedure TfrmYCClothRZPList.ToolButton4Click(Sender: TObject);
begin
  if Trim(Order_Main.fieldbyname('RKOrdID').AsString) = '' then
    exit;
  PrintCKMDG(Trim(Order_Main.fieldbyname('RKOrdID').AsString));
end;

procedure TfrmYCClothRZPList.X1Click(Sender: TObject);
var
  str, SSubId, SGangNo: string;
  ZChiShu, DQChiShu: integer;
  ISSel: boolean;
begin
  ISSel := true;
  SSubId := trim(Order_Main.FieldByName('SubId').AsString);
  SGangNo := trim(Order_Main.FieldByName('Mjstr4').AsString);
  str := '';
  if InputQuery('选择', '请输入数字', str) then
  begin
    ZChiShu := strtointdef(str, 0);
    if ZChiShu <= 0 then
      exit;

    with Order_Main do
    begin

      Order_Main.DisableControls;
      first;
      DQChiShu := 0;
      while not eof do
      begin

        if ((SSubId = trim(FieldByName('SubId').AsString)) and (SGangNo = trim(FieldByName('Mjstr4').AsString))) then
        begin
          edit;
          FieldByName('SSel').value := ISSel;
          DQChiShu := DQChiShu + 1;
          Post;
        end
        else
        begin
          edit;
          FieldByName('SSel').value := false;
          Post;
        end;
        if DQChiShu = ZChiShu then
          ISSel := false;
        Next;
      end;
      Order_Main.Locate('SubId;Mjstr4', VarArrayOf([SSubId, SGangNo]), []);
      Order_Main.EnableControls;
    end;
  end;

end;

procedure TfrmYCClothRZPList.cxTabControl1Change(Sender: TObject);
begin
  CurrentPage := 1;
  InitGrid();
  SetStatus();
end;

procedure TfrmYCClothRZPList.Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin

// FKuLin := AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('PJKuLin').Index];


  ACanvas.Brush.Color := $0045FF;

end;

end.

