예제 #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Logins login = new Logins();
            AuthenticateTableAdapter taAuth = new AuthenticateTableAdapter();

            login.userName = textBox1.Text;
            login.passWord = textBox2.Text;
            try
            {
                DataTable dt = new DataTable();
                taAuth.Fill(authDS.Authenticate, login.userName, login.passWord);
                if (authDS.Tables[0].Rows.Count == 1)
                {
                    label3.Text = "Success!";

                    // Application.Run(new Main());
                }
                else
                {
                    label3.Text = "Failure!";
                }
            }
            catch (Exception ex)
            {
                label3.Text = ex.Message;
            }
        }
예제 #2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Logins login = new Logins();
            AuthenticateTableAdapter taAuth = new AuthenticateTableAdapter();

            login.userName = userText.Text;
            login.passWord = userPass.Text;
            try
            {
                DataTable dt = new DataTable();
                taAuth.Fill(authDS.Authenticate, login.userName, login.passWord);
                if (authDS.Tables[0].Rows.Count == 1)
                {
                    Ready_Label.Text = "Login Success!";
                    MessageBox.Show("Welcome " + " " + login.userName + " :)");
                    Main main = new Main();
                    this.Hide();
                    // ^ this hides the login box after they login but then we cant exit the program properly so we have to figure that out.
                    main.Show();
                }
                else
                {
                    Ready_Label.Text = "login unsucessful\n" + attempts
                                       + "out of 3";
                    attempts++;
                }

                if (login.userName == userText.Text && login.passWord == "")
                {
                    Ready_Label.Text = "Please enter the password";
                }

                if (login.userName == "" && login.passWord == "")
                {
                    Ready_Label.Text = "Please enter the username and password";
                }
            }
            catch (Exception ex)
            {
                Ready_Label.Text = "Something went wrong... please try again\n" + ex.Message;
            }
            if (attempts == 4)
            {
                MessageBox.Show("You have reached maximum number of attempts... ");
            }
        }