DetallesArticuloDinamico.java
11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
package com.focasoftware.deboinventario;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* Permite ver el detalle de un artculo de un inventario dinmico seleccionado.
* Llamada desde PaginaInventarioDinamico.java.
* Pensada para en un futuro eliminar el articulo del Inventario Dinmico actual.
* @author GuillermoR
*
*/
public class DetallesArticuloDinamico extends Activity implements DialogPersoSimple {
/**
* Variable para almacenar los datos de contexto de la actividad
*/
@NonNull
private Context ctxt = this;
/**
* Variable de instancia para manejar las conexiones y operaciones con la BD
*/
private BaseDatos bdd;
/**
* Botn que permite volver a la activity anterior cerrando la actual
*/
private Button boton_volver;
/**
* Almacena los datos del articulo cuyos detalles se estan mostrando
*/
@Nullable
private Articulo articulo_on_focus;
/**
* Variable para mostrar el nombre del articulo
*/
private TextView textview_nombre;
/**
* Variable para mostrar el sector
*/
private TextView textview_sector;
/**
* Variable para mostrar el codigo del articulo
*/
private TextView textview_codigo;
/**
* Variable que muestra los codigos de barra concatenados por comas
*/
private TextView textview_codbar;
/**
* Variable que muestra el precio del articulo
*/
private TextView textview_precio;
/**
* Variable para moestrar el costo del articulo
*/
private TextView textview_costo;
/**
* Variable para mostrar la cantidad actual inventariada
*/
private TextView textview_cantidad;
/*123456*/
private TextView textview_exis;
/**
* Variable accesoria donde se almacena el nombre de la imagen
*/
@NonNull
private String nombreImagen = "";
/**
* Arreglo de bytes accesorio para leer la foto o imagen tomada
*/
@Nullable
private byte[] ba = null;
/**
* Dialogo para confirmar la correctitud de la foto
*/
private DialogPersoComplexFotoSiNo dialogo;
/**
* Boton para permitir eliminar el articulo del inventario actual, temporalmente
* inhabilitado hasta que se apruebe esa mejora
*/
private Button botonEliminar;
/**
* Dialogo que pregunta por la confirmacin del borrado del articulo del inventario
*/
private DialogPersoComplexSiNo dialogoContinuarBorrar;
/**
* Variable para almacenar los datos del intent que llama a esta activity
*/
private Intent intentPadre;
/**
* Variable acceesoria Para almacenar el sector del articulo actual
*/
private int sector;
/**
* Variable accesoria para guardar el codigo del articulo
*/
private int codigo;
/**
* Variable para almacenar el numero de inventario del articulo actual
*/
private int inventario;
/**
* Variable para mostrar en caso que no se pueda abrir la cmara
*/
private ProgressDialog PopUps;
private boolean estadoCamara;
/**
* Se inicializa la UI y se cargan los handlers
* <p>1 Recuperamos los extras
* <p>2 Recuperamos la lista de todos los datos que mostrar en pantalla
* <p>3 Recuperamos los elementos de la parte grfica
* <p>4 Cargado de handlers sobre la imagen y botones
* <p>5 Configuracin del valor
* <p>6 Chequeamos si ya tenemos una foto en la tablet para mostrar,
* sino buscamos en la red
*/
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xml_detallesarticulo_dinamico);
System.out.println(":::llega para llamar a detalles articulos");
final GestorLogEventos log = new GestorLogEventos();
log.setUbicacion(ParametrosInventario.CARPETA_LOGTABLET);
log.tipo_0 = Parametros.PREF_LOG_EVENTOS;
log.tipo_2 = Parametros.PREF_LOG_PROCESOS;
log.tipo_3 = Parametros.PREF_LOG_MENSAJES;
log.tipo_4 = Parametros.PREF_LOG_EXCEPCIONES;
log.log("[-- 149 --]" + "DetalleArticuloDinamico", 2);
intentPadre=getIntent();
// BUNDLES:
Bundle bundle = intentPadre.getExtras();
//1 Recuperamos los extras:
sector = bundle.getInt(ParametrosInventario.extra_sector);
codigo = bundle.getInt(ParametrosInventario.extra_codigo);
inventario = bundle.getInt(ParametrosInventario.extra_inventario);
//Parametros.PREF_URL_CONEXION_SERVIDOR = "http://192.167.1.156/Dalvian/webservice.php";
// BASE DE DATOS:
bdd = new BaseDatos(ctxt);
//2 Recuperamos la lista de todos los datos que mostrar en pantalla:
try {
articulo_on_focus = bdd.selectArticuloConCodigos(sector, codigo, inventario);
} catch (ExceptionBDD e) {
e.printStackTrace();
showSimpleDialogOK("Error en el articulo", e.toString()).show();
log.log("[-- 172 --]" + e.toString(), 4);
}
// INTERFAZ:
//3 Recuperamos los elementos de la parte grfica:
textview_nombre = (TextView) findViewById(R.id.DART_art_nombre);
textview_sector = (TextView) findViewById(R.id.DART_art_sector);
textview_codigo = (TextView) findViewById(R.id.DART_art_codigo);
textview_codbar = (TextView) findViewById(R.id.DART_art_codbar);
textview_precio = (TextView) findViewById(R.id.DART_art_precio);
textview_costo = (TextView) findViewById(R.id.DART_art_costo);
textview_cantidad = (TextView) findViewById(R.id.DART_art_cantidad);
textview_exis = (TextView) findViewById(R.id.DART_art_exisventa);
boton_volver = (Button) findViewById(R.id.DART_boton_salir);
//4 Cargado de handlers sobre la imagen y botones
boton_volver.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//No hubo eliminacion del articulo
setResult(RESULT_OK,intentPadre);
finish();
log.log("[-- 203 --]" + "Volvi hacia atras", 0);
}
});
//5 Configuracin del valor:
textview_nombre.setText(articulo_on_focus.getDescripcion());
textview_sector.setText(String.valueOf(articulo_on_focus.getSector()));
textview_codigo.setText(String.valueOf(articulo_on_focus.getCodigo()));
textview_codbar.setText(articulo_on_focus.getCodigos_barras_string());
textview_precio.setText(String.valueOf(articulo_on_focus.getPrecio_venta()));
textview_costo.setText(String.valueOf(articulo_on_focus.getPrecio_costo()));
textview_cantidad.setText(String.valueOf(articulo_on_focus.getCantidad()));
/*getDescripcion
* */
double exis = articulo_on_focus.getExis_venta();
double dep = articulo_on_focus.getExis_deposito();
double resutado = exis + dep;
// textview_exis.setText(String.valueOf(resultado));
String existencia;
SharedPreferences setting = PreferenceManager.getDefaultSharedPreferences(ctxt);
boolean mostrarExistencia = setting.getBoolean(ParametrosInventario.tablet_mostrar_existencia, ParametrosInventario.mostrar_existencia);
if(mostrarExistencia) {
existencia = String.valueOf(articulo_on_focus.getExis_venta() + articulo_on_focus.getExis_deposito());
}else{
existencia = ParametrosInventario.no_disponible;
}
textview_exis.setText(existencia);
/*123456*/
// textview_exis.setText(String.valueOf(articulo_on_focus.getExis_venta()));
/**
* Boton para eliminar articulos: en el caso de necesitar esta
* funcionalidad, descomentar esta parte del codigo, esto
* perimitira dar la posibilidad de eliminar el articulo actual
* del inventario.
*/
// botonEliminar= (Button) findViewById(R.id.DART_eliminar);
//
// botonEliminar.setOnClickListener(new View.OnClickListener() {
//
//
// public void onClick(View v) {
// /**
// * Generamos los listeners
// */
// View.OnClickListener listenerPositivo=new View.OnClickListener() {
//
//
// public void onClick(View v) {
//
// BaseDatos bdd=new BaseDatos(ctxt);
// int resultado=ParametrosInventario.RETURN_ART_ELIM_FALLO;
// try {
// //Eliminamos los datos del articulo del inventario actual
// bdd.borrarArcticuloInventario(sector,codigo,inventario);
// //Pasamos los datos del articulo eliminado
// intentPadre.putExtra(ParametrosInventario.extra_sector, sector);
// intentPadre.putExtra(ParametrosInventario.extra_codigo, codigo);
// intentPadre.putExtra(ParametrosInventario.extra_codBar, articulo_on_focus.getCodigos_barras_string());
// resultado=ParametrosInventario.RETURN_ART_ELIM;
// setResult(resultado, intentPadre);
// dialogoContinuarBorrar.dismiss();
// finish();
// } catch (ExceptionBDD e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// Toast.makeText(ctxt, "Error al intentar borrar el articulo",
// Toast.LENGTH_LONG).show();
//// resultado=ParametrosInventario.RETURN_ART_ELIM_FALLO;
// dialogoContinuarBorrar.dismiss();
// }
// }
// };
//
// View.OnClickListener listenerNegativo=new View.OnClickListener() {
//
//
// public void onClick(View v) {
// //Cerramos el dialog
// dialogoContinuarBorrar.dismiss();
//
// }
// };
//
// dialogoContinuarBorrar=new DialogPersoComplexSiNo(ctxt, "Eliminar " +
// "Artculo", "Esta seguro que desea eliminar el artculo del inventario?",
// DialogPerso.ALERTAR,
// listenerPositivo,
// listenerNegativo);
//
// dialogoContinuarBorrar.show();
//
//
// }
// });
/**
* Hasta aqui hay que descomentar
*/
}
/**
* Al presionar back, volvemos cerrando la activity actual
*/
public void onBackPressed() {
finish();
}
/**
* Muestra un dialogo con la opcion de presionar "Ok" para cerrarlo
*/
public AlertDialog showSimpleDialogOK(String titulo, String mensaje) {
final GestorLogEventos log = new GestorLogEventos();
log.setUbicacion(ParametrosInventario.CARPETA_LOGTABLET);
log.tipo_0 = Parametros.PREF_LOG_EVENTOS;
log.tipo_2 = Parametros.PREF_LOG_PROCESOS;
log.tipo_3 = Parametros.PREF_LOG_MENSAJES;
log.tipo_4 = Parametros.PREF_LOG_EXCEPCIONES;
log.log("[-- 314 --]" + "titulo: " + titulo + "; \n mensaje: " + mensaje , 0);
AlertDialog.Builder dialogoSimple = new AlertDialog.Builder(this);
dialogoSimple.setCancelable(false)
.setTitle(titulo)
.setMessage(mensaje)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(@NonNull DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = dialogoSimple.create();
return alert;
}
/**
* No implementado
*/
@Nullable
public AlertDialog showSimpleDialogSiNo(String titulo, String mensaje, Class<?> clase) {
return null;
}
}