コード例 #1
0
        // Code to add functionality for BackButton
        private void BackButton_Click(object sender, EventArgs e)
        {
            DialogResult resultBack = MessageBox.Show("Do you wish to go back??", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (resultBack == DialogResult.Yes)
            {
                this.Hide();

                //Declarrng a variable for WelcomeForm
                WelcomeForm form2 = new WelcomeForm();

                //Showing WelcomeForm
                form2.ShowDialog();
            }
        }
コード例 #2
0
        // Functionality on clicking LogInButton
        private void LogInButton_Click(object sender, EventArgs e)
        {
            if (PasswordTextBox.Text == "")
            {
                MessageBox.Show("Please enter the password and try again", "Password needed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }


            else if (PasswordTextBox.Text == PASSWORD)

            {
                this.Hide();

                //Declaring a variable for WelcomeForm
                WelcomeForm form2 = new WelcomeForm();

                //Showing WelcomeForm
                form2.ShowDialog();
            }

            // if the user enters an incorrect password, application displays an attention message box
            else if (passwordCount > 1)
            {
                passwordCount--;
                MessageBox.Show("Sorry! You have entered an incorrect password. \r\n" + "You are left with " + passwordCount + " attempts.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Error);
                PasswordTextBox.Clear();
                PasswordTextBox.Focus();
            }

            else
            {
                // if the user enters an incorrect password 3 times, this message box will appear
                MessageBox.Show(" Sorry! You have entered an incorrect password.\r\n You are blocked as no chances are left. \r\n Please try again after sometime.", "Blocked", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                // Application will close
                this.Close();
            }
        }