private string detailpriceBlock(int num) { Block[] block = cupboard.GetBlock(); if (num <= block.Length) { Dictionary <string, Object> Description = block[num - 1].GetDescription(); if (cupboard.BlockStock(num, stock)) { return("In stock" + " Price: " + Description["price"] + "€"); } else { return("Out of stock" + " Price: " + Description["price"] + "€"); } } else { return(""); } }
/***************************************************************************** * Pre : - Receives a cupboard as a parameter * * - Database server is on * * Post : Calls OrderPart for each par of the cupboard * *****************************************************************************/ public Dictionary <string, int> MakeOrder(Cupboard cupboard) { /*Maximum number of arts in a cupboard is (7 boxes * 15 parts) + 4 angles = 109*/ Dictionary <string, int> quantities = new Dictionary <string, int>(); for (int b = 0; b < cupboard.GetBlock().Length; b++) { Block block = cupboard.GetBlock()[b]; for (int p = 0; p < block.GetParts().Length; p++) { Part part = block.GetParts()[p]; if (part != null) { string code = part.GetDescription()["code"].ToString(); /*Part is counted as ordered*/ OrderPart(part); if (quantities.ContainsKey(code)) { quantities[code] += 1; } else { quantities.Add(code, 1); } } } } Angle[] angles = cupboard.GetAngles(); if (angles.Length == 4) { quantities.Add(angles[0].GetDescription()["code"].ToString(), 4); } else { Console.WriteLine("There are not 4 angles in the cupboard, there must have been an issue with addAngles function."); } return(quantities); }