Exemplo n.º 1
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();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void List_Async()
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                txtPesquizar.Enabled = false;

                if (string.IsNullOrWhiteSpace(txtPesquizar.Text))
                {
                    usuariosBindingSource.DataSource = UsuariosInstaciaList.ToList();
                }
                else
                {
                    usuariosBindingSource.DataSource = UsuariosInstaciaList
                                                       .Where(x => x.UsuarioNomeCompleto.ToUpper()
                                                              .Contains(txtPesquizar.Text.ToLower()) ||
                                                              x.Login.ToUpper()
                                                              .Contains(txtPesquizar.Text.ToUpper())).ToList();
                }
            }
            finally
            {
                //prog.Mostrar_Close(this);
                Cursor = Cursors.Default;
                this.txtPesquizar.Enabled = true;
                this.txtPesquizar.Focus();
            }
        }
Exemplo n.º 3
0
        private void Edit(int I, string user)
        {
            try
            {
                prog.Mostrar(this, "Aguarde!...", "Aguarde");

                var item = UsuariosInstaciaList.Where(x => x.UsuariosId == I ||
                                                      x.UsuarioNomeCompleto.ToLower() == user.ToLower()).FirstOrDefault();

                if (item != null)
                {
                    txtCodigo.Text        = item.UsuariosId.ToString();
                    txtNomeCompleto.Text  = item.UsuarioNomeCompleto;
                    txtApelido.Text       = item.Apelido;
                    txtLogin.Text         = item.Login;
                    txtSenha.Text         = item.Senha;
                    txtRepetir_Senha.Text = item.Senha;
                    dateEdit1.EditValue   = item.DataNascimento;
                    txtEmail.Text         = item.Email;
                    txtPIN.Text           = item.Pin;
                    checkEdit1.EditValue  = item.Estado;
                    txtGrupos.EditValue   = item.GrupoId;

                    UserPassword = item.Senha;
                    UserPIN      = item.Pin;

                    var ImagemProd = item.Perfil;
                    if (ImagemProd != null)
                    {
                        ImagemPictureEdit.Image = (Image)ImagemTratamento.byteArrayToImage(item.Perfil);
                        ImagemProd = null;
                    }
                    else
                    {
                        ImagemPictureEdit.Image = null;
                    }
                }
                txtNomeCompleto.Focus();
            }
            catch (System.Exception exe)
            {
                MessageBox.Show("Erro ao passar Dados" + exe.Message, "Erro de Dados", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                prog.Mostrar_Close(this);
                txtNomeCompleto.Focus();
            }
        }
Exemplo n.º 4
0
        private void Inicializar(string Titulim)
        {
            Text = Titulim;
            txtNomeCompleto.TextChanged += TxtNomeCompleto_TextChanged;

            // Instacias Inicias
            prog              = new Progress_Bar();
            this.FormClosing += new FormClosingEventHandler(FrmModelos_FormClosing);

            // Chamadas dos Botões
            btnNovo.Click     += new EventHandler(BtnNovo_TextChangedAsync);
            btnGuardadr.Click += new EventHandler(BtnGuardadr_TextChanged);
            btnApagar.Click   += new EventHandler(BtnApagar_Click);

            txtCodigo.TextChanged += new EventHandler(TxtCodigo_TextChanged);

            this.Load += frmModern__LoadAsync;

            brnRefresk.Click += delegate { Listar_Tudo(); };

            txtCodigo.ButtonClick += delegate
            {
                try
                {
                    Cursor = Cursors.WaitCursor;

                    dataGridView1.Rows.Clear();

                    foreach (var item in UsuariosInstaciaList)
                    {
                        dataGridView1.Rows.Add(item.UsuariosId, item.UsuarioNomeCompleto);
                    }

                    flyoutPanel1.ShowBeakForm();
                    txtPesquisa_Flag.Focus();
                }
                catch (System.Exception exception)
                {
                    MessageBox.Show("Erro " + exception, "Erro de SQL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            };
            dataGridView1.MouseDoubleClick += delegate {
                if (dataGridView1.Rows.Count > 0)
                {
                    txtCodigo.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); flyoutPanel1.HidePopup(); Edit(Convert.ToInt32(txtCodigo.Text), "");
                }
                ;
            };
            txtPesquisa_Flag.TextChanged += TxtPesquisa_Flag_TextChanged;

            #region Validações Rapidas dos Campos
            txtGrupos.TextChanged += delegate { if (!txtGrupos.Text.Equals(string.Empty))
                                                {
                                                    errorProvider1.Clear();
                                                }
                                                else
                                                {
                                                    errorProvider1.SetError(txtGrupos, "Atenção Este campo tem que ter valores");
                                                } };
            txtNomeCompleto.TextChanged += delegate { if (!txtNomeCompleto.Text.Equals(string.Empty))
                                                      {
                                                          errorProvider1.Clear();
                                                      }
                                                      else
                                                      {
                                                          errorProvider1.SetError(txtNomeCompleto, "Atenção Este campo tem que ter valores");
                                                      } };
            txtApelido.TextChanged += delegate { if (!txtApelido.Text.Equals(string.Empty))
                                                 {
                                                     errorProvider1.Clear();
                                                 }
                                                 else
                                                 {
                                                     errorProvider1.SetError(txtApelido, "Atenção Este campo tem que ter valores");
                                                 } };
            txtLogin.TextChanged += delegate { if (!txtLogin.Text.Equals(string.Empty))
                                               {
                                                   errorProvider1.Clear();
                                               }
                                               else
                                               {
                                                   errorProvider1.SetError(txtLogin, "Atenção Este campo tem que ter valores");
                                               } };
            txtSenha.TextChanged += delegate { if (!txtSenha.Text.Equals(string.Empty))
                                               {
                                                   errorProvider1.Clear();
                                               }
                                               else
                                               {
                                                   errorProvider1.SetError(txtSenha, "Atenção Este campo tem que ter valores");
                                               } };
            txtRepetir_Senha.TextChanged += delegate { if (!txtRepetir_Senha.Text.Equals(string.Empty))
                                                       {
                                                           errorProvider1.Clear();
                                                       }
                                                       else
                                                       {
                                                           errorProvider1.SetError(txtRepetir_Senha, "Atenção Este campo tem que ter valores");
                                                       } };
            txtPIN.TextChanged += delegate { if (!txtPIN.Text.Equals(string.Empty))
                                             {
                                                 errorProvider1.Clear();
                                             }
                                             else
                                             {
                                                 errorProvider1.SetError(txtPIN, "Atenção Este campo tem que ter valores");
                                             } };
            #endregion

            //txtSenha.Validating += delegate {
            //    OnValidatePassword(new object(),
            //                       new ValidatePasswordEventArgs("", txtSenha.Text, true));
            //};
            txtEmail.Validating += TxtEmail_Validating;


            // Validações dos Valores da PAssword 1
            txtSenha.GotFocus += delegate {
                if (string.IsNullOrWhiteSpace(UserPassword))
                {
                    isNew = true;
                }
                else
                {
                    txtSenha.Text = string.Empty;
                }
            };

            txtSenha.LostFocus += delegate {
                if (string.IsNullOrWhiteSpace(UserPassword))
                {
                    return;
                }
                else if (!string.IsNullOrWhiteSpace(UserPassword) && string.IsNullOrWhiteSpace(txtSenha.Text))
                {
                    txtSenha.Text = UserPassword; isNew = false;
                }
                else
                {
                    isNew = true;
                }
            };

            // Validações dos Valores da PAssword 2
            txtRepetir_Senha.GotFocus += delegate {
                if (string.IsNullOrWhiteSpace(UserPassword))
                {
                    isNew = true;
                }
                else
                {
                    txtRepetir_Senha.Text = string.Empty;
                }
            };

            txtRepetir_Senha.LostFocus += delegate {
                if (string.IsNullOrWhiteSpace(UserPassword))
                {
                    return;
                }
                else if (!string.IsNullOrWhiteSpace(UserPassword) && string.IsNullOrWhiteSpace(txtRepetir_Senha.Text))
                {
                    txtRepetir_Senha.Text = UserPassword; isNew = false;
                }
                else
                {
                    isNew = true;
                }
            };

            // Validações dos Valores da PIN
            txtPIN.GotFocus += delegate {
                if (string.IsNullOrWhiteSpace(UserPassword))
                {
                    isNew = true;
                }
                else
                {
                    txtPIN.Text = string.Empty;
                }
            };

            txtPIN.LostFocus += delegate {
                if (string.IsNullOrWhiteSpace(UserPassword))
                {
                    return;
                }
                else if (!string.IsNullOrWhiteSpace(UserPassword) && string.IsNullOrWhiteSpace(txtPIN.Text))
                {
                    txtPIN.Text = UserPassword; isNew = false;
                }
                else
                {
                    isNew = true;
                }
            };
            txtPIN.TextChanged += delegate
            {
                #region Validar
                //string actualdata = string.Empty;
                //char[] entereddata = txtPIN.Text.ToCharArray();

                //foreach (char aChar in entereddata.AsEnumerable())
                //{
                //    if (Char.IsDigit(aChar))
                //    {
                //        actualdata = actualdata + aChar;
                //        // MessageBox.Show(aChar.ToString());
                //    }
                //    else
                //    {
                //        MessageBox.Show(aChar + " is not numeric");
                //        actualdata.Replace(aChar, ' ');
                //        actualdata.Trim();
                //    }
                //}
                //txtPIN.Text = actualdata;
                #endregion
            };
            txtPIN.KeyPress += (sender, e) =>
            {
                #region Validar
                // Text
                string text = ((Control)sender).Text;

                // Is Negative Number?
                if (e.KeyChar == '-' && text.Length == 0)
                {
                    e.Handled = false;
                    return;
                }
                // Is Float Number?
                if (e.KeyChar == '.' && text.Length > 0 && !text.Contains("."))
                {
                    e.Handled = false;
                    return;
                }
                // Is Digit?
                e.Handled = (!char.IsDigit(e.KeyChar));
                #endregion
            };

            txtPIN.Validating += (sender, e) =>
            {
                var t      = Encriptar.GetMD5Hash(txtEmail.Text);
                var result = UsuariosInstaciaList.Where(x => x.Pin == t && x.GrupoId == (int)txtGrupos.EditValue)
                             .FirstOrDefault();
                if (result != null)
                {
                    if (!string.IsNullOrWhiteSpace(txtCodigo.Text) || !txtCodigo.Text.Equals("0"))
                    {
                        if (result.UsuariosId != int.Parse(txtCodigo.Text))
                        {
                            XtraMessageBox.Show("Lamentamos mais este PIN Esta Indisponivel!...", "PIN Indisponivel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtEmail.Focus();
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Lamentamos mais este PIN Esta Indisponivel!...", "PIN Indisponivel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtEmail.Focus();
                    }
                }
            };
            txtNomeCompleto.KeyDown += TxtNomeCompleto_KeyDown1;
            ListGeral();
        }
Exemplo n.º 5
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
        }
Exemplo n.º 6
0
 private int GetExistingData()
 {
     return(UsuariosInstaciaList.Where(x => (x.Login == txtLogin.Text && x.Senha == txtSenha.Text) || x.Pin == txtPIN.Text).Count());
 }