Guest User

Untitled

a guest
Feb 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. if (networkInfo!= null && networkInfo.isConnected()) {
  2.  
  3.  
  4. String cpf = EdCpf.getText().toString();
  5. String placa = EdPlaca.getText().toString();
  6. String modelo = EdModelo.getText().toString();
  7. String telefone = EdTel.getText().toString();
  8. String email = EdEmail.getText().toString();
  9. String nome = EdNome.getText().toString();
  10. String endereco= EdEndereço.getText().toString();
  11.  
  12. if (placa.isEmpty() || cpf.isEmpty() || modelo.isEmpty() ||
  13. telefone.isEmpty() || email.isEmpty() || nome.isEmpty() || endereco.isEmpty()) {
  14. Toast.makeText(getApplicationContext(), "Nenhum campo pode estar vazio", Toast.LENGTH_SHORT).show();
  15. } else {
  16.  
  17. parametros = "modelo="+ modelo + "&nome="+ nome + "&telefone="+ telefone + "&endereco="+ endereco +
  18. "&email="+ email + "&placa="+ placa + "&cpf="+ cpf;
  19.  
  20. url = "http://192.168.0.21/relatorio/registrar_mensalista.php";
  21.  
  22. new SolicitaDados().execute(url);
  23.  
  24. }
  25. }else{
  26. Toast.makeText(getApplicationContext(),"Nenhuma conexão encontrada", Toast.LENGTH_SHORT).show();
  27.  
  28. }
  29. }
  30. });
  31. }
  32.  
  33. private class SolicitaDados extends AsyncTask<String,Void,String> {
  34. @Override
  35. protected String doInBackground(String... urls) {
  36. return Conexao.postdados(urls[0], parametros);
  37. }
  38. @Override
  39. protected void onPostExecute(String resultado) {
  40.  
  41. if(resultado.contains("registro_ok")){
  42. Toast.makeText(getApplicationContext(), "Registro concluído com sucesso", Toast.LENGTH_SHORT).show();
  43. }else{
  44. Toast.makeText(getApplicationContext(), "Ocorreu um erro", Toast.LENGTH_SHORT).show();
  45.  
  46. }
  47.  
  48. }
  49. }
Add Comment
Please, Sign In to add comment