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 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); } }
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); } }