public List <ClaseInventario> MostrarInventario() { sqlConnection.Open(); try { SqlCommand command = new SqlCommand("MostrarInventario", sqlConnection); command.CommandType = CommandType.StoredProcedure; SqlDataReader reader = command.ExecuteReader(); List <ClaseInventario> TestList = new List <ClaseInventario>(); ClaseInventario test = null; while (reader.Read()) { test = new ClaseInventario(); test.IdMaterial = int.Parse(reader["id_material"].ToString()); test.NombreMaterial = reader["nombre"].ToString(); test.Cantidad = int.Parse(reader["cantidad"].ToString()); TestList.Add(test); } return(TestList); } catch { throw; } finally { sqlConnection.Close(); } }
public void actualizarCantidad(ClaseInventario inventario) { try { sqlConnection.Open(); SqlCommand command = new SqlCommand("EditarInventario", sqlConnection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@nombre", inventario.NombreMaterial); command.Parameters.AddWithValue("@cantidad", inventario.Cantidad); command.Parameters.AddWithValue("@id", inventario.IdMaterial); command.ExecuteNonQuery(); } catch { throw; } finally { sqlConnection.Close(); } }