unit U_GeMeiOutputSel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
  cxEdit, DB, cxDBData, ToolWin, ComCtrls, U_BaseHelp, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls,
  cxGridCustomView, cxGrid, DBClient, ADODB, ImgList, StdCtrls, ExtCtrls,
  cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels,
  cxLookAndFeelPainters, cxNavigator, dxDateRanges, dxBarBuiltInMenu,
  System.ImageList, U_BaseInput, cxContainer, cxImageList,
  dxScrollbarAnnotations, dxSkinsCore, dxSkinsDefaultPainters;

type
  TfrmGeMeiOutputSel = class(TfrmBaseHelp)
    TV1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    ToolBar1: TToolBar;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    DS_1: TDataSource;
    CDS_1: TClientDataSet;
    TBSave: TToolButton;
    TBClose: TToolButton;
    ToolButton1: TToolButton;
    ADOConnection1: TADOConnection;
    GPM_1: TcxGridPopupMenu;
    ImageList1: TImageList;
    TV1Column1: TcxGridDBColumn;
    TV1Column2: TcxGridDBColumn;
    TV1Column3: TcxGridDBColumn;
    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;
    SHuangSeCu: TcxStyle;
    cxImageList_bar: TcxImageList;
    TV1Column4: TcxGridDBColumn;
    TV1Column5: TcxGridDBColumn;
    TV1Column6: TcxGridDBColumn;
    TV1Column7: TcxGridDBColumn;
    TV1Column8: TcxGridDBColumn;
    TV1Column9: TcxGridDBColumn;
    TV1Column10: TcxGridDBColumn;
    TV1Column11: TcxGridDBColumn;
    TV1Column12: TcxGridDBColumn;
    TV1Column13: TcxGridDBColumn;
    TV1Column14: TcxGridDBColumn;
    TV1Column15: TcxGridDBColumn;
    TV1Column16: TcxGridDBColumn;
    TV1Column17: TcxGridDBColumn;
    TV1Column18: TcxGridDBColumn;
    TV1Column19: TcxGridDBColumn;
    TV1Column20: TcxGridDBColumn;
    TV1Column21: TcxGridDBColumn;
    TV1Column22: TcxGridDBColumn;
    TV1Column23: TcxGridDBColumn;
    TV1Column24: TcxGridDBColumn;
    TV1Column25: TcxGridDBColumn;
    TV1Column26: TcxGridDBColumn;
    TV1Column27: TcxGridDBColumn;
    TV1Column28: TcxGridDBColumn;
    TV1Column29: TcxGridDBColumn;
    TV1Column30: TcxGridDBColumn;
    TV1Column31: TcxGridDBColumn;
    TV1Column32: TcxGridDBColumn;
    TV1Column33: TcxGridDBColumn;
    TV1Column34: TcxGridDBColumn;
    TV1Column35: TcxGridDBColumn;
    TV1Column36: TcxGridDBColumn;
    TV1Column37: TcxGridDBColumn;
    TV1Column38: TcxGridDBColumn;
    TV1Column39: TcxGridDBColumn;
    TV1Column40: TcxGridDBColumn;
    TV1Column41: TcxGridDBColumn;
    TV1Column42: TcxGridDBColumn;
    TV1Column43: TcxGridDBColumn;
    TV1Column44: TcxGridDBColumn;
    TV1Column45: TcxGridDBColumn;
    TV1Column46: TcxGridDBColumn;
    TV1Column47: TcxGridDBColumn;
    TV1Column48: TcxGridDBColumn;
    TV1Column49: TcxGridDBColumn;
    TV1Column50: TcxGridDBColumn;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure TV1DblClick(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ToolButton1Click(Sender: TObject);
  private
    procedure InitGrid();
    //function SaveData(): Boolean;
    { Private declarations }
  public
    FCoType, FAuthority, FStores, FSTKName: string;
    { Public declarations }
  end;

var
  frmGeMeiOutputSel: TfrmGeMeiOutputSel;

implementation

uses
  U_DataLink, U_RTFun;

{$R *.dfm}

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

procedure TfrmGeMeiOutputSel.FormCreate(Sender: TObject);
begin
  inherited;
  try
    with ADOConnection1 do
    begin
      Connected := false;
      ConnectionString := DConString;
      Connected := true;
    end;
    ADOQueryBaseCmd.Connection := ADOConnection1;
    ADOQueryBaseTemp.Connection := ADOConnection1;
  except
    application.MessageBox('网络连接失败！', '提示信息');
  end;
end;

procedure TfrmGeMeiOutputSel.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      sql.Add(' select A.* ,Pieceint=CEILING(A.Piece) ');
      sql.Add(' from BS_Cloth_IO A where 1 = 1');
      sql.Add(' and isnull(stkName,'''')=''' + Trim('格美门店') + '''');
      sql.Add(' and IOFlag=''出库''  ');
      sql.Add(' order by IOTime desc');

      Open;
    end;

    SCreateCDS(ADOQueryMain, CDS_1);
    SInitCDSData(ADOQueryMain, CDS_1);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

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

  InitGrid();

  ReadCxGrid('单位名称' + Trim(FCoType), TV1, '自定义数据');

end;

procedure TfrmGeMeiOutputSel.TBCloseClick(Sender: TObject);
begin
  inherited;
  Close;
end;

procedure TfrmGeMeiOutputSel.TBSaveClick(Sender: TObject);
begin
  WriteCxGrid('单位名称' + Trim(FCoType), TV1, '自定义数据');

end;

procedure TfrmGeMeiOutputSel.ToolButton1Click(Sender: TObject);
begin
  ModalResult := 1;
end;

procedure TfrmGeMeiOutputSel.TV1DblClick(Sender: TObject);
begin
  ModalResult := 1;
end;

procedure TfrmGeMeiOutputSel.FormDestroy(Sender: TObject);
begin
  inherited;
  frmGeMeiOutputSel := nil;
end;

end.

