|
|
@@ -19,7 +19,7 @@ class DBHelper { |
|
|
|
if (_db == null) _db = await initDb(); |
|
|
|
return _db; |
|
|
|
} |
|
|
|
backupDb(context) async{ |
|
|
|
backupDb({context}) async{ |
|
|
|
var result = {"STATUS":0,"MSG":"Backup gagal!"}; |
|
|
|
var stock_id = prefs.getString(keyClass.stock_id)??''; |
|
|
|
if(stock_id != ''){ |
|
|
@@ -226,6 +226,14 @@ class DBHelper { |
|
|
|
final database = await db; |
|
|
|
var res = await database.update("${tableName.master}", unitUpdate.toJson(), |
|
|
|
where: "${columnName.id} = ?", whereArgs: [unitUpdate.id]); |
|
|
|
// print('Row Updated'); |
|
|
|
|
|
|
|
var checkCount = await database.query(tableName.master,where: "${columnName.flag} = ?", whereArgs: ['TRUE']); |
|
|
|
// print(["check count",checkCount.length]); |
|
|
|
if(checkCount.isNotEmpty&& checkCount.length%5==0){ |
|
|
|
// print('auto backup file'); |
|
|
|
backupDb(); |
|
|
|
} |
|
|
|
print('Row Updated'); |
|
|
|
return res; |
|
|
|
} |
|
|
|