unit U_GetPlanListHelp;

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
  TfrmGetPlanListHelp = 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;
    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;
    { Public declarations }
  end;

var
  frmGetPlanListHelp: TfrmGetPlanListHelp;

implementation
uses
  U_global,U_SelfForm;


{$R *.dfm}

procedure TfrmGetPlanListHelp.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 TfrmGetPlanListHelp.InitGrid();
var
  fsj:string;
begin
  fsj:=SGetFinds(Panel1,1,2);
  if (Trim(fsj)='' ) and ( (DtpRq1.Checked=False and DtpRq2.Checked=True) or (DtpRq2.Checked=False and DtpRq1.Checked=True) ) then
  begin
    Application.MessageBox('查询条件不能为空！','提示',0);
    Exit;
  end;
  try
    ADOQueryHelp.DisableControls;
    with ADOQueryHelp do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add('exec P_Get_PlanListHelp :PStatus,:begdate,:enddate,:WSql');
      Parameters.ParamByName('PStatus').Value:=statusId;
     //if Trim(fsj)<>'' then
      Parameters.ParamByName('WSql').Value:=fsj;
      if DtpRq1.Checked=True then
        Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',DtpRq1.DateTime));
      if DtpRq2.Checked=True then
        Parameters.ParamByName('enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',DtpRq2.DateTime+1));
      Open;
    end;
  finally
    ADOQueryHelp.EnableControls;
  end;
end;

procedure TfrmGetPlanListHelp.TBFindClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmGetPlanListHelp.FormShow(Sender: TObject);
begin
  //InitGrid();
  DtpRq1.Checked:=False;
  DtpRq2.Checked:=False;
end;
procedure TfrmGetPlanListHelp.TBOkClick(Sender: TObject);
begin
  ModalResult:=1;
end;

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

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

end.
