public void LoadAllDatabase(List <ProductStorages> listProductStorages) { DatabaseConnection(); sqlConnection.Open(); sqlCommand.CommandText = "EXEC dbo.ProcProductStoragesSelect"; SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { var productStorage = new ProductStorages(); for (int i = 0; i < sqlDataReader.FieldCount; i++) { var colName = sqlDataReader.GetName(i); var value = sqlDataReader.GetValue(i); var property = productStorage.GetType().GetProperty(colName); if (property != null) { property.SetValue(productStorage, value); } } listProductStorages.Add(productStorage); } sqlConnection.Close(); }
public void InsertProductStorages(ProductStorages productStorages) { //productStorages.ProductstorageId = listProductStorages.Count() + 1; //productStorages.ProductDelivery = DateTime.Today.ToString("d"); //listProductStorages.Add(productStorages); ////SQL INSERT //database.InsertProductStorages(productStorages); }
public void UpdateProductStorages(ProductStorages productStorages) { //var xProductStorage = listProductStorages.Where(e => e.ProductstorageId == productStorages.ProductstorageId).FirstOrDefault(); //listProductStorages.Remove(xProductStorage); //productStorages.ProductstorageCode = xProductStorage.ProductstorageCode; //productStorages.ProductCode = xProductStorage.ProductCode; //productStorages.ProductDimension = xProductStorage.ProductDimension; //productStorages.ProductDelivery = xProductStorage.ProductDelivery; //listProductStorages.Add(productStorages); //SQL UPDATE //database.UpdateProductStorages(productStorages); }
public void UpdateProductStorages(ProductStorages productStorages) { DatabaseConnection(); sqlConnection.Open(); //sqlCommand.CommandText = "EXEC ProcProductStoragesUpdate @id, @codes, @code, @dimension, @quantity, @delivery, @note"; //sqlCommand.Parameters.AddWithValue("@id", productStorages.ProductstorageId); //sqlCommand.Parameters.AddWithValue("@codes", productStorages.ProductstorageCode); //sqlCommand.Parameters.AddWithValue("@code", productStorages.ProductCode); //sqlCommand.Parameters.AddWithValue("@dimension", productStorages.ProductDimension); //sqlCommand.Parameters.AddWithValue("@quantity", productStorages.ProductQuantity); //sqlCommand.Parameters.AddWithValue("@delivery", productStorages.ProductDelivery); //sqlCommand.Parameters.AddWithValue("@note", productStorages.ProductstorageNote); //sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); }
public int Put([FromBody] ProductStorages productStorages) { return(1); }