public List<StoreSale> chartMonthGross(int storeID) { try { connection.Open(); MySqlCommand command; MySqlDataReader data; //string query = "SELECT Quantity,Product_idProduct,Date FROM sales WHERE Date < CURDATE() AND Date > (CURDATE() - 30) AND Store_idStore =" + storeID + ";"; string query = "chartMonthGross"; List<StoreSale> listOfSales = new List<StoreSale>(); command = new MySqlCommand(query, connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@storeId", storeID); data = command.ExecuteReader(); while (data.Read()) { int quantity = data.GetInt32("Quantity"); int productID = data.GetInt32("Product_idProduct"); decimal value = data.GetDecimal("Price"); //decimal value = getProductPrice(data.GetInt32("Product_idProduct")); //StoreSale store = new StoreSale(quantity, value); StoreSale store = new StoreSale(); store.setQuantity(quantity); store.setProductId(productID); store.setValue(value); listOfSales.Add(store); } connection.Close(); /*foreach (StoreSale sale in listOfSales) { decimal value = getProductPrice(sale.getProductID()); sale.setValue(value); }*/ return listOfSales; } catch (Exception e) { MessageBox.Show(e.Message); return null; } }
public List<StoreSale> getWaterPData(int storeID) { try { connection.Open(); MySqlCommand command; MySqlDataReader data; // string query = "SELECT Quantity,Product_idProduct FROM sales WHERE Store_idStore =" + storeID + ";"; string query = "getWaterPData"; List<StoreSale> listOfSales = new List<StoreSale>(); command = new MySqlCommand(query, connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@storeId", storeID); data = command.ExecuteReader(); while (data.Read()) { int quantity = data.GetInt32("Quantity"); int productID = data.GetInt32("Product_idProduct"); bool waterproof = data.GetBoolean("Waterproof"); //decimal value = getProductPrice(data.GetInt32("Product_idProduct")); //StoreSale store = new StoreSale(quantity, value); StoreSale store = new StoreSale(); store.setQuantity(quantity); store.setProductId(productID); store.setWaterproof(waterproof); listOfSales.Add(store); } connection.Close(); /*foreach (StoreSale sale in listOfSales) { int materialID = getMaterialID(sale.getProductID()); bool waterproof = getWaterProof(materialID); sale.setWaterproof(waterproof); }*/ return listOfSales; } catch (Exception e) { MessageBox.Show(e.Message); return null; } }