Ejemplo n.º 1
0
        private string GetGoodInfo(Classes.Good targetGood)
        {
            if (targetGood is Classes.Game)
            {
                if (targetGood as VideoGame != null)
                {
                    return((targetGood as VideoGame).GetInfo());
                }
                if (targetGood as ConstructorGame != null)
                {
                    return((targetGood as ConstructorGame).GetInfo());
                }
                if (targetGood as SoftToy != null)
                {
                    return((targetGood as SoftToy).GetInfo());
                }
            }

            if (targetGood is Classes.Product)
            {
                if (targetGood as Classes.DairyProduct != null)
                {
                    return((targetGood as Classes.DairyProduct).GetInfo());
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        private void ListView_ItemActivate(object sender, EventArgs e)
        {
            ListView currentListView = sender as ListView;

            if (currentListView.SelectedItems.Count != 1)
            {
                return;
            }
            ListViewItem selectedListViewItem = currentListView.SelectedItems[0];

            if (currentListView.Equals(GoodListView))
            {
                Classes.Good findGood;
                if (goodDictionary.TryGetValue(Convert.ToInt32(selectedListViewItem.Tag), out findGood))
                {
                    Classes.Good newGood = findGood.Clone() as Classes.Good;

                    ListViewItem copyListItem = selectedListViewItem.Clone() as ListViewItem;
                    OrderListView.Items.Add(copyListItem).Group = OrderListView.Groups[0];
                    copyListItem.Tag = copyListItem.GetHashCode();
                    orderDictionary.Add(Convert.ToInt32(copyListItem.Tag), newGood);

                    CountOfGood.Text = (Convert.ToInt32(CountOfGood.Text) + 1).ToString();
                    MainLabel.Text   = "You can pay for your order clicking to button \"Pay for the purchase\"";
                }
            }

            if (currentListView.Equals(OrderListView))
            {
                orderDictionary.Remove(Convert.ToInt32(selectedListViewItem.Tag));
                currentListView.Items.Remove(selectedListViewItem);

                CountOfGood.Text = (Convert.ToInt32(CountOfGood.Text) - 1).ToString();
                if (CountOfGood.Text == "0")
                {
                    MainLabel.Text = "Select products";
                }
            }
        }