unit U_ClothInfoTechnicsSel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
  cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
  cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
  cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
  cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
  RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
  cxTextEdit, cxPC, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
  dxBarBuiltInMenu, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges;

type
  TfrmClothInfoTechnicsSel = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    Label1: TLabel;
    GYName: TEdit;
    ADOQueryMain: TADOQuery;
    RM1: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    Label3: TLabel;
    GYNO: TEdit;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    cxGridLevel1: TcxGridLevel;
    GPM_2: TcxGridPopupMenu;
    DS_2: TDataSource;
    CDS_2: TClientDataSet;
    cxTabControl1: TcxTabControl;
    v2GYGX: TcxGridDBColumn;
    v2Ssel: TcxGridDBColumn;
    v2GYName: TcxGridDBColumn;
    v2GYNO: TcxGridDBColumn;
    DS_1: TDataSource;
    CDS_1: TClientDataSet;
    ADOQuery1: TADOQuery;
    GPM_1: TcxGridPopupMenu;
    TBOK: TToolButton;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBTableView;
    XUHAO: TcxGridDBColumn;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure GYNOChange(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure TBOKClick(Sender: TObject);
    procedure Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
  private
    { Private declarations }

    procedure InitGrid();
    procedure SetStatus();
    procedure InitGlide();
  public
    fflag: integer;
    { Public declarations }
    RKFlag, FCYID, fmanage: string;
  end;

var
  frmClothInfoTechnicsSel: TfrmClothInfoTechnicsSel;

implementation

uses
  U_DataLink, U_RTFun;

{$R *.dfm}

procedure TfrmClothInfoTechnicsSel.SetStatus();
begin

end;

procedure TfrmClothInfoTechnicsSel.InitGlide();
begin
  try
    ADOQueryTemp.DisableControls;
    with ADOQueryTemp do
    begin
      Close;
      SQL.Clear;
      sql.Add(' select A.*,B.* FROM BS_Cloth_Technics_Sub A inner join Bs_Cloth_Process B on A.PSId=B.PSId ');
      sql.Add(' Where A.CTMID=''' + trim(CDS_2.fieldbyname('CTMID').AsString) + '''');
      SQL.Add(' ORDER BY A.PSNO');
      Open;
    end;
    SCreateCDS(ADOQueryTemp, CDS_1);
    SInitCDSData(ADOQueryTemp, CDS_1);
  finally
    ADOQueryTemp.EnableControls;
  end;
end;

procedure TfrmClothInfoTechnicsSel.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      SQL.Clear;
      sql.Add(' select * FROM BS_Cloth_Technics_Main');
      if cxTabControl1.TabIndex < 2 then
        sql.Add(' where status=''' + inttostr(cxTabControl1.TabIndex) + ''' ');
      Open;
    end;
    SCreateCDS(ADOQueryMain, CDS_2);
    SInitCDSData(ADOQueryMain, CDS_2);
  finally
    ADOQueryMain.EnableControls;
    ToolButton2.Click;
    //CDS_1.EmptyDataSet;
  end;
end;

procedure TfrmClothInfoTechnicsSel.FormDestroy(Sender: TObject);
begin
  frmClothInfoTechnicsSel := nil;
end;

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

procedure TfrmClothInfoTechnicsSel.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('工艺登记', Tv2, '工艺管理');
  Close;
end;

procedure TfrmClothInfoTechnicsSel.FormShow(Sender: TObject);
begin
  fflag := 0;
  ReadCxGrid('工艺登记', Tv2, '工艺管理');
  SetStatus();
  InitGrid();
end;

procedure TfrmClothInfoTechnicsSel.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmClothInfoTechnicsSel.ToolButton2Click(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS(ADOQueryMain, CDS_2);
    SInitCDSData(ADOQueryMain, CDS_2);
  end;
end;

procedure TfrmClothInfoTechnicsSel.GYNOChange(Sender: TObject);
begin
  ToolButton2.Click;
end;

procedure TfrmClothInfoTechnicsSel.cxTabControl1Change(Sender: TObject);
begin
  SetStatus();
  InitGrid();
end;

procedure TfrmClothInfoTechnicsSel.Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
begin
  InitGlide();
end;

procedure TfrmClothInfoTechnicsSel.FormCreate(Sender: TObject);
begin
  fmanage := Trim(DParameters1);
end;

procedure TfrmClothInfoTechnicsSel.TBOKClick(Sender: TObject);
begin
  if CDS_2.IsEmpty then
    exit;
  self.ModalResult := 1;
end;

end.


