unit fdlgcobros;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.DBCtrls, Vcl.StdCtrls, Data.DB,
  Vcl.ComCtrls;

type
  Tdlgcobros = class(TForm)
    vfecha: TDateTimePicker;
    dsformaspago: TDataSource;
    Button1: TButton;
    Label14: TLabel;
    comboformapago: TDBLookupComboBox;
    Label1: TLabel;
    Label2: TLabel;
    lentrega: TEdit;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  dlgcobros: Tdlgcobros;

implementation

{$R *.dfm}
uses frecibos_s;

procedure Tdlgcobros.Button1Click(Sender: TObject);
begin
  if comboformapago.KeyValue = Null then
  begin
    ShowMessage('Debe seleccionar una forma de pago válida.');
    Exit;
  end;

  // Validar que el importe sea numérico
  if StrToFloatDef(lentrega.Text, -1) < 0 then
  begin
    ShowMessage('El importe de entrega no es válido.');
    Exit;
  end;

  ModalResult := mrOk; // Cierra y devuelve 1
end;

procedure Tdlgcobros.Button2Click(Sender: TObject);
begin
   ModalResult := mrCancel;
end;

procedure Tdlgcobros.FormKeyPress(Sender: TObject; var Key: Char);
begin
    begin
      key:=upcase(key);

    end;
    if (ActiveControl=nil) and (key=#13) then
    begin
        Perform(WM_NextDLGCtl, 0, 0);
        key:=#0;
    end;
end;

end.
