unit U_FinishedClothKBan;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
  cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System,
  RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, MovePanel, cxTextEdit,
  cxContainer, cxCurrencyEdit, BtnEdit, RM_e_main, RM_e_htm, RM_e_Graphic,
  RM_e_Jpeg, RM_e_txt, RM_e_csv, RM_E_llPDF, Math, Clipbrd, cxPC, Mask,
     jpeg;

type
  TfrmFinishedClothKBan = class(TForm)
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DS_Main: TDataSource;
    RM2: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    ADOQueryPrint: TADOQuery;
    RMXLSExport1: TRMXLSExport;
    Order_Main: TClientDataSet;
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label18: TLabel;
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    Panel5: TPanel;
    Panel6: TPanel;
    Panel7: TPanel;
    Panel8: TPanel;
    Timer1: TTimer;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure Timer1Timer(Sender: TObject);
  private
    DQdate: TDateTime;
    FLeft, FTop: Integer;
    FDCheG,FPCode,FUserName: string;
    CurrentPage, RecordsNumber: Integer;
    procedure InitGrid();
    { Private declarations }
  public
    FFInt: Integer;
    canshu1: string;
    { Public declarations }
  end;

implementation

uses
  U_DataLink, U_Fun, U_MJEdit, U_ZDYHelp, U_SysLogHelp;

{$R *.dfm}

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

procedure TfrmFinishedClothKBan.FormCreate(Sender: TObject);
begin
  DQdate := SGetServerDate(ADOQueryTemp);
  Timer1.Enabled := true;
end;

procedure TfrmFinishedClothKBan.InitGrid();

begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      SQL.Add('exec P_View_KBan');
      SQL.Add('@Begdate='+ QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', SGetServerDate10(ADOQueryTemp)))));
      SQL.Add(',@Enddate='+ QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', SGetServerDate10(ADOQueryTemp)+1))));
      //ShowMessage(SQL.Text);
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_Main);
    SInitCDSData20(ADOQueryMain, Order_Main);
    if Order_Main.IsEmpty=False then
    begin
      Panel1.Caption:=Trim(Order_Main.fieldbyname('ZJQty').AsString);
      Panel3.Caption:=Trim(Order_Main.fieldbyname('SZQty').AsString);
      Panel4.Caption:=Trim(Order_Main.fieldbyname('XZQty').AsString);
      Panel5.Caption:=Trim(Order_Main.fieldbyname('CZQty').AsString);
      Panel2.Caption:=Trim(Order_Main.fieldbyname('TJQty').AsString);
      Panel8.Caption:=Trim(Order_Main.fieldbyname('JTQty').AsString);
      Panel6.Caption:=Trim(Order_Main.fieldbyname('DJQty').AsString);
      Panel7.Caption:=Trim(Order_Main.fieldbyname('DJCLiang').AsString)+'Ã×';
    end;
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmFinishedClothKBan.FormShow(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmFinishedClothKBan.Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  FLeft := X;
  FTop := Y;
end;

procedure TfrmFinishedClothKBan.Timer1Timer(Sender: TObject);
begin
   Label9.Caption:=FormatDateTime('yyyy-mm-dd hh:mm:ss', Now);
   InitGrid();
end;

end.

