using GlobalPayments.Api.Terminals;
using GlobalPaymentsTestApp.Control;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace GlobalPaymentsTestApp.Forms {
    public partial class TransactionNumber : Form {
        private StandardModeControl _userControl;

        public TransactionNumber(StandardModeControl control) {
            InitializeComponent();
            _userControl = control;
        }

        private void btnOK_Click(object sender, EventArgs e) {
            try {

                if (string.IsNullOrEmpty(txtTransactionNumber.Text))
                    throw new Exception("Please input the transaction number you want to.");

                _userControl.TransactionId = txtTransactionNumber.Text;

                this.DialogResult = DialogResult.OK;
                this.Close();
            } catch(Exception ex) {
                MessageBox.Show(ex.Message, "Error");
            }
        }

        private void txtTransactionNumber_KeyPress(object sender, KeyPressEventArgs e) {
            e.Handled = !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar);
        }
    }
}
