Beispiel #1
0
        private void LoadVariablesTB()
        {
            Classes.Validation valid = new Classes.Validation();
            if (valid.TextIsShorterThan(TB_Streetname.Text, 32) && valid.TextIsShorterThan(TB_Description.Text, 300) && valid.IsTextNumeric(TB_Streetno.Text) && valid.IsTextNumeric(TB_Bedrooms.Text) && valid.IsTextNumeric(TB_Bathrooms.Text) && valid.IsTextNumeric(TB_Garages.Text) && valid.IsTextNumeric(TB_PlotSize.Text) && valid.IsTextNumeric(TB_HouseSize.Text) && valid.IsTextNumeric(TB_ListPrice.Text) && valid.IsTextNumeric(TB_Price.Text) && valid.IsTextNumeric(TB_ComplexNo.Text))
            {
                streetName    = TB_Streetname.Text;
                streetNo      = Convert.ToInt32(TB_Streetno.Text);
                bedrooms      = Convert.ToInt32(TB_Bedrooms.Text);
                bathrooms     = Convert.ToInt32(TB_Bathrooms.Text);
                garages       = Convert.ToInt32(TB_Garages.Text);
                plotSize      = Convert.ToInt32(TB_PlotSize.Text);
                houseSize     = Convert.ToInt32(TB_HouseSize.Text);
                propertyPrice = Convert.ToInt32(TB_ListPrice.Text);
                propertyValue = Convert.ToInt32(TB_Price.Text);
                isSold        = Convert.ToInt32(CB_isSold.IsChecked);
                isNegotiable  = Convert.ToInt32(CB_isNegotiable.IsChecked);
                hasPool       = Convert.ToInt32(CB_hasPool.IsChecked);
                description   = TB_Description.Text;

                complexName = "Null";
                complexNo   = 0;

                if (CB_Complex.IsChecked == true)
                {
                    complexName = TB_ComplexName.Text;
                    complexNo   = Convert.ToInt32(TB_ComplexNo.Text);
                }
            }
            else
            {
                DisplayNotifyBox("ERROR", "Invalid Input. Please ensure all text inputs are below 32 characters, 300 for the description. Also streetnumber, bedrooms, bathrooms, garages, plotsize, house size, property price and property value must be numeric", 15);
            }
        }
        private void BT_Edit_Click(object sender, RoutedEventArgs e)
        {
            if( CanEdit() )
            {
                Classes.Validation valid = new Classes.Validation();
                if( (bool)CB_ChangeUsername.IsChecked )
                {
                    if (valid.TextIsShorterThan(GetUsername(), 32))
                    {
                        EditUsername();
                    }
                    else
                    {
                        DisplayNotifybox("ERROR", "Your password must contain at least one of each of the following: a special character, a number and an uppercase letter. It must also have a length of between 8 and 32 characters.");
                    }
                }

                if( (bool)CB_ChangePassword.IsChecked )
                {
                    if (valid.TextHasNumber(PB_Password.Password.ToString()) && valid.TextHasSpecialChars(PB_Password.Password.ToString()) && valid.TextIsLongerThan(PB_Password.Password.ToString(), 8) && valid.TextIsShorterThan(PB_Password.Password.ToString(), 32) && valid.TextContainsUpperCase(PB_Password.Password.ToString()))
                    {
                        EditPassword();
                    }
                    else
                    {
                        DisplayNotifybox("ERROR", "Your password must contain at least one of each of the following: a special character, a number and an uppercase letter. It must also have a length of between 8 and 32 characters.");
                    }
                }
                this.Close();
            }
            else
            {
                DisplayNotifybox("Error", "Cannot edit admin");
            }
        }
        private void AddAdmin()
        {
            new System.Threading.Thread(() =>
            {
                Classes.AdminManager adminManager = new Classes.AdminManager();

                if (adminManager.CanAddAdmin(GetUsername()))
                {
                    Classes.Validation valid = new Classes.Validation();
                    SetLoadingState(true);
                    if (valid.TextIsShorterThan(GetUsername(), 32))
                    {
                        if (adminManager.AddAdmin(GetUsername(), GetPassword()))
                        {
                            DisplayNotifyBox("Admin Added", GetUsername() + " has been successfully added", 5);
                            ClearForm();
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Could not add " + GetUsername(), 5);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Please use a username with length shorter than 32 characters", 10);
                    }
                }
                else
                {
                    DisplayNotifyBox("Username Exists Already", "Cannot add " + GetUsername() + ", the username exits already", 5);
                }

                SetLoadingState(false);
            }).Start();
        }
Beispiel #4
0
        private void BT_Edit_Click(object sender, RoutedEventArgs e)
        {
            if (CanEdit())
            {
                Classes.Validation valid = new Classes.Validation();
                if ((bool)CB_ChangeUsername.IsChecked)
                {
                    if (valid.TextIsShorterThan(GetUsername(), 32))
                    {
                        EditUsername();
                    }
                    else
                    {
                        DisplayNotifybox("ERROR", "Your password must contain at least one of each of the following: a special character, a number and an uppercase letter. It must also have a length of between 8 and 32 characters.");
                    }
                }

                if ((bool)CB_ChangePassword.IsChecked)
                {
                    if (valid.TextHasNumber(PB_Password.Password.ToString()) && valid.TextHasSpecialChars(PB_Password.Password.ToString()) && valid.TextIsLongerThan(PB_Password.Password.ToString(), 8) && valid.TextIsShorterThan(PB_Password.Password.ToString(), 32) && valid.TextContainsUpperCase(PB_Password.Password.ToString()))
                    {
                        EditPassword();
                    }
                    else
                    {
                        DisplayNotifybox("ERROR", "Your password must contain at least one of each of the following: a special character, a number and an uppercase letter. It must also have a length of between 8 and 32 characters.");
                    }
                }
                this.Close();
            }
            else
            {
                DisplayNotifybox("Error", "Cannot edit admin");
            }
        }
 private void BT_AddAgent_Click(object sender, RoutedEventArgs e)
 {
     if (PB_ConfirmPassword.Password.ToString() == PB_Password.Password.ToString())
     {
         Classes.Validation valid = new Classes.Validation();
         if (valid.TextHasNumber(PB_Password.Password.ToString()) && valid.TextHasSpecialChars(PB_Password.Password.ToString()) && valid.TextIsLongerThan(PB_Password.Password.ToString(), 8) && valid.TextIsShorterThan(PB_Password.Password.ToString(), 32) && valid.TextContainsUpperCase(PB_Password.Password.ToString()))
         {
             if (valid.TextisEmail(GetEmail()) && valid.TextIsShorterThan(GetEmail(), 32))
             {
                 AddAgent();
             }
             else
             {
                 DisplayNotifyBox("ERROR", "Please use a valid email address with length shorter than 32 characters", 10);
             }
         }
         else
         {
             DisplayNotifyBox("ERROR", "Your password must contain at least one of each of the following: a special character, a number and an uppercase letter. It must also have a length of between 8 and 32 characters.", 10);
         }
     }
     else
     {
         DisplayNotifyBox("ERROR", "The passwords do not match", 2);
     }
 }
        private void AddAdmin()
        {
            new System.Threading.Thread(() =>
            {
                Classes.AdminManager adminManager = new Classes.AdminManager();

                if( adminManager.CanAddAdmin(GetUsername()) )
                {
                    Classes.Validation valid = new Classes.Validation();
                    SetLoadingState(true);
                    if (valid.TextIsShorterThan(GetUsername(), 32))
                    {
                        if (adminManager.AddAdmin(GetUsername(), GetPassword()))
                        {
                            DisplayNotifyBox("Admin Added", GetUsername() + " has been successfully added", 5);
                            ClearForm();
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Could not add " + GetUsername(), 5);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Please use a username with length shorter than 32 characters", 10);
                    }
                }
                else
                {
                    DisplayNotifyBox("Username Exists Already", "Cannot add " + GetUsername() + ", the username exits already", 5);
                }

                SetLoadingState(false);
            }).Start();
        }
        private void AddAgent()
        {
            new System.Threading.Thread(() =>
            {
                Classes.AgentManager agentManager = new Classes.AgentManager();

                if (agentManager.CanAddAgent(GetEmail()))
                {
                    SetLoadingState(true);

                    Classes.Validation valid = new Classes.Validation();
                    if (valid.TextIsShorterThan(GetName(), 32) && valid.TextIsShorterThan(GetSurname(), 32) && valid.TextIsShorterThan(GetPhone(), 12))
                    {
                        if (valid.IsTextNumeric(GetPhone()))
                        {
                            if (agentManager.AddAgent(GetName(), GetSurname(), GetPhone(), GetEmail(), GetPassword()))
                            {
                                DisplayNotifyBox("Agent Added", GetName() + " has been successfully added", 5);

                            }
                            else
                            {
                                DisplayNotifyBox("ERROR", "Could not add " + GetName(), 2);
                            }
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a valid cellphone number with local 099 999 999 format", 10);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Please ensure all fields have lengths shorter than 32 characters", 10);
                    }
                    ClearForm();
                }
                else
                {
                    DisplayNotifyBox("Username Exists Already", "Cannot add " + GetName() + ", the email " + GetEmail() + " exits already", 3);
                }

                SetLoadingState(false);
            }).Start();
        }
        private void AddAgent()
        {
            new System.Threading.Thread(() =>
            {
                Classes.AgentManager agentManager = new Classes.AgentManager();

                if (agentManager.CanAddAgent(GetEmail()))
                {
                    SetLoadingState(true);

                    Classes.Validation valid = new Classes.Validation();
                    if (valid.TextIsShorterThan(GetName(), 32) && valid.TextIsShorterThan(GetSurname(), 32) && valid.TextIsShorterThan(GetPhone(), 12))
                    {
                        if (valid.IsTextNumeric(GetPhone()))
                        {
                            if (agentManager.AddAgent(GetName(), GetSurname(), GetPhone(), GetEmail(), GetPassword()))
                            {
                                DisplayNotifyBox("Agent Added", GetName() + " has been successfully added", 5);
                            }
                            else
                            {
                                DisplayNotifyBox("ERROR", "Could not add " + GetName(), 2);
                            }
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a valid cellphone number with local 099 999 999 format", 10);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Please ensure all fields have lengths shorter than 32 characters", 10);
                    }
                    ClearForm();
                }
                else
                {
                    DisplayNotifyBox("Username Exists Already", "Cannot add " + GetName() + ", the email " + GetEmail() + " exits already", 3);
                }

                SetLoadingState(false);
            }).Start();
        }
        private void BT_Edit_Click(object sender, RoutedEventArgs e)
        {
            if( TB_NewProvinceName.Text != "")
            {
                if( TB_NewProvinceName.Text.ToString() != provinceToEdit )
                {
                    new System.Threading.Thread(() =>
                        {
                            Classes.LocationManager locationManager = new Classes.LocationManager();

                            if( locationManager.CanAddProvince(GetNewProvinceName()))
                            {
                                Classes.Validation valid = new Classes.Validation();

                                if (valid.TextIsShorterThan(GetNewProvinceName(), 32))
                                {
                                    if (locationManager.ChangeProvinceName(provinceToEdit, GetNewProvinceName()))
                                    {
                                        DisplayNotifyBox(provinceToEdit + " Edited", provinceToEdit + " was changed to " + GetNewProvinceName(), 2);
                                        isEdited = true;
                                    }
                                    else
                                    {
                                        DisplayNotifyBox("Could not edit " + provinceToEdit, provinceToEdit + " was not changed. Please try again", 3);
                                    }

                                    if (isEdited == true)
                                    {
                                        CloseForm();
                                    }
                                }
                                else
                                {
                                    DisplayNotifyBox("ERROR", "Province name must be shorter than 32 character", 5);
                                }

                            }
                            else
                            {
                                DisplayNotifyBox("Province Name Already Exists", "Cannot change " + provinceToEdit + " to " + GetNewProvinceName() + " because " + GetNewProvinceName() + " already exists",3);
                            }

                        }).Start();
                }
                else
                {
                    DisplayNotifyBox("ERROR", "New province name must be different form old province name", 2);
                }
            }
            else
            {
                DisplayNotifyBox("ERROR", "New Province Name cannot be empty", 2);
            }
        }
 private void BT_AddClient_Click(object sender, RoutedEventArgs e)
 {
     if (PB_ConfirmPassword.Password.ToString() == PB_Password.Password.ToString())
     {
         Classes.Validation valid = new Classes.Validation();
         if (valid.TextHasNumber(GetPassword()) && valid.TextHasSpecialChars(GetPassword()) && valid.TextIsLongerThan(GetPassword(), 8) && valid.TextIsShorterThan(GetPassword(), 32) && valid.TextContainsUpperCase(GetPassword()))
         {
             if (valid.TextIsShorterThan(GetName(), 32) && valid.TextIsShorterThan(GetSurname(), 32) && valid.TextIsShorterThan(GetPhone(), 12))
             {
                 if (valid.IsTextNumeric(GetPhone()))
                 {
                     if (valid.TextisEmail(GetEmail()) && valid.TextIsShorterThan(GetEmail(), 32))
                     {
                         AddClient();
                     }
                     else
                     {
                         DisplayNotifyBox("ERROR", "Please use a valid email address with length shorter than 32 characters", 10);
                     }
                 }
                 else
                 {
                     DisplayNotifyBox("ERROR", "Please use a valid cellphone number with local 099 999 999 format", 10);
                 }
             }
             else
             {
                 DisplayNotifyBox("ERROR", "Please ensure all fields have lengths shorter than 32 characters", 10);
             }
         }
         else
         {
             DisplayNotifyBox("ERROR", "Your password must contain at least one of each of the following: a special character, a number and an uppercase letter. It must also have a length of between 8 and 32 characters.", 10);
         }
     }
     else
     {
         DisplayNotifyBox("ERROR", "The passwords do not match", 2);
     }
 }
Beispiel #11
0
        private void BT_Edit_Click(object sender, RoutedEventArgs e)
        {
            if (TB_NewProvinceName.Text != "")
            {
                if (TB_NewProvinceName.Text.ToString() != provinceToEdit)
                {
                    new System.Threading.Thread(() =>
                    {
                        Classes.LocationManager locationManager = new Classes.LocationManager();

                        if (locationManager.CanAddProvince(GetNewProvinceName()))
                        {
                            Classes.Validation valid = new Classes.Validation();

                            if (valid.TextIsShorterThan(GetNewProvinceName(), 32))
                            {
                                if (locationManager.ChangeProvinceName(provinceToEdit, GetNewProvinceName()))
                                {
                                    DisplayNotifyBox(provinceToEdit + " Edited", provinceToEdit + " was changed to " + GetNewProvinceName(), 2);
                                    isEdited = true;
                                }
                                else
                                {
                                    DisplayNotifyBox("Could not edit " + provinceToEdit, provinceToEdit + " was not changed. Please try again", 3);
                                }

                                if (isEdited == true)
                                {
                                    CloseForm();
                                }
                            }
                            else
                            {
                                DisplayNotifyBox("ERROR", "Province name must be shorter than 32 character", 5);
                            }
                        }
                        else
                        {
                            DisplayNotifyBox("Province Name Already Exists", "Cannot change " + provinceToEdit + " to " + GetNewProvinceName() + " because " + GetNewProvinceName() + " already exists", 3);
                        }
                    }).Start();
                }
                else
                {
                    DisplayNotifyBox("ERROR", "New province name must be different form old province name", 2);
                }
            }
            else
            {
                DisplayNotifyBox("ERROR", "New Province Name cannot be empty", 2);
            }
        }
        private void AddProvince()
        {
            new System.Threading.Thread(() =>
                {
                    if( GetProvinceName() != "" )
                    {
                        Classes.LocationManager locationManager = new Classes.LocationManager();
                        Classes.Validation valid = new Classes.Validation();
                        if (valid.TextIsShorterThan(GetProvinceName(), 32))
                        {
                            if (locationManager.CanAddProvince(GetProvinceName()))
                            {
                                SetLoadingState(true);

                                if (locationManager.AddProvince(GetProvinceName()))
                                {
                                    DisplayNotifyBox(GetProvinceName() + " Added", GetProvinceName() + " has been added successfully", 2);
                                    ClearForm();
                                }
                                else
                                {
                                    DisplayNotifyBox("Could not Add", GetProvinceName() + " was not added", 2);
                                }

                                SetLoadingState(false);

                            }
                            else
                            {
                                DisplayNotifyBox("Cannot add " + GetProvinceName(), "A province with the same name already exists", 2);
                            }
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Province name must be shorter than 32 character", 5);
                        }

                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Province name cannot be empty",2);
                    }
                }).Start();
        }
Beispiel #13
0
        private void AddCity()
        {
            if (TB_CityName.Text != "")
            {
                new System.Threading.Thread(() =>
                {
                    SetLoadingState(true);
                    Classes.LocationManager locationManager = new Classes.LocationManager();

                    Classes.Validation valid = new Classes.Validation();
                    if (valid.TextIsShorterThan(GetCityName(), 32))
                    {
                        if (locationManager.CanAddCity(GetCityName(), GetProvinceName()))
                        {
                            if (locationManager.AddCity(GetCityName(), GetProvinceName()))
                            {
                                DisplayNotifyBox(GetCityName() + " Added", GetCityName() + " was added in " + GetProvinceName(), 3);
                                ClearForm();
                            }
                            else
                            {
                                DisplayNotifyBox("Could not Add City", GetCityName() + " could not be added. Please try again", 3);
                            }
                        }
                        else
                        {
                            DisplayNotifyBox("Cannot Add City", GetCityName() + " already exists in " + GetProvinceName(), 3);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "City name must be shorter than 32 character", 5);
                    }


                    SetLoadingState(false);
                }).Start();
            }
            else
            {
                DisplayNotifyBox("ERROR", "City name cannot be empty", 2);
            }
        }
 private void BT_AddAdmin_Click(object sender, RoutedEventArgs e)
 {
     Classes.Validation valid = new Classes.Validation();
     if (PB_ConfirmPassword.Password.ToString() == PB_Password.Password.ToString())
     {
         if (valid.TextHasNumber(PB_Password.Password.ToString()) && valid.TextHasSpecialChars(PB_Password.Password.ToString()) && valid.TextIsLongerThan(PB_Password.Password.ToString(), 8) && valid.TextIsShorterThan(PB_Password.Password.ToString(), 32) && valid.TextContainsUpperCase(PB_Password.Password.ToString()))
         {
             AddAdmin();
         }
         else
         {
             DisplayNotifyBox("ERROR", "Your password must contain at least one of each of the following: a special character, a number and an uppercase letter. It must also have a length of between 8 and 32 characters.", 10);
         }
     }
     else
     {
         DisplayNotifyBox("ERROR", "The passwords do not match", 5);
     }
 }
Beispiel #15
0
        private void EditArea(string oldName, string newName, string oldCity, string newCity, string oldProvince, string newProvince)
        {
            new System.Threading.Thread(() =>
            {
                bool edited = false;
                SetLoadingState(true);

                Classes.LocationManager locationManager = new Classes.LocationManager();
                Classes.Validation valid = new Classes.Validation();

                if (valid.TextIsShorterThan(newName, 32))
                {
                    if (locationManager.CanAddArea(newName, newCity, newProvince))
                    {
                        if (locationManager.EditArea(oldName, newName, oldCity, newCity, oldProvince, newProvince))
                        {
                            DisplayNotifyBox("Edited", oldName + "," + oldCity + "," + oldProvince + " changed to " + newName + "," + newCity + "," + newProvince, 3);
                            edited = true;
                        }
                        else
                        {
                            DisplayNotifyBox("Could not edit", "En error occured. Please try again later", 3);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("Could not edit", "Cannot change " + oldName + "," + oldCity + "," + oldProvince + " to " + newName + "," + newCity + "," + newProvince + " because " + newName + "," + newCity + "," + newProvince + " already exists", 4);
                    }
                }
                else
                {
                    DisplayNotifyBox("ERROR", "Area name must be shorter than 32 character", 5);
                }


                SetLoadingState(false);

                if (edited)
                {
                    CloseForm();
                }
            }).Start();
        }
        private void AddProvince()
        {
            new System.Threading.Thread(() =>
            {
                if (GetProvinceName() != "")
                {
                    Classes.LocationManager locationManager = new Classes.LocationManager();
                    Classes.Validation valid = new Classes.Validation();
                    if (valid.TextIsShorterThan(GetProvinceName(), 32))
                    {
                        if (locationManager.CanAddProvince(GetProvinceName()))
                        {
                            SetLoadingState(true);

                            if (locationManager.AddProvince(GetProvinceName()))
                            {
                                DisplayNotifyBox(GetProvinceName() + " Added", GetProvinceName() + " has been added successfully", 2);
                                ClearForm();
                            }
                            else
                            {
                                DisplayNotifyBox("Could not Add", GetProvinceName() + " was not added", 2);
                            }

                            SetLoadingState(false);
                        }
                        else
                        {
                            DisplayNotifyBox("Cannot add " + GetProvinceName(), "A province with the same name already exists", 2);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Province name must be shorter than 32 character", 5);
                    }
                }
                else
                {
                    DisplayNotifyBox("ERROR", "Province name cannot be empty", 2);
                }
            }).Start();
        }
        private void LoadVariablesTB()
        {
            Classes.Validation valid = new Classes.Validation();
            if (valid.TextIsShorterThan(TB_Streetname.Text, 32) && valid.TextIsShorterThan(TB_Description.Text, 300) && valid.IsTextNumeric(TB_Streetno.Text) && valid.IsTextNumeric(TB_Bedrooms.Text) && valid.IsTextNumeric(TB_Bathrooms.Text) && valid.IsTextNumeric(TB_Garages.Text) && valid.IsTextNumeric(TB_PlotSize.Text) && valid.IsTextNumeric(TB_HouseSize.Text) && valid.IsTextNumeric(TB_ListPrice.Text) && valid.IsTextNumeric(TB_Price.Text) && valid.IsTextNumeric(TB_ComplexNo.Text) )
            {
                streetName = TB_Streetname.Text;
                streetNo = Convert.ToInt32(TB_Streetno.Text);
                bedrooms = Convert.ToInt32(TB_Bedrooms.Text);
                bathrooms = Convert.ToInt32(TB_Bathrooms.Text);
                garages = Convert.ToInt32(TB_Garages.Text);
                plotSize = Convert.ToInt32(TB_PlotSize.Text);
                houseSize = Convert.ToInt32(TB_HouseSize.Text);
                propertyPrice = Convert.ToInt32(TB_ListPrice.Text);
                propertyValue = Convert.ToInt32(TB_Price.Text);
                isSold = Convert.ToInt32(CB_isSold.IsChecked);
                isNegotiable = Convert.ToInt32(CB_isNegotiable.IsChecked);
                hasPool = Convert.ToInt32(CB_hasPool.IsChecked);
                description = TB_Description.Text;

                complexName = "Null";
                complexNo = 0;

                if (CB_Complex.IsChecked == true)
                {
                    complexName = TB_ComplexName.Text;
                    complexNo = Convert.ToInt32(TB_ComplexNo.Text);
                }
            }
            else
            {
                DisplayNotifyBox("ERROR", "Invalid Input. Please ensure all text inputs are below 32 characters, 300 for the description. Also streetnumber, bedrooms, bathrooms, garages, plotsize, house size, property price and property value must be numeric", 15);
            }
        }
        private void EditArea(string oldName, string newName, string oldCity , string newCity, string oldProvince, string newProvince)
        {
            new System.Threading.Thread(() =>
            {
                bool edited = false;
                SetLoadingState(true);

                Classes.LocationManager locationManager = new Classes.LocationManager();
                Classes.Validation valid = new Classes.Validation();

                if (valid.TextIsShorterThan(newName, 32))
                {
                    if (locationManager.CanAddArea(newName, newCity, newProvince))
                    {
                        if (locationManager.EditArea(oldName, newName, oldCity, newCity, oldProvince, newProvince))
                        {
                            DisplayNotifyBox("Edited", oldName + "," + oldCity + "," + oldProvince + " changed to " + newName + "," + newCity + "," + newProvince, 3);
                            edited = true;
                        }
                        else
                        {
                            DisplayNotifyBox("Could not edit", "En error occured. Please try again later", 3);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("Could not edit", "Cannot change " + oldName + "," + oldCity + "," + oldProvince + " to " + newName + "," + newCity + "," + newProvince + " because " + newName + "," + newCity + "," + newProvince + " already exists", 4);
                    }
                }
                else
                {
                    DisplayNotifyBox("ERROR", "Area name must be shorter than 32 character", 5);
                }

                SetLoadingState(false);

                if (edited)
                    CloseForm();
            }).Start();
        }
        private void BT_SaveAndClose_Click(object sender, RoutedEventArgs e)
        {
            if (editName || editSurname || editPhone || editEmail || editPassword)
            {
                Classes.Validation valid = new Classes.Validation();
                edited = true;
                if (editName)
                {
                    if (GetNewName() != "")
                    {
                        if (valid.TextIsShorterThan(GetNewName(), 32))
                        {
                            EditName(clientEmail, GetNewName());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a name shorter than 32 characters", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New name cannot be empty", 3);
                    }
                }

                if (editSurname)
                {
                    if (GetNewSurname() != "")
                    {
                        if (valid.TextIsShorterThan(GetNewSurname(), 32))
                        {
                            EditSurname(clientEmail, GetNewSurname());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a surname shorter than 32 characters", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New surname cannot be empty", 3);
                    }
                }

                if (editPhone)
                {
                    if (GetNewPhone() != "")
                    {
                        if (valid.IsTextNumeric(GetNewPhone()) && valid.TextIsShorterThan(GetNewPhone(), 12))
                        {
                            EditPhone(clientEmail, GetNewPhone());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a valid cellphone number with local 099 999 9999 format", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New phone number cannot be empty", 3);
                    }
                }

                if (editEmail)
                {
                    if (GetNewEmail() != "")
                    {
                        if (valid.TextisEmail(GetNewEmail()) && valid.TextIsShorterThan(GetNewEmail(), 32))
                        {
                            EditEmail(clientEmail, GetNewEmail());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a valid email address with length shorter than 32 characters", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New email cannot be empty", 3);
                    }
                }

                if (editPassword)
                {
                    if (GetNewPassword() != "" && CanEditPassword())
                    {
                        if (valid.TextHasNumber(GetNewPassword()) && valid.TextHasSpecialChars(GetNewPassword()) && valid.TextIsLongerThan(GetNewPassword(), 8) && valid.TextIsShorterThan(GetNewPassword(), 32) && valid.TextContainsUpperCase(GetNewPassword()))
                        {
                            EditPassword(clientEmail, GetNewPassword());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Your password must contain at least one of each of the following: a special character, a number and an uppercase letter. It must also have a length of between 8 and 32 characters.", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New password cannot be empty", 3);
                    }
                }

                if (edited)
                {
                    CloseForm();
                }
            }
            else
            {
                DisplayNotifyBox("No change selected", "Please select a property to change", 3);
            }
        }
        private void BT_SaveAndClose_Click(object sender, RoutedEventArgs e)
        {
            if (editName || editSurname || editPhone || editEmail || editPassword)
            {
                edited = true;
                Classes.Validation valid = new Classes.Validation();

                if (editName)
                {
                    if (GetNewName() != "")
                    {
                        if (valid.TextIsShorterThan(GetNewName(), 32))
                        {
                            EditName(agentEmail, GetNewName());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a name shorter than 32 characters", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New name cannot be empty", 5);
                    }
                }

                if (editSurname)
                {
                    if (GetNewSurname() != "")
                    {
                        if (valid.TextIsShorterThan(GetNewSurname(), 32))
                        {
                            EditSurname(agentEmail, GetNewSurname());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a surname shorter than 32 characters", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New surname cannot be empty", 5);
                    }
                }

                if (editPhone)
                {
                    if (GetNewPhone() != "")
                    {
                        if (valid.IsTextNumeric(GetNewPhone()) && valid.TextIsShorterThan(GetNewPhone(), 12))
                        {
                            EditPhone(agentEmail, GetNewPhone());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a valid cellphone number with local 099 999 9999 format", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New phone number cannot be empty", 5);
                    }
                }

                if (editEmail)
                {
                    if (GetNewEmail() != "")
                    {
                        if (valid.TextisEmail(GetNewEmail()) && valid.TextIsShorterThan(GetNewEmail(), 32))
                        {
                            EditEmail(agentEmail, GetNewEmail());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a valid email address with length shorter than 32 characters", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New email cannot be empty", 5);
                    }
                }

                if (editPassword)
                {
                    if (GetNewPassword() != "" && CanEditPassword())
                    {
                        if (valid.TextHasNumber(GetNewPassword()) && valid.TextHasSpecialChars(GetNewPassword()) && valid.TextIsLongerThan(GetNewPassword(), 8) && valid.TextIsShorterThan(GetNewPassword(), 32) && valid.TextContainsUpperCase(GetNewPassword()))
                        {
                            EditPassword(agentEmail, GetNewPassword());
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Your password must contain at least one of each of the following: a special character, a number and an uppercase letter. It must also have a length of between 8 and 32 characters.", 10);
                        }
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("ERROR", "New password cannot be empty", 5);
                    }
                }

               if (edited)
               {
                   CloseForm();
               }
            }
            else
            {
                DisplayNotifyBox("No change selected", "Please select a property to change", 5);
            }
        }