private void EmailTextEdit_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            EmailTextEdit.Text = EmailTextEdit.Text.Trim();

            if (!string.IsNullOrWhiteSpace(EmailTextEdit.Text.Trim()))
            {
                if (!EmailValidade.GetIstance().IsValidEmail(EmailTextEdit.Text.Trim()))
                {
                    XtraMessageBox.Show("Email Inválido coloque um email válido", "Email Inválido", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    EmailTextEdit.Focus();
                }
                else
                {
                    var result = userRepository.GetAll().Where(x => x.Email.ToLower() == EmailTextEdit.Text.ToLower()).FirstOrDefault();
                    if (result != null)
                    {
                        if (string.IsNullOrWhiteSpace(IDTextEdit.Text) || IDTextEdit.Text.Equals(0))
                        {
                            XtraMessageBox.Show("Lamentamos mais este E-Mail já Existe no Sistema", "E-Mail Existente", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            EmailTextEdit.Focus();
                        }
                        else
                        {
                            if (result.ID != int.Parse(IDTextEdit.Text))
                            {
                                XtraMessageBox.Show("Lamentamos mais este E-Mail já Existe no Sistema", "E-Mail Existente", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                EmailTextEdit.Focus();
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private void TxtEmail_Validating(object sender, CancelEventArgs e)
        {
            txtEmail.Text = txtEmail.Text.Trim();

            if (!string.IsNullOrWhiteSpace(txtEmail.Text.Trim()))
            {
                if (!EmailValidade.GetIstance().IsValidEmail(txtEmail.Text.Trim()))
                {
                    XtraMessageBox.Show("Email Inválido coloque um email válido", "Email Inválido", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtEmail.Focus();
                }
                else
                {
                    var result = UsuariosInstaciaList.Where(x => x.Email.ToLower() == txtEmail.Text.ToLower()).FirstOrDefault();
                    if (result != null)
                    {
                        if (string.IsNullOrWhiteSpace(txtCodigo.Text) || txtCodigo.Text.Equals(0))
                        {
                            XtraMessageBox.Show("Lamentamos mais este E-Mail já Existe no Sistema", "E-Mail Existente", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtEmail.Focus();
                        }
                        else
                        {
                            if (result.UsuariosId != int.Parse(txtCodigo.Text))
                            {
                                XtraMessageBox.Show("Lamentamos mais este E-Mail já Existe no Sistema", "E-Mail Existente", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                txtEmail.Focus();
                            }
                        }
                    }
                }
            }
        }
 private void TxtEmail_Validating(object sender, CancelEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtToEmail.Text))
     {
         if (!EmailValidade.GetIstance().IsValidEmail(txtToEmail.Text))
         {
             txtToEmail.SelectAll();
             btnEnviar.Enabled = false;
             txtToEmail.Focus();
         }
         else
         {
             btnEnviar.Enabled = true;
         }
     }
     else
     {
         btnEnviar.Enabled = false;
     }
 }
Example #4
0
        bool Validar1(int Metodo1ou2)
        {
            if (txtGrupos.Text.Equals("[Por Favor selecione o seu grupo por favor!...]"))
            {
                XtraMessageBox.Show("Selecione o grupo  aque vai pertencer este Usuário!... preencha por favor!", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtGrupos, "Grupo invalido");
                txtGrupos.ShowPopup();
                txtGrupos.Focus();
                return(false);
            }
            if (txtNomeCompleto.Text.Trim().Equals(string.Empty))
            {
                XtraMessageBox.Show("Digite o nome do Usuário por favor!... \npreencha por favor!", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtNomeCompleto, "Usuário invalido");
                txtNomeCompleto.Focus();
                return(false);
            }
            else if (txtSenha.Text.Trim().Equals(string.Empty))
            {
                XtraMessageBox.Show("Digite a senha do usuário por favor!... \npreencha por favor!", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtSenha, "Password inválido");
                txtSenha.Focus();
                return(false);
            }
            else if (txtRepetir_Senha.Text.Trim().Equals(string.Empty))
            {
                XtraMessageBox.Show("Pepita a senha por favor!... preencha por favor!", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtRepetir_Senha, "Senha invalido");
                txtRepetir_Senha.Focus();
                return(false);
            }
            else if (txtPIN.Text.Trim().Equals(string.Empty))
            {
                XtraMessageBox.Show("Digite o pin Por favor!... preencha por favor!", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtPIN, "PIN invalido");
                txtPIN.Focus();
                return(false);
            }
            else if (txtSenha.Text.Trim().Length <= 4)
            {
                XtraMessageBox.Show("Desculpe não é permitido palavra passe com menos de 6 Caracter\n tente colocar uma com mais caracter!...", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtSenha, "Senha invalido");
                errorProvider1.SetError(txtRepetir_Senha, "Senha invalido");
                txtRepetir_Senha.SelectAll();
                txtSenha.SelectAll();
                txtSenha.Focus();
                return(false);
            }
            else if (txtPIN.Text.Length < 0)
            {
                XtraMessageBox.Show("Desculpe mais não permitimos pin com menos de 2 Caracter", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtPIN, "PIN invalido");
                txtPIN.SelectAll();
                txtPIN.Focus();
                return(false);
            }
            else if (!txtSenha.Text.Trim().Equals(txtRepetir_Senha.Text))
            {
                XtraMessageBox.Show("Desculpe mais os 2 Campos da senha não Conscidem \n tente colocar senhas iguas para os 2 Campos!...", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtSenha, "Senha invalido");
                errorProvider1.SetError(txtRepetir_Senha, "Senha invalido");
                txtRepetir_Senha.SelectAll();
                txtSenha.SelectAll();
                txtSenha.Focus();
                return(false);
            }
            #region Validação 2
            // Validar Email
            var result = UsuariosInstaciaList.ToList();

            if (!EmailValidade.GetIstance().IsValidEmail(txtEmail.Text.Trim()))
            {
                XtraMessageBox.Show("Email Inválido coloque um email válido", "Erro de Email", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.SelectAll();
                txtEmail.Focus();
                return(false);
            }
            else
            {
                if (Metodo1ou2 == 1)
                {
                    var result12 = result.Where(x => x.Email == txtEmail.Text).FirstOrDefault();

                    if (result12 != null)
                    {
                        if (!string.IsNullOrWhiteSpace(txtCodigo.Text) || !txtCodigo.Text.Equals("0"))
                        {
                            if (result12.UsuariosId != int.Parse(txtCodigo.Text))
                            {
                                XtraMessageBox.Show("Lamentamos mais este E-Mail já Existe no Sistema", "Erro de Email", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                txtEmail.Focus();
                                return(false);
                            }
                        }
                        else
                        {
                            XtraMessageBox.Show("Lamentamos mais este E-Mail já Existe no Sistema", "Erro de Email", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtEmail.Focus();
                            return(false);
                        }
                    }
                    // Pin
                    var t       = Encriptar.GetMD5Hash(txtPIN.Text.Trim());
                    var result1 = result.Where(x => x.Pin == t && x.GrupoId == (int)(txtGrupos.EditValue as Grupos).GrupoId).FirstOrDefault();
                    if (result1 != null)
                    {
                        if (!string.IsNullOrWhiteSpace(txtCodigo.Text) || !txtCodigo.Text.Equals("0"))
                        {
                            if (result1.UsuariosId != int.Parse(txtCodigo.Text))
                            {
                                XtraMessageBox.Show("Lamentamos mais este PIN Esta Indisponivel!...", "Erro de PIN", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                txtEmail.Focus();
                                return(false);
                            }
                        }
                        else
                        {
                            XtraMessageBox.Show("Lamentamos mais este PIN Esta Indisponivel!...", "Erro de PIN", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtEmail.Focus();
                            return(false);
                        }
                    }
                }
                else
                {
                    // Pin
                    var t       = Encriptar.GetMD5Hash(txtPIN.Text);
                    var result1 = result.Where(x => x.Pin == t && x.GrupoId == (int)(txtGrupos.EditValue as Grupos).GrupoId).FirstOrDefault();

                    if (result.Where(x => x.Pin == t && x.GrupoId == (int)(txtGrupos.EditValue as Grupos).GrupoId).Count() > 1)
                    {
                        if (!string.IsNullOrWhiteSpace(txtCodigo.Text) || !txtCodigo.Text.Equals("0"))
                        {
                            if (result1.UsuariosId != int.Parse(txtCodigo.Text))
                            {
                                XtraMessageBox.Show("Lamentamos mais este PIN Esta Indisponivel!...", "Erro de PIN", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                txtEmail.Focus();
                                return(false);
                            }
                        }
                        else
                        {
                            XtraMessageBox.Show("Lamentamos mais este PIN Esta Indisponivel!...", "Erro de PIN", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtEmail.Focus();
                            return(false);
                        }
                    }
                }
            }
            return(true);

            #endregion
        }