Skip to content

Commit

Permalink
[FIX] Create database
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-teruel committed Dec 31, 2014
1 parent 056a11e commit 1e29752
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
buildToolsVersion '21.1.2'

defaultConfig {
applicationId "es.incaser.apps.stockcontrol"
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/es/incaser/apps/stockcontrol/DbAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class DbAdapter extends SQLiteOpenHelper {
{"MovimientoStock", "SELECT * FROM MovimientoStock", "AcumuladoStock=0"},
//{"INC_Incidencias", "SELECT * FROM INC_Incidencias", "INC_PendienteSync <> 0"},
//Fin Tablas a importar
{"MovimientosArticuloSerie", "SELECT * FROM MovimientosArticuloSerie", "(FechaRegistro > GETDATE() - 3)"},
//{"MArtSerie", "SELECT * FROM MovimientosArticuloSerie", "(FechaRegistro > GETDATE() - 3)"},
{"MovimientoArticuloSerie", "SELECT * FROM MovimientoArticuloSerie", "(FechaRegistro > '2014-12-23')"},
};
public static int tablesToImport = 4; // Modificar en caso de añadir mas tablas
public static int tablesToExport = 4; // Exportar tablas a partir de este indice
Expand Down Expand Up @@ -69,6 +70,8 @@ protected String doInBackground(Integer... params) {
rsmd = rs.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
colname = rsmd.getColumnName(i);
Log.d(query[0] + " " + String.valueOf(columnsSql.length()), colname + " " + String.valueOf(i));

coltype = rsmd.getColumnTypeName(i);
columnsSql += ", '" + colname + "' " + coltype;
}
Expand Down Expand Up @@ -126,7 +129,7 @@ public boolean checkTables(){
if (i > 0){
tableList = tableList + ",";
}
tableList = tableList + "'" + query + "'";
tableList = tableList + "'" + query[0] + "'";
i ++;
}
Cursor curtmp = getCursor("Select * from sqlite_master WHERE name IN (" + tableList + ")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,19 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

public void onClickButtons(View view){
DbAdapter dbAdapter = new DbAdapter(getApplicationContext());
switch (view.getId()){
case R.id.btn_sync:
//forzamos el proceso de sincronizacion de los movimientos
//DbAdapter dbAdapter = new DbAdapter(getApplicationContext());
//dbAdapter.recreateDb();
launchHardSync();
break;
case R.id.btn_entradas_previstas:
if (! dbAdapter.checkTables()){
dbAdapter.recreateDb();
};
break;
case R.id.btn_entradas_libres:
dbAdapter.recreateDb();
break;
case R.id.btn_expediciones:
break;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc2'
classpath 'com.android.tools.build:gradle:1.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 1e29752

Please sign in to comment.