unit U_TradeXinYuStkList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Vcl.Printers, 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, cxCheckBox, RM_Common, RM_Class, RM_e_Xls, RM_Dataset,
  RM_System, RM_GridReport, Menus, cxCalendar, cxButtonEdit, cxTextEdit,
  cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxDateRanges,
  dxBarBuiltInMenu, U_BaseList, dxScrollbarAnnotations, cxContainer,
  cxProgressBar, cxButtons, cxMaskEdit, dxSkinsCore, dxSkinsDefaultPainters,
  cxPC;

type
  TfrmTradeXinYuStkList = class(TfrmBaseList)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    ADOQueryCmd: TADOQuery;
    ADO_2: TADOQuery;
    ADOQueryTemp: TADOQuery;
    PopupMenu1: TPopupMenu;
    Label3: TLabel;
    Label4: TLabel;
    Label2: TLabel;
    C_name: TcxTextEdit;
    C_Code: TcxTextEdit;
    C_Color: TcxTextEdit;
    ToolButton2: TToolButton;
    Label6: TLabel;
    C_ColorNo: TcxTextEdit;
    N1: TMenuItem;
    N2: TMenuItem;
    ToolButton3: TToolButton;
    GPM_2: TcxGridPopupMenu;
    CDS_2: TClientDataSet;
    DS_2: TDataSource;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBTableView;
    cxGridDBColumn14: TcxGridDBColumn;
    cxGridDBColumn9: TcxGridDBColumn;
    cxGridDBColumn15: TcxGridDBColumn;
    cxGridDBColumn16: TcxGridDBColumn;
    cxGridDBColumn24: TcxGridDBColumn;
    cxGridDBColumn26: TcxGridDBColumn;
    cxGridDBColumn28: TcxGridDBColumn;
    cxGridDBColumn29: TcxGridDBColumn;
    cxGridDBColumn17: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBRafreshClick(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure MPRTCodeNameChange(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure ToolButton2Click(Sender: TObject);
    procedure FromCoNamePropertiesChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure C_CodeKeyPress(Sender: TObject; var Key: Char);
  private
    canshu1, FSTKName, canshu3, canshu4: string;
    procedure InitGrid2();
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmTradeXinYuStkList: TfrmTradeXinYuStkList;

implementation

uses
  U_DataLink, U_RTFun, U_PrintLabFun, U_dynamicsDll, U_printPdf,
  U_TradeClothSplit, U_LabelPrint;

{$R *.dfm}

procedure TfrmTradeXinYuStkList.FormDestroy(Sender: TObject);
begin
  inherited;
  frmTradeXinYuStkList := nil;
end;

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

procedure TfrmTradeXinYuStkList.FormCreate(Sender: TObject);
begin
  inherited;
  canshu1 := Trim(self.fParameters1);
  FSTKName := Trim(self.fParameters2);
  canshu3 := Trim(self.fParameters3);
  canshu4 := Trim(self.fParameters4);
end;

procedure TfrmTradeXinYuStkList.InitGrid2();
var
  SqlStr: string;
begin

  SqlStr := ' EXEC P_BS_Cloth_Xinyu_Stk';

//  ShowMessage(SqlStr);
  InitCDSData(ADO_2, CDS_2, Tv2, SqlStr, SGetFilters(Panel1, 1, 2), 'C_Code');

end;

procedure TfrmTradeXinYuStkList.TBRafreshClick(Sender: TObject);
begin
  InitGrid2();
end;

procedure TfrmTradeXinYuStkList.TBCloseClick(Sender: TObject);
begin

  Close;
end;

procedure TfrmTradeXinYuStkList.FormShow(Sender: TObject);
begin
  inherited;

  ReadCxGrid(trim(Self.Caption) + 'Tv2', Tv2, '贸易汇总仓库');
  canshu4 := Trim(self.fParameters4);
  InitGrid2();
end;

procedure TfrmTradeXinYuStkList.C_CodeKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
    TBFind.Click;
end;

procedure TfrmTradeXinYuStkList.FromCoNamePropertiesChange(Sender: TObject);
begin
  if Length(Trim(TcxTextEdit(Sender).Text)) < 4 then
    Exit;
  TBFind.Click;
end;

procedure TfrmTradeXinYuStkList.TBFindClick(Sender: TObject);
begin

  CDSDataFilter(ADO_2, CDS_2, Tv2, '{"FilterStr":"' + CommonFiltersByContainer(Panel1, '  {"EquTag": 1,"LikeTag": 2,"Fields": "C_name|C_Color|C_ColorNo"}') + '"  }');

end;

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

procedure TfrmTradeXinYuStkList.ToolButton2Click(Sender: TObject);
begin
  WriteCxGrid(trim(Self.Caption) + 'Tv2', Tv2, '贸易汇总仓库');
end;

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

end.

