unit U_DyeClothIOFlow;

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, cxCalendar, RM_System, RM_Common,
  RM_Class, RM_GridReport, RM_Dataset, cxLookAndFeels, cxLookAndFeelPainters,
  cxNavigator, U_BaseList, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges,
  dxBarBuiltInMenu;

type
  TfrmDyeClothIOFlow = class(TfrmBaseList)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBExport: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    cxGridPopupMenu1: TcxGridPopupMenu;
    Label3: TLabel;
    MPRTCodeName: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    CDS_Main: TClientDataSet;
    cxGrid2Level1: TcxGridLevel;
    cxGrid2: TcxGrid;
    MovePanel2: TMovePanel;
    Label10: TLabel;
    RMGridReport1: TRMGridReport;
    MPRTSpec: TEdit;
    Label16: TLabel;
    customerNoName: TEdit;
    Label13: TLabel;
    TV1: TcxGridDBBandedTableView;
    TV1Column1: TcxGridDBBandedColumn;
    TV1Column2: TcxGridDBBandedColumn;
    TV1Column3: TcxGridDBBandedColumn;
    TV1Column5: TcxGridDBBandedColumn;
    TV1Column6: TcxGridDBBandedColumn;
    TV1Column8: TcxGridDBBandedColumn;
    TV1Column9: TcxGridDBBandedColumn;
    TV1Column11: TcxGridDBBandedColumn;
    TV1Column12: TcxGridDBBandedColumn;
    TV1Column14: TcxGridDBBandedColumn;
    TV1Column15: TcxGridDBBandedColumn;
    ThreeColorBase: TcxStyleRepository;
    SHuangSe: TcxStyle;
    SkyBlue: TcxStyle;
    Default: TcxStyle;
    QHuangSe: TcxStyle;
    Red: TcxStyle;
    FontBlue: TcxStyle;
    TextSHuangSe: TcxStyle;
    FonePurple: TcxStyle;
    FoneClMaroon: TcxStyle;
    FoneRed: TcxStyle;
    RowColor: TcxStyle;
    handBlack: TcxStyle;
    cxBlue: TcxStyle;
    cxStyle1: TcxStyle;
    RMDBMain: TRMDBDataSet;
    Label6: TLabel;
    ywy: TEdit;
    TV1Column4: TcxGridDBBandedColumn;
    TV1Column7: TcxGridDBBandedColumn;
    TV1Column10: TcxGridDBBandedColumn;
    TV1Column13: TcxGridDBBandedColumn;
    TV1Column16: TcxGridDBBandedColumn;
    TV1Column17: TcxGridDBBandedColumn;
    ToolButton1: TToolButton;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ConNoMChange(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure MPRTCodeNameChange(Sender: TObject);
    procedure PRTColorChange(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
  private
    FLeft, FTop: Integer;
    procedure InitGrid();
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmDyeClothIOFlow: TfrmDyeClothIOFlow;

implementation

uses
  U_DataLink, U_RTFun, U_ZDYHelp;

{$R *.dfm}

procedure TfrmDyeClothIOFlow.FormDestroy(Sender: TObject);
begin
  inherited;
  frmDyeClothIOFlow := nil;
end;

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

procedure TfrmDyeClothIOFlow.FormCreate(Sender: TObject);
begin
  inherited;
  BegDate.DateTime := SGetServerDateTime(ADOQueryTemp);
  EndDate.DateTime := SGetServerDateTime(ADOQueryTemp)
end;

procedure TfrmDyeClothIOFlow.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      Filtered := False;
      sql.Add(' EXEC P_Dye_Cloth_IOFlow ');
      sql.Add(' @begdate=''' + formatdateTime('yyyy-MM-dd', begdate.DateTime) + ''' ');
      sql.Add(',@enddate=''' + formatdateTime('yyyy-MM-dd', enddate.DateTime + 1) + ''' ');

      Open;
    end;
    SCreateCDS(ADOQueryMain, CDS_Main);
    SInitCDSData(ADOQueryMain, CDS_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmDyeClothIOFlow.TBRafreshClick(Sender: TObject);
begin
  MovePanel2.Visible := True;
  MovePanel2.Refresh;
  InitGrid();
  MovePanel2.Visible := False;
end;

procedure TfrmDyeClothIOFlow.ToolButton1Click(Sender: TObject);
begin
  WriteCxBandedGrid(self.Caption + tv1.Name, Tv1, '³ÉÆ·²Ö¿â');
end;

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

procedure TfrmDyeClothIOFlow.TBCloseClick(Sender: TObject);
begin

  Close;
end;

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

procedure TfrmDyeClothIOFlow.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then
    exit;
  TcxGridToExcel(self.Caption, cxgrid2);
 // TcxGridToExcel(self.Caption,cxGrid2);
end;

procedure TfrmDyeClothIOFlow.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS(ADOQueryMain, CDS_Main);
    SInitCDSData(ADOQueryMain, CDS_Main);
  end;
end;

procedure TfrmDyeClothIOFlow.MPRTCodeNameChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmDyeClothIOFlow.PRTColorChange(Sender: TObject);
begin
  TBFind.Click;
end;

end.

