Click here to Skip to main content
15,886,091 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to make "for exp " 'metro progress spinner' visible on the form while the app is checking the tbl_login in the database for username and password,

here is my code:

C#
< private void metroButton1_Click(object sender, EventArgs e)
        {
            clss_link._User = txtbx_user.Text;

            if (txtbx_user.Text == "" || txtbx_pass.Text == "")
            {
                DialogResult result1;

                result1 = MetroFramework.MetroMessageBox.Show(this, "Enter both Username and Password!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);


            }


            else
            {

                model1.DB_PrjMgntEntities DB = new model1.DB_PrjMgntEntities();

                var query = from r in DB.tbl_login
                            where r.Username == txtbx_user.Text &&
                                r.Password == txtbx_pass.Text
                            select r;

                if (query.Count() == 1)
                {
                    System.Threading.Thread.Sleep(3000);

                    frm_main mainFrm = new frm_main();
                    mainFrm.Show();
                    this.Hide();

                }
                else
                {

                    DialogResult result;

                    result = MetroFramework.MetroMessageBox.Show(this, "Invalid Username or Password!", "Warning", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);


                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        txtbx_pass.Clear();
                        txtbx_user.Clear();

                    }

                    else
                    {
                        this.Close();

                    }

                }
            }

        }

        private void metroCheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (metroCheckBox1.Checked == true)
            {
                txtbx_pass.UseSystemPasswordChar = false;
            }
            else
            {
                txtbx_pass.UseSystemPasswordChar = true;
            }
        }
>
Posted
Updated 25-Jun-15 22:00pm
v3
Comments
Richard Deeming 26-Jun-15 8:11am    
You are storing passwords in plain text. That is a very bad idea. You should only ever store a salted hash of the password.

Secure Password Authentication Explained Simply[^]
Salted Password Hashing - Doing it Right[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900