コード例 #1
0
        private async void Sell(object sender, RoutedEventArgs e)
        {
            if (isSelling)
            {
                return;
            }

            if (item.Stock == 0)
            {
                MessageBox.Show("This item is not in stock.");
                return;
            }

            isSelling = true;

            string      priceString = Item_NewPrice.Text;
            PriceSuffix suffix      = (PriceSuffix)Item_NewPriceSuffix.SelectedItem;

            try
            {
                Price price = priceString.ToPrice(suffix);
                item.Sell(price);
                Item_NewPrice.Clear();
            }
            catch
            {
                MessageBox.Show("Please enter a valid price.");
            }

            await Task.Delay(sameActionTimeout);

            isSelling = false;
        }
コード例 #2
0
        private async void LogEncounter(object sender, RoutedEventArgs e)
        {
            if (isLogging)
            {
                return;
            }

            isLogging = true;

            string      priceString = Item_NewPrice.Text;
            PriceSuffix suffix      = (PriceSuffix)Item_NewPriceSuffix.SelectedItem;

            try
            {
                Price price = priceString.ToPrice(suffix);
                item.Log(price);
                Item_NewPrice.Clear();
            }
            catch (Exception)
            {
                MessageBox.Show("Please enter a valid price.");
            }

            await Task.Delay(sameActionTimeout);

            isLogging = false;
        }