private static DetalleInventario RowToDto(DetalleInventarioDS.tbl_detalleInventarioRow row) { DetalleInventario objDetalleInventario = new DetalleInventario(); objDetalleInventario.IdDetalleInventario = row.id; objDetalleInventario.IdProducto = row.idProducto; objDetalleInventario.IdInventario = row.idInventario; objDetalleInventario.Cantidad = row.cantidad; return(objDetalleInventario); }
/// <summary> /// Funcion encargada de guardar un nuevo registro en la base de datos /// </summary> /// <param name="nDetalleInventario"></param> public static void RegistrarNuevoDetalleInventario(DetalleInventario nDetalleInventario) { try { using (var ctx = new DataModel()) { ctx.DetalleInventario.Add(nDetalleInventario); ctx.SaveChanges(); } } catch (Exception) { throw; } }
/// <summary> /// Funcion encargada de modificar un registro de la base de datos /// </summary> /// <param name="nDetalle"></param> public static void Modificar(DetalleInventario nDetalle) { try { using (var ctx = new DataModel()) { ctx.DetalleInventario.Attach(nDetalle); ctx.Entry(nDetalle).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception) { throw; } }
/// <summary> /// Funcion encargada de eliminar un registro de la base de datos mediante una id /// </summary> /// <param name="pkDetalle"></param> public static void Eliminar(int pkDetalle) { try { using (var ctx = new DataModel()) { DetalleInventario nDetalle = ManejoDetalleInventario.getById(pkDetalle); ctx.Entry(nDetalle).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception) { throw; } }
public static DetalleInventario InsertarDetalle(string idProducto, string cantidad, string idInventario, string tipo) { DetalleInventario objDetalleInventario = DetalleInventarioBLL.InsertWithReturn(idProducto, cantidad, idInventario); Producto objProducto = ProductoBLL.SelectById(Convert.ToInt32(idProducto)); int stock = objProducto.Stock; if (tipo == "Ingreso") { stock = stock + Convert.ToInt32(cantidad); } else { stock = stock - Convert.ToInt32(cantidad); } ProductoBLL.UpdateStock(idProducto, stock); return(objDetalleInventario); }