Ejemplo n.º 1
0
        //Next Button
        //for Input validation and saving new user info
        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            FreeCustomer    cs  = new FreeCustomer(username);
            PremiumCustomer pcs = new PremiumCustomer();

            pcs.FirstName          = cs.FirstName = av.validateFirstNameInput(txtBlockFNameError, txtBoxFName);
            pcs.LastName           = cs.LastName = av.validateLastNameInput(txtBlockLNameError, txtBoxLName);
            pcs.Phone              = cs.Phone = av.validatePhoneNoInput(txtBlockPhoneError, txtBoxPhone);
            pcs.DOB                = cs.DOB = av.validateDOBInput(txtBlockDOBError, txtBoxDOBDay, txtBoxDOBMonth, txtBoxDOBYear);
            pcs.Country            = cs.Country = av.validateCountryInput(selectionValueCountry, txtBlockCountryError);
            pcs.TownOrCity         = cs.TownOrCity = av.validateTownOrCityInput(txtBlockCityError, txtBoxCity);
            pcs.Nationality        = cs.Nationality = av.validateNationalityInput(selectionValueNationality, txtBlockNationalityError);
            pcs.CustAddress        = cs.CustAddress = av.validateAddressInput(txtBlockAddressError, txtBoxAddress);
            pcs.PostalCd           = cs.PostalCd = av.validatePostalCdInput(txtBlockPostalCdError1, txtBlockPostalCdError2, txtBoxPostalCd);
            pcs.CustPassword       = cs.CustPassword = av.validatePasswordInput(txtBlockPWError1, txtBlockPWError2, txtBlockPWError3, txtBlockConfirmPWError, txtBoxPW, txtBoxConfirmPW);
            pcs.CardType           = cs.CardType = av.validateCardTypeInput(selectionValueCardType, txtBlockCardTypeError);
            pcs.CardNo             = cs.CardNo = av.validateCardNoInput(txtBlockCardNoError1, txtBlockCardNoError2, txtBoxCardNo);
            pcs.CardExpirationDate = cs.CardExpirationDate = av.validateExpirationDateInput(txtBlockExpDateError, txtBoxExpMonth, txtBoxExpYear);
            pcs.CardHolderName     = cs.CardHolderName = av.validateCardHolderNameInput(txtBlockCardHolderNameError, txtBoxCardHolderName);
            pcs.CCV                = cs.CCV = av.validateCCVInput(txtBlockCCVError, txtBoxCCV);
            pcs.Email              = cs.Email = validateEmailInput();
            pcs.Username           = cs.Username = username;
            pcs.Subsidy            = subsidy;
            cs.ExpiryDate          = expDate;

            if (cbMembership.IsChecked == true)
            {
                pcs.Membership = "Premium";
                cs.Membership  = "";
            }
            else
            {
                pcs.Membership = "";
                cs.Membership  = "Free";
            }

            if (cs.FirstName != null && cs.LastName != null && cs.Email != "" && cs.Phone != null && cs.DOB != null && cs.Country != null && cs.TownOrCity != null && cs.Nationality != null && cs.CustAddress != null && cs.PostalCd != null && cs.CustPassword != null && cs.CardType != null && cs.CardNo != null && cs.CardExpirationDate != null && cs.CardHolderName != null && cs.CCV != null)
            {
                dbBooking db = new dbBooking();
                if (pcs.Membership == "Premium")
                {
                    pcs.Subsidy = 0.9;
                    if (cs.getCustomerDetail(username, 17) == "Free")
                    {
                        MessageBox.Show("You have signed up for premium membership! $20 has been charged to your card.");
                    }
                    pcs.updatePremiumCustDB(pcs.FirstName, pcs.LastName, pcs.Email, pcs.Phone, pcs.DOB, pcs.Country, pcs.TownOrCity, pcs.Nationality, pcs.CustAddress, pcs.PostalCd, pcs.Username, pcs.CustPassword, pcs.CardType, pcs.CardNo, pcs.CardExpirationDate, pcs.CardHolderName, pcs.CCV, pcs.Membership, pcs.Subsidy);
                }
                else if (cs.Membership == "Free")
                {
                    cs.updateFreeCustDB(cs.FirstName, cs.LastName, cs.Email, cs.Phone, cs.DOB, cs.Country, cs.TownOrCity, cs.Nationality, cs.CustAddress, cs.PostalCd, cs.Username, cs.CustPassword, cs.CardType, cs.CardNo, cs.CardExpirationDate, cs.CardHolderName, cs.CCV, cs.Membership, cs.ExpiryDate);
                }


                this.NavigationService.Navigate(new SettingsPage(username, windowColor));
            }
        }
Ejemplo n.º 2
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //Display current user's info in controls for user to edit
            Customer        c     = new Customer();
            Customer        cust  = (Customer)c.getCustomerRow(username);
            FreeCustomer    fc    = new FreeCustomer();
            FreeCustomer    fcust = (FreeCustomer)fc.getCustomerRow(username);
            PremiumCustomer pc    = new PremiumCustomer();
            PremiumCustomer pcust = (PremiumCustomer)pc.getCustomerRow(username);

            if (cust.Membership == "Premium")
            {
                cbMembership.IsChecked          = true;
                PremiumErrorTxtBlock.Visibility = MembershipErrorTxtBlock.Visibility = Visibility.Hidden;
                cbBoxTheme.IsHitTestVisible     = true;
                subsidy = pcust.Subsidy;
            }
            else if (cust.Membership == "Free")
            {
                cbMembership.IsChecked          = false;
                PremiumErrorTxtBlock.Visibility = MembershipErrorTxtBlock.Visibility = Visibility.Visible;
                cbBoxTheme.IsHitTestVisible     = false;
                expDate = fcust.ExpiryDate;
            }

            txtBoxFName.Text = cust.FirstName;
            txtBoxLName.Text = cust.LastName;
            txtBoxPhone.Text = cust.Phone;
            string birth = Convert.ToDateTime(cust.DOB).ToShortDateString();

            string[] DOBParts = birth.Split('/');
            txtBoxDOBDay.Text                 = DOBParts[0];
            txtBoxDOBMonth.Text               = DOBParts[1];
            txtBoxDOBYear.Text                = DOBParts[2];
            txtBoxCity.Text                   = cust.TownOrCity;
            comboBoxCountry.SelectedValue     = cust.Country;
            comboBoxNationality.SelectedValue = cust.Nationality;
            txtBoxAddress.Text                = cust.CustAddress;
            txtBoxPostalCd.Text               = cust.PostalCd;
            txtBoxPW.Password                 = txtBoxConfirmPW.Password = cust.CustPassword;
            comboBoxCardType.Text             = cust.CardType;
            txtBoxCardNo.Text                 = cust.CardNo;
            string[] Parts = cust.CardExpirationDate.Split('/');
            txtBoxExpMonth.Text       = Parts[0];
            txtBoxExpYear.Text        = Parts[1];
            txtBoxCardHolderName.Text = cust.CardHolderName;
            txtBoxCCV.Text            = cust.CCV;
            txtBoxEmail.Text          = cust.Email;
            email = cust.Email;
            txtBoxExpMonth.Foreground = txtBoxExpYear.Foreground = txtBoxPhone.Foreground = txtBoxDOBDay.Foreground = txtBoxDOBMonth.Foreground = txtBoxDOBYear.Foreground = Brushes.Black;
        }
        public void CanCreatePemiumCustomer()
        {
            bool crashed = false;

            try
            {
                PremiumCustomer test = new PremiumCustomer("Bob", "333224444");
            }
            catch
            {
                crashed = true;
            }
            Assert.IsFalse(crashed);
        }
Ejemplo n.º 4
0
        // BINDS UI TO OBSERVABLE COLLECTION OF CART OBJECTS - TO DISPLAY CART
        private void refreshCartItems()
        {
            Customer customer = new Customer();

            customer = (Customer)customer.getCustomerRow(username);
            FreeCustomer    fcust = new FreeCustomer(username);
            PremiumCustomer pcust = new PremiumCustomer(username);
            Cart            ct    = new Cart(username);

            ListBoxCartItems.ItemsSource = ct.getCartItems();

            if (ct.getCartItems().Count == 0) //shows/hides 'none selected' text block ui
            {
                txtBlockNone.Visibility = Visibility.Visible;
            }
            else
            {
                txtBlockNone.Visibility = Visibility.Collapsed;
            }



            if (customer.Membership == "Free")
            {
                fcust.populateCustomerDetails();
                txtBlockSubsidy.Text = "None";
                finalprice           = ct.calculateTotal();
            }
            else if (customer.Membership == "Premium")
            {
                pcust.populateCustomerDetails();
                txtBlockSubsidy.Text = "10%";
                finalprice           = ct.calculateTotal();
            }

            finalprice = ct.calculateTotal();
            txtBlockTotalCost.DataContext = new Booking {
                TotalCost = finalprice
            };
        }
Ejemplo n.º 5
0
        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            if (chkBox1.IsChecked == false)
            {
                MessageBox.Show("Please read and agree to the terms and conditions, and check the checkbox to proceed.");
            }
            else if (chkBox1.IsChecked == true)
            {
                if (rbYes.IsChecked == true)
                {
                    cs.Membership = "Premium";

                    PremiumCustomer pcs = new PremiumCustomer(cs.FirstName, cs.LastName, cs.Email, cs.Phone, cs.DOB, cs.Country, cs.TownOrCity, cs.Nationality, cs.CustAddress, cs.PostalCd, cs.Username, cs.CustPassword, cs.CardType, cs.CardNo, cs.CardExpirationDate, cs.CardHolderName, cs.CCV, cs.Membership, 0.9);

                    pcs.addNewCustomer();
                }
                else if (rbNo.IsChecked == true)
                {
                    cs.Membership = "Free";
                    DateTime expDate = (DateTime.Now).AddDays(30);
                    MessageBox.Show("Please note that your account will be automatically deleted at " + expDate.ToShortDateString(), "Note", MessageBoxButton.OK, MessageBoxImage.Information);
                    FreeCustomer fcs = new FreeCustomer(cs.FirstName, cs.LastName, cs.Email, cs.Phone, cs.DOB, cs.Country, cs.TownOrCity, cs.Nationality, cs.CustAddress, cs.PostalCd, cs.Username, cs.CustPassword, cs.CardType, cs.CardNo, cs.CardExpirationDate, cs.CardHolderName, cs.CCV, cs.Membership, expDate.ToShortDateString());

                    fcs.addNewCustomer();
                }

                MessageBox.Show("Welcome, " + cs.FirstName + " " + cs.LastName + "!", "Welcome"); //show msg box to welcome firstname, like: "Welcome, John!"
                var newWindow = new MainWindow(cs.Username, BorderColor);                         //create new window (Open all-tour page)
                newWindow.Top          = Window.GetWindow(this).Top;
                newWindow.Left         = Window.GetWindow(this).Left;
                newWindow.Main.Content = new BrowseToursPage(cs.Username, BorderColor);
                newWindow.Show();                                   //Show the new window

                var currentWindow = Application.Current.Windows[0]; //Set current window to variable
                currentWindow.Close();                              //Close the current window
            }
        }
 public void ValidateCPR_TenDigitCPR_ThrowArgumentException()
 {
     PremiumCustomer test = new PremiumCustomer("name", "1");
 }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome ABC Ecomm Store!!\nWe have following products in store.\n");

            Thread.Sleep(2000);

            var allProducts = ECommData.GetAllProducts();

            ECommData.DisplayProductsInStore(allProducts);

            /*
             *
             * WebCustomer webCustomer = new WebCustomer();
             *
             * //Must Login First
             * webCustomer.LogIn();
             * ContinueShopping:
             * System.Threading.Thread.Sleep(2000);
             * Console.WriteLine("Enter Product Name and Quantity to Add to Your Cart");
             * var itemName = Console.ReadLine();
             * var quantity = Console.ReadLine();
             * var product = allProducts.FirstOrDefault(x => x.ProductName.ToUpper() == itemName.ToUpper());
             * if (product != null)
             *  webCustomer.AddProductInCart(product, int.Parse(quantity));
             *
             * Console.WriteLine("Still shopping? Y/N");
             *
             * var response = Console.ReadLine();
             *
             * if (response.ToUpper() == "Y")
             *  goto ContinueShopping;
             *
             * webCustomer.CalculateTotal();
             *
             */


            //If Customer is Premium customer, should I repeat above code again??
            //NO

            //ToDo: Use below code

            Console.WriteLine("");
            Console.WriteLine("Enter 'P' for premium customer or enter any other key for web customer");
            var customerType = Console.ReadLine();

            BaseCustomer customer;

            if (customerType.ToUpper() == "P")
            {
                customer       = new PremiumCustomer();
                customer.Name  = "John Smith";
                customer.Email = "*****@*****.**";
                customer.Id    = 1015;
            }
            else
            {
                customer       = new WebCustomer();
                customer.Name  = "John Smith";
                customer.Email = "*****@*****.**";
                customer.Id    = 1015;
            }


            //Must Login First
            customer.LogIn();
ContinueShopping:
            System.Threading.Thread.Sleep(2000);
            Console.WriteLine("Enter Product Name and Quantity to Add to Your Cart");
            var itemName = Console.ReadLine();
            var quantity = Console.ReadLine();
            var product  = allProducts.FirstOrDefault(x => x.ProductName.ToUpper() == itemName.ToUpper());

            if (product != null)
            {
                customer.AddProductInCart(product, int.Parse(quantity));
            }

            Console.WriteLine("Still shopping? Y/N");

            var response = Console.ReadLine();

            if (response.ToUpper() == "Y")
            {
                goto ContinueShopping;
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\nItems in your cart\n");
            Console.ForegroundColor = ConsoleColor.White;
            customer.ViewAllCartProducts();
            Console.WriteLine("");
            decimal totalToPay = customer.CalculateTotal();

            Console.WriteLine($"You need to pay {totalToPay}");

            customer.MakePayment(totalToPay);

            Thread.Sleep(1500);
            Console.WriteLine("Cheking customer's rewards.\n");

            Thread.Sleep(1500);
            if (customerType.ToUpper() == "P")
            {
                int rewardPoints = (customer as IRewardSystem).GetTheRewardPoints();
                Console.WriteLine($"You have total {rewardPoints} so far.\n\n");
            }
            else
            {
                Console.WriteLine("Web customer is not eligible for reward system");
            }
        }