Пример #1
0
        public bool checkPassword()
        {
            MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["TestCapstone"].ConnectionString);

            conn.Open();
            string       checkUser = "******";
            MySqlCommand comd      = new MySqlCommand(checkUser, conn);

            comd.Parameters.AddWithValue("@UserName", UserName);
            MySqlDataReader dr = comd.ExecuteReader();

            dr.Read();
            if (dr.HasRows)
            {
#pragma warning disable CS0436 // Type conflicts with imported type
                if (dr["Password"].ToString().Equals(value: EncryptPassword.encryptString(password)))
#pragma warning restore CS0436 // Type conflicts with imported type
                {
                    dr.Close();
                    conn.Close();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public void resetPassword(string newpwd)
        {
            MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["TestCapstone"].ConnectionString);

            conn.Open();
            string       checkUser = "******";
            MySqlCommand comd      = new MySqlCommand(checkUser, conn);

            comd.Parameters.AddWithValue("@UserName", UserName);
            comd.Parameters.AddWithValue("@password", EncryptPassword.encryptString(newpwd));
            comd.ExecuteNonQuery();
            conn.Close();
        }
Пример #3
0
        public void insertdata()
        {
            MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["TestCapstone"].ConnectionString);

            conn.Open();
            string insertString = "insert into users (UserName, password, email, firstname, lastname, UserType, phoneNumber, profileImage) " +
                                  "values (@UserName, @password, @Email, @firstname, @lastname, @UserType, @phoneNumber, @profileImage) ";
            MySqlCommand comd = new MySqlCommand(insertString, conn);

            comd.Parameters.AddWithValue("@UserName", UserName);
            comd.Parameters.AddWithValue("@password", EncryptPassword.encryptString(password));
            comd.Parameters.AddWithValue("@Email", email);
            comd.Parameters.AddWithValue("@firstname", firstname);
            comd.Parameters.AddWithValue("@Lastname", lastname);
            comd.Parameters.AddWithValue("@UserType", UserType);
            comd.Parameters.AddWithValue("@phoneNumber", phoneNumber);
            comd.Parameters.AddWithValue("@profileImage", profileImage);

            comd.ExecuteNonQuery();
            conn.Close();
        }