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 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(); } }
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(); } }
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(); }
private int GetExistingData() { return(UsuariosInstaciaList.Where(x => (x.Login == txtLogin.Text && x.Senha == txtSenha.Text) || x.Pin == txtPIN.Text).Count()); }