unit UT0902;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls, emapi, uss, auxiapi;

type
  TGW0902 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Edit1: TEdit;
    Panel2: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Panel1: TPanel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
    procedure GotoNextCTL(Key: Char);
    function IsReady:Boolean;
    function PACKFIELDS:TBuffer;
    function Send(Host, Port, inPackage: String):String;
  public
    { Public declarations }
    sinComm: TSinComm;
    soutComm: TSoutComm;
  end;

var
  GW0902: TGW0902;
  procedure T0902(inCommArea: TSinComm; var outCommArea: TSoutComm);stdcall;

implementation

{$R *.DFM}

procedure T0902(inCommArea: TSinComm; var outCommArea: TSoutComm);stdcall;
var
   tmpGW0902: TGW0902;
begin
   tmpGW0902 := TGW0902.Create(nil);
   tmpGW0902.sinComm := inCommArea;

   If (tmpGW0902.sinComm.SIBRANCH = '0000')and(tmpGW0902.sinComm.SITELLER = '0000') then
   begin
      tmpGW0902.Label21.Caption := '?????';
      tmpGW0902.Label5.Caption := '?????';
      tmpGW0902.Label7.Caption := '?????';

      tmpGW0902.Label9.Caption := inCommArea.SITRXSQNO;
      tmpGW0902.Label11.Caption := inCommArea.SISYSDATE;
   end else begin
      tmpGW0902.Label21.Caption := StringOfChar('0', 5 - Length(inCommArea.SIZONENO)) + inCommArea.SIZONENO;
      tmpGW0902.Label5.Caption := StringOfChar('0', 5 - Length(inCommArea.SIBRANCH)) + inCommArea.SIBRANCH;
      tmpGW0902.Label7.Caption := StringOfChar('0', 5 - Length(inCommArea.SITELLER)) + inCommArea.SITELLER;

      tmpGW0902.Label9.Caption := inCommArea.SITRXSQNO;
      tmpGW0902.Label11.Caption := inCommArea.SISYSDATE;
   end;

   tmpGW0902.ShowModal;

   outCommArea := tmpGW0902.soutComm;
   tmpGW0902.Free;
end;

procedure TGW0902.GotoNextCTL(Key: Char);
begin
  If Ord(Key) = VK_RETURN then
  begin
    Self.Perform(WM_NEXTDLGCTL,0,0);
  end;
end;

function TGW0902.IsReady:Boolean;
begin
{****************************************}
{  TO DO : Modified for Input Parameters }
{****************************************}
  BitBtn1.Enabled := False;
  BitBtn2.Enabled := False;

  If Edit1.Text='' then
  begin
    ShowMessage('ÇëÊäÈë¡°¹ñÔ±ºÅ¡±');
    Edit1.SelectAll;
    Edit1.SetFocus;
    BitBtn1.Enabled := True;
    BitBtn2.Enabled := True;
    Result:=False;
  end else begin
    Result:=True;
  end;
{****************************************}
{  TO DO : Modified for Input Parameters }
{****************************************}
end;

procedure TGW0902.BitBtn2Click(Sender: TObject);
begin
   soutComm.SOOVERID := SOCANCELEDTRX; // È¡Ïû
   soutComm.SOSTATEMENT := SOSTATCANCELEDTRX;
   Close;
end;

function TGW0902.PACKFIELDS:TBuffer;
begin
{****************************************}
{  TO DO : Modified for Input Parameters }
{****************************************}
   Result.FIELD00 := Edit1.Text;
{****************************************}
{  TO DO : Modified for Input Parameters }
{****************************************}
end;

function TGW0902.Send(Host, Port, inPackage: String):String;
begin
   try
     Netreq_Request(Host, Port, inPackage, Result);
   except
     Result := Ut_IntoPackage(ROERRORCOMMPT,ROSTATERRORCOMMPT);
   end;
end;

procedure TGW0902.BitBtn1Click(Sender: TObject);
var
  inStr, outStr: String;
begin
  If IsReady then
  begin
    inStr := packTinComm(sinComm, PACKFIELDS);
    outStr := Send(sinComm.SIHOST, sinComm.SIPORT, inStr);
    soutComm := unpackToutComm(outStr);
    Close;
  end;
end;

procedure TGW0902.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  GotoNextCTL(Key);
end;

end.
