Пример #1
0
 private void BtnLogin_Click(object sender, RoutedEventArgs e)
 {
     if (txtUserName.Text == "username")
     {
         if (txtPassword.Password == "password")
         {
             Slot_Machine slot_Machine = new Slot_Machine();
             slot_Machine.different = txtUserName.Text;
             slot_Machine.Show();
             Close();
         }
         else
         {
             MessageBox.Show("Enter a valid password.");
             txtPassword.Clear();
         }
     }
     else
     {
         MessageBox.Show("Enter a valid username.");
         txtUserName.Clear();
     }
 }
Пример #2
0
        private void BtnUpdateBanking_Click(object sender, RoutedEventArgs e)
        {
            BankingCustomer bankingCustomer = new BankingCustomer();

            if (comboCardType.SelectedItem.ToString() == "Master Card")
            {
                bankingCustomer.CardType = comboCardType.SelectedItem.ToString();
                if (txtCardName.Text != "" && int.TryParse(txtCardName.Text, out int cardNameResult) == false)
                {
                    bankingCustomer.CustomerName = txtCardName.Text;
                    if (txtCardNumber.Text.Length == 16 && long.TryParse(txtCardNumber.Text, out long cardNumberResult) && txtCardNumber.Text.ToString().StartsWith("5"))
                    {
                        bankingCustomer.CardNumber = Convert.ToInt64(txtCardNumber.Text);
                        if (txtSecurityCode.Text.ToString().Length == 3 && int.TryParse(txtSecurityCode.Text, out int securityCodeResult))
                        {
                            bankingCustomer.SecurityCode = Convert.ToInt32(txtSecurityCode.Text);
                            NewUser newUser = new NewUser();
                            newUser.Show();
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid security code.");
                            txtSecurityCode.Clear();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a valid card number.");
                        txtCardNumber.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a valid cardholder name.");
                    txtCardName.Clear();
                }
            }
            else if (comboCardType.SelectedItem.ToString() == "American Express")
            {
                bankingCustomer.CardType = comboCardType.SelectedItem.ToString();
                if (txtCardName.Text != "" && int.TryParse(txtCardName.Text, out int cardNameResult) == false)
                {
                    bankingCustomer.CustomerName = txtCardName.Text;
                    if (txtCardNumber.Text.Length == 15 && long.TryParse(txtCardNumber.Text, out long cardNumberResult) && txtCardNumber.Text.ToString().StartsWith("3"))
                    {
                        bankingCustomer.CardNumber = Convert.ToInt64(txtCardNumber.Text);
                        if (txtSecurityCode.Text.ToString().Length == 4 && int.TryParse(txtSecurityCode.Text, out int securityCodeResult))
                        {
                            bankingCustomer.SecurityCode = Convert.ToInt32(txtSecurityCode.Text);
                            Slot_Machine slot_Machine = new Slot_Machine();
                            slot_Machine.Show();
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid security code.");
                            txtSecurityCode.Clear();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a valid card number.");
                        txtCardNumber.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a valid cardholder name.");
                    txtCardName.Clear();
                }
            }
            else if (comboCardType.SelectedItem.ToString() == "Visa")
            {
                bankingCustomer.CardType = comboCardType.SelectedItem.ToString();
                if (txtCardName.Text != "" && int.TryParse(txtCardName.Text, out int cardNameResult) == false)
                {
                    bankingCustomer.CustomerName = txtCardName.Text;
                    if (txtCardNumber.Text.Length == 16 && long.TryParse(txtCardNumber.Text, out long cardNumberResult) && txtCardNumber.Text.ToString().StartsWith("4"))
                    {
                        bankingCustomer.CardNumber = Convert.ToInt64(txtCardNumber.Text);
                        if (txtSecurityCode.Text.ToString().Length == 3 && int.TryParse(txtSecurityCode.Text, out int securityCodeResult))
                        {
                            bankingCustomer.SecurityCode = Convert.ToInt32(txtSecurityCode.Text);
                            Slot_Machine slot_Machine = new Slot_Machine();
                            slot_Machine.Show();
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid security code.");
                            txtSecurityCode.Clear();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a valid card number.");
                        txtCardNumber.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a valid cardholder name.");
                    txtCardName.Clear();
                }
            }
            else
            {
                MessageBox.Show("Please select a card type.");
            }
        }
Пример #3
0
        private void BtnCreateAccount_Click(object sender, RoutedEventArgs e)
        {
            NewCustomer newCustomer = new NewCustomer();

            if (txtFirstName.Text != "" && int.TryParse(txtFirstName.Text, out int firstNameResult) == false)
            {
                newCustomer.FirstName = txtFirstName.Text;
                if (txtLastName.Text != "" && int.TryParse(txtLastName.Text, out int lastNameResult) == false)
                {
                    newCustomer.LastName = txtLastName.Text;
                    if (int.TryParse(txtAge.Text, out int ageNumberResult))
                    {
                        newCustomer.Age = Convert.ToInt32(txtAge.Text);
                        if (lstGender.SelectedItem != null)
                        {
                            newCustomer.Gender = lstGender.SelectedItem.ToString();
                            if (txtEmail.Text != "")
                            {
                                newCustomer.EmailAddress = txtEmail.Text;
                                if (txtUsername.Text != "")
                                {
                                    newCustomer.Username = txtUsername.Text;
                                    if (txtPassword.Text != "")
                                    {
                                        newCustomer.Password = txtPassword.Text;
                                        Slot_Machine slot_Machine = new Slot_Machine();
                                        slot_Machine.different = txtUsername.Text;
                                        slot_Machine.Show();
                                        Close();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Please enter a valid password.");
                                        txtPassword.Clear();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Please enter a valid username.");
                                    txtUsername.Clear();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Please enter an email address.");
                                txtEmail.Clear();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please select a gender.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Enter a valid age.");
                        txtAge.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Enter a valid last name.");
                    txtLastName.Clear();
                }
            }
            else
            {
                MessageBox.Show("Enter a valid first name.");
                txtFirstName.Clear();
            }
        }