private void logInBtn_Click(object sender, EventArgs e) { bool correct = false; int res = 0; if (emailTxt.Text != "" && pwdText.Text != "") { string pattern = "^([0-9a-zA-z]([-\\.\\w]*[0-9a-zA-z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)" + "[a-zA-Z]{2,9})$"; if (!Regex.IsMatch(emailTxt.Text, pattern)) { MessageBox.Show("Escribir un correo electrónico válido.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var logIn = new LogIn(emailTxt.Text, pwdText.Text); var emailHandler = new EmailHandler(); var pwdHandler = new PasswordHandler(); emailHandler.SetNext(pwdHandler); res = Convert.ToInt32(ClientHandler.ClientCode(emailHandler, logIn)); if (res != 0) { correct = true; } } else { MessageBox.Show("Rellenar todos los campos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!correct) { MessageBox.Show("Correo o contraseña incorrectos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); pwdText.Clear(); return; } else { user = proxy.GetUserById(res); } user.friends = proxy.GetFriends(user.ID); this.Hide(); Form next = new FeedView(); next.ShowDialog(); this.Close(); }