private void btnLogin_Click(object sender, EventArgs e) { AccountsDAO accountsDao = new AccountsDAO(); DataTable table = accountsDao.Select_All(); if (table.Rows.Count == 0) { accountsDao.insert(new Account() { Username = CryptMngr.Encrypt("admin"), Password = CryptMngr.Encrypt("admin"), Account_type = (int)Account.account_types.admin }); table = accountsDao.Select_All(); } bool didFind = false; DataRow account = table.NewRow(); foreach (DataRow item in table.Rows) { if (CryptMngr.Decrypt(item["username"].ToString()) == txtUsername.Text && CryptMngr.Decrypt(item["password"].ToString()) == txtPassword.Text) { account = item; didFind = true; break; } } if (didFind) { LogintoIt(account); } else { MessageBox.Show("As credenciais inseridas não correspondem a nenhuma conta", "Erro de Login"); txtPassword.Clear(); txtUsername.Clear(); } }
private void frmMain_Load(object sender, EventArgs e) { tsmiAccountName.Text = CryptMngr.Decrypt(account["username"].ToString()); }