unit U_LSSQKCHZSel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
  cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView,
  cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses,
  cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls,
  ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient,
  cxDropDownEdit, MovePanel, cxButtonEdit, cxCheckBox, cxLookAndFeels,
  cxLookAndFeelPainters, cxNavigator;

type
  TfrmLSSQKCHZSel = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    cxGridPopupMenu1: TcxGridPopupMenu;
    CDS_Main: TClientDataSet;
    ToolButton1: TToolButton;
    cxgrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column5: TcxGridDBColumn;
    v2Column1: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    cxgrdMJLen: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v1Column11: TcxGridDBColumn;
    cxgrid1Level1: TcxGridLevel;
    MovePanel2: TMovePanel;
    v1Column2: TcxGridDBColumn;
    Panel1: TPanel;
    Label5: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Y_CodeName: TEdit;
    Y_Spec: TEdit;
    FactoryName: TEdit;
    BatchNo: TEdit;
    Edit1: TEdit;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBRafreshClick(Sender: TObject);
    procedure ConNoMChange(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure C_CodeNameChange(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
  private
    procedure InitGrid();
    { Private declarations }
  public
    { Public declarations }
    FCode, FClothType, FSeBie, FZZType: string;
  end;

var
  frmLSSQKCHZSel: TfrmLSSQKCHZSel;

implementation

uses
  U_DataLink, U_Fun, U_ZDYHelp;

{$R *.dfm}

procedure TfrmLSSQKCHZSel.FormDestroy(Sender: TObject);
begin
  frmLSSQKCHZSel := nil;
end;

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

procedure TfrmLSSQKCHZSel.InitGrid();
var
  fwhere, Pwhere: string;
begin
  Pwhere := SGetFilters(Panel1, 1, 2);
  if trim(Pwhere) <> '' then
    fwhere := fwhere + ' where ' + trim(Pwhere);
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      SQL.Add('exec P_YTCK_Get_KCHZ_Sel');
      sql.Add('''' + fwhere + ''' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_Main);
    SInitCDSData20(ADOQueryMain, CDS_Main);

  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmLSSQKCHZSel.TBRafreshClick(Sender: TObject);
begin
  //BegDate.SetFocus;
  MovePanel2.Visible := True;
  MovePanel2.Refresh;
  InitGrid();
  MovePanel2.Visible := False;
end;

procedure TfrmLSSQKCHZSel.ConNoMChange(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
  end;
end;

procedure TfrmLSSQKCHZSel.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('JTS发货申请专用1', Tv1, 'JTS库存');
  Close;
end;

procedure TfrmLSSQKCHZSel.FormShow(Sender: TObject);
begin
  ReadCxGrid('JTS发货申请专用1', Tv1, 'JTS库存');
  InitGrid();
end;

procedure TfrmLSSQKCHZSel.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS20(ADOQueryMain, CDS_Main);
    SInitCDSData20(ADOQueryMain, CDS_Main);
  end;
end;

procedure TfrmLSSQKCHZSel.C_CodeNameChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmLSSQKCHZSel.ToolButton1Click(Sender: TObject);
begin
  ModalResult := 1;
end;

end.

