unit U_GetPlanListJCHelp;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, ADODB, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
  cxControls, cxGridCustomView, cxGrid, StdCtrls, ComCtrls, ImgList,
  ToolWin, ExtCtrls;

type
  TfrmGetPlanListJCHelp = class(TForm)
    ToolBar1: TToolBar;
    ToolButton5: TToolButton;
    TBOk: TToolButton;
    ToolButton8: TToolButton;
    TBClose: TToolButton;
    pubquery: TADOQuery;
    ImageList1: TImageList;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    Tv1PlanNo1: TcxGridDBColumn;
    Tv1BusineesName1: TcxGridDBColumn;
    Tv1CustomNo: TcxGridDBColumn;
    Tv1P_ChnName1: TcxGridDBColumn;
    Tv1P_Spec1: TcxGridDBColumn;
    Tv1P_YHNo1: TcxGridDBColumn;
    v1P_BaseChnName: TcxGridDBColumn;
    Tv1P_Color: TcxGridDBColumn;
    Tv1p_num1: TcxGridDBColumn;
    Tv1p_fhs1: TcxGridDBColumn;
    Tv1p_kcs1: TcxGridDBColumn;
    Tv1UnitName1: TcxGridDBColumn;
    Tv1filltime1: TcxGridDBColumn;
    Tv1P_Breadth1: TcxGridDBColumn;
    Tv1P_UpBreadth1: TcxGridDBColumn;
    Tv1B_UnitName1: TcxGridDBColumn;
    Tv1P_Gram1: TcxGridDBColumn;
    Tv1G_UnitName1: TcxGridDBColumn;
    v1RRequest: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    DataSource1: TDataSource;
    ADOQueryHelp: TADOQuery;
    ADOConnection1: TADOConnection;
    TBFind: TToolButton;
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    DtpRq1: TDateTimePicker;
    DtpRq2: TDateTimePicker;
    PlanNo: TEdit;
    CustomName: TEdit;
    P_ChnName: TEdit;
    P_ColStd: TEdit;
    P_YHNo: TEdit;
    v1LbStr6: TcxGridDBColumn;
    v1SupplierName: TcxGridDBColumn;
    v1Sbtr2: TcxGridDBColumn;
    v1P_FqNo: TcxGridDBColumn;
    v1GroupNo: TcxGridDBColumn;
    procedure FormCreate(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBOkClick(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure TBCloseClick(Sender: TObject);
  private
    procedure InitGrid();
    { Private declarations }
  public
    statusId:Integer;
    ADType:String;
    { Public declarations }
  end;

var
  frmGetPlanListJCHelp: TfrmGetPlanListJCHelp;

implementation
uses
  U_global,U_SelfForm;


{$R *.dfm}

procedure TfrmGetPlanListJCHelp.FormCreate(Sender: TObject);
begin
  with ADOConnection1 do
  begin
    ADOConnection1.Connected:=False;
    ADOConnection1.ConnectionString:=gConString;
    ADOConnection1.Connected:=True;
  end;
  DtpRq1.DateTime:=SGetServerDate(ADOQueryHelp);
  DtpRq2.DateTime:=DtpRq1.DateTime;
end;
procedure TfrmGetPlanListJCHelp.InitGrid();
begin
  try
    ADOQueryHelp.DisableControls;
    with ADOQueryHelp do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_Get_PlanListJCHelp :PStatus,:begdate,:enddate,:ADType,:PlanNO,:P_SeqNo');
      Parameters.ParamByName('PStatus').Value:=statusId;
      Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',DtpRq1.DateTime));
      Parameters.ParamByName('enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',DtpRq2.DateTime+1));
      Parameters.ParamByName('ADType').Value:=ADType;
      Open;
    end;
  finally
    ADOQueryHelp.EnableControls;
  end;
end;

procedure TfrmGetPlanListJCHelp.TBFindClick(Sender: TObject);
begin
  InitGrid();
  if ADOQueryHelp.Active then
  begin
    SDofilter(ADOQueryHelp,SGetFilters(Panel1,1,2));
  end;
end;

procedure TfrmGetPlanListJCHelp.FormShow(Sender: TObject);
begin
  InitGrid();
end;
procedure TfrmGetPlanListJCHelp.TBOkClick(Sender: TObject);
begin
  ModalResult:=1;
end;

procedure TfrmGetPlanListJCHelp.Tv1CellDblClick(
  Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  ModalResult:=1;
end;

procedure TfrmGetPlanListJCHelp.TBCloseClick(Sender: TObject);
begin
  Close;
  ModalResult:=-1;
end;

end.
