unit U_MJSJFX;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
  cxEdit, DB, cxDBData, cxTextEdit, DBClient, ADODB, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
  cxControls, cxGridCustomView, cxGrid, StdCtrls, ExtCtrls, ComCtrls, ToolWin,
  cxButtonEdit, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;

type
  TfrmMJSJFX = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    Panel1: TPanel;
    Label1: TLabel;
    OrderNo: TEdit;
    ADOTmp: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOCmd: TADOQuery;
    DataSource1: TDataSource;
    Order_YC: TClientDataSet;
    Label2: TLabel;
    Ma: TLabel;
    Label7: TLabel;
    MJQty1: TEdit;
    Label5: TLabel;
    Label8: TLabel;
    MJFK: TEdit;
    Label9: TLabel;
    Label3: TLabel;
    Label11: TLabel;
    MJSJKZ: TEdit;
    Label13: TLabel;
    MJQty2: TEdit;
    Panel2: TPanel;
    Order_CD: TClientDataSet;
    DataSource2: TDataSource;
    Order_XG: TClientDataSet;
    DataSource3: TDataSource;
    DataSource4: TDataSource;
    Order_Del: TClientDataSet;
    Label4: TLabel;
    Panel4: TPanel;
    cxGrid3: TcxGrid;
    TV3: TcxGridDBTableView;
    cxGridDBColumn7: TcxGridDBColumn;
    cxGridDBColumn8: TcxGridDBColumn;
    cxGridDBColumn9: TcxGridDBColumn;
    cxGridDBColumn10: TcxGridDBColumn;
    cxGridDBColumn11: TcxGridDBColumn;
    cxGridDBColumn12: TcxGridDBColumn;
    TV3Column1: TcxGridDBColumn;
    TV3Column2: TcxGridDBColumn;
    TV3Column3: TcxGridDBColumn;
    cxGridLevel3: TcxGridLevel;
    Panel5: TPanel;
    Panel6: TPanel;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBTableView;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridDBColumn2: TcxGridDBColumn;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridDBColumn4: TcxGridDBColumn;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    TV1Column1: TcxGridDBColumn;
    TV1Column2: TcxGridDBColumn;
    TV1Column3: TcxGridDBColumn;
    TV1Column4: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    Panel7: TPanel;
    Panel9: TPanel;
    cxGrid4: TcxGrid;
    TV4: TcxGridDBTableView;
    cxGridDBColumn19: TcxGridDBColumn;
    cxGridLevel4: TcxGridLevel;
    Panel8: TPanel;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBTableView;
    cxGridDBColumn13: TcxGridDBColumn;
    cxGridDBColumn14: TcxGridDBColumn;
    cxGridDBColumn15: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    TV4Column1: TcxGridDBColumn;
    TV4Column2: TcxGridDBColumn;
    Panel3: TPanel;
    cxGrid5: TcxGrid;
    Tv5: TcxGridDBTableView;
    cxGridDBColumn20: TcxGridDBColumn;
    cxGridDBColumn21: TcxGridDBColumn;
    cxGridDBColumn22: TcxGridDBColumn;
    cxGridLevel5: TcxGridLevel;
    Order_TH: TClientDataSet;
    DataSource5: TDataSource;
    TV1Column5: TcxGridDBColumn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
    function SaveData(): Boolean;
  public
    { Public declarations }
  end;

var
  frmMJSJFX: TfrmMJSJFX;

implementation

uses
  U_Fun, U_ZDYHelp, U_DataLink;

{$R *.dfm}

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

procedure TfrmMJSJFX.FormDestroy(Sender: TObject);
begin
  frmMJSJFX := nil;
end;

function TfrmMJSJFX.SaveData(): Boolean;
begin

end;

procedure TfrmMJSJFX.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('布匹管理', Tv2, '数据分析');     
end;

procedure TfrmMJSJFX.FormShow(Sender: TObject);
var
  key: Char;
begin

  key := #13;
  OrderNoKeyPress(OrderNo, key);
end;

procedure TfrmMJSJFX.OrderNoKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_Get_YichangData ''' + trim(orderno.Text) + ''' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_YC);
    SInitCDSData20(ADOQueryMain, Order_YC);

    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_View_SJFX ''' + trim(orderno.Hint) + ''' ,''0'' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_CD);
    SInitCDSData20(ADOQueryMain, Order_CD);

    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_View_SJFX ''' + trim(orderno.Hint) + ''' ,''1'' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_XG);
    SInitCDSData20(ADOQueryMain, Order_XG);

    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_View_SJFX ''' + trim(orderno.Hint) + ''' ,''2'' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_Del);
    SInitCDSData20(ADOQueryMain, Order_Del);
    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_View_SJFX ''' + trim(orderno.Hint) + ''' ,''3'' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_TH);
    SInitCDSData20(ADOQueryMain, Order_TH);
  end;
end;

end.

