Beispiel #1
0
        private void signUpConfirm_Click(object sender, EventArgs e)
        {
            string namePattern = @"^\D+$";
            Regex  num         = new Regex(@"^[0-9]*$");
            Regex  name        = new Regex(namePattern);

            passingName = signUpNameTxt.Text + "-Registered";
            passingNum  = richTextBox2.Text;

            bool y = name.IsMatch(passingName);
            bool x = num.IsMatch(passingNum);

            if (x == true && y == true)
            {
                register = true;
                ChatApplication clientGUI = new ChatApplication();
                clientGUI.Show();
                if (clientGUI.loginResult == "Registered")
                {
                    this.Hide();
                }
                else if (clientGUI.loginResult == "Existed")
                {
                    lblResult.Text = "User already exist";
                }
                else
                {
                    lblResult.Text = "Register Failed!";
                }
                numCatch.Visible  = false;
                nameCatch.Visible = false;
            }
            else if (x == false && y == false)
            {
                numCatch.Visible  = true;
                nameCatch.Visible = true;
            }
            else if (x == false)
            {
                numCatch.Visible = true;
            }
            else if (y == false)
            {
                nameCatch.Visible = true;
            }
        }
Beispiel #2
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            string namePattern = @"^[a-zA-Z ]*$";
            Regex  num         = new Regex(@"^[0-9]*$");
            Regex  name        = new Regex(namePattern);

            passingName = nameTxt.Text;
            passingNum  = numTxt.Text;

            bool y = name.IsMatch(passingName);
            bool x = num.IsMatch(passingNum);

            if (x == true && y == true)
            {
                ChatApplication clientGUI = new ChatApplication();
                clientGUI.Show();
                if (clientGUI.loginResult == "Success")
                {
                    this.Hide();
                }
                else if (clientGUI.loginResult == "InUsed")
                {
                    lblResult.Text = "User has been logged into the system";
                }
                else
                {
                    lblResult.Text = "Login Failed!";
                }
                numCatch.Visible  = false;
                nameCatch.Visible = false;
            }
            else if (x == false && y == false)
            {
                numCatch.Visible  = true;
                nameCatch.Visible = true;
            }
            else if (x == false)
            {
                numCatch.Visible = true;
            }
            else if (y == false)
            {
                nameCatch.Visible = true;
            }
        }