Example #1
0
        private bool CheckUsernamePassword()
        {
            ObservableCollection <Account> AccountListTemp1 = new ObservableCollection <Account>();
            ObservableCollection <Account> AccountListTemp2 = new ObservableCollection <Account>();

            if (ValidateAllEntries())
            {
                AccountListTemp1 = PostgreSQL.searchByUsername(UsernameEntry.Text);

                if (AccountListTemp1 == null)
                {
                    Verify.Visibility = Visibility.Visible;
                    return(false);
                }
                else
                {
                    AccountListTemp2 = PostgreSQL.validateUsernamePassword(UsernameEntry.Text, PasswordEntry.Password);
                    if (AccountListTemp2.Count == 0)
                    {
                        Verify.Visibility = Visibility.Visible;
                        return(false);
                    }
                    else
                    {
                        AccountToLogin    = AccountListTemp2.FirstOrDefault(a => a.Username == UsernameEntry.Text);
                        Verify.Visibility = Visibility.Hidden;
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #2
0
        private void Submit(object sender, RoutedEventArgs e)
        {
            ObservableCollection <Account> acct = PostgreSQL.searchByUsername(UsernameEntry.Text);

            if (acct.Count != 0)
            {
                MessageBox.Show("Username already exists. Please choose another username!");
            }
            if (ValidateEntries() && acct.Count == 0)
            {
                Account Account = new Account();

                Account.FirstName         = FirstNameEntry.Text;
                Account.LastName          = LastNameEntry.Text;
                Account.Telephone         = PhoneEntry.Text;
                Account.Username          = UsernameEntry.Text;
                Account.Password          = PasswordEntry.Password;
                Account.CartItems         = "0";
                Account.CartTotal         = "0";
                Account.CartContent       = new ObservableCollection <Animal>();
                Account.PreviousPurchases = new ObservableCollection <Animal>();


                if (Shopper.IsChecked == true)
                {
                    Account.Type = Shopper.Content.ToString();
                    PostgreSQL.addAccount(Account);
                    ZipCodePanel.Visibility = Visibility.Hidden;
                    openLogin(Account);
                }
                else if (Seller.IsChecked == true)
                {
                    Account.Type = Seller.Content.ToString();
                    PostgreSQL.addAccount(Account);
                    openLogin(Account);
                }
            }
        }