protected override void OnNavigatedTo(NavigationEventArgs e)
        {

            try
            {
                base.OnNavigatedTo(e);
                parentId = (int)e.Parameter;

                objParentViewModel = new ParentViewModel();
                objRegister = new Register();

                objRegister = objParentViewModel.getParentDetails(parentId);

                lblParentID.Text = "" + objRegister.Id;
                txtEnterNewName.Text = "" + objRegister.Name;
                txtEnterNewSurname.Text = "" + objRegister.Surname;
                txtEnterNewEmail.Text = "" + objRegister.Email;
                txtEnterNewPhoneNo.Text = "" + objRegister.PhoneNo;
                txtEnterNewPassword.Text = "" + objRegister.Password;




                base.OnNavigatedTo(e);

            }
            catch (Exception)
            {

            }


        }
        private void btnResetPassword_Click(object sender, RoutedEventArgs e)
        {
            
            objParentViewModel = new ParentViewModel();
            newPassW = txtNewPassword.Text;
            confirmNewPassw = pbConfirmPassword.Password;
            int resultPassword = 0;

            
            if((!newPassW.Equals("")) && (!confirmNewPassw.Equals("")))
            {
                if(newPassW.Equals(confirmNewPassw))
                {
                    try
                    {
                        int ParentId = (int)objReg.Id;
                        resultPassword = objParentViewModel.updatePassword(ParentId, newPassW);

                        if (resultPassword > 0)
                        {
                            msg = "Password successfully updated!" +
                                  "\nPlease use the new password to login next time!";
                            messageBox(msg);
                            this.Frame.Navigate(typeof(MainPage));
                        }
                        else
                        {
                            msg = "Password updated was unsuccessful!" +
                                  "\nPlease start the reset password process again!";
                            messageBox(msg);
                            this.Frame.Navigate(typeof(MainPage));
                        }
                    }
                    catch(Exception)
                    {

                    }

                   

                }
                else
                {
                    msg = "Please ensure that the new password text field is identical to the confirmation password text field!";
                    messageBox(msg);
                }


            }
            else
            {
                msg = "Please ensure that all text fields are entered!";
                messageBox(msg);

            }



        }
Esempio n. 3
0
        //Display the ID of the parent currently logged in
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                base.OnNavigatedTo(e);
                getTheId = (int)e.Parameter;

                objRegister = new Register();
                objParentViewModel = new ParentViewModel();

                objRegister = objParentViewModel.getParentDetails(getTheId);


                lblParentIdenNum.Text = "" + objRegister.Name + " " +objRegister.Surname;
            }
            catch(Exception)
            {

            }
           

        }
 public ObservableCollection<ParentViewModel> GetParents()
 {
     parents = new ObservableCollection<ParentViewModel>();
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Query<Register>("select * from parents");
         foreach (var _register in query)
         {
             var register = new ParentViewModel()
             {
                 Id = _register.Id,
                 Name = _register.Name,
                 Surname = _register.Surname,
                 Email = _register.Email,
                 PhoneNo = _register.PhoneNo,
                 Password = _register.Password
                  
             };
             parents.Add(register);
         }
     }
     return parents;
 }
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            objParent = new ParentViewModel();

            String name, surname, email, phoneNumber, password;

            name = txtEnterName.Text;
            surname = txtEnterSurname.Text;
            email = txtEnterEmail.Text;
            phoneNumber = txtEnterPhoneNo.Text;
            password = txtEnterPassword.Text;
            bool isFoundAtSign = false;
            bool isFoundPeriod = false;
            bool itsANumber = false;
            char getChar = ' ';

           
            
                //Verify that user inputs are not empty first
                if ((!name.Equals("")) && (!surname.Equals("")) && (!email.Equals("")) && (!phoneNumber.Equals("")) && (!password.Equals("")))
                {
                    //Verify that the cell phone number is 10 characters long
                    int count = 0;
                    for (int z = 0; z < phoneNumber.Length; z++)
                    {
                        count = count + 1;
                    }
                    
                    //Insert the supplied user inputs into database here!
                    //Verify that the information was successfully inserted!
                    //user inputs were saved then redirect user to Login page!


                    //Check whether email address is correct
                    string findTheAtSign = "@";
                    string findThePeriod = ".";
                    for (int x = 0; x < email.Length; x++)
                    {
                        isFoundAtSign = email.Contains(findTheAtSign);
                        isFoundPeriod = email.Contains(findThePeriod);
                    }

                
                    if((isFoundAtSign == true) && (isFoundPeriod == true))
                    {
                        if(count == 10)
                        {

                            int verifyNum;
                            bool isNumerical = int.TryParse(phoneNumber, out verifyNum);

                            if(isNumerical == true)
                            {
                                objParent.SaveCustomer(name, surname, email, phoneNumber, password);
                                this.Frame.Navigate(typeof(MainPage));
                                messageToDisplay = "You have succesfully registered a new account..." +
                                                   "\nPlease use your new user credentials to login!";
                                messageBox(messageToDisplay);
                            }
                            else
                            {
                                messageToDisplay = "Please enter numeric characters only for the phone number! ";
                                messageBox(messageToDisplay);
                            }
                        }
                        else
                        {
                            messageToDisplay = "Phone number must be ten (10) characters long!" +
                                               "\nThe number you entered is: (" + count + ") characters long!";
                            messageBox(messageToDisplay);
                        }
                        
                    }
                    else
                    {
                        messageToDisplay = "Invalid email address entered!" +
                                           "\nPlease ensure that the email address contains these characters: (@) and (.)";
                        messageBox(messageToDisplay);
                    }
                   


                }
                else
                {
                    //Enter error message box here!
                    messageToDisplay = "Invalid user inputs..." + 
                        "\nPlease ensure that all text fields are filled in before proceeding!";
                    messageBox(messageToDisplay);
                }


            //this.Frame.Navigate(typeof(MenuPage));
        }
Esempio n. 6
0
        //This buttons controls the Login fuctionalities
        private void btnLogin1_Click(object sender, RoutedEventArgs e)
        {
            //Ojbjects for ParentViewModel and Register classes
            objParent = new ParentViewModel();
            objReg = new Register();
            objMenu = new MenuPage();

            //this.Frame.Navigate(typeof(MenuPage));
            string username = txtUsername.Text;
            string password = pwbEnterPassword.Password;

            //String ErrorMessage
            string messageToDisplay = "";
            
           

                    if ((!username.Equals("")) && (!password.Equals("")))
                    {
                        try
                        {
                            string findTheAtSign = "@";
                            string findThePeriod = ".";
                            bool isFoundAtSign = false;
                            bool isFoundPeriod = false;
                            for (int x = 0; x < username.Length; x++)
                            {
                                isFoundAtSign = username.Contains(findTheAtSign);
                                isFoundPeriod = username.Contains(findThePeriod);
                                
                            }

                            if((isFoundAtSign == true) && (isFoundPeriod == true))
                            {
                                 //Get all parent details matching user supplied information
                                var confirm = objParent.getParent(username, password);
                                if(confirm != null)
                                {

                                    this.Frame.Navigate(typeof(MenuPage), confirm.Id);
                                    int iden = Convert.ToInt32(confirm.Id);//confirm.Id;
                                    objMenu.getID(iden);

                                    messageToDisplay = "Welcome " + confirm.Name + " " + confirm.Surname +
                                                       "\nYour user ID is: " + confirm.Id;
                                    messageBox(messageToDisplay);

                                
                                
                                }
                                 else
                                {
                                    messageToDisplay = "Invalid user details entered!" +
                                                       "\nPlease ensure that the username and password entered are correct...";
                                    messageBox(messageToDisplay);
                                }

                            }
                            else
                            {
                                messageToDisplay = "Invalid email address entered!";
                                messageBox(messageToDisplay);
                            }
                                

                            
                            
                        }
                        catch(Exception ex)
                        {
                            string ErrorMessage = "Error: " + ex.Message;
                            messageBox(ErrorMessage);
                        }
                        
                    }
                    else
                    {
                        //Enter error message box here!
                        string ErrorMessage = "Please ensure that all text fields are entered!";
                        messageBox(ErrorMessage);
                        //this.Frame.Navigate(typeof(MainPage));
                        
                    }
                
           
            
            //Verify that user inputs are not empty first
        
        }
        private void btnVerifyUserDetails_Click(object sender, RoutedEventArgs e)
        {
            bool isFoundAtSign = false;
            bool isFoundPeriod = false;

            objReg = new Register();
            objParentViewModel = new ParentViewModel();
            
            getEmail = txtConfirmEmail.Text;
            getPhoneNum = txtConfirmPhoneNo.Text;

            
            if((!getEmail.Equals("")) && (!getPhoneNum.Equals("")))
            {

                //Check whether email address is correct
                string findTheAtSign = "@";
                string findThePeriod = ".";
                for (int x = 0; x < getEmail.Length; x++)
                {
                    isFoundAtSign = getEmail.Contains(findTheAtSign);
                    isFoundPeriod = getEmail.Contains(findThePeriod);
                }

                //check the phone number for validity
                int count = 0;
                for (int z = 0; z < getPhoneNum.Length; z++)
                {
                    count = count + 1;
                }

                int verifyNum;
                bool isNumerical = int.TryParse(getPhoneNum, out verifyNum);

                if ((isFoundAtSign == true) && (isFoundPeriod == true))
                {
                    if (count == 10)
                   {
                        if(isNumerical == true)
                        {
                            try
                            {
                                objReg = objParentViewModel.checkUserExistence(getEmail, getPhoneNum);
                            }
                            catch (Exception)
                            {

                            }

                            if (objReg != null)
                            {
                                this.Frame.Navigate(typeof(ResetPasswordPage), objReg);
                                msg = "User account details found in the database!" +
                                      "\nProceed to reset your password.";
                                messageBox(msg);
                            }
                            else
                            {
                                this.Frame.Navigate(typeof(VerifyUserPage));
                                msg = "Information entered did not match anything in the database!" +
                                      "\nEnsure that the information is correct!";
                                messageBox(msg);
                            }
                        }
                        else
                        {
                            msg = "Please enter numeric characters only for the phone number!";
                            messageBox(msg);
                        }
                   }
                   else
                   {
                       msg = "Phone number must be ten (10) characters long!" +
                             "\nThe number you entered is: (" + count + ") characters long!";
                       messageBox(msg);
                   }
                }
                else
                {
                    msg = "Invalid email address entered!" +
                          "\nPlease ensure that the email address contains these characters: (@) and (.)";
                    messageBox(msg);
                }




                

            }
            else
            {
                msg = "Please ensure that all text fields are filled in before proceeding!";
                messageBox(msg);
            }

        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string getId = lblParentID.Text;
            int convID = Convert.ToInt32(getId);
            string updateName = txtEnterNewName.Text;
            string updateSurname = txtEnterNewSurname.Text;
            string updateEmail = txtEnterNewEmail.Text;
            string updatePhone = txtEnterNewPhoneNo.Text;
            string updatePassword = txtEnterNewPassword.Text;

            bool isFoundAtSign = false;
            bool isFoundPeriod = false;


            if ((!updateName.Equals("")) && (!updateSurname.Equals("")) && (!updateEmail.Equals("")) && (!updatePhone.Equals("")) && (!updatePassword.Equals("")))
            {
                objRegister = new Register();
                int updateResult = 0;
                objParentViewModel = new ParentViewModel();

                //Check whether email address is correct
                string findTheAtSign = "@";
                string findThePeriod = ".";
                for (int x = 0; x < updateEmail.Length; x++)
                {
                    isFoundAtSign = updateEmail.Contains(findTheAtSign);
                    isFoundPeriod = updateEmail.Contains(findThePeriod);
                }

                //check the phone number for validity
                int count = 0;
                for (int z = 0; z < updatePhone.Length; z++)
                {
                    count = count + 1;
                }

                int verifyNum;
                bool isNumerical = int.TryParse(updatePhone, out verifyNum);

                if ((isFoundAtSign == true) && (isFoundPeriod == true))
                {
                    if (count == 10)
                    {
                        if (isNumerical == true)
                        {
                            try
                            {
                                updateResult = objParentViewModel.updateParentDetails(convID, updateName, updateSurname, updateEmail, updatePhone, updatePassword);
                            }
                            catch (Exception)
                            {

                            }

                            if (updateResult > 0)
                            {
                                this.Frame.Navigate(typeof(MenuPage), parentId);
                                msg = "Update was successful!";
                                messageBox(msg);
                            }
                            else
                            {
                                msg = "Update was unsuccessful!";
                                messageBox(msg);
                            }
                        }
                        else
                        {
                            msg = "Please enter numeric characters only for the phone number! ";
                            messageBox(msg);
                        }
                    }
                    else
                    {
                        msg = "Phone number must be ten (10) characters long!" +
                              "\nThe number you entered is: (" + count + ") characters long!";
                        messageBox(msg);
                    }
                }
                else
                {
                    msg = "Invalid email address entered!" +
                          "\nPlease ensure that the email address contains these characters: (@) and (.)";
                    messageBox(msg);
                }

            }
            else
            {
                msg = "Please ensure that all text fields are filled in!";
                messageBox(msg);
            }
        }