Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == textBox2.Text)
            {
                string sqlText    = string.Format("select password from logins where email='{0}';", emailas);
                var    connection = DBFunctions.OpenConnection();
                if (connection == null)
                {
                    return;
                }
                OldPassword = (string)DBFunctions.ExecuteSqlScalar(sqlText, connection);

                sqlText = string.Format("UPDATE logins SET Password='******' WHERE Password='******';", PasswordClass.GetMD5hash(textBox2.Text), OldPassword);

                DBFunctions.ExecuteSqlNoReturn(sqlText, connection);
                connection.Close();
                connection.Dispose();
            }
        }
Exemple #2
0
        private void label10_Click(object sender, EventArgs e)
        {
            string sqlText    = "select count(id) from logins where UserName='******';";
            var    connection = DBFunctions.OpenConnection();

            if (connection == null)
            {
                return;
            }
            if ((long)DBFunctions.ExecuteSqlScalar(sqlText, connection) == 0)
            {
                MessageBox.Show("User does not exist");
                return;
            }

            sqlText = string.Format("select id,username,password,email,ChannelColour,subscribers from logins where Username='******' and Password='******';", textBox1.Text, PasswordClass.GetMD5hash(textBox2.Text));
            var reader = DBFunctions.ExecuteSqlSelect(sqlText, connection);

            if (reader == null)
            {
                return;
            }
            if (!reader.HasRows)
            {
                MessageBox.Show("Wrong password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            userData user = new userData();

            while (reader.Read())
            {
                user.user_ID          = (ulong)reader[0];
                user.user_username    = reader[1].ToString();
                user.user_password    = reader[2].ToString();
                user.user_email       = reader[3].ToString();
                user.user_colour      = reader[4].ToString();
                user.user_subscribers = reader[5].ToString();
            }
            reader.Close();
            reader.Dispose();
            connection.Close();
            connection.Dispose();
            //open main form
            prnt.loaduser(user);

            prnt.label2.Visible = false;

            prnt.panel2.Visible = true;

            prnt.label12.Text = user.user_username;
            Color red = Color.FromName(user.user_colour);

            prnt.label6.BackColor = red;
            prnt.active           = true;

            if (prnt.Controls.ContainsKey("hmw"))
            {
                prnt.Controls.RemoveByKey("hmw");
                prnt.loadtrends();
            }
            if (prnt.Controls.ContainsKey("wthvid"))
            {
                prnt.loadtrends();
            }

            this.Close();
        }
Exemple #3
0
        private void sendRegInfoToDatabase(string username, string password, string email, string color, int subs)
        {
            string sqlText = string.Format("INSERT INTO logins VALUES(null,'{0}','{1}','{2}','{3}',{4});", username, PasswordClass.GetMD5hash(textBox3.Text), email, color, subs);

            var connection = DBFunctions.OpenConnection(); //get connection to server

            if (connection == null)
            {
                return;
            }
            DBFunctions.ExecuteSqlNoReturn(sqlText, connection);
            connection.Close();
            connection.Dispose();
        }