using System.Windows.Forms;
using TinyHeels.App_Code;

namespace TinyHeels
{
    public partial class SelectNumber : Form
    {
        double q;
        public SelectNumber(double q)
        {
            InitializeComponent();
            this.q = q;
            txtRollBack.Text = q.ToString();
            txtTotal.Text = q.ToString();
            txtRollBack.Select();
        }

        private void button2_Click(object sender, System.EventArgs e)
        {
            Common.command = false;
            this.Close();
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            double newQ = double.Parse(string.IsNullOrWhiteSpace(txtRollBack.Text) ? "0.0" : txtRollBack.Text);
            if (newQ > this.q)
            {
                ErrorBox error = new ErrorBox("Sorry Can Not Return More Than Available");
                error.Show();
            }
            else
            {
                Common.command = true;
                Common.quantity = newQ;
                this.Close();
            }
        }
    }
}
