private void AceptarButton_Click(object sender, EventArgs e) { try { if (validarCamposRequeridos().Length == 0) { registrarUsuario(UsuarioTextBox.Text.Trim(), PasswordTextBox.Text.Trim()); } else if (UserData.UserData.getUsuario() != null && UserData.UserData.getUsuario().usuarioRegistrable.getTipo() == UserData.UserData.TIPO_ADMIN && UsuarioTextBox.Text.Length == 0 && PasswordTextBox.Text.Length == 0) { var res = MessageBox.Show("Dese autogenerar el usuario y la contraseña", "Advertencia", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { string usuario = null; if (tipoUsuario == TIPO_CLIENTE) { Cliente cli = altaClieForm.getCliente(); if (cli != null) { usuario = cli.nombre + "." + cli.apellido; } } else if (tipoUsuario == TIPO_EMPRESA) { Empresa emp = altaEmpresaForm.getEmpresa(); if (emp != null) { usuario = emp.razonSocial.Substring(0, 2) + emp.cuit.Substring(emp.cuit.Length - 2); } } if (usuario != null && usuario.Length != 0) { registrarUsuario(usuario, "1234"); } else { throw new GenericException(""); } } else { throw new GenericException(""); } } else { string mensaje = "Los siguientes campos son requeridos:\n\n" + validarCamposRequeridos(); MessageBox.Show(mensaje); } } catch (GenericException ex) { } catch (Exception ex) { MessageBox.Show(ex.Message); } }