Example #1
0
        private void button_Click_1(object sender, RoutedEventArgs e)
        {
            Zephora newZephora = new Zephora(usernames);

            this.Close();
            newZephora.ShowDialog();
        }
Example #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                LoginPacket sendData = new LoginPacket();
                sendData.ChatName = Username.Text + "\n" + "Password:"******"74.80.233.85");

                // Initialise the IPEndPoint for the server and use port 30000
                server = new IPEndPoint(serverIP, 4546);

                // Initialise the EndPoint for the server
                epServer = (EndPoint)server;

                // Get packet as byte array
                byte[] data = sendData.GetDataStream();

                // Send data to server
                clientSocket.BeginSendTo(data, 0, data.Length, SocketFlags.None, epServer, new AsyncCallback(this.SendData), null);

                // Initialise data stream
                this.dataStream = new byte[1024];


                // Begin listening for broadcasts


                clientSocket.BeginReceiveFrom(this.dataStream, 0, this.dataStream.Length, SocketFlags.None, ref epServer, new AsyncCallback(this.ReceiveData), null);



                string          myConnection = "datasource=74.80.233.83;port=3306;uid=barant2003;password=onedollar2;";
                MySqlConnection myConn       = new MySqlConnection(myConnection);

                MySqlCommand connection = new MySqlCommand("SELECT * FROM `zephora`.character WHERE Username= '******' AND Password= '******';", myConn);



                MySqlDataReader myReader;
                myConn.Open();
                myReader = connection.ExecuteReader();

                int count = 0;


                while (myReader.Read())
                {
                    count = count + 1;
                }


                if (count == 1)
                {
                    label3.Content = "Connected";

                    string  username = Username.Text;
                    Zephora fs       = new Zephora(username);
                    this.Close();
                    fs.ShowDialog();
                }
                else if (count > 1)
                {
                    label3.Content = "Duplicate usernames";
                }
                else
                {
                    label3.Content = "Invalid connection";
                    myConn.Close();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }