Beispiel #1
0
        private void SendAuction_Click(object client, RoutedEventArgs e)
        {
            double newPrice = int.Parse(newPriceTextBox.Text);
            var    item     = productCombobox.SelectedItem as Product;

            if (double.Parse(item.BeginCost) >= newPrice)
            {
                MessageBox.Show("You can't pay a lower price than origin price.");
                newPriceTextBox.Focus();
            }
            else
            {
                AuctionPacket packetSend = new AuctionPacket()
                {
                    Email = _email,
                    ID    = item.ID,
                    Cost  = newPriceTextBox.Text
                };

                OnSend(this.client, packetSend);
                sendAuctingbtn.IsEnabled = false;
                Product p = GetProductFromID(packetSend.ID);
                productList.Remove(p);
                productBoard.ItemsSource = null;
                productBoard.ItemsSource = productList;
                isSent = true;
            }
        }
Beispiel #2
0
        private void OnSend(Socket socket, AuctionPacket auctPacket)
        {
            if (auctPacket == null)
            {
                byte[] sendMsg = Encoding.ASCII.GetBytes("null/null/null");
                socket.Send(sendMsg);
                return;
            }

            if (socket.Connected == true)
            {
                //get data from packet

                byte[] sendMsg = Encoding.ASCII.GetBytes($"{auctPacket.ID}/{auctPacket.Email}/{auctPacket.Cost}");
                socket.Send(sendMsg);
            }
        }