private void inicioSesionUsuario(object sender, EventArgs e) { try { Boolean err = false; string mens = ""; string id = ""; string pin = ""; if (txt_loginUsuario.TextLength == 0) { err = true; mens += "El campo Login es obligatorio \n"; } else { id = txt_loginUsuario.Text; } if (txt_contraseñaUsuario.TextLength == 0) { err = true; mens += "El campo Password es obligatorio \n"; } else { pin = txt_contraseñaUsuario.Text; } if (err) { DialogResult answer = MessageBox.Show(this, "Revise los datos introducidos \n" + mens, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { loginUser = service.login(id, pin); ventanaIniciado vi = new ventanaIniciado(service); vi.ShowDialog(); } } catch (ServiceException ex) { MessageBox.Show(ex.Message); } }
void testLogin() { User u; Console.WriteLine(); Console.WriteLine("TESTING LOGIN..."); try { u = service.login("user1", "user1"); if (u != null) { Console.WriteLine(" Login " + u.Name); } else { Console.WriteLine(" NOLOGIN"); } } catch (Exception e) { printError(e); } service.logout(); try { u = service.login("user2", "user2"); if (u != null) { Console.WriteLine(" Login " + u.Name); } else { Console.WriteLine(" NOLOGIN"); } } catch (Exception e) { printError(e); } service.logout(); try { u = service.login("user5", "user1"); if (u != null) { Console.WriteLine(" Login " + u.Name); } else { Console.WriteLine(" NOLOGIN"); } } catch (Exception e) { printError(e); } service.logout(); try { Employee e = service.login("11111111A", 1234); if (e != null) { Console.WriteLine(" Login " + e.Name); } else { Console.WriteLine(" NOLOGIN"); } } catch (Exception exc) { printError(exc); } service.logout(); try { Employee e = service.login("12341234A", 1234); if (e != null) { Console.WriteLine(" Login " + e.Name); } else { Console.WriteLine(" NOLOGIN"); } } catch (Exception exc) { printError(exc); } }