public bool InsertOne(Inventariop o) { try { using (var db = new DymContext()) { db.Add(o); return(db.SaveChanges() > 0 ? true : false); } } catch (Exception ex) { Ambiente.Mensaje("Algo salio mal con: " + MethodBase.GetCurrentMethod().Name + "@" + GetType().Name + "\n" + ex.ToString()); } return(false); }
public bool Update(Inventariop o) { try { using (var db = new DymContext()) { db.Entry(o).State = Microsoft.EntityFrameworkCore.EntityState.Modified; return(db.SaveChanges() > 0 ? true : false); } } catch (Exception ex) { Ambiente.Mensaje("Algo salio mal con: " + MethodBase.GetCurrentMethod().Name + "@" + GetType().Name + "\n" + ex.ToString()); } return(false); }
private void Incializa() { tipoInventarioController = new TipoInventarioController(); productoController = new ProductoController(); inventarioController = new InventarioController(); inventariopController = new InventariopController(); loteController = new LoteController(); movInvController = new MovInvController(); tipoInventario = null; producto = null; lote = null; inventario = null; categoria = null; partida = null; Costo = 0; partidas = new List <Inventariop>();; CreaInventario(); TxtTipoInv.Focus(); }
private void InsertaPartida() { if (producto == null && TxtProducto.Text.Trim().Length == 0) { Ambiente.Mensaje("Producto no encontrado"); return; } if (producto.TieneLote && lote == null) { Ambiente.Mensaje("Seleccione el lote del articulo"); return; } //producto = productoController.SelectOne(TxtProducto.Text.Trim()); try { if ((bool)producto.Ocupado) { Ambiente.Mensaje("Operación abortada, el articulo está bloqueado por otro proceso [INVENTARIOS, AJUSTES, AUTORIZACIONES, ETC]"); return; } } catch (Exception ex) { Ambiente.Mensaje(ex.Message); } var partida = new Inventariop(); partida.InventarioId = inventario.InventarioId; partida.ProductoId = producto.ProductoId; partida.ExistenciaTeorica = producto.Stock; partida.ExistenciaFisica = NCantidad.Value; partida.Descripcion = producto.Descripcion; partida.Costo = producto.Costopp; partida.MovInvId = null; if (lote == null) { partida.LoteId = null; } else { partida.LoteId = lote.LoteId; } if (partida.ExistenciaTeorica > partida.ExistenciaFisica) { partida.Diferencia = partida.ExistenciaTeorica - partida.ExistenciaFisica; partida.Diferencia = partida.Diferencia * -1; } else { partida.Diferencia = partida.ExistenciaFisica - partida.ExistenciaTeorica; } partida.CostoParcial = partida.Costo * partida.Diferencia; //partida al grid Malla.Rows.Add(); Malla.Rows[Malla.RowCount - 1].Cells[0].Value = partida.ProductoId; Malla.Rows[Malla.RowCount - 1].Cells[1].Value = partida.Descripcion; Malla.Rows[Malla.RowCount - 1].Cells[2].Value = partida.ExistenciaFisica; partidas.Add(partida); ResetPartida(); //CalculaTotales(); }