public IActionResult GetByCodUbicacion(string codubi, string articulo, string lote) { dsAlmacen.BULTOSDataTable dtBultos = new dsAlmacen.BULTOSDataTable(); dtBultos.FillByUbicacion(codubi); if (dtBultos.Count == 0) { return(NotFound()); } else { List <Bulto> lstMov = new List <Bulto>(); foreach (dsAlmacen.BULTOSRow row in dtBultos.Rows) { //Buscamos los bultos de esa ubicacion que contengan ese articulo -- lote if (!row.IsLOTENull() && row.LOTE == lote && row.ARTICULO == articulo) { lstMov.Add(ParseBulto(row)); } } string JSONresult; JSONresult = JsonConvert.SerializeObject(lstMov); return(StatusCode(200, JSONresult)); } }
private Movimiento ParseSQLRow(DataRow row) { Movimiento mov = new Movimiento() { Articulo = (string)row["ARTICULO"], Descripcion = (string)row["TEXT"], BultoId = (int)row["CODBULTO"], Cantidad = Decimal.ToInt32((decimal)row["CANTIDAD"]), Fecha = (System.DateTime)row["F_MOV"], Lote = (string)row["LOTE"], Orden = (row["OFS"] == System.DBNull.Value ? null : row["OFS"].ToString()), MovimientoId = (int)row["CODMOV"], UserName = (string)row["TERMINAL"], UbicacionCode = (string)row["CODUBI"] }; dsAlmacen.UBICACIONESDataTable dtUbicacion = new dsAlmacen.UBICACIONESDataTable(); dtUbicacion.FillByCODUBI(mov.UbicacionCode); if (dtUbicacion.Count == 1) { mov.Ubicacion = Ubicacion.Parse(dtUbicacion[0]); } if (mov.Orden != null) { dsOfs.OFSDataTable dtOfs = new dsOfs.OFSDataTable(); dtOfs.FillByOfs(int.Parse(mov.Orden)); if (dtOfs.Count == 1) { mov.Ofs = Orden.Parse(dtOfs[0]); } } dsAlmacen.BULTOSDataTable dtBultos = new dsAlmacen.BULTOSDataTable(); dtBultos.FillByCODBULTO(mov.BultoId); if (dtBultos.Count == 1) { mov.Bulto = ParseBulto(dtBultos[0]); mov.Bulto.Ubicacion = mov.Ubicacion; } return(mov); }
public IActionResult Reubicar(string ubicacion, int bulto, string username) { int codMov = 0; try { dsAlmacen.BULTOSDataTable dtBultos = new dsAlmacen.BULTOSDataTable(); dtBultos.FillByCODBULTO(bulto); if (dtBultos.Count == 1) { LogiData.GestionAlmacen.Reubicar(bulto, ubicacion, dtBultos[0].CANTIDAD, username); } } catch (Exception e) { return(BadRequest(e.Message.ToString())); } return(Ok(codMov)); }
public IActionResult Delete(string id, string username) { int codMov = 0; try { dsAlmacen.MOVIMIENTOSDataTable dtMovimientos = new dsAlmacen.MOVIMIENTOSDataTable(); dtMovimientos.FillByCODMOV(int.Parse(id)); if (dtMovimientos.Count == 1) { if (!dtMovimientos[0].ANULADO) { Movimiento movRetorno = ParseMovimiento(dtMovimientos[0]); dsAlmacen.BULTOSDataTable dtBultos = new dsAlmacen.BULTOSDataTable(); dtBultos.FillByCODBULTO(dtMovimientos[0].CODBULTO); //Hace el retorno contra esa orden.. codMov = LogiData.GestionAlmacen.Retorno(movRetorno.UbicacionCode, movRetorno.Articulo, movRetorno.Descripcion, movRetorno.Lote, (System.DateTime?)(dtBultos[0].IsCADUCIDADNull() ? null : (System.DateTime?)dtBultos[0].CADUCIDAD), movRetorno.Cantidad, true, false, username, movRetorno.Orden); //Lo marca como anulado dtMovimientos[0].ANULADO = true; dtMovimientos.Update(); } else { throw new System.Exception("El movimiento ya esta anulado"); } } } catch (Exception ex) { return(BadRequest(ex.Message.ToString())); } return(Ok(codMov)); }
public IActionResult GetByCodUbicacion(string codubi) { dsAlmacen.BULTOSDataTable dtBultos = new dsAlmacen.BULTOSDataTable(); dtBultos.FillByUbicacion(codubi); if (dtBultos.Count == 0) { return(NotFound()); } else { List <Bulto> lstMov = new List <Bulto>(); foreach (dsAlmacen.BULTOSRow row in dtBultos.Rows) { lstMov.Add(ParseBulto(row)); } string JSONresult; JSONresult = JsonConvert.SerializeObject(lstMov); return(StatusCode(200, JSONresult)); } }
private Movimiento ParseMovimiento(dsAlmacen.MOVIMIENTOSRow row) { Movimiento mov = Movimiento.Parse(row); dsAlmacen.BULTOSDataTable dtBultos = new dsAlmacen.BULTOSDataTable(); dtBultos.FillByCODBULTO(mov.BultoId); if (dtBultos.Count == 1) { mov.Articulo = dtBultos[0].ARTICULO; mov.Lote = dtBultos[0].LOTE; mov.Descripcion = dtBultos[0].TEXT; } dsAlmacen.UBICACIONESDataTable dtUbicacion = new dsAlmacen.UBICACIONESDataTable(); dtUbicacion.FillByCODUBI(mov.UbicacionCode); if (dtUbicacion.Count == 1) { mov.Ubicacion = Ubicacion.Parse(dtUbicacion[0]); } return(mov); }