Ejemplo n.º 1
0
        private void LogIn_Click(object sender, RoutedEventArgs e)
        {
            if (Login.Text.Length == 0 || Password.Password.Length == 0)
            {
                MessageBox.Show("Fill all fields!");
            }
            else
            {
                string        textoflogin = "******" + "%1" + Login.Text.ToString() + "%2" + Password.Password.ToString() + "%3";
                TcpClient     client      = new TcpClient(server_ip, port);
                NetworkStream stream      = client.GetStream();
                byte[]        bytesToSend = ASCIIEncoding.ASCII.GetBytes(textoflogin);
                stream.Write(bytesToSend, 0, bytesToSend.Length);

                byte[] bytesToRead       = new byte[client.ReceiveBufferSize];
                int    bytesRead         = stream.Read(bytesToRead, 0, client.ReceiveBufferSize);
                string messagefromserver = Encoding.ASCII.GetString(bytesToRead, 0, bytesRead);
                if (messagefromserver.StartsWith("success_user"))
                {
                    Ticket1 Tick = new Ticket1();
                    Tick.Show();
                    Close();
                }
                else if (messagefromserver.StartsWith("error_user"))
                {
                    MessageBox.Show("Incorrect login or password");
                }
            }
        }
Ejemplo n.º 2
0
        private void BackPayment(object sender, RoutedEventArgs e)
        {
            Ticket1 BP1 = new Ticket1();

            BP1.Show();
            Close();
        }