public override View GetView(int position, View convertView, ViewGroup parent) { var view = convertView; var item = _items[position]; if (view == null) { var inflater = LayoutInflater.FromContext(_context); view = inflater.Inflate(Resource.Layout.ProductoRow, parent, false); view.FindViewById <ImageButton>(Resource.Id.AccionExistenciaProducto).Click += DeleteExistencia; view.FindViewById <ImageButton>(Resource.Id.AccionRemove10).Click += Remove10; view.FindViewById <ImageButton>(Resource.Id.AccionRemove).Click += Remove; view.FindViewById <ImageButton>(Resource.Id.AccionAdd10).Click += Add10; view.FindViewById <ImageButton>(Resource.Id.AccionAdd).Click += Add; } _existencias = item; string newId = _existencias.IdExistencias.ToString(); string newValue = _existencias.FechaEntrada.ToShortDateString(); string newCantidad = _existencias.Cantidad.ToString(); view.FindViewById <TextView>(Resource.Id.ValueProducto).Tag = newId; view.FindViewById <TextView>(Resource.Id.ValueProducto).Text = newValue; view.FindViewById <TextView>(Resource.Id.CantidadProducto).Text = newCantidad; view.FindViewById <ImageButton>(Resource.Id.AccionRemove10).Tag = newId; view.FindViewById <ImageButton>(Resource.Id.AccionRemove).Tag = newId; view.FindViewById <ImageButton>(Resource.Id.AccionAdd10).Tag = newId; view.FindViewById <ImageButton>(Resource.Id.AccionAdd).Tag = newId; view.FindViewById <ImageButton>(Resource.Id.AccionExistenciaProducto).Tag = newId; return(view); }
/// <summary> /// Obtiene la existencia por id</summary> public void GetExistencia() { Negocio.Existencias _existencias = GestorApp.myData.GetExistencia(this); if (_existencias != null) { IdExistencias = _existencias.IdExistencias; IdElemento = _existencias.IdElemento; FechaEntrada = _existencias.FechaEntrada; FechaCaducidad = _existencias.FechaCaducidad; Cantidad = _existencias.Cantidad; } }
/// <summary> /// Actualiza la informacion en base de datos de la existencia </summary> /// <param name="existencia">Negocio.Existencias del que se desea actualziar la informacion </param> /// <returns>- 1 en caso de error</returns> public long UpdateExistencias(Negocio.Existencias existencia) { using (var db = new SQLiteConnection(_helper.WritableDatabase.Path)) { try { return(db.Update(existencia)); } catch (Exception ex) { return(-1); } } }
/// <summary> /// Obtiene la existencia </summary> /// <param name="existencia">Existencia de la que se desea obtener la informacion, la busquedad se realiza por id </param> /// <returns> Negocio.Existencias con el id indicado</returns> public Negocio.Existencias GetExistencia(Negocio.Existencias existencia) { Negocio.Existencias _existencia = new Negocio.Existencias(); using (var database = new SQLiteConnection(_helper.ReadableDatabase.Path)) { try { return(database.Table <Negocio.Existencias>().FirstOrDefault(u => u.IdExistencias == existencia.IdExistencias)); } catch (Exception ex) { return(null); } } }
/// <summary> /// Inserta en base de datos la existencia </summary> /// <param name="_existencia">existencia </param> /// <returns> Existencias</returns> public Negocio.Existencias InsertExistencias(Negocio.Existencias _existencia) { using (var db = new SQLiteConnection(_helper.WritableDatabase.Path)) { try { db.Insert(_existencia); return(_existencia); } catch (Exception ex) { return(null); } } }
private int GetElementoAbsolutePosition(Negocio.Existencias _existencia) { int resultado; resultado = 0; foreach (Existencias e in DataList) { if ((e.FechaEntrada == _existencia.FechaEntrada) && (e.FechaCaducidad == _existencia.FechaCaducidad)) { return(resultado); } else { resultado++; } } return(resultado); }