1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
public void ajoutRdv(View view) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
String situation1 = null;
//Recuperation des données saisi par l'utilisateur//
EditText nRdv = (EditText) findViewById(R.id.nameRdv);
EditText pRdv = (EditText) findViewById(R.id.prenomRdv);
EditText telRdv = (EditText) findViewById(R.id.telRdv);
String NomRdv = nRdv.getText().toString();
String PrenomRdv = pRdv.getText().toString();
String TelRdv = telRdv.getText().toString();
Spinner techniqueVolumeRusse = (Spinner) findViewById(R.id.spinner4);
String tvolumeRusse = techniqueVolumeRusse.getSelectedItem().toString();
Spinner techniqueCill = (Spinner) findViewById(R.id.spinner);
String tCill = techniqueCill.getSelectedItem().toString();
TimePicker timePicker = (TimePicker) findViewById(R.id.tp);
timePicker.setIs24HourView(true);
String hourRdv = timePicker.getCurrentHour().toString();
String minuteRdv = timePicker.getCurrentMinute().toString();
String timeRdv = hourRdv + " " + "HEURE" + " " + minuteRdv;
DatePicker datePicker = (DatePicker) findViewById(R.id.datePicker);
int Month = datePicker.getMonth()+1;
int Day = datePicker.getDayOfMonth();
int Year = datePicker.getYear();
Calendar calendar = Calendar.getInstance();
calendar.set(Year, Month, Day);
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
String strDate = format.format(calendar.getTime());
// String Date =Day+"/ "+Month+"/"+Year+" ";
//String datefinal = Date;//.........................................//
System.out.println();
HttpPost httppost = new HttpPost("http://testhiber.livehost.fr/rdv.php");
//Envoie les variables dans le fichier php//
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(7);
nameValuePair.add(new BasicNameValuePair("NomRdv", NomRdv));
nameValuePair.add(new BasicNameValuePair("PrenomRdv", PrenomRdv));
nameValuePair.add(new BasicNameValuePair("TelRdv", TelRdv));
nameValuePair.add(new BasicNameValuePair("tvolumeRusse", tvolumeRusse));
nameValuePair.add(new BasicNameValuePair("tCill", tCill));
nameValuePair.add(new BasicNameValuePair("timeRdv ", timeRdv ));
nameValuePair.add(new BasicNameValuePair("Date ", strDate ));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePair));
System.out.println(strDate);
} catch (UnsupportedEncodingException e) {
Log.i("test2", tvolumeRusse);
e.printStackTrace();
}
//Execution de la requete//
HttpClient httpClient = new DefaultHttpClient();
try {
HttpResponse response = httpClient.execute(httppost);
HttpEntity entite = response.getEntity();
String reponse = EntityUtils.toString(entite);
Log.i("requete", reponse);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
Log.i("test3", tvolumeRusse);
e.printStackTrace();
} catch (IOException e) {
Log.i("test4", tvolumeRusse);
// TODO Auto-generated catch block
e.printStackTrace();
}
Toast.makeText(getApplicationContext(), "Le rdv a bien a été envoyé", Toast.LENGTH_LONG).show();
} |