unit U_HCJYView;  //25

interface

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

type
  TfrmHCJYView = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    Label3: TLabel;
    OrderNo: TEdit;
    ClientDataSet6: TClientDataSet;
    DataSource6: TDataSource;
    ADOQuery1: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Label1: TLabel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    Label18: TLabel;
    MPRTCode: TEdit;
    Label19: TLabel;
    MPRTCodeName: TEdit;
    ADOQueryMain: TADOQuery;
    cxGridPopupMenu1: TcxGridPopupMenu;
    cxGrid6: TcxGrid;
    Tv6: TcxGridDBBandedTableView;
    cxGridDBBandedColumn1: TcxGridDBBandedColumn;
    cxGridDBBandedColumn2: TcxGridDBBandedColumn;
    Tv6Column1: TcxGridDBBandedColumn;
    Tv6Column2: TcxGridDBBandedColumn;
    v6Column15: TcxGridDBBandedColumn;
    v6Column16: TcxGridDBBandedColumn;
    v6Column17: TcxGridDBBandedColumn;
    v6Column20: TcxGridDBBandedColumn;
    v6Column21: TcxGridDBBandedColumn;
    v6Column1: TcxGridDBBandedColumn;
    v6Column2: TcxGridDBBandedColumn;
    v6Column3: TcxGridDBBandedColumn;
    v6Column14: TcxGridDBBandedColumn;
    v6Column19: TcxGridDBBandedColumn;
    v6Column22: TcxGridDBBandedColumn;
    cxGridLevel3: TcxGridLevel;
    v6Column4: TcxGridDBBandedColumn;
    v6Column5: TcxGridDBBandedColumn;
    v6Column6: TcxGridDBBandedColumn;
    v6Column7: TcxGridDBBandedColumn;
    v6Column8: TcxGridDBBandedColumn;
    v6Column9: TcxGridDBBandedColumn;
    Label2: TLabel;
    PRTColor: TEdit;
    Panel2: TPanel;
    v6Column10: TcxGridDBBandedColumn;
    v6Column11: TcxGridDBBandedColumn;
    v6Column12: TcxGridDBBandedColumn;
    v6Column13: TcxGridDBBandedColumn;
    v6Column18: TcxGridDBBandedColumn;
    v6Column23: TcxGridDBBandedColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure v6Column14PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
    procedure TBFindClick(Sender: TObject);
    procedure OrderNoChange(Sender: TObject);
    procedure MPRTCodeChange(Sender: TObject);
  private
    { Private declarations }
    procedure InitGrid();
    procedure InitGridKK();
  public
    { Public declarations }
  end;

var
  frmHCJYView: TfrmHCJYView;

implementation
uses
  U_DataLink,U_RTFun, U_GYSList,U_ZDYHelp;
{$R *.dfm}

procedure TfrmHCJYView.FormDestroy(Sender: TObject);
begin
  frmHCJYView:=nil;
end;

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

procedure TfrmHCJYView.TBRafreshClick(Sender: TObject);
begin
  Panel2.Visible:=True;
  Panel2.Refresh;
  InitGrid();
  Panel2.Visible:=False;
end;
procedure TfrmHCJYView.InitGrid();
begin
  with ADOQueryMain do
  begin
    Filtered:=False;
    Close;
    sql.Clear;
    sql.Add(' exec P_View_ORDHuiCangJianYan :begdate,:endate,'''' ');
    Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date));
    Parameters.ParamByName('endate').Value:=Trim(FormatDateTime('yyyy-MM-dd',EndDate.Date+1));
    Open;
  end;
  SCreateCDS20(ADOQueryMain,ClientDataSet6);
  SInitCDSData20(ADOQueryMain,ClientDataSet6);
end;
procedure TfrmHCJYView.InitGridKK();
begin
  

end;
procedure TfrmHCJYView.FormShow(Sender: TObject);
begin
  ReadCxBandedGrid('Tv611',Tv6,'µ÷½Ú²Ö¿â');
  EndDate.Date:=SGetServerDate(ADOQuery1);
  BegDate.Date:=EndDate.Date-7;
end;

procedure TfrmHCJYView.TBCloseClick(Sender: TObject);
begin
  WriteCxBandedGrid('Tv611',Tv6,'µ÷½Ú²Ö¿â');
  close;
end;

procedure TfrmHCJYView.v6Column14PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmGYSList:=TfrmGYSList.Create(Application);
    with frmGYSList do
    begin
      if ShowModal=1 then
      begin
        with Self.ClientDataSet6 do
        begin
          Edit;
          FieldByName('ToFactoryNo').Value:=Trim(frmGYSList.Order_Main.fieldbyname('ZKID').AsString) ;
          FieldByName('ToFactoryName').Value:=Trim(frmGYSList.Order_Main.fieldbyname('KHNameJC').AsString);
          //Post;
        end;
      end;
    end;
  finally
    frmGYSList.Free;
  end;
end;

procedure TfrmHCJYView.OrderNoKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    if Trim(OrderNo.Text)='' then Exit;
    Panel2.Visible:=True;
    Panel2.Refresh;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add(' exec P_View_ORDHuiCangJianYan '''','''',:OrderNo ');
      Parameters.ParamByName('OrderNo').Value:=Trim(OrderNo.Text);
      Open;
    end;
    SCreateCDS20(ADOQueryMain,ClientDataSet6);
    SInitCDSData20(ADOQueryMain,ClientDataSet6);
    Panel2.Visible:=False;
  end;

end;

procedure TfrmHCJYView.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active=False then Exit;
  SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  SCreateCDS20(ADOQueryMain,ClientDataSet6);
  SInitCDSData20(ADOQueryMain,ClientDataSet6);
end;

procedure TfrmHCJYView.OrderNoChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmHCJYView.MPRTCodeChange(Sender: TObject);
begin
  TBFind.Click;
end;

end.
