Exemple #1
0
        private void uploadBtn_Click(object sender, EventArgs e)
        {
            string fileName = filePathBox.Text;
            int    encrypt  = 0;

            if (optionsList.CheckedItems.Count > 0)
            {
                encrypt = 1;
            }

            string data = "203";

            data += fileName.Length.ToString().PadLeft(2, '0');
            data += fileName;
            data += encrypt.ToString();

            SocketHandler sh = new SocketHandler();

            try
            {
                sh.sendData(data);
            }
            catch (SocketException)
            {
                errorLbl.Text = "Can't connect to the server";
            }
        }
Exemple #2
0
        private void signupBtn_Click(object sender, EventArgs e)
        {
            SocketHandler sh   = new SocketHandler();
            string        data = "202" + signUsernameBox.Text.Length.ToString().PadLeft(2, '0') + signUsernameBox.Text +
                                 signPasswordBox.Text.Length.ToString().PadLeft(2, '0') + signPasswordBox.Text +
                                 signEmailBox.Text.Length.ToString().PadLeft(2, '0') + signEmailBox.Text +
                                 signSizeBox.Text.Length.ToString().PadLeft(2, '0') + signSizeBox.Text;


            try
            {
                sh.sendData(data);
                string result = sh.recvData();

                switch (result)
                {
                case "1010":
                    signErrorLbl.Text = "Success";
                    break;

                case "1011":
                    signErrorLbl.Text = "Pass illegal";
                    break;

                case "1012":
                    signErrorLbl.Text = "Username already exists";
                    break;

                case "1013":
                    signErrorLbl.Text = "Username is illegal";
                    break;

                case "1015":
                    signErrorLbl.Text = "Not enough room on the computer";
                    break;
                }
                if (result.Equals("1000"))
                {
                    signErrorLbl.Text = "Success";
                }
            }
            catch (Exception)
            {
                signErrorLbl.Text = "Can't connect to the server";
            }
        }
Exemple #3
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            /* For testing */
            MainScreen main1 = new MainScreen();

            this.Hide();
            //main1.Closed += (s, args) => this.Close();
            main1.ShowDialog();

            this.Close();
            /* For testing */

            SocketHandler sh   = new SocketHandler();
            string        data = "200" + usernameBox.Text.Length.ToString().PadLeft(2, '0') + usernameBox.Text +
                                 passwordBox.Text.Length.ToString().PadLeft(2, '0') + passwordBox.Text;


            try
            {
                sh.sendData(data);
                string result = sh.recvData();
                if (!result.Equals("1000"))
                {
                    errorLbl.Text = "Wrong username or password";
                }
                else
                {
                    MainScreen main = new MainScreen();
                    this.Hide();
                    main.Closed += (s, args) => this.Close();
                    main.Show();
                }
            }
            catch (Exception)
            {
                errorLbl.Text = "Can't connect to the server";
            }
        }