unit U_TradeClothSplit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DB, ADODB;

type
  TfrmTradeClothSplit = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Label1: TLabel;
    Button2: TButton;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Len: TEdit;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    FStkID: string;
    { Public declarations }
  end;

var
  frmTradeClothSplit: TfrmTradeClothSplit;

implementation

uses
  U_DataLink;
{$R *.dfm}

procedure TfrmTradeClothSplit.Button2Click(Sender: TObject);
begin
  Close;
end;

procedure TfrmTradeClothSplit.Button1Click(Sender: TObject);
begin
  if StrToFloatDef(Len.Text, 0) = 0 then
  begin
    application.MessageBox('请输入拆分米数', '提示信息', 0);
  end;

  try
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add(' exec P_Trade_Cloth_Split ');
      sql.Add(' @StkID=' + QuotedStr(FStkID));
      sql.Add(',@SplitMeter=' + Len.Text);
      Sql.Add(',@FillId=' + quotedstr(DCode));
      Sql.Add(',@Filler=' + quotedstr(DName));
      open;
    end;
    if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
      raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
    ModalResult := 1;
  except
    application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0);
  end;

end;

end.

