public static void ResetPassword(string new_password, Bunifu.Framework.UI.BunifuCustomLabel label) { //string query = "update logins set password='******' where username=admin"; string query = "UPDATE logins SET [password]='" + Crypter.Encrypt(new_password) + "' WHERE username='******'"; cmd.CommandType = System.Data.CommandType.Text; cmd = new OleDbCommand(query, con); con.Open(); try { cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Errore"); label.Text = "Errore! Password non modificata."; label.ForeColor = Color.Red; } finally { label.Text = "Password modificata, Accedere!"; label.ForeColor = Color.Green; } con.Close(); }
public static bool TryLogin(string username, string password, Bunifu.Framework.UI.BunifuCustomLabel label) { try { if ((username == string.Empty) || (password == string.Empty)) { label.Text = "Credenziali errate. Riprovare."; label.ForeColor = Color.Red; } cmd = new OleDbCommand("select count(*) from logins where username='******' AND password='******'", con); if (con.State == System.Data.ConnectionState.Closed) { con.Open(); i = (int)cmd.ExecuteScalar(); } con.Close(); if (i > 0) { return(true); } else { return(false); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); }; }