Ejemplo n.º 1
0
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            usernameValue.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            Password = passwordValue.Password;

            // Check if the username & password that entered are correct (found in our DB).
            if (!LoginOK)
            {
                // Displays an error indication to the user.
                errorText.Visibility     = Visibility.Visible;
                usernameValue.Text       = "wrong";
                usernameValue.Foreground = Brushes.LightGray;
                errorUsername.Visibility = Visibility.Visible;
                errorPassword.Visibility = Visibility.Visible;
                cleanUser     = true;
                cleanPassword = true;
                removeError1  = false;
                removeError2  = false;
            }
            else
            {
                // User exists => login successful.
                // Show user's restaurant view.
                RestaurantOwnerWindow rest = new RestaurantOwnerWindow(usernameValue.Text);
                rest.Show();
                this.Close();
            }
        }
Ejemplo n.º 2
0
        private void Go_Back_Click(object sender, RoutedEventArgs e)
        {
            // Go Back - show the Restaurant Owner Window view. (without add new rest)
            IsAddRest = false;
            RestaurantOwnerWindow row = new RestaurantOwnerWindow(owner);

            row.Show();
            this.Close();
        }
Ejemplo n.º 3
0
        private void Insert_Click(object sender, RoutedEventArgs e)
        {
            // Update name & url filed to be the inserted name & url.
            url  = newurltAdd.Text;
            name = newrestName.Text;

            // Update visbility.
            if (!name.Equals(""))
            {
                errorName.Visibility = Visibility.Collapsed;
            }

            // Checks if all mandatory details have been entered.
            if (name.Equals("") || city.Equals("") || country.Equals(""))
            {
                string errorMessage = " You must enter ";
                if (name.Equals(""))
                {
                    errorName.Visibility = Visibility.Visible;
                    errorMessage        += "name, ";
                }
                if (city.Equals(""))
                {
                    errorCity.Visibility = Visibility.Visible;
                    errorMessage        += "city, ";
                }
                if (country.Equals(""))
                {
                    errorCountry.Visibility = Visibility.Visible;
                    errorMessage           += "country, ";
                }
                errorText.Visibility = Visibility.Visible;
                errorText.Text       = errorMessage;
            }
            else
            {
                // All mandatory details have been entered.
                // Create new Restaurant object and add it to the rest list.
                Restaurant newRest = new Restaurant("", name, country, city, styles, 0, price, 0, new List <UserReview>(), url, owner);
                myRest.Add(newRest);

                // Insert to DB the new rest.
                MyRestaurants = myRest;

                // Show the Restaurant Owner Window view. (with the new rest)
                RestaurantOwnerWindow row = new RestaurantOwnerWindow(owner);
                row.Show();
                this.Close();
            }
        }
Ejemplo n.º 4
0
 private void Go_Back_Click(object sender, RoutedEventArgs e)
 {
     if (WhoIsIt)
     {
         // Client
         // Back button - Client view.
         Search search = new Search(true);
         search.Show();
         this.Close();
     }
     else
     {
         // Owner
         // Back button - Restaurant Owner window view.
         RestaurantOwnerWindow restOwner = new RestaurantOwnerWindow(RestDetails.Owner);
         restOwner.Show();
         this.Close();
     }
 }
Ejemplo n.º 5
0
        public Rest(RestaurantOwnerWindow rest, string idRest)
        {
            // Constructor.
            IModel model = (DataBaseModel)Application.Current.Properties["model"];

            DataContext = new ViewModelRestaurantOwner(model);

            var VMMyRests      = "VM_RestsResults";
            var bindingMyRests = new Binding(VMMyRests)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(MyRestaurantsProperty, bindingMyRests);

            var VMRestID      = "VM_RestID";
            var bindingRestID = new Binding(VMRestID)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(RestIDProperty, bindingRestID);

            var VMIDToRemove      = "VM_IDToRemove";
            var bindingIDToRemove = new Binding(VMIDToRemove)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(IDToRemoveProperty, bindingIDToRemove);

            InitializeComponent();

            // Initialize the fileds.
            restID = idRest;
            restow = rest;
        }
Ejemplo n.º 6
0
        private void Sign_up_Click(object sender, RoutedEventArgs e)
        {
            string username        = usernameValue.Text;
            string password        = passwordValue.Password;
            string passwordConfirm = passwordConfirmValue.Password;

            // Checks if the password for the confirmation password is the same.
            if (!password.Equals(passwordConfirm))
            {
                // Displays an error indication to the user.
                errorText.Visibility     = Visibility.Visible;
                errorText.Text           = " The passwords are not the same.\n Try again!";
                errorPassword.Visibility = Visibility.Visible;
                errorConfirm.Visibility  = Visibility.Visible;
                cleanUser     = false;
                cleanConfirm  = true;
                cleanPassword = true;
            }
            else
            {
                // The passwords are the same.
                // Insert the new restaurant owner to the DB.
                usernameValue.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                NewPassword = passwordConfirm;
                // Checks if the username is available.
                if (!UsernameFree)
                {
                    // Displays an error indication to the user.
                    errorText.Visibility     = Visibility.Visible;
                    errorText.Text           = " Username is already taken.\n Try differnet username!";
                    usernameValue.Text       = "wrong";
                    usernameValue.Foreground = Brushes.LightGray;
                    errorUsername.Visibility = Visibility.Visible;
                    cleanUser     = true;
                    cleanPassword = false;
                    cleanConfirm  = false;
                }
                else
                {
                    // Username free (not exsits in DB) => sing up successful.
                    // Checks if the input is incorrect.
                    if (password.Equals("") || username.Equals("wrong") || username.Equals(""))
                    {
                        // Displays an error indication to the user.
                        errorText.Visibility     = Visibility.Visible;
                        errorText.Text           = " The password or username are\n not valid. Try again!";
                        usernameValue.Text       = "wrong";
                        usernameValue.Foreground = Brushes.LightGray;
                        errorUsername.Visibility = Visibility.Visible;
                        errorPassword.Visibility = Visibility.Visible;
                        errorConfirm.Visibility  = Visibility.Visible;
                        cleanUser     = true;
                        cleanPassword = true;
                        cleanConfirm  = true;
                    }
                    else
                    {
                        // All input is correct for a new user.
                        // Show user's restaurant view.
                        RestaurantOwnerWindow rest = new RestaurantOwnerWindow(username);
                        rest.Show();
                        this.Close();
                    }
                }
            }
        }