samedi 30 janvier 2016

comparing values of textfields with values rendered by a function (not working)

I have a function that renders 2 columns: date and time for upcoming appointments. When the user enter date and time in the textfields, I want to avoid conflict time, so I want to compare those values with values of dates and times rendered by the function. If he entered date and time similar to a record from the rendered function, I want to show a toast message to tell him to change the date and time since this appointment is booked.

Here is my code that I inserted in the OnCreateView of the class that extends fragment :

Cursor res = myDB.getUpcomAp();

StringBuffer buffer = new StringBuffer();
while (res.moveToNext()){

if( (res.getString(0)).equals(chosdate.getText().toString())&&(res.getString(1)).equals(chostime.getText().toString()))

Toast.makeText(getActivity(), "This appointment is booked, please choose another one", Toast.LENGTH_LONG).show();


};

But nothing is rendered when the user choose the same date and time of a booked appointment. Please help

Aucun commentaire:

Enregistrer un commentaire