コード例 #1
0
ファイル: Check.xaml.cs プロジェクト: pow2/TU-Sofia
        private void btn4Sent_Click(object sender, RoutedEventArgs e)
        {
            // Clear the log
            ClearLog();

            // Make sure we can perform this action with valid data
            if (ValidateRemoteHost() && ValidateInput())
            {
                Chk chk1 = new Chk(txtName.Text, txtLastName.Text, txtNumber.Text);
                // Instantiate the SocketClient
                SocketClient client = new SocketClient();

                // Attempt to connect to the echo server
                //Log(String.Format("Connecting to server '{0}' over port {1} ...", remotehost, remoteport), true);
                string result = client.Connect(remotehost, remoteport);
                //Log(result, false);

                // Attempt to send our message to be echoed to the echo server
                //Log(String.Format("Sending '{0}' to server ...", chk1.ToString()), true);
                result = client.Send(chk1.ToString());
                //Log(result, false);

                // Receive a response from the echo server
                //Log("Requesting Receive ...", true);
                //ClearLog();
                result = client.Receive();
                Log(result, false);

                // Close the socket connection explicitly
                client.Close();
            }
            //endbtn
        }
コード例 #2
0
ファイル: Create.xaml.cs プロジェクト: pow2/TU-Sofia
        private void btn6Reg_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateRemoteHost() && ValidateInput())
            {
                register reg1 = new register(TempMem.username, TempMem.password, txtFname.Text, txtLname.Text, txtNum.Text, txtBrand.Text, txtModel.Text, TempMem.cartype.ToString(), TempMem.caraddinfo.ToString(), TempMem.price.ToString(), TempMem.city.ToString(), TempMem.ID.ToString());
                SocketClient client = new SocketClient();
                string result = client.Connect(remotehost, remoteport);
                result = client.Send(reg1.ToString());
                result = client.Receive();
                client.Close();
                if (result == "Системата не може да изпълни заявката в момента") { MessageBox.Show(result); }
                else
                {
                    try
                    {
                        MessageBox.Show(result);
                    }
                    catch
                    {
                        MessageBox.Show("Грешка в получените данни");
                    }
                }

            }
            //endbtn
        }
コード例 #3
0
ファイル: Login.xaml.cs プロジェクト: pow2/TU-Sofia
        private void btn6Login_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateRemoteHost() && ValidateInput())
            {
                logininf li1 = new logininf(txtUsername.Text, pwdbox1.Password);
                SocketClient client = new SocketClient();
                string result = client.Connect(remotehost, remoteport);
                result = client.Send(li1.ToString());
                result = client.Receive();
                client.Close();
                if (result == "Грешно име или парола") { MessageBox.Show(result); }
                else
                {
                    //MessageBox.Show(result);
                    try
                    {
                        TempMem.ID = Convert.ToInt32(result);
                        TempMem.username = txtUsername.Text;
                        TempMem.password = pwdbox1.Password;
                        this.NavigationService.Navigate(new Uri("/Create.xaml", UriKind.Relative));
                    }
                    catch
                    {
                        MessageBox.Show("Грешка в получените данни");
                    }
                }

            }
            //endbtn
        }