Beispiel #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");
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            ChannelFactory <IShopKeeper> service = new ChannelFactory <IShopKeeper>("ShopKeeperTcp");

            client = service.CreateChannel();
        }