public void checkLastValidation(SqlCommand cmd, SqlConnection con)
        {
            string     query     = "Select * from register where username = @uname";
            SqlCommand cmdSelect = new SqlCommand(query, con);

            cmdSelect.Parameters.AddWithValue("@uname", (textBox3.Text));

            SqlDataAdapter adp = new SqlDataAdapter(cmdSelect);
            DataSet        ds  = new DataSet();

            adp.Fill(ds);

            int count = ds.Tables[0].Rows.Count;

            if (count >= 1)
            {
                MessageBox.Show("This username has taken");
                reset();
            }
            else
            {
                cmd.ExecuteNonQuery();
                con.Close();
                this.Hide();
                DashboardForm df = new DashboardForm();
                df.Show();
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("No missed field!!!");
                return;
            }
            try
            {
                SqlConnection con = new SqlConnection(constr);
                con.Open();
                string     query = "Select * from register where username = @uname and pass = @upass";
                SqlCommand cmd   = new SqlCommand(query, con);
                cmd.Parameters.AddWithValue("@uname", (textBox1.Text.Trim()));
                cmd.Parameters.AddWithValue("@upass", (textBox2.Text.Trim()));

                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                DataSet        ds  = new DataSet("users");
                adp.Fill(ds);
                //con.Close();

                int count = ds.Tables[0].Rows.Count;
                if (count == 1)
                {
                    this.Hide();
                    DashboardForm df = new DashboardForm();
                    df.Show();
                }
                else
                {
                    MessageBox.Show("Login failed!!!");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }