public static Producto GetProductoById(int productoId) { if (productoId <= 0) { throw new ArgumentException("El productoId no puede ser menor o igual que cero"); } ProductoDSTableAdapters.ProductoTableAdapter adapter = new ProductoDSTableAdapters.ProductoTableAdapter(); ProductoDS.ProductoDataTable table = adapter.GetProductoById(productoId); if (table == null || table.Rows.Count != 1) { throw new Exception("La table obtenida no tiene el numero correcto de filas"); } Producto obj = GetProductoFromRow(table[0]); return(obj); }
public static Producto GetProductoById(int ProductoId) { Producto theData = null; try { ProductoDSTableAdapters.ProductoTableAdapter localAdapter = new ProductoDSTableAdapters.ProductoTableAdapter(); ProductoDS.ProductoDataTable table = localAdapter.GetProductoById(ProductoId); if (table != null && table.Rows.Count > 0) { ProductoDS.ProductoRow row = table[0]; theData = FillReccord(row); } } catch (Exception q) { throw new ArgumentException(q.Message, q); } return(theData); }