コード例 #1
0
        private void getButton_Click(object sender, RoutedEventArgs e)
        {
            string item = itemTextBox.Text;

            using (var client = new CustomerSupportClient())
            {
                int stock = client.Inquire(item);
                quantityTextBox.Text = stock.ToString();
            }
        }
コード例 #2
0
        private void buyButton_Click(object sender, RoutedEventArgs e)
        {
            string item     = itemTextBox.Text;
            int    quantity = int.Parse(quantityTextBox.Text);

            using (var client = new CustomerSupportClient())
            {
                Receipt purchase = client.Purchase(item, quantity);
                if (purchase.Status != 0)
                {
                    purchases.Add(new PurchaseEntry
                    {
                        Order    = purchase.Status,
                        Item     = item,
                        Quantity = quantity,
                        Amount   = purchase.Payment
                    });
                }
                else
                {
                    MessageBox.Show("Not available!", this.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }