unit U_inicial;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    ed_produto: TEdit;
    ed_custo: TEdit;
    ed_lucro: TEdit;
    ed_venda: TEdit;
    ed_estoqueAtual: TEdit;
    ed_minimo: TEdit;
    ed_ValorEstoque: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    lb_status: TLabel;
    procedure ed_estoqueAtualKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ed_estoqueAtualKeyPress(Sender: TObject; var Key: Char);
  var
  minimo, atual, total, venda : real;
begin
  if (key = #13) then
  begin
  minimo := StrToInt(ed_minimo.text);
  atual := StrToInt(ed_estoqueAtual.text);

  if atual <= minimo then
    begin
      lb_status.Caption := 'Comprar';
      lb_status.Font.Color := clred;
    end
    else
    begin
      lb_status.Caption := 'Ok';
      lb_status.Font.Color := clblue ;
    end;
  end;
    venda :=  StrToFloat(ed_venda.Text);
    lb_status.Visible := true;
    total := venda*atual;
    ed_ValorEstoque.Text := FormatFloat('R$ 0.00', total) ;
end;

end.
