Beispiel #1
0
        private void Back_Click(object sender, EventArgs e)
        {
            this.Hide();
            WelcomeHomePage welcome = new WelcomeHomePage();

            welcome.Show();
        }
Beispiel #2
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(FirstNameBox.Text) || String.IsNullOrEmpty(LastNameBox.Text))
                {
                    MessageBox.Show("The First Name and Last Name fields are required");
                }

                string gender = null;

                if (FemaleCheckBox.Checked && !MaleCheckBox.Checked)
                {
                    gender = "Female";
                }
                if (!FemaleCheckBox.Checked && MaleCheckBox.Checked)
                {
                    gender = "Male";
                }
                if (FemaleCheckBox.Checked && MaleCheckBox.Checked)
                {
                    MessageBox.Show("Please pick only one gender");
                }
                if (!FemaleCheckBox.Checked && !MaleCheckBox.Checked)
                {
                    MessageBox.Show("Please pick a gender");
                }

                if (String.IsNullOrWhiteSpace(UsernameBox.Text) || String.IsNullOrWhiteSpace(PassCodeBox.Text))
                {
                    MessageBox.Show("The username and password fields are required");
                    return;
                }

                var phoneNumberUtil = PhoneNumbers.PhoneNumberUtil.GetInstance();


                if (!String.IsNullOrWhiteSpace(PhoneNumberBox.Text))
                {
                    try
                    {
                        //TODO: FORMAT THE NUMBER USING ASYOUTYPE FORMATER
                        phoneNumberUtil.Parse(PhoneNumberBox.Text, null);
                    }
                    catch
                    {
                        MessageBox.Show("Please enter a valid phone number in the format. Ex: +20-2-1234-1234");
                        PhoneNumberBox.Text = null;
                        return;
                    }
                }



                //TODO: Configure for email validation.
                if (!EmailBox.Text.Contains("@") || !EmailBox.Text.Contains("."))
                {
                    MessageBox.Show("Please enter a valid email account.");
                    return;
                }

                if (PassCodeBox.Text.Length < 8)
                {
                    MessageBox.Show("Passcodes must be longer than 8 characters in length");
                    PassCodeBox.Text = null;
                    return;
                }

                else
                {
                    int returnValue = doAction.createSchedulerAccount(FirstNameBox.Text, LastNameBox.Text, PhoneNumberBox.Text,
                                                                      EmailBox.Text, gender, UsernameBox.Text, PassCodeBox.Text, ReenterPasscodeBox.Text);

                    if (returnValue is 1)
                    {
                        MessageBox.Show("That username already exists. Please try another one");
                    }

                    if (returnValue is 2)
                    {
                        MessageBox.Show("The two passcodes don't match. Please try again");
                    }
                    if (returnValue is 3)
                    {
                        MessageBox.Show("Please pick a different passcode. That passcode already exists");
                    }
                    if (returnValue is 0)
                    {
                        this.Close();
                        WelcomeHomePage welcome = new WelcomeHomePage();
                        welcome.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(FirstNameBox.Text) || String.IsNullOrEmpty(LastNameBox.Text))
                {
                    MessageBox.Show("The First Name and Last Name fields are required");
                }

                string gender = null;

                if (FemaleCheckBox.Checked && !MaleCheckBox.Checked)
                {
                    gender = "Female";
                }
                if (!FemaleCheckBox.Checked && MaleCheckBox.Checked)
                {
                    gender = "Male";
                }
                if (FemaleCheckBox.Checked && MaleCheckBox.Checked)
                {
                    MessageBox.Show("Please pick only one gender");
                }

                if (String.IsNullOrWhiteSpace(UsernameBox.Text) || String.IsNullOrWhiteSpace(PassCodeBox.Text))
                {
                    MessageBox.Show("The username and password fields are required");
                    return;
                }

                var phoneNumberUtil = PhoneNumbers.PhoneNumberUtil.GetInstance();


                if (!String.IsNullOrWhiteSpace(PhoneNumberBox.Text))
                {
                    try
                    {
                        //TODO: FORMAT THE NUMBER USING ASYOUTYPE FORMATER
                        phoneNumberUtil.Parse(PhoneNumberBox.Text, null);
                    }
                    catch
                    {
                        MessageBox.Show("Please enter a valid phone number");
                        PhoneNumberBox.Text = null;
                        return;
                    }
                }

                if (PassCodeBox.Text.Length < 8)
                {
                    MessageBox.Show("Passcodes must be longer than 8 characters");
                    PassCodeBox.Text = null;
                    return;
                }

                //TODO: Configure for email validation.
                if (!EmailBox.Text.Contains("@") || !EmailBox.Text.Contains("."))
                {
                    MessageBox.Show("Please enter a valid email account.");
                }

                else
                {
                    int returnValue = doAction.createProviderAccount(FirstNameBox.Text, LastNameBox.Text,
                                                                     TitleBox.Text, PhoneNumberBox.Text, EmailBox.Text, JobTypeBox.Text, gender, UsernameBox.Text,
                                                                     PassCodeBox.Text, ReenterPasscodeBox.Text);



                    if (returnValue is 1)
                    {
                        MessageBox.Show("That username already exists. Please try another one");
                    }

                    if (returnValue is 2)
                    {
                        MessageBox.Show("The two passcodes don't match. Please try again");
                    }
                    if (returnValue is 3)
                    {
                        MessageBox.Show("Please pick a different passcode. That passcode already exists");
                    }
                    if (returnValue is 0)
                    {
                        string providerName = FirstNameBox.Text + " " + LastNameBox.Text;
                        foreach (DataGridViewRow data in SchedulerTable.SelectedRows)
                        {
                            doAction.createProviderSchedulerRelation(UsernameBox.Text, providerName,
                                                                     (String)SchedulerTable[0, data.Index].Value);
                        }

                        this.Close();
                        WelcomeHomePage welcome = new WelcomeHomePage();
                        welcome.Show();
                    }
                }
            }
            catch
            {
                MessageBox.Show("Please enter a valid username and passcode combination");
            }
        }