I am stuck on a project, need help to solve this issue.
I receive the data from 3 different inputs (2 are Spinners and 1 is a TextView).
The table column name are: customer id, quantity and production id.
I need to check production id for duplicate entries before inserting to my table.
Here is what I currently do:
if(res.getCount()==0){
boolean isInserted = mytempDB.insertdataintotemptable(
ProducationSpinner.getSelectedItem().toString(), QuantityText.getText().toString(),
CustomerSpinner.getSelectedItem().toString());
if (isInserted == true)
Toast.makeText(orderChalan.this, "Data save successfully", Toast.LENGTH_LONG).show();
else
Toast.makeText(orderChalan.this, "Data not Inserted", Toast.LENGTH_LONG).show();
} else {
while(res.isAfterLast()){
if (res.getString(4).toString() == CustomerSpinner.getSelectedItem().toString()) {
boolean isInserted = mytempDB.insertdataintotemptable(ProducationSpinner.getSelectedItem().toString(),
QuantityText.getText().toString(), CustomerSpinner.getSelectedItem().toString());
if (isInserted == true)
Toast.makeText(orderChalan.this, "Data save successfully", Toast.LENGTH_LONG).show();
else
Toast.makeText(orderChalan.this, "Data not Inserted", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(orderChalan.this, "Production ID can not different", Toast.LENGTH_LONG).show();
}
}
}
I select the first row and receive a production ID value.
After that I try to match the user input and data from the table each time, then I insert into the table.
If the data don't match, I then display an error message "Production Id can not different" and also I check the first time entry if there is no data for the first input; in that case there are no checks.
The error I get is "Production id can not be different" - I get this message from the 2nd time input.
Any suggestion?