コード例 #1
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            Signin signin = new Signin();

            if (txtUsername.Text == "" && txtPassword.Text == "")
            {
                MessageBox.Show("Please! Enter UserName and Password", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtUsername.Text == "")
            {
                MessageBox.Show("Please! Enter UserName", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("Please! Enter Password", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (signin.checkCipher(txtUsername.Text))
                {
                    //Open Cipher Form
                    if (signin.AuthenticateUser(txtUsername.Text, txtPassword.Text))
                    {
                        this.Hide();
                        username = txtUsername.Text;
                        SecurityCode sc = new SecurityCode(txtUsername.Text);
                        sc.Show();
                        if (SecurityCode.passfail)
                        {
                            if (signin.AuthenticateUser(txtUsername.Text, txtPassword.Text))
                            {
                                UserSignin.username = txtUsername.Text;
                                this.Hide();
                            }
                            else
                            {
                                UserSignin.username = "";
                                MessageBox.Show("Invalid Username and Password", "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username and Password", "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    }
                }

                else
                {
                    if (signin.AuthenticateUser(txtUsername.Text, txtPassword.Text))
                    {
                        this.Hide();
                        MainMenu mm1 = new MainMenu();
                        mm1.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username or Password", "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    }
                }
            }
        }