Ejemplo n.º 1
0
        private void ConfirmPINentry_Click_1(object sender, EventArgs e)
        {
            Boolean blocked = false;

            //checking whether PIN is correct:
            PIN = this.PinEntry.Text;

            if (Lib.getBlocked())
            {
                AutoClosingMessageBox.Show("No attempts left, no money for you, your card is being captured.", "Bad news", 2000, Parent: Form.ActiveForm);
                PINentries = 3;
                blocked    = true;
                this.Close();
            }



            //if not CHAR then continue
            else if (!PIN.Any(char.IsLetter)) //Continue if PIN contains only numeric
            {
                blocked = false;
                //increasing the pin tries 1
                PINentries = PINentries + 1;


                //Checking if pin is correct and tries <=3
                if (PINentries <= 3 & PIN == correctPIN)
                {
                    Lib.update(PINentries.ToString(), blocked, Int32.Parse(Lib.getBalance()));
                    //delayed mesgbx
                    AutoClosingMessageBox.Show("PIN entry successful!", "Success", 2000, Parent: Form.ActiveForm);

                    //next screen after messagebox
                    Form ATM6 = new ATM6(); // Instantiate a Form object.
                    ATM6.Show();            //show the new Form
                    //Resetting the PIN:
                    PIN          = "";
                    this.Visible = false;  //Hide the old form
                }
                else if (PINentries < 3 & PIN != correctPIN)
                {
                    Lib.update(PINentries.ToString(), blocked, Int32.Parse(Lib.getBalance()));
                    //if incorrect PIN:
                    AutoClosingMessageBox.Show("PIN entry not successful, retry! Left attempts: " + Convert.ToString(3 - PINentries), "Retry!", 2000, Parent: Form.ActiveForm);
                    //Resetting the PIN:
                    PIN = "";
                }
                else if (PINentries > 3)
                {
                    blocked = true;
                    Lib.update(PINentries.ToString(), blocked, Int32.Parse(Lib.getBalance()));
                    //3 times Wrong PIN entry:
                    AutoClosingMessageBox.Show("Last PIN entry not successful, no attempts left, no money for you, your card is being captured.", "Success", 2000, Parent: Form.ActiveForm);
                    PIN = "";
                    this.Close(); //return;
                }
                ;
            }
            else
            {
                //in case of alphanumeric keyboard:
                AutoClosingMessageBox.Show("Please provide a numercial PIN.", "Error", 2000, Parent: Form.ActiveForm);
                PIN = "";
            }

            //set back to empty box:
            this.PinEntry.Text = "";
        }