mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-13 00:51:35 +01:00
fix typo and alignment; fix bug with cursor and getDrugByCIP13
This commit is contained in:
parent
cb73cdce70
commit
f966e32065
1 changed files with 37 additions and 38 deletions
|
@ -67,10 +67,12 @@ class DBMedoc extends SQLiteOpenHelper{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {}
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
}
|
||||
|
||||
private void copyDatabase(String dbPath) {
|
||||
Log.d(TAG, "try to copy database");
|
||||
|
@ -108,6 +110,7 @@ class DBMedoc extends SQLiteOpenHelper{
|
|||
|
||||
/**
|
||||
* Lookup in the DB for a record corresponding to cpi1
|
||||
*
|
||||
* @param cip13 string representing the object we're looking for
|
||||
* @return return a medicament object
|
||||
*/
|
||||
|
@ -117,31 +120,25 @@ class DBMedoc extends SQLiteOpenHelper{
|
|||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
|
||||
// Build query
|
||||
Cursor cursor = db.query(TABLE_NAME, // Which table
|
||||
/*Cursor cursor = db.query(TABLE_NAME, // Which table
|
||||
COLUMNS_NAMES, // column names
|
||||
" cip13 =?", // selections
|
||||
new String[]{cip13}, // selections args
|
||||
null, // group by
|
||||
null, // having
|
||||
null, // order by
|
||||
null); // limits
|
||||
|
||||
if (cursor != null)
|
||||
cursor.moveToFirst();
|
||||
null); // limits*/
|
||||
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_NAME + " where cip13 = " + cip13, null);
|
||||
if (cursor.getCount() != 0) {
|
||||
|
||||
// Build medicament object
|
||||
Medicament medicament = new Medicament();
|
||||
// medicament.setId(Integer.parseInt(cursor.getString(0)));
|
||||
assert cursor != null;
|
||||
medicament.setCis(cursor.getString(0));
|
||||
medicament.setCip13(cursor.getString(1));
|
||||
medicament.setMode_administration(cursor.getString(2));
|
||||
medicament.setNom(cursor.getString(3));
|
||||
medicament.setPresentation(cursor.getString(4));
|
||||
/*medicament.setStock(Double.parseDouble(cursor.getString(5)));
|
||||
medicament.setPrise(Double.parseDouble(cursor.getString(6)));
|
||||
medicament.setWarnThreshold(Integer.parseInt(cursor.getString(7)));
|
||||
medicament.setAlertThreshold(Integer.parseInt(cursor.getString(8)));*/
|
||||
|
||||
// Set default values
|
||||
medicament.setStock(0);
|
||||
|
@ -156,5 +153,7 @@ class DBMedoc extends SQLiteOpenHelper{
|
|||
|
||||
cursor.close();
|
||||
return medicament;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue