Пример #1
0
        private void purchaseButton_Click(object sender, EventArgs e)
        {
            string item     = itemTextBox.Text;
            int    quantity = int.Parse(quantityTextBox.Text);

            using (var service = new ChannelFactory <IShopKeeper>(binding, address))
            {
                IShopKeeper client = service.CreateChannel();

                ItemInfo info = client.GetItemInfo(item);

                if (info == null)
                {
                    paymentTextBox.Text = "item not sold!";
                }
                else if (quantity > info.CurrentStock)
                {
                    paymentTextBox.Text = "item not in stock!";
                }
                else
                {
                    float  discount = client.GetBulkDiscount(quantity);
                    double payment  = quantity * info.UnitPrice * (1 - discount / 100);

                    paymentTextBox.Text = payment.ToString("0.00");
                }
            }
        }
Пример #2
0
        private void purchaseButton_Click(object sender, RoutedEventArgs e)
        {
            ItemInfo info = client.GetItemInfo(itemTextBox.Text);

            if (info == null)
            {
                paymentTextBox.Text = "N/A - Item not found";
            }
            else
            {
                int q = Convert.ToInt32(quantityTextBox.Text);
                if (q > info.CurrentStock)
                {
                    paymentTextBox.Text = "N/A - Out of stock";
                }
                else
                {
                    double p       = info.UnitPrice;
                    float  r       = client.GetBulkDiscount(q);
                    double payment = p * q * (1 - r / 100);
                    paymentTextBox.Text = payment.ToString("0.00");
                }
            }
        }