protected void add_Click(object sender, EventArgs e) { error.Visible = false; success.Visible = false; encrypt en = new encrypt(); SQL sql = new SQL(); string username = user.Value.ToString().Trim(); string password = pas.Value.ToString(); string conf = confirm.Value.ToString(); bool checknewUser = sql.checkNewUser(username); if (checknewUser) { errmsg.InnerText = "This user already exsists!"; error.Visible = true; } else { if (password == conf && password != string.Empty) { string enpassword = en.Encrypt(password); sql.addUser(username, enpassword); } else { errmsg.InnerText = "The passwords do not match.."; error.Visible = true; } } Reload(); }
protected void reset_Click(object sender, EventArgs e) { error.Visible = false; success.Visible = false; int id = int.Parse(userDrop.SelectedItem.Value); string password = pas.Value.ToString(); string conf = confirm.Value.ToString(); encrypt en = new encrypt(); if (password == conf && password != string.Empty) { string enpassword = en.Encrypt(password); try { SQL sql = new SQL(); sql.resetPassword(id, enpassword); successmsg.InnerText = "Password Reset"; success.Visible = true; } catch (Exception ex) { errmsg.InnerText = "Error occoured changing password " + ex.Message.ToString(); error.Visible = true; } } else { errmsg.InnerText = "The passwords do not match.."; error.Visible = true; } }