unit U_EmptyRollerkCList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, StdCtrls, ExtCtrls, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
  cxButtonEdit, cxDropDownEdit, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
  cxGrid, DBClient, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu, cxCheckBox,
  RM_Common, RM_Class, RM_GridReport, RM_System, RM_Dataset, MMSystem, Menus,
  BtnEdit, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinBlack,
  dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom,
  dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle,
  dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary,
  dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin,
  dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
  dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin,
  dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine,
  dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue, dxSkinscxPCPainter,
  cxNavigator;

type
  TfrmEmptyRollerkCList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBExport: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Qty: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    ADOQueryCmd: TADOQuery;
    ADOQueryTmp: TADOQuery;
    DataSource1: TDataSource;
    CDS_Main: TClientDataSet;
    cxGridPopupMenu1: TcxGridPopupMenu;
    TOk: TToolButton;
    Label7: TLabel;
    ADOQueryPrint: TADOQuery;
    RMDB_Main: TRMDBDataSet;
    RM1: TRMGridReport;
    ADOQueryMain: TADOQuery;
    v1Column16: TcxGridDBColumn;
    Label31: TLabel;
    FactoryName: TEdit;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    ToolButton2: TToolButton;
    v1Ssel: TcxGridDBColumn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure P_CodeNameChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TOkClick(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
  private
    procedure InitGrid();
    procedure SetStatus();
    { Private declarations }
  public
    fCKName, canshu1: string;
    
    { Public declarations }
  end;

var
  frmEmptyRollerkCList: TfrmEmptyRollerkCList;

implementation

uses
  U_DataLink, U_Fun10, U_ZDYHelp;
{$R *.dfm}

procedure TfrmEmptyRollerkCList.SetStatus();
begin
  TOk.Visible := false;
  TOk.Visible := false;
  if Trim(canshu1) = '选择' then
  begin
    TOk.Visible := true;
    v1Ssel.Visible := true;
  end;
  if Trim(canshu1) = '管理' then
  begin
    TOk.Visible := true;
    v1Ssel.Visible := true;
  end;
end;

procedure TfrmEmptyRollerkCList.InitGrid();
begin
  try
    with adoqueryMain do
    begin
      close;
      sql.Clear;
      sql.Add(' exec P_View_EmptyRollerkC ');

      open;
    end;
    SCreateCDS20(adoqueryMain, CDS_Main);
    SInitCDSData20(adoqueryMain, CDS_Main);
  finally
  end;
end;

procedure TfrmEmptyRollerkCList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  writeCxGrid(self.Caption, Tv1, '仓储管理');
  if Trim(canshu1) = '选择' then
    Action := cahide
  else
    Action := cafree;
end;

procedure TfrmEmptyRollerkCList.FormDestroy(Sender: TObject);
begin
  frmEmptyRollerkCList := nil;
end;

procedure TfrmEmptyRollerkCList.P_CodeNameChange(Sender: TObject);
begin
  if adoqueryMain.Active = False then
    Exit;
  SDofilter(adoqueryMain, SGetFilters(Panel1, 1, 2));
  SCreateCDS20(adoqueryMain, CDS_Main);
  SInitCDSData20(adoqueryMain, CDS_Main);
end;

procedure TfrmEmptyRollerkCList.FormShow(Sender: TObject);
begin
  readCxGrid(self.Caption, Tv1, '仓储管理');
  SetStatus();
  InitGrid();
end;

procedure TfrmEmptyRollerkCList.TBCloseClick(Sender: TObject);
begin
  close;
end;

procedure TfrmEmptyRollerkCList.TBRafreshClick(Sender: TObject);
begin
  initGrid();
end;

procedure TfrmEmptyRollerkCList.TBExportClick(Sender: TObject);
begin
  if CDS_Main.IsEmpty then
    Exit;
  TcxGridToExcel(self.Caption, cxgrid1);
end;

procedure TfrmEmptyRollerkCList.TOkClick(Sender: TObject);
begin
  if CDS_Main.IsEmpty then
    Exit;
  ModalResult := 1;
end;

procedure TfrmEmptyRollerkCList.N1Click(Sender: TObject);
begin
  SelOKNo(CDS_Main, true);
end;

procedure TfrmEmptyRollerkCList.N2Click(Sender: TObject);
begin
  SelOKNo(CDS_Main, false);
end;

procedure TfrmEmptyRollerkCList.ToolButton2Click(Sender: TObject);
begin
  if adoqueryMain.Active = False then
    Exit;
  SDofilter(adoqueryMain, SGetFilters(Panel1, 1, 2));
  SCreateCDS20(adoqueryMain, CDS_Main);
  SInitCDSData20(adoqueryMain, CDS_Main);
end;

end.

