예제 #1
0
 private void Email_LostFocus(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrWhiteSpace(this.Email.Text))
     {
         this.ErrorEmail.Text = "Please Enter an Email Id.";
     }
     else
     {
         if (!ValidationClass.ValidateEmailID(this.Email.Text))
         {
             this.ErrorEmail.Text = "This is not a valid Email Id.";
         }
         else
         {
             using (var ctx = new Choukash_Revamp_DemoEntities()) {
                 var email = ctx.SuperAdmins.Where(a => a.email == this.Email.Text).FirstOrDefault <SuperAdmin>();
                 if (email == null)
                 {
                     this.ErrorEmail.Text = "";
                 }
                 else
                 {
                     this.ErrorEmail.Text = "This email is alraedy associated with another user";
                 }
             }
         }
     }
 }
예제 #2
0
        public void Validation(string name)
        {
            switch (name)
            {
            case "UserName":
                if (String.IsNullOrWhiteSpace(UserName))
                {
                    ErrorUserName = "******";
                }
                else
                {
                    ErrorUserName = "";
                    if (EditUserMode)
                    {
                        EditUser();
                    }
                }

                break;

            case "UserEmail":
                if (String.IsNullOrWhiteSpace(UserEmail))
                {
                    ErrorUserEmail = "Please enter email id";
                }
                else
                {
                    if (!ValidationClass.ValidateEmailID(UserEmail))
                    {
                        ErrorUserEmail = "Email id is not valid";
                    }
                    else
                    {
                        if (!ValidationClass.UniqueTestforEmail(UserEmail, "User") && !EditUserMode)
                        {
                            ErrorUserEmail = "This Email ID is already associated with another user";
                        }
                        else if (EditUserMode && CurrentUser != null)
                        {
                            if (!ValidationClass.UniqueTestforEmail(CurrentUser.id, UserEmail, "User"))
                            {
                                ErrorUserEmail = "This Email ID is already associated with another user";
                            }
                        }
                        else
                        {
                            ErrorUserEmail = "";
                            if (EditUserMode)
                            {
                                EditUser();
                            }
                        }
                    }
                }
                break;

            case "Password":
                if (String.IsNullOrWhiteSpace(Password))
                {
                    ErrorPassword = "******";
                }
                else
                {
                    if (!ValidationClass.ValidatePassword(Password))
                    {
                        ErrorPassword = "******";
                    }
                    else
                    {
                        ErrorPassword = "";
                    }
                }
                break;

            case "ConfirmPassword":
                if (String.IsNullOrWhiteSpace(ConfirmPassword))
                {
                    ErrorConfirmPassword = "******";
                }
                else
                {
                    if (Password != ConfirmPassword)
                    {
                        ErrorConfirmPassword = "******";
                    }
                    else
                    {
                        ErrorConfirmPassword = "";
                        if (EditUserMode)
                        {
                            EditUser();
                        }
                    }
                }
                break;

            case "Roles":
                if (CurrentUserRole == null)
                {
                    ErrorUserRole = "Please select arole for user.";
                }
                else
                {
                    ErrorUserRole = "";
                }
                break;
            }
        }
        public void Validation(string ControlName)
        {
            switch (ControlName)
            {
            case "UserName":
                if (String.IsNullOrWhiteSpace(UserName))
                {
                    ErrorUserName = "******";
                    break;
                }
                else
                {
                    ErrorUserName = "";
                }
                break;

            case "UserEmail":
                if (String.IsNullOrWhiteSpace(UserEmail))
                {
                    ErrorUserEmail = "Please enter email";
                    break;
                }
                else
                {
                    if (!ValidationClass.ValidateEmailID(UserEmail))
                    {
                        ErrorUserEmail = "This email id is not valid";
                        break;
                    }
                    else
                    {
                        using (var ctx = new Choukash_Revamp_DemoEntities())
                        {
                            var email = ctx.Users.Where(a => a.email == this.UserEmail).FirstOrDefault <User>();
                            if (email == null)
                            {
                                this.ErrorUserEmail = "";
                            }
                            else
                            {
                                this.ErrorUserEmail = "This email is alraedy associated with another user";
                            }
                        }
                        break;
                    }
                }

            case "Password":
                if (String.IsNullOrWhiteSpace(Password))
                {
                    ErrorPassword = "******";
                    break;
                }
                else
                {
                    if (!ValidationClass.ValidatePassword(Password))
                    {
                        ErrorPassword = "******";
                        break;
                    }
                    else
                    {
                        ErrorPassword = "";
                        break;
                    }
                }

            case "ConfirmPassword":
                if (String.IsNullOrWhiteSpace(ConfirmPassword))
                {
                    ErrorConfirmPassword = "******";
                    break;
                }
                else
                {
                    if (Password != ConfirmPassword)
                    {
                        ErrorConfirmPassword = "******";
                    }
                    else
                    {
                        ErrorConfirmPassword = "";
                    }

                    break;
                }
            }
        }