Beispiel #1
0
        /// <summary>
        /// Prints out Items for sale
        /// </summary>
        public void ListItems()
        {
            Console.WriteLine("Items for sale: ");
            Console.WriteLine("\nItem\t\tPrice");

            foreach (KeyValuePair <string, double> kvp in _cm.GetItemsForSale())
            {
                //textBox3.Text += ("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
                Console.WriteLine("{0}\t{1}", kvp.Key, kvp.Value.ToString("C"));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes the cashier GUI.
        /// </summary>
        /// <param name="cm">An instance of cashier model</param>
        /// <param name="t">The date for the cashier's sales</param>
        /// <param name="rHan">RemoveItemHandler delegate</param>
        /// <param name="aHan">AddItemHandler delegate</param>
        /// <param name="cmHan">CompleteSaleHandler delegate</param>
        /// <param name="cHan">CreateSaleHandler delegate</param>
        public CashierGUI(CashierModel cm, DateTime t, RemoveItemHandler rHan, AddItemHandler aHan,
                          CompleteSaleHandler cmHan, CreateSaleHandler cHan)
        {
            InitializeComponent();
            _cashierModel = cm;
            _itemsd       = _cashierModel.GetItemsForSale();
            uxItems.Columns.Add("Name", 93);
            uxItems.Columns.Add("Price", 93);
            uxCart.Columns.Add("Name", 93);
            uxCart.Columns.Add("Quantity", 93);
            uxCart.Columns.Add("Price", 92);
            date     = t;
            _totCost = 0;

            this._rHan  = rHan;
            this._aHan  = aHan;
            this._cmHan = cmHan;
            this._cHan  = cHan;

            foreach (KeyValuePair <string, double> k in _itemsd)
            {
                uxItems.Items.Add(new ListViewItem(new[] { k.Key, String.Format("{0:c}", k.Value) }));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Gets the priceof an item
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public double GetPriceOf(string name)
        {
            Dictionary <string, double> itemsForSale = _cashierModel.GetItemsForSale();

            return(itemsForSale[name]);
        }