private void btnLogin_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; BankDetails account = new BankDetails(); var hash = account.GetHash(txtAccountNumber.Text); if (hash == "") { MessageBox.Show("Gebruiker niet gevonden!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (BCrypt.Net.BCrypt.EnhancedVerify(txtPassword.Text, hash)) { account = account.GetAccount(txtAccountNumber.Text, hash); if (account.DeletedState == false) { account.PinHash = null; new LoggedIn(account, sql).ShowDialog(); } else { MessageBox.Show("Dit account is geblokkeerd.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Incorrect wachtwoord!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Cursor.Current = Cursors.Default; }
public static BankDetails LoadAccount(Dictionary <string, string> dict) { var account = new BankDetails(); PropertyInfo[] props = typeof(BankDetails).GetProperties(); foreach (PropertyInfo prop in props.Where(x => x.CustomAttributes.Count() != 0).Where(x => x.CustomAttributes.First().AttributeType == typeof(FieldName))) { if (dict.ContainsKey(prop.Name)) { if (prop.PropertyType == typeof(int)) { prop.SetValue(account, int.Parse(dict[prop.Name])); } else if (prop.PropertyType == typeof(double)) { prop.SetValue(account, double.Parse(dict[prop.Name])); } else if (prop.PropertyType == typeof(bool)) { prop.SetValue(account, bool.Parse(dict[prop.Name])); } else { prop.SetValue(account, dict[prop.Name]); } } } return(account); }
public LoggedIn(BankDetails _account, SQL _sql) { sql = _sql; account = _account; var userName = sql.GetUserName(account.UserID); InitializeComponent(); lblUserName.Text = "Welcome, " + userName; LoadSaldo(); LoadTransactions(); }
public BankDetails GetAccount(string accountNumber, string pinHash) { return(BankDetails.LoadAccount(database.QueryToDictionary(String.Format("select * from bankdetails where bank_rekeningnummer = '{0}' AND pin = '{1}'", accountNumber, pinHash), ClassReader.ClassToDictionary(typeof(BankDetails))))); }