using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace GeoTema { public partial class ResetPassword : Form { public ResetPassword() { InitializeComponent(); } private void btnReset_Click(object sender, EventArgs e) { string User = txtUserName.Text; if (User == "") MessageBox.Show("Please fill in the necessary fields!"); else if (User == MainMenu.User) MessageBox.Show("User can't reset their own password! Please use the Change password function instead!"); else { string statement1 = "use GeoTema_Users select Username from Users where Username = @Exist"; if (!Sql.ExistCheck(statement1, User)) MessageBox.Show("No user with that name exists!"); else { List param = new List { User }; string statement2 = "use GeoTema_Users update Users set password = 'Passw0rd' where Username = @User"; Sql.SQLConnect(statement2, param); string statement3 = "use master declare @sql nvarchar(max) set @sql = 'alter login ' + @User + ' with password = ''Passw0rd''' exec(@sql)"; Sql.SQLConnect(statement3, param); MessageBox.Show("Password reset to: Passw0rd"); } } } private void btnBack_Click(object sender, EventArgs e) { this.Hide(); AdminMenu Admin1 = new AdminMenu(); Admin1.ShowDialog(); Close(); } } }