/// <summary> /// buy more of existing products /// </summary> private void Buy() { // get the product type the user wants to buy more of Product.ProductType productType = _consoleView.DisplayBuyExistingProducut(_salesperson); int numberOfUnits = 0; // foreach loop to find the existing product foreach (Product item in _salesperson.CurrentStock) { // if product type is found it prompts the user for number of products // and adds them to the product if (item.Type == productType && productType != Product.ProductType.None) { numberOfUnits = _consoleView.GetNumberOfUnitsToBuy(); item.AddProducts(numberOfUnits); // find the product in the salesInfo list and update the number of units bought foreach (Product product in city.SalesInfo) { if (productType == product.Type) { product.BuyProducts(numberOfUnits); } } } } }
/// <summary> /// sell product /// </summary> private void Sell() { // get the product type the user wants to sell Product.ProductType productType = _consoleView.DisplaySellProducts(_salesperson); int numberOfUnits = 0; // foreach loop to find the existing product foreach (Product item in _salesperson.CurrentStock) { // if product type is found it prompts the user for number of products // and subtracts them from the product if (item.Type == productType && productType != Product.ProductType.None) { numberOfUnits = _consoleView.GetNumberOfUnitsToSell(); item.SubtractProducts(numberOfUnits); // if more products are sold than exist in inventory // backorder notification is displayed to the user if (item.OnBackorder) { _consoleView.DisplayBackorderNotification(item, numberOfUnits); } // find the product in the salesIndo list and update the number of units sold foreach (Product product in city.SalesInfo) { if (productType == product.Type) { product.SellProducts(numberOfUnits); } } } } }
/// <summary> /// Gets an integer from the user about the number of units they want to sell /// Sets the backorder flag if they sell more than the current inventory /// </summary> /// <param name="product"></param> /// <returns></returns> public int DisplayGetNumberOfUnitsToSell(out Product.ProductType productType) { // // initialize variable // int productAmount = 0; // // set up the console // ConsoleUtil.HeaderText = "Unit Selling"; ConsoleUtil.DisplayReset(); // // get the product type // if (!ConsoleValidator.GetEnumValueFromUser <Product.ProductType>(MAXIMUM_ATTEMPTS, "What type of vehicle do you want to sell?", out productType)) { ConsoleUtil.DisplayMessage("Maximum attempts exceeded, returning to main menu."); } // // validate the input // if (!ConsoleValidator.TryGetIntegerFromUser(MINIMUM_BUYSELL_AMOUNT, MAXIMUM_BUYSELL_AMOUNT, MAXIMUM_ATTEMPTS, $"{productType.ToString()}s", out productAmount)) { ConsoleUtil.DisplayMessage("Maximum attempts exceeded, returning to main menu."); } DisplayContinuePrompt(); return(productAmount); }
protected Animal(Product.ProductType product, DateTime birth, string?chipCode = null) { Birth = birth; ChipCode = chipCode; Product = new Product { Type = product }; }
public FormatProductPriceCalculation( Product.ProductType productType, OrderParameter orderParameter, ProductCalculationResult calculationResult) { _productType = productType; _orderParameter = orderParameter; _calculationResult = calculationResult; }
public void DisplayProdToBuyandSell(Salesperson salesperson) { ConsoleUtil.HeaderText = "Choosing another product"; ConsoleUtil.DisplayReset(); Product.ProductType oldProduct = new Product.ProductType(); oldProduct = salesperson.CurrentStock.Type; int attempts = 0; bool productSelected = false; while (MAXIMUM_ATTEMPTS > attempts && !productSelected) { ConsoleUtil.DisplayMessage("Enter on of the following products to buy and sell: "); ConsoleUtil.DisplayPromptMessage(Product.ProductType.Dancing.ToString() + " " + Product.ProductType.Furry.ToString() + " " + Product.ProductType.Spotted.ToString() + " : "); string ProductType = Console.ReadLine(); switch (UppercaseFirst(ProductType)) { case "Furry": salesperson.CurrentStock.Type = Product.ProductType.Furry; productSelected = true; break; case "Dancing": salesperson.CurrentStock.Type = Product.ProductType.Dancing; productSelected = true; break; case "Spotted": salesperson.CurrentStock.Type = Product.ProductType.Spotted; productSelected = true; break; default: ConsoleUtil.DisplayMessage("You did not enter one of the Available products"); salesperson.CurrentStock.Type = Product.ProductType.None; break; } attempts++; } if (oldProduct == salesperson.CurrentStock.Type) { ConsoleUtil.DisplayMessage("You decided not change the product you were selling"); } else if (oldProduct != salesperson.CurrentStock.Type) { ConsoleUtil.DisplayMessage("You discard your " + oldProduct.ToString() + " product to make room for " + salesperson.CurrentStock.Type + " product."); salesperson.CurrentStock.ResetProductAmount(); } DisplayContinuePrompt(); }
public Customer.CustomerConfig FindCustomerConfig(Product.ProductType type) { foreach (var c in productCustomerConfigs) { if (c.product == type) { return(c.config); } } return(null); }
} //TODO chance DateTime to something that works with pausing etc. #endregion Data #region Construction public Order(Customer customer, Product.ProductType productType, uint amount) { this.customer = customer; this.productType = productType; this.amount = amount; this.amountLeft = amount; int minutesToDeadline = 5 + (int)amount / 10; //TODO Formula needs tweaking. Currently puts deadline to 5-15 minutes for 5-100 products. this.deadline = DateTime.Now.AddMinutes(minutesToDeadline); }
public ProductPriceCalculationMainViewModel( ProductTypesRepository repository, Product.ProductType productType, OrderParameter orderParameter, ProductCalculationResult calculationResult) { _repository = repository; _productType = productType; _orderParameter = orderParameter; _calculationResult = calculationResult; ProductType = ProductTypeOptions.First(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); // Aanmaken van producten Product p1 = new Product(); p1.Naam = "Cola"; Product.ProductType pt1 = Product.ProductType.Drank; p1.Type = pt1; Prijs prijs1 = new Prijs(); prijs1.Waarde = "3"; prijs1.Val = Prijs.Valuta.EUR; MenuItem mi1 = new MenuItem(); mi1.Item = p1; mi1.Waarde = prijs1; Console.WriteLine(mi1.ToString()); Product p2 = new Product(); p2.Naam = "Fanta"; Product.ProductType pt2 = Product.ProductType.Drank; p2.Type = pt2; Prijs prijs2 = new Prijs(); prijs2.Waarde = "3"; prijs2.Val = Prijs.Valuta.EUR; MenuItem mi2 = new MenuItem(); mi2.Item = p2; mi2.Waarde = prijs2; Console.WriteLine(mi2.ToString()); Console.WriteLine(p2.BerekenKCal().ToString()); Snack s = new Snack(); Console.WriteLine(s.BerekenKCal().ToString()); Drank d = new Drank(); Console.WriteLine(d.BerekenKCal().ToString()); }
/// <summary> /// Display sell products /// </summary> /// <param name="salesperson"></param> /// <returns></returns> public Product.ProductType DisplaySellProducts(Salesperson salesperson) { ConsoleUtil.HeaderText = "Sell Inventory"; ConsoleUtil.DisplayReset(); ConsoleUtil.DisplayMessage("Your current inventory:"); ConsoleUtil.DisplayMessage(""); CurrentInventory(salesperson); Product.ProductType productType = GetTypeOfProduct(salesperson, "sell", out bool inStock); if (!inStock) { ConsoleUtil.DisplayMessage("This product does not exist in your inventory."); DisplayContinuePrompt(); } return(productType); }
// Display Salesperson Inventory public void DisplayInventory(Product product) { ConsoleUtil.HeaderText = "Inventory"; ConsoleUtil.DisplayReset(); int units = product.NumberOfUnits; Product.ProductType productType = product.Type; if (product.NumberOfUnits < 0) { Console.WriteLine("You are currently on backorder of the following product type: " + productType); Console.WriteLine("Number of products on backorder: " + product.NumberOfUnits * -1); } else { Console.WriteLine("You currently have " + units + " products of type: " + productType); } DisplayContinuePrompt(); }
/// <summary> /// Display buy new products and add to the salesperson /// </summary> /// <param name="salesperson"></param> /// <returns></returns> public Product.ProductType DisplayBuyNewProducts(Salesperson salesperson) { ConsoleUtil.HeaderText = "Buy New Products"; ConsoleUtil.DisplayReset(); DisplayAvailableProducts(); Product.ProductType productType = GetTypeOfProduct(salesperson, "buy", out bool inStock); // if the product already exist in the inventory, the return will be set to none if (inStock) { productType = Product.ProductType.None; ConsoleUtil.DisplayMessage("This product already exist in your inventory."); DisplayContinuePrompt(); } return(productType); }
public void SetDevicePutPoints(Product.ProductType product, Product.SalverType salver, ref PointInfo[,] Points) { if (product == Product.ProductType.Accepts) //合格品 { for (int i = 0; i < Product.SalverRow; i++) { for (int j = 0; j < Product.SalverCol; j++) { DeviceAcceptsPutPoints[i, j] = Points[i, j]; } } } else if (product == Product.ProductType.UnAccepts) //不合格品 { for (int i = 0; i < Product.SalverRow; i++) { for (int j = 0; j < Product.SalverCol; j++) { DeviceUnAcceptsPutPoints[i, j] = Points[i, j]; } } } }
public void AddOrder(Product.ProductType productType, uint amount) { AddOrder(new Order(this, productType, amount)); }
public ReadyParams(Product.ProductType t) { type = t; }
public ProductPriceCalculator(Product.ProductType productType, OrderParameter orderParameter) { _productType = productType; _orderParameter = orderParameter; }
/// <summary> /// display a list of product types and return the selected product with cost /// </summary> public void DisplayProductUserSelection(Salesperson salesperson) { bool usingMenu = true; int maxAttempts = 3; bool maxAttemptsExceeded = false; Product product = new Product(); Product.ProductType productType = new Product.ProductType(); productType = Product.ProductType.None; // // set up display area // ConsoleUtil.DisplayReset(); ConsoleUtil.HeaderText = "Select a Product"; Console.CursorVisible = false; while (usingMenu) { // // set up display area // ConsoleUtil.DisplayReset(); Console.CursorVisible = false; // // display the menu // ConsoleUtil.DisplayMessage("Please type the number of your menu choice."); ConsoleUtil.DisplayMessage(""); Console.Write( "\t" + "1. Furry" + Environment.NewLine + "\t" + "2. Spotted" + Environment.NewLine + "\t" + "3. Dancing" + Environment.NewLine); // // get and process the user's response // note: ReadKey argument set to "true" disables the echoing of the key press // ConsoleKeyInfo userResponse = Console.ReadKey(true); switch (userResponse.KeyChar) { case '1': productType = Product.ProductType.Furry; usingMenu = false; break; case '2': productType = Product.ProductType.Spotted; usingMenu = false; break; case '3': productType = Product.ProductType.Dancing; usingMenu = false; break; default: ConsoleUtil.DisplayMessage( "It appears you have selected an incorrect choice." + Environment.NewLine + "Press any key to continue."); userResponse = Console.ReadKey(true); if (userResponse.Key == ConsoleKey.Escape) { usingMenu = false; } break; } product.Type = productType; } Console.Clear(); if (!string.IsNullOrEmpty(product.Type.ToString())) { product.Cost = ConsoleValidator.TestForDouble(maxAttempts, $"{product.Type} Product Cost:", out maxAttemptsExceeded); } Console.CursorVisible = true; salesperson.CurrentStock = product; //return product; }
/// <summary> /// Metod för att bygga upp en lista av ListViewItems för att visa tio-i-topp information /// </summary> /// <param name="stock">Varulager</param> /// <param name="receiptList">Lista på alla kvitton</param> /// <param name="type">Produkttyp</param> /// <param name="showOnlyActive">Ska listan enbart visa aktiva instrument</param> /// <param name="mode">Vilken typ av list ska produceras: AllTime, för i år, eller för denna månad. (AllTime, Year, Month) </param> /// <returns>Tio-I-Top lista av ListViewItem</returns> public static List <ListViewItem> Top10(Stock stock, List <Receipt> receiptList, Product.ProductType type, bool showOnlyActive, Mode mode) { List <ListViewItem> listViewItems = new List <ListViewItem>(); //Get all receipts for producttype if (receiptList != null && stock != null) { //Alla kvitton för angiven produkttyp, aktiva eller alla produkter och för vilken typ av lista (mode) //grupperade per produkt. var receiptQuery = from rec in receiptList join prod in stock.Products.Values on rec.ProductCode equals prod.ProductCode where (showOnlyActive ? (prod.Status == Product.ProductStatus.Active && prod.Type == type) : prod.Type == type) && (mode == Mode.Month ? DateTime.Parse(rec.DateOfSale, CultureInfo.CurrentCulture.DateTimeFormat).Month == DateTime.Today.Month : (mode == Mode.Year ? DateTime.Parse(rec.DateOfSale, CultureInfo.CurrentCulture.DateTimeFormat).Year == DateTime.Today.Year : DateTime.Parse(rec.DateOfSale, CultureInfo.CurrentCulture.DateTimeFormat) >= DateTime.MinValue)) group rec by rec.ProductCode into receiptGroup select receiptGroup; //Produktnummer, antal List <KeyValuePair <uint, uint> > statList = new List <KeyValuePair <uint, uint> >(); //För varje produkt foreach (var receiptGroup in receiptQuery) { uint sumqty = 0; uint code = 0; //Gå igenom varje kvitto foreach (var receipt in receiptGroup) { code = receipt.ProductCode; sumqty += receipt.Quantity; } //Addera produkt, totalt antal sålda till listan statList.Add(new KeyValuePair <uint, uint>(code, sumqty)); //Sortera listan statList.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value)); } int i = 1; //Bygg upp listan av ListViewItems //Rank, Produktnummer, Titel, TotalSåldVolym foreach (var item in statList) { ListViewItem lvi = new ListViewItem(i.ToString(CultureInfo.CurrentCulture)); lvi.Name = lvi.Text; lvi.SubItems.Add(item.Key.ToString(CultureInfo.CurrentCulture)); lvi.SubItems.Add(stock.GetProduct(item.Key).Title); lvi.SubItems.Add(item.Value.ToString(CultureInfo.CurrentCulture)); //Sätt font baserad på Status lvi.Font = stock.GetProduct(item.Key).Status == Product.ProductStatus.Active ? Product.DefaultFont : Product.InactiveFont; //Lägg till i listan över ListViewItems listViewItems.Add(lvi); i++; } } //Skicka upp listan return(listViewItems); }
/// <summary> /// reads data from Data.csv into a Salesperson object, then returns that object /// </summary> public Salesperson ReadSalespersonFromDataFile() { Salesperson salesperson = new Salesperson(); Product.ProductType productType = new Product.ProductType(); string salespersonInfo; string[] salespersonInfoArray = new string[7]; string citiesTraveled; // // initialize a FileStream object for writing // FileStream rFileStream = File.OpenRead(DataSettings.dataFilePathCsv); // // wrap the FileStream object in a using statement the ensure of the dispose // using (rFileStream) { // wrap the FileStream object in a StreamWriter object to simplify wrting strings\ StreamReader sReader = new StreamReader(rFileStream); using (sReader) { salespersonInfo = sReader.ReadLine(); citiesTraveled = sReader.ReadLine(); } } // // convert and write data to salesperson object // salespersonInfoArray = salespersonInfo.Split(','); salesperson.FirstName = salespersonInfoArray[0]; salesperson.LastName = salespersonInfoArray[1]; salesperson.AccountID = salespersonInfoArray[2]; salesperson.StartingCity = salespersonInfoArray[3]; if (!Enum.TryParse <Product.ProductType>(salespersonInfoArray[4], out productType)) { productType = Product.ProductType.None; } salesperson.CurrentStock.Type = productType; salesperson.CurrentStock.AddProducts(Convert.ToInt32(salespersonInfoArray[5])); salesperson.CurrentStock.OnBackorder = Convert.ToBoolean(salespersonInfoArray[6]); // // if citiesTraveled is null, then ignore // if (citiesTraveled == null) { return(salesperson); } else { salesperson.CitiesVisited = citiesTraveled.Split(',').ToList(); } return(salesperson); }