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();
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 5
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 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();
        }
Ejemplo n.º 7
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            Classes.Validation objValidate = new Classes.Validation();
            bool error = false;
            litError.Text = "";

            if (!objValidate.isValidName(txtName.Text.ToString()))
            {
                error = true;
                litError.Text += "Invalid Name<br>";
            }

            if (!objValidate.isValidEmail(txtEmail.Text.ToString()))
            {
                error = true;
                litError.Text += "Invalid Email Address<br>";
            }

            if (!objValidate.isValidPassword(txtPassword.Text.ToString()))
            {
                error = true;
                litError.Text += "Invalid Password<br>";
            }

            if (txtPassword.Text.ToString() != txtRePassword.Text.ToString())
            {
                error = true;
                litError.Text += "Passwords do not match<br>";
            }

            if (error)
                return;

            Classes.User objUser = new Classes.User();

            if (objUser.addUser(txtName.Text.ToString(), txtEmail.Text.ToString(), txtPassword.Text.ToString(), null, "Customer"))
            {
                string activationCode = objUser.getActivationCode(txtEmail.Text.ToString());

                string activationLink = "http://" + Request.Url.Authority + "/Account/Activate.aspx?code=" + activationCode + "&email=" + txtEmail.Text.ToString(); ;

                string activationMessage = "Hello " + txtName.Text.ToString() + ",<br><br>";
                activationMessage += "Please activate your account by clicking on the link:<br><br>";
                activationMessage += activationLink;

                Classes.Mail objMail = new Classes.Mail(txtEmail.Text.ToString(), "eShopee Account Activation", activationMessage);

                litError.Text = "You are successfully registered";

            }

            else
                litError.Text = "Your account could not be registered";

            objUser.close();
        }
        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);
            }
        }
Ejemplo n.º 9
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string email = txtEmail.Text.ToString();
                string password = txtPassword.Text.ToString();
                bool error = false;
                litError.Text = "";

                Classes.Validation objValidate = new Classes.Validation();

                if (!objValidate.isValidEmail(email))
                {
                    error = true;
                    litError.Text += "Invalid Email Address<br>";
                }

                if (!objValidate.isValidPassword(password))
                {
                    error = true;
                    litError.Text += "Invalid Password<br>";
                }

                if (error)
                    return;

                Classes.Cryptography crypto = new Classes.Cryptography();

                password = crypto.genPassHash(password);

                Classes.User objUser = new Classes.User();

                if (password == objUser.getPassword(email))
                {
                    Session["username"] = email;
                    Session["loggedIn"] = "true";
                    Session["role"] = objUser.getRole(email);

                    Response.Redirect("Dashboard.aspx");
                }

                else
                {
                    litError.Text = "Invalid Account Login Information Provided";
                }
            }

            catch (Exception ex)
            {
                litError.Text = "Invalid Account Login Information Provided";
            }
        }
Ejemplo n.º 10
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 IPOctetValidation(object sender, TextCompositionEventArgs e)
        {
            bool eHandled = true;
            TextBox temp = (TextBox)sender;
            string temp_text;
            Classes.Validation validation = new Classes.Validation();

            if( validation.IsTextNumeric(e.Text) )
            {
                temp_text = temp.Text.ToString() + e.Text;
                eHandled = !validation.IsNumberInRange(0, 255, temp_text);
            }

            e.Handled = eHandled;
        }
Ejemplo n.º 12
0
        private void IPOctetValidation(object sender, TextCompositionEventArgs e)
        {
            bool    eHandled = true;
            TextBox temp     = (TextBox)sender;
            string  temp_text;

            Classes.Validation validation = new Classes.Validation();

            if (validation.IsTextNumeric(e.Text))
            {
                temp_text = temp.Text.ToString() + e.Text;
                eHandled  = !validation.IsNumberInRange(0, 255, temp_text);
            }

            e.Handled = eHandled;
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            Classes.User objUser = new Classes.User();
            Classes.Cryptography objCrypto = new Classes.Cryptography();
            Classes.Validation objValidate = new Classes.Validation();

            try
            {
                string email = Session["username"].ToString();
                string oldPassword = txtOldPassword.Text.ToString();
                string newPassword = txtNewPassword.Text.ToString();
                bool error = false;

                if (objUser.getPassword(email) != objCrypto.genPassHash(oldPassword))
                {
                    error = true;
                    litError.Text += "Incorrect Old Password<br>";
                }

                if (!objValidate.isValidPassword(newPassword))
                {
                    error = true;
                    litError.Text = "Invalid New Password";
                }

                if (newPassword != txtConfNewPassword.Text.ToString())
                {
                    error = true;
                    litError.Text = "Passwords Do Not Match";
                }

                if (error)
                    return;

                if (objUser.setPassword(email, newPassword))
                {
                    litError.Text = "Password Updated Successfully";
                }
            }

            catch (Exception ex)
            {
                litError.Text = "Password Could Not Be Updated";
            }

            objUser.close();
        }
        private bool SetPreferences()
        {
            bool flag = false;

            Classes.Validation valid = new Classes.Validation();
            this.Dispatcher.Invoke(() =>
            {
                if (valid.IsTextNumeric(TB_MinPlotSize.Text) && valid.IsTextNumeric(TB_MaxPlotSize.Text) && valid.IsTextNumeric(TB_MinHouseSize.Text) && valid.IsTextNumeric(TB_MaxHouseSize.Text) && valid.IsTextNumeric(TB_MinPrice.Text) && valid.IsTextNumeric(TB_MaxPrice.Text))
                {
                    try
                    {
                        if (valid.IsNumberInRange(Convert.ToInt32(CB_MinBedrooms.SelectedItem), 50, CB_MaxBedrooms.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(CB_MinBathrooms.SelectedItem), 50, CB_MaxBathrooms.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(CB_MinGarages.SelectedItem), 50, CB_MaxGarages.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(TB_MinPlotSize.Text), 2147483645, TB_MaxPlotSize.Text) && valid.IsNumberInRange(Convert.ToInt32(TB_MinHouseSize.Text), 2147483645, TB_MaxHouseSize.Text) && valid.IsNumberInRange(Convert.ToInt32(TB_MinPrice.Text), 2147483645, TB_MaxPrice.Text))
                        {
                            minBedrooms  = Convert.ToInt32(CB_MinBedrooms.SelectedItem);
                            maxBedrooms  = Convert.ToInt32(CB_MaxBedrooms.SelectedItem);
                            minBathrooms = Convert.ToInt32(CB_MinBathrooms.SelectedItem);
                            maxBathrooms = Convert.ToInt32(CB_MaxBathrooms.SelectedItem);
                            minGarages   = Convert.ToInt32(CB_MinGarages.SelectedItem);
                            maxGarages   = Convert.ToInt32(CB_MaxGarages.SelectedItem);
                            minPlotSize  = Convert.ToInt32(TB_MinPlotSize.Text);
                            maxPlotSize  = Convert.ToInt32(TB_MaxPlotSize.Text);
                            minHouseSize = Convert.ToInt32(TB_MinHouseSize.Text);
                            maxHouseSize = Convert.ToInt32(TB_MaxHouseSize.Text);
                            minPrice     = Convert.ToInt32(TB_MinPrice.Text);
                            maxPrice     = Convert.ToInt32(TB_MaxPrice.Text);
                            hasPool      = Convert.ToInt32(CB_HasPool.SelectedIndex.ToString());
                            flag         = true;
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please ensure that all min values are smaller than their corresponding max values", 10);
                        }
                    }
                    catch
                    {
                        DisplayNotifyBox("ERROR", "Please ensure that all field values are smaller than 2 147 483 645", 10);
                    }
                }
                else
                {
                    DisplayNotifyBox("ERROR", "Please ensure that the plotsize, housesize and price fields are numeric", 10);
                }
            });
            return(flag);
        }
        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 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();
        }
Ejemplo n.º 17
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 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_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);
     }
 }
Ejemplo n.º 20
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 BT_AddOffer_Click(object sender, RoutedEventArgs e)
 {
     Classes.OfferManager offerManager = new Classes.OfferManager();
     Classes.Validation valid = new Classes.Validation();
     if (valid.IsTextNumeric(TB_Price.Text) && valid.IsNumberInRange(0, 2147483645, TB_Price.Text) && valid.DateTest(TB_Price.Text))
     {
         if (offerManager.AddOffer(listID[CB_Listing.SelectedIndex], clientsID[CB_Client.SelectedIndex], Convert.ToInt32(TB_Price.Text), CB_Status.SelectedIndex, DP_Date.Text))
         {
             DisplayNotifyBox("Offer added", "The offer from " + CB_Client.SelectedItem + " has been added", 5);
             ClearAddOfferOverlay();
         }
         else
         {
             DisplayNotifyBox("ERROR", "Offer could not be added", 5);
         }
     }
     else
     {
         DisplayNotifyBox("ERROR", "Please ensure the price is numeric and lower than 2 147 483 645, and that the date is in the valid format", 5);
     }
 }
 private void BT_AddOffer_Click(object sender, RoutedEventArgs e)
 {
     Classes.OfferManager offerManager = new Classes.OfferManager();
     Classes.Validation   valid        = new Classes.Validation();
     if (valid.IsTextNumeric(TB_Price.Text) && valid.IsNumberInRange(0, 2147483645, TB_Price.Text) && valid.DateTest(TB_Price.Text))
     {
         if (offerManager.AddOffer(listID[CB_Listing.SelectedIndex], clientsID[CB_Client.SelectedIndex], Convert.ToInt32(TB_Price.Text), CB_Status.SelectedIndex, DP_Date.Text))
         {
             DisplayNotifyBox("Offer added", "The offer from " + CB_Client.SelectedItem + " has been added", 5);
             ClearAddOfferOverlay();
         }
         else
         {
             DisplayNotifyBox("ERROR", "Offer could not be added", 5);
         }
     }
     else
     {
         DisplayNotifyBox("ERROR", "Please ensure the price is numeric and lower than 2 147 483 645, and that the date is in the valid format", 5);
     }
 }
 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);
     }
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            Classes.User objUser = new Classes.User();

            try
            {
                string email = Session["username"].ToString();
                string name = txtName.Text.ToString();
                string mobile = txtMobile.Text.ToString();

                Classes.Validation objValidate = new Classes.Validation();
                bool error = false;
                litError.Text = "";

                if (!objValidate.isValidName(name))
                {
                    error = true;
                    litError.Text = "Invalid Name";
                }

                if (error)
                    return;

                if (objUser.setUser(name, email, mobile))
                {
                    litError.Text = "Account Updated Successfully";
                }

            }

            catch (Exception ex)
            {
                litError.Text = "Account Could Not be Updated";
            }

            objUser.close();
        }
        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 PortValidation(object sender, TextCompositionEventArgs e)
 {
     Classes.Validation validation = new Classes.Validation();
     e.Handled = !validation.IsTextNumeric(e.Text);
 }
Ejemplo n.º 28
0
 private void PortValidation(object sender, TextCompositionEventArgs e)
 {
     Classes.Validation validation = new Classes.Validation();
     e.Handled = !validation.IsTextNumeric(e.Text);
 }
        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);
            }
        }
        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 bool SetPreferences()
 {
     bool flag = false;
     Classes.Validation valid = new Classes.Validation();
     this.Dispatcher.Invoke(() =>
     {
         if (valid.IsTextNumeric(TB_MinPlotSize.Text) && valid.IsTextNumeric(TB_MaxPlotSize.Text) && valid.IsTextNumeric(TB_MinHouseSize.Text) && valid.IsTextNumeric(TB_MaxHouseSize.Text) && valid.IsTextNumeric(TB_MinPrice.Text) && valid.IsTextNumeric(TB_MaxPrice.Text))
         {
             try
             {
                 if (valid.IsNumberInRange(Convert.ToInt32(CB_MinBedrooms.SelectedItem), 50, CB_MaxBedrooms.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(CB_MinBathrooms.SelectedItem), 50, CB_MaxBathrooms.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(CB_MinGarages.SelectedItem), 50, CB_MaxGarages.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(TB_MinPlotSize.Text), 2147483645, TB_MaxPlotSize.Text) && valid.IsNumberInRange(Convert.ToInt32(TB_MinHouseSize.Text), 2147483645, TB_MaxHouseSize.Text) && valid.IsNumberInRange(Convert.ToInt32(TB_MinPrice.Text), 2147483645, TB_MaxPrice.Text))
                 {
                     minBedrooms = Convert.ToInt32(CB_MinBedrooms.SelectedItem);
                     maxBedrooms = Convert.ToInt32(CB_MaxBedrooms.SelectedItem);
                     minBathrooms = Convert.ToInt32(CB_MinBathrooms.SelectedItem);
                     maxBathrooms = Convert.ToInt32(CB_MaxBathrooms.SelectedItem);
                     minGarages = Convert.ToInt32(CB_MinGarages.SelectedItem);
                     maxGarages = Convert.ToInt32(CB_MaxGarages.SelectedItem);
                     minPlotSize = Convert.ToInt32(TB_MinPlotSize.Text);
                     maxPlotSize = Convert.ToInt32(TB_MaxPlotSize.Text);
                     minHouseSize = Convert.ToInt32(TB_MinHouseSize.Text);
                     maxHouseSize = Convert.ToInt32(TB_MaxHouseSize.Text);
                     minPrice = Convert.ToInt32(TB_MinPrice.Text);
                     maxPrice = Convert.ToInt32(TB_MaxPrice.Text);
                     hasPool = Convert.ToInt32(CB_HasPool.SelectedIndex.ToString());
                     flag = true;
                 }
                 else
                 {
                     DisplayNotifyBox("ERROR", "Please ensure that all min values are smaller than their corresponding max values", 10);
                 }
             }
             catch
             {
                 DisplayNotifyBox("ERROR", "Please ensure that all field values are smaller than 2 147 483 645", 10);
             }
         }
         else
         {
             DisplayNotifyBox("ERROR", "Please ensure that the plotsize, housesize and price fields are numeric", 10);
         }
     });
     return flag;
 }