Ejemplo n.º 1
0
        private void cmdResgister_Click(object sender, EventArgs e)
        {
            string[] arr = new string[checkedListBox1.Items.Count];
            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemChecked(i))
                {
                    arr[i] = (string)checkedListBox1.Items[i];
                }
            }
            bool Validate;
            bool valid;

            server.Service1 server = new server.Service1();
            server.AddUser(txtUsernameR.Text, txtPasswordR.Text, txtConfirmPassword.Text, txtSecretQuestion.Text, txtAnswer.Text, txtgender.Text, arr, out Validate, out valid);
            if (txtPasswordR.Text != txtConfirmPassword.Text)
            {
                MessageBox.Show("Password does not match!");
            }
            else
            {
                if (Validate == true)
                {
                    if (checkBox1.Checked == true)
                    {
                        MessageBox.Show("Congragulations! You registered successfully.");
                        txtUsernameR.Text       = "";
                        txtPasswordR.Text       = "";
                        txtConfirmPassword.Text = "";
                        txtSecretQuestion.Text  = "";
                        txtAnswer.Text          = "";
                        foreach (int i in checkedListBox1.CheckedIndices)
                        {
                            checkedListBox1.SetItemCheckState(i, CheckState.Unchecked);
                        }
                        txtgender.Text    = "";
                        checkBox1.Checked = false;
                    }
                    else
                    {
                        MessageBox.Show("You need to agree with terms and condition in order to proceed");
                    }
                }
                else
                {
                    MessageBox.Show("Invalid inputs");
                    checkBox1.Checked       = false;
                    txtPasswordR.Text       = "";
                    txtConfirmPassword.Text = "";
                }
            }
        }
Ejemplo n.º 2
0
        private void cmdResgister_Click(object sender, EventArgs e)
        {
            server.Interest[] arr = new server.Interest[checkedListBox1.CheckedItems.Count + 1];
            int j = 0;

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemChecked(i))
                {
                    server.Interest interest = new server.Interest();
                    interest.type = checkedListBox1.Items[i].ToString();

                    arr[j] = interest;
                    j++;
                }
            }

            bool Validate;
            bool valid;

            if (txtPasswordR.TextLength < 6)
            {
                MessageBox.Show("Password should be at least 6 characters.");
            }
            else if (txtPasswordR.Text != txtConfirmPassword.Text)
            {
                MessageBox.Show("Password does not match!");
                txtPasswordR.Text       = "";
                txtConfirmPassword.Text = "";
            }
            else
            {
                server.Service1 server = new server.Service1();
                server.AddUser(txtUsernameR.Text, txtPasswordR.Text, txtConfirmPassword.Text, txtSecretQuestion.Text, txtAnswer.Text, txtgender.Text, arr, out Validate, out valid);
                if (Validate == true & valid == true)
                {
                    if (checkBox1.Checked == true)
                    {
                        MessageBox.Show("Congratulations! You registered successfully.");
                        txtUsernameR.Text       = "";
                        txtPasswordR.Text       = "";
                        txtConfirmPassword.Text = "";
                        txtSecretQuestion.Text  = "";
                        txtAnswer.Text          = "";
                        foreach (int i in checkedListBox1.CheckedIndices)
                        {
                            checkedListBox1.SetItemCheckState(i, CheckState.Unchecked);
                        }
                        txtgender.Text    = "";
                        checkBox1.Checked = false;
                    }
                    else
                    {
                        MessageBox.Show("You need to agree with terms and condition in order to proceed");
                    }
                }
                else
                {
                    MessageBox.Show("Invalid user");
                    checkBox1.Checked       = false;
                    txtPasswordR.Text       = "";
                    txtConfirmPassword.Text = "";
                }
            }
        }