private void btnLogin_Click(object sender, EventArgs e) { int count = 0; if (txtBxUser.Text == "" || txtBxUser.Text == "*") { lblUser.ForeColor = Color.Red; txtBxUser.ForeColor = Color.Red; txtBxUser.Text = "*"; count++; } else { txtBxUser.ForeColor = Color.Black; } if(txtBxPass.Text == "" || txtBxPass.Text == "*") { lblPass.ForeColor = Color.Red; txtBxPass.ForeColor = Color.Red; txtBxPass.Text = "*"; count++; } else { txtBxPass.ForeColor = Color.Black; } if (count > 0) { //Display something about Missing fields. } else { int index = 0; bool authenticated = false; //Check for the username. for(;index < userDB.Count;index++) { if(userDB[index].Username == txtBxUser.Text) { if(userDB[index].Password == txtBxPass.Text) { MessageBox.Show("Authenticated!"); authenticated = true; break; } else { MessageBox.Show("Incorrect Password!"); break; } } } if(authenticated) { frmMain main = new frmMain(); main.passUser(userDB[index],index); main.ShowDialog(); if(main.dataChanged()) { main.retrieveNew(ref userDB,index); writeLine(ref userDB); } txtBxPass.Text = ""; txtBxUser.Text = ""; } } }