Beispiel #1
0
 private void RegisterButton_Click(object sender, RoutedEventArgs e)
 {
     if (UserNameTextBox.Text == "" || PasswordBox.Password == "" || ConfirmPasswordBox.Password == "" || EmailTextBox.Text == "")
     {
         if (UserNameTextBox.Text == "")
         {
             UserNameTextBox.Background = Brushes.Red;
         }
         if (PasswordBox.Password == "")
         {
             PasswordBox.Background = Brushes.Red;
         }
         if (ConfirmPasswordBox.Password == "")
         {
             ConfirmPasswordBox.Background = Brushes.Red;
         }
         if (EmailTextBox.Text == "")
         {
             EmailTextBox.Background = Brushes.Red;
         }
         MessageBox.Show("U moet een Username en Wachtwoord invoeren!", "Let op!", MessageBoxButton.OK,
                         MessageBoxImage.Exclamation);
     }
     else
     {
         if (_userBus.UsernameExist(UserNameTextBox.Text) == false)
         {
             if (Validation.IsValidEmail(EmailTextBox.Text))
             {
                 var _user = new User();
                 _user.Username = UserNameTextBox.Text;
                 _user.Password = PasswordStorage.CreateHash(PasswordBox.Password);
                 _user.Email    = EmailTextBox.Text;
                 _user.Role     = "User";
                 _userBus.Create(_user);
                 MessageBox.Show("User created");
             }
             else
             {
                 EmailTextBox.Background = Brushes.Red;
                 EmailTextBox.SelectAll();
                 EmailTextBox.Focus();
             }
         }
         else
         {
             MessageBox.Show("Deze Username is al in gebruik!", "Let op!", MessageBoxButton.OK,
                             MessageBoxImage.Exclamation);
             UserNameTextBox.Background = Brushes.Red;
             UserNameTextBox.SelectAll();
             UserNameTextBox.Focus();
         }
     }
 }
Beispiel #2
0
 private void EmailTextBox_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     EmailTextBox.Focus();
     EmailTextBox.SelectAll();
 }
Beispiel #3
0
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            string Str = TransactionNumberTextBox.Text;
            double Num;
            bool   isNum = double.TryParse(Str, out Num);

            string Str2 = PhoneNumberTextBox.Text;
            double Num2;
            bool   isNum2 = double.TryParse(Str2, out Num2);

            if (isNum)
            {
                if (NameTextBox.Text != "")
                {
                    if (isNum2)
                    {
                        if (EmailTextBox.Text != "")
                        {
                            Message = ("Details of your transaction below\n" +
                                       "Transaction id: " + TransactionNumberTextBox.Text + "\n" +
                                       "Name: " + NameTextBox.Text + "\n" +
                                       "Phone Number: " + PhoneNumberTextBox.Text + "\n" +
                                       "Email: " + EmailTextBox.Text + "\n" + "Principal+interest: " +
                                       value + "\n" +
                                       "If the details above are correct and you wish to proceed click OK ");
                            Heading = "Confirmation";
                            MessageBoxButtons buttons     = MessageBoxButtons.OKCancel;
                            MessageBoxIcon    messageIcon = MessageBoxIcon.Question;
                            DialogResult      result;
                            result = MessageBox.Show(Message, Heading, buttons, messageIcon);
                            if (result == DialogResult.OK)
                            {
                                FileWriter();

                                MessageBox.Show("Clients details have been saved ", "Details Saved", MessageBoxButtons.OK);

                                TransCount     += TransactionNumberTextBox.Text + "\n";
                                InvestedAmount += decimal.Parse(InvestAmountTextBox.Text);
                                NumberOfTransactions++;

                                SummaryGB.Visible     = true;
                                SummaryButton.Visible = true;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please enter your email address");
                            EmailTextBox.Focus();
                            EmailTextBox.SelectAll();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a phone number, Only numeric Input accepted");
                        PhoneNumberTextBox.Focus();
                        PhoneNumberTextBox.SelectAll();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter your name");
                    NameTextBox.Focus();
                    NameTextBox.SelectAll();
                }
            }
            else
            {
                MessageBox.Show("Please enter a SIX digit unique key");
                TransactionNumberTextBox.Focus();
                TransactionNumberTextBox.SelectAll();
            }
        }
Beispiel #4
0
 private void EmailTextBox_Click(object sender, EventArgs e)
 {
     EmailTextBox.SelectAll();
 }
Beispiel #5
0
        /*
         * Event Handler for Confirm Button
         * -Validating FUll Name, Telephone Number, Email Address
         * -
         */
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            StreamWriter FileWriter;
            string       DynamicMessage;

            if (ProceedButton.Enabled == true)
            {
                MessageBox.Show("Please Confirm the Term by pressing Proceed button before confirming the membership");
            }
            else
            {
                if (NotNullValue(FullNameTextBox.Text, 1))
                {
                    //Full Name Regular Express Validation
                    //One Word is mandatory which includes Capital and small Letters
                    if (!Regex.IsMatch(FullNameTextBox.Text, @"^[A-Z a-z]*([A-Z a-z]*)+$"))
                    {
                        MessageBox.Show("Please enter valid name", "Invalid Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        FullNameTextBox.Focus();
                        FullNameTextBox.SelectAll();
                    }
                    else
                    {
                        if (NotNullValue(TelephoneTextBox.Text, 2))
                        {
                            //Telephone Number Reguar Expression Validation
                            //Grouping of 3 Number followed by space(not mandatory), then Next 3 numbers followed by space and then last 4 digits
                            if (!Regex.IsMatch(TelephoneTextBox.Text, @"^(\(?\d{3}\)*\s?\d{3}\s?\d{4})$"))
                            {
                                MessageBox.Show("Please enter valid telephone Number", "Invalid Number", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                TelephoneTextBox.Focus();
                                TelephoneTextBox.SelectAll();
                            }
                            else
                            {
                                if (NotNullValue(EmailTextBox.Text, 3))
                                {
                                    //Email Validation by Regular Expression
                                    bool CorrectEmail = Regex.IsMatch(EmailTextBox.Text, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

                                    if (!CorrectEmail)
                                    {
                                        MessageBox.Show("Please enter valid email address", "Invalid Email Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        EmailTextBox.Focus();
                                        EmailTextBox.SelectAll();
                                    }
                                    else
                                    {
                                        //If all the detais are correct, providing popup
                                        DynamicMessage = "Provided Details are as below:";
                                        DynamicMessage = DynamicMessage + "\n\nMembership Details :";
                                        DynamicMessage = DynamicMessage + "\nMembership ID      : " + MembershipIDLabel.Text;
                                        DynamicMessage = DynamicMessage + "\nConfirmed Term     : " + ConfirmedTerm.ToString();
                                        DynamicMessage = DynamicMessage + "\nMembership Fees  : " + ConfirmedTermTotal.ToString();
                                        DynamicMessage = DynamicMessage + "\n\nPersonal Details :";
                                        DynamicMessage = DynamicMessage + "\nFull Name              : " + FullNameTextBox.Text;
                                        DynamicMessage = DynamicMessage + "\nTelephone No.      : " + TelephoneTextBox.Text;
                                        DynamicMessage = DynamicMessage + "\nEmail ID                 : " + EmailTextBox.Text;
                                        DynamicMessage = DynamicMessage + "\n\nDo you want to cofirm the Membership Details?";

                                        //Yes No Popup  Display decision
                                        DialogResult DR = MessageBox.Show(DynamicMessage, "Do you want to Continue?", MessageBoxButtons.YesNo);
                                        if (DR == DialogResult.Yes)
                                        {
                                            try
                                            {
                                                //Saving details of membership to the Database File
                                                FileWriter = File.AppendText(DatabaseFileName);
                                                FileWriter.WriteLine(MembershipIDLabel.Text);
                                                FileWriter.WriteLine(JoinDayLabel.Text);
                                                FileWriter.WriteLine(FullNameTextBox.Text);
                                                FileWriter.WriteLine(TelephoneTextBox.Text);
                                                FileWriter.WriteLine(EmailTextBox.Text);
                                                FileWriter.WriteLine(ConfirmedTerm.ToString());
                                                FileWriter.WriteLine(ConfirmedTermTotal.ToString("N2"));
                                                FileWriter.Close();
                                                //closing File Writer

                                                if (SummaryButton.Enabled == false)
                                                {
                                                    SummaryButton.Enabled = true;
                                                }
                                                if (SearchButton.Enabled == false)
                                                {
                                                    SearchButton.Enabled = true;
                                                }

                                                //Confirmation Message
                                                DynamicMessage = "Hello, " + FullNameTextBox.Text + "!. Welcome Aboard. :) \n Your Membership ID is : " + MembershipIDLabel.Text;
                                                MessageBox.Show(DynamicMessage, "Membership Confirmed", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                MembershipDetailsGroupBox.Visible = false;
                                                //Clearing Fields
                                                TermTextBox.Text =
                                                    ClientConfirmedTextBox.Text               =
                                                        PricePerMonthLabel.Text               =
                                                            PriceFullTermLabel.Text           =
                                                                PriceNextTermLabel.Text       =
                                                                    FullNameTextBox.Text      =
                                                                        TelephoneTextBox.Text =
                                                                            EmailTextBox.Text = "";
                                                //Enabling Buttons
                                                SearchButton.Enabled        =
                                                    SummaryButton.Enabled   =
                                                        TermTextBox.Enabled =
                                                            ClientConfirmedTextBox.Enabled = true;
                                            }
                                            catch (Exception ex)
                                            {
                                                // Display an error message.
                                                MessageBox.Show(ex.Message);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #6
0
 private void EmailTextBox_GotFocus(object sender, RoutedEventArgs e)
 {
     EmailTextBox.SelectAll();
     ErrorEmailTextBlock.Visibility = Visibility.Collapsed;
     //SetTextBlockVisibilityCollapsed();
 }
        public bool ValidateEdition()
        {
            String errors      = "";
            String line        = "";
            bool   focusSetted = false;

            if (String.IsNullOrWhiteSpace(NameTextBox.Text) && String.IsNullOrWhiteSpace(FirstNameTextBox.Text))
            {
                errors += line + "Name and first name can't be empty.";
                line    = "\n";
                if (!focusSetted)
                {
                    if (String.IsNullOrWhiteSpace(NameTextBox.Text))
                    {
                        NameTextBox.Focus();
                        NameTextBox.SelectAll();
                    }
                    else
                    {
                        FirstNameTextBox.Focus();
                        FirstNameTextBox.SelectAll();
                    }
                    focusSetted = true;
                }
            }

            if (String.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                //errors += line + "Email can't be empty.";
                //line = "\n";
                //if (!focusSetted)
                //{
                //    EmailTextBox.Focus();
                //    EmailTextBox.SelectAll();
                //    focusSetted = true;
                //}
            }
            else if (!UserUtil.validateEmail(EmailTextBox.Text))
            {
                errors += line + "Wrong email format.";
                line    = "\n";
                if (!focusSetted)
                {
                    EmailTextBox.Focus();
                    EmailTextBox.SelectAll();
                    focusSetted = true;
                }
            }

            if (String.IsNullOrWhiteSpace(LoginTextBox.Text))
            {
                errors += line + "Login can't be empty.";
                line    = "\n";
                if (!focusSetted)
                {
                    LoginTextBox.Focus();
                    LoginTextBox.SelectAll();
                    focusSetted = true;
                }
            }

            if (String.IsNullOrWhiteSpace(PasswordTextBox.Password))
            {
                errors += line + "Password can't be empty.";
                line    = "\n";
                if (!focusSetted)
                {
                    PasswordTextBox.Focus();
                    PasswordTextBox.SelectAll();
                    focusSetted = true;
                }
            }
            else if (!Util.UserUtil.validatePassword(PasswordTextBox.Password, ConfirmPasswordTextBox.Password))
            {
                errors += line + "Password does not match.";
                line    = "\n";
                if (!focusSetted)
                {
                    ConfirmPasswordTextBox.Focus();
                    ConfirmPasswordTextBox.SelectAll();
                    focusSetted = true;
                }
            }
            bool isValid = String.IsNullOrWhiteSpace(errors);

            this.Console.Text       = errors;
            this.Console.Visibility = isValid ? Visibility.Collapsed : Visibility.Visible;
            return(isValid);
        }
Beispiel #8
0
 private void EndViewOnLoaded(object sender, RoutedEventArgs e)
 {
     EmailTextBox.Focus();
     EmailTextBox.SelectAll();
 }