unit U_ProductJYHZList;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters,  cxStyles, cxCustomData,
  cxFilter, cxData, cxDataStorage, cxEdit, cxNavigator, dxDateRanges,
  dxScrollbarAnnotations, Data.DB, cxDBData, cxCalendar, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
  cxGridCustomView, cxGrid, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.ExtCtrls,
  Vcl.ToolWin, U_BaseList, Data.Win.ADODB, dxBarBuiltInMenu,
  cxGridCustomPopupMenu, cxGridPopupMenu, RM_Common, RM_Class, RM_GridReport,
  cxContainer, cxTextEdit, dxCore, cxDateUtils, dxLayoutcxEditAdapters,
  dxLayoutContainer, cxMaskEdit, cxDropDownEdit, dxLayoutControl, cxProgressBar;

type
  TfrmProductJYHZList = class(TfrmBaseList)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    Tmx: TToolButton;
    TBExport: TToolButton;
    TBClose: TToolButton;
    C_name: TcxTextEdit;
    orderNo: TcxTextEdit;
    C_color: TcxTextEdit;
    batchNo: TcxTextEdit;
    conNo: TcxTextEdit;
    buyconNo: TcxTextEdit;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1CRTime: TcxGridDBColumn;
    v1orderNo: TcxGridDBColumn;
    v1conNo: TcxGridDBColumn;
    v1buyconNo: TcxGridDBColumn;
    v2C_Name: TcxGridDBColumn;
    v1C_color: TcxGridDBColumn;
    v1C_ecolor: TcxGridDBColumn;
    v1C_pattern: TcxGridDBColumn;
    v1batchno: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1meter: TcxGridDBColumn;
    v1ordUnit: TcxGridDBColumn;
    v2grossWeight: TcxGridDBColumn;
    v1netWeight: TcxGridDBColumn;
    Tv1CKROLL: TcxGridDBColumn;
    Tv1CKMeter: TcxGridDBColumn;
    Tv1KCROLL: TcxGridDBColumn;
    Tv1kcMeter: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    DataSource1: TDataSource;
    ADOQueryMain: TADOQuery;
    RMGridReport1: TRMGridReport;
    cxGridPopupMenu1: TcxGridPopupMenu;
    Tv1yardage: TcxGridDBColumn;
    Tv1kcyardage: TcxGridDBColumn;
    Tv1kcgrossWeight: TcxGridDBColumn;
    Tv1kcnetWeight: TcxGridDBColumn;
    Tv1AddwetPresent: TcxGridDBColumn;
    Tv1AddLenPresent: TcxGridDBColumn;
    Tv1C_StyleNo: TcxGridDBColumn;
    ToolButton2: TToolButton;
    dxLayoutControl_query: TdxLayoutControl;
    C_styleNo: TcxTextEdit;
    enddate: TcxDateEdit;
    begdate: TcxDateEdit;
    C_Pattern: TcxTextEdit;
    dxLayoutControl_queryGroup_Root: TdxLayoutGroup;
    dxLayoutItem_begdate: TdxLayoutItem;
    dxLayoutItem2: TdxLayoutItem;
    dxLayoutItem_color: TdxLayoutItem;
    dxLayoutItem_pm: TdxLayoutItem;
    dxLayoutItem_end: TdxLayoutItem;
    dxLayoutItem_hth: TdxLayoutItem;
    dxLayoutItem_khdh: TdxLayoutItem;
    dxLayoutItem_Pattern: TdxLayoutItem;
    dxLayoutGroup1: TdxLayoutGroup;
    dxLayoutGroup2: TdxLayoutGroup;
    dxLayoutItem1: TdxLayoutItem;
    dxLayoutItem3: TdxLayoutItem;
    procedure TBCloseClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure TmxClick(Sender: TObject);
    procedure Tv1DblClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
  private
    procedure InitGrid();
  public
    { Public declarations }
  end;

var
  frmProductJYHZList: TfrmProductJYHZList;

implementation
uses
  U_DataLink,U_RtFun,U_ZDYHelp,U_globalVar,U_TradeClothInspList,U_FormLayOutDesign;
{$R *.dfm}

procedure TfrmProductJYHZList.TBCloseClick(Sender: TObject);
begin
  inherited;
  WriteCxGrid(self.Caption+tv1.Name,Tv1,'³ÉÆ·²Ö¿â');
  Close;
end;

procedure TfrmProductJYHZList.TBExportClick(Sender: TObject);
begin
  inherited;
  if ADOQueryMain.IsEmpty then exit;
  TcxGridToExcel(self.Caption,cxGrid1);
end;
procedure TfrmProductJYHZList.TBFindClick(Sender: TObject);
begin
  inherited;
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain,SLGetFilters(dxLayoutControl_query,1,2));
   // SCreateCDS20(ADOQueryMain,CDS_Main);
   // SInitCDSData20(ADOQueryMain,CDS_Main);
  end;
end;

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

procedure TfrmProductJYHZList.TmxClick(Sender: TObject);
begin
  inherited;
   if ADOQueryMain.IsEmpty then Exit;
    //frmTradeClothInspList:=TfrmTradeClothInspList.Create(Application);
    with TfrmTradeClothInspList.Create(Application) do
    begin
      orderno.Text:=trim(self.ADOQueryMain.fieldbyname('orderno').asstring);
      batchNo.Text:=trim(self.ADOQueryMain.fieldbyname('batchNo').asstring);
      C_Color.Text:=trim(self.ADOQueryMain.fieldbyname('C_Color').asstring);
      if ShowModal=1 then
      begin
       //     InitGrid();
      end;
      free;
    end;
end;

procedure TfrmProductJYHZList.ToolButton2Click(Sender: TObject);
begin
  inherited;
  WriteCxGrid(self.Caption, Tv1, gDllFileCaption);
  if gIsCanDesign then
  begin
    saveLayOut(application,dxLayoutControl_query, ADOQueryBaseCmd,PWideChar( fDllFileName + '|' + Self.Name + '|' + dxLayoutControl_query.Name + '.ini'));
  end;
end;

procedure TfrmProductJYHZList.Tv1DblClick(Sender: TObject);
begin
  inherited;
  Tmx.Click;
end;

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

procedure TfrmProductJYHZList.FormCreate(Sender: TObject);
begin
  inherited;
  BegDate.Date:=SGetServerDateTime(ADOQueryBaseTemp);
  EndDate.Date:=BegDate.Date ;
  cxGrid1.Align:=alClient;
end;

procedure TfrmProductJYHZList.FormDestroy(Sender: TObject);
begin
  inherited;
  frmProductJYHZList:=nil;
end;

procedure TfrmProductJYHZList.FormShow(Sender: TObject);
begin
  inherited;
  readCxGrid(self.Caption+tv1.Name,Tv1,'³ÉÆ·²Ö¿â');
  InitGrid();
end;

procedure TfrmProductJYHZList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      Filtered:=False;
      sql.Add('exec p_select_pieceCheckHz_list');
      sql.Add('@begdate='+QuotedStr(FormatDateTime('yyyy-MM-dd', BegDate.Date)));
      sql.Add(',@enddate='+QuotedStr(FormatDateTime('yyyy-MM-dd', endDate.Date+1)));
      sql.Add(',@orderNo='+QuotedStr(orderNo.Text));
      sql.Add(',@groupBy=''1''');
      Open;
      //ShowMessage(SQL.Text);
    end;
   // SCreateCDS(ADOQueryMain,CDS_Main);
   // SInitCDSData(ADOQueryMain,CDS_Main);
   SDofilter(ADOQueryMain,SLGetFilters(dxLayoutControl_query,1,2));
  finally
    ADOQueryMain.EnableControls;
  end;
end;
end.
