unit U_TradeClothSplit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DB, ADODB, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxContainer, cxEdit, dxSkinsCore,
  dxSkinsDefaultPainters, Vcl.Menus, cxButtons, cxTextEdit, cxCurrencyEdit;

type
  TfrmTradeClothSplit = class(TForm)
    Panel1: TPanel;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Label11: TLabel;
    Qty: TcxCurrencyEdit;
    cxButton1: TcxButton;
    cxButton2: TcxButton;
    Label1: TLabel;
    procedure cxButton1Click(Sender: TObject);
    procedure cxButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    FStkID: string;
    { Public declarations }
  end;

var
  frmTradeClothSplit: TfrmTradeClothSplit;

implementation

uses
  U_DataLink, U_RTFun;
{$R *.dfm}

procedure TfrmTradeClothSplit.cxButton1Click(Sender: TObject);
begin
  if StrToFloatDef(Qty.Text, 0) = 0 then
  begin
    application.MessageBox('请输入拆分米数', '提示信息', 0);
  end;
           //FStkID
  try
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      Sql.Add('exec P_BS_Cloth_IOALL ');
      Sql.Add('  @Operation=' + quotedstr(Trim('库存拆分')));
      Sql.Add(' ,@StkID=' + quotedstr(Trim(FStkID)));
      Sql.Add(' ,@IOTime=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', SGetServerDate(ADOQueryTemp)))));
      Sql.Add(' ,@Piece=' + Trim('0.01'));
      Sql.Add(' ,@Qty=' + Trim(Qty.Text));
      Sql.Add(' ,@Dcode=' + quotedstr(Trim(Dcode)));
      Sql.Add(' ,@DName=' + quotedstr(Trim(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;

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

end.

