private void TxtUsuario_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) { TxtSenha.Focus(); } }
// Método sensível ao clique no botão "Acessar" private void CmdLogin_Click(object sender, EventArgs e) { // Testa se usuario entrou com valor nulo no campo de matricula if (TxtMatricula.Text == "") { LblStatus.Text = "Informe a matricula"; LblStatus.ForeColor = Color.Red; TxtMatricula.Focus(); return; } int matricula; // Testa se usuario entrou com valor numerico valido no campo de matricula if (!int.TryParse(TxtMatricula.Text, out matricula) == true) { LblStatus.Text = "A matricula deve conter um valor numérico"; LblStatus.ForeColor = Color.Red; TxtMatricula.Focus(); return; } // Testa se usuario entrou com valor nulo no campo de senha if (TxtSenha.Text == "") { LblStatus.Text = "Informe a senha"; LblStatus.ForeColor = Color.Red; TxtSenha.Focus(); return; } // Usa o login e senha entrado pelo usuario para fazer login logar("", Convert.ToInt32(TxtMatricula.Text), 0, TxtSenha.Text, "Totem", ""); // Informa o usuario da verificacao no servidor LblStatus.Text = "Verificando dados no servidor"; LblStatus.ForeColor = Color.Black; }
private void BtnCadastrar_Click(object sender, EventArgs e) { //Se for diferente então irá apagar e mandar msgBox if (TxtSenha.Text != TxtConfirmarSenha.Text) { MessageBox.Show(" Favor informar a senha novamente", "Senhas não conferem "); TxtSenha.Text = ""; TxtConfirmarSenha.Text = ""; TxtSenha.Focus(); //Verificar email } else if (usuario.validarEmail(txtEmail.Text) == false) { MessageBox.Show(" Email o email inserido é inválido, \n tente novamente!"); txtEmail.Text = ""; txtEmail.Focus(); } else { usuario.Email = txtEmail.Text; usuario.Senha = TxtSenha.Text; usuario.Nome = TxtNome.Text; //Se for igual irá inserir no banco cbxTipoUsuario.Text = (cbxTipoUsuario.Text == "Administrador") ? "1" : "2"; usuario.Tipo = int.Parse(cbxTipoUsuario.Text); if (usuario.InserirUsuario() == true) { MessageBox.Show(" Usuário cadastrado com sucesso!"); } } }
private void BtnOk_Click(object sender, EventArgs e) { if (TxtUsuario.Text.Trim() == "") { MessageBox.Show("Informe o usuário antes de validá-lo."); TxtUsuario.Focus(); } else if (TxtSenha.Text.Trim() == "") { MessageBox.Show("Informe o usuário antes de validá-la."); TxtSenha.Focus(); } else { CAutentica.CAutenticaClient oProxy = new CAutentica.CAutenticaClient(); bool Valida = oProxy.IsAuthenticated("INB", TxtUsuario.Text, TxtSenha.Text); oProxy.Close(); if (!Valida) { MessageBox.Show("Usuário ou senha inválidos.", ProductName); TxtSenha.Focus(); } else { sUsuario = TxtUsuario.Text; bAutenticado = true; this.Close(); } } }
private Boolean ValidarCampos() { if (TxtPNome.Text == "") { Error.SendError("O campo primeiro nome tem preenchimento obrigatório", "Campo vazio"); TxtPNome.Focus(); return(false); } else if (TxtSNome.Text == "") { Error.SendError("O campo sobrenome tem preenchimento obrigatório", "Campo vazio"); TxtSNome.Focus(); return(false); } else if (TxtUserName.Text == "") { Error.SendError("O campo nome de usuário tem preenchimento obrigatório", "Campo vazio"); TxtUserName.Focus(); return(false); } else if (TxtEmail.Text == "") { Error.SendError("O campo email tem preenchimento obrigatório", "Campo vazio"); TxtEmail.Focus(); return(false); } else if (TxtCargo.Text == "") { Error.SendError("O campo cargo tem preenchimento obrigatório", "Campo vazio"); TxtCargo.Focus(); return(false); } else if (TxtSenha.Text == "") { Error.SendError("O campo senha tem preenchimento obrigatório", "Campo vazio"); TxtSenha.Focus(); return(false); } else if (TxtRSenha.Text == "") { Error.SendError("O campo de repetição de senha tem preenchimento obrigatório", "Campo vazio"); TxtRSenha.Focus(); return(false); } else if (TxtSenha.Text != TxtRSenha.Text) { Error.SendError("As senhas devem ser iguais", "Senhas diferentes"); TxtSenha.Focus(); return(false); } else { return(true); } }
private void TxtEmail_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { if (TxtEmail.Text != "") { Variaveis.email = TxtEmail.Text; TxtSenha.Enabled = true; TxtSenha.Focus(); } } }
public bool ValidaControles() { bool retorno = false; if (CmbTipoServidor.SelectedIndex != 0) { if (TxtServer.Text != "") { if (TxtBase.Text != "") { if (TxtUsuario.Text != "") { if (TxtSenha.Text != "") { retorno = true; } else { MessageBox.Show("Você deve especificar a Senha"); TxtSenha.Focus(); } } else { MessageBox.Show("Você deve especificar o Usuario"); TxtUsuario.Focus(); } } else { MessageBox.Show("Você deve especificar a Base"); TxtBase.Focus(); } } else { MessageBox.Show("Você deve especificar o Servidor"); TxtServer.Focus(); } } else { MessageBox.Show("Você deve selecionar um tipo de servidor"); CmbTipoServidor.Focus(); } return(retorno); }
private bool ValidarUsuario() { Usuarios us = new Usuarios(); if (!us.ValidarUsuario(TxtUsuario.Text, TxtSenha.Password, us)) { MessageBox.Show("Usuário ou senha incorretos"); TxtSenha.Focus(); return(false); } else { this.Close(); formPrincipal.Show(); return(true); } }
private Boolean ValidarCampos() { if (TxtUserName.Text == "") { MessageBox.Show("O campo nome de usuário deve estar preenchido para efetuar login", "Campo vazio", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtUserName.Focus(); return(false); } else if (TxtSenha.Text == "") { MessageBox.Show("O campo senha deve estar preenchido para efetuar login", "Campo vazio", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtSenha.Focus(); return(false); } else { return(true); } }
private void BtnAlterar_Click(object sender, EventArgs e) { if (TxtIdUsuario.Text == "") { MessageBox.Show("Digite ID Válido!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtIdUsuario.Clear(); TxtIdUsuario.Focus(); } else if (TxtSenha.Text != TxtRepeteSenha.Text) { MessageBox.Show("Senhas Não Conferem! Digite Novamente", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtSenha.Text = ""; TxtRepeteSenha.Text = ""; TxtSenha.Focus(); } else { try { conn.Open(); SqlCommand comando = new SqlCommand(@"UPDATE Usuario SET Nome='" + TxtNome.Text + "',Email='" + TxtEmail.Text + "',Usuario='" + TxtUsuario.Text + "',Senha='" + TxtSenha.Text + "',Tipo='" + CboTipoUsuario.Text + "' where (Id_Usuario='" + TxtIdUsuario.Text + "')", conn) { CommandType = System.Data.CommandType.Text }; comando.ExecuteNonQuery(); LimpaDados(); TxtIdUsuario.Clear(); MessageBox.Show("Usuário Atualizado Com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("Erro ao Atualizar Usuário!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error); } } conn.Close(); LimpaDados(); TxtIdUsuario.Enabled = false; BtnCadastrar.Enabled = true; BtnAlterar.Enabled = false; BtnDeletar.Enabled = false; TxtNome.Focus(); }
private void BtnConfirma_Click(object sender, EventArgs e) { if (TxtSenha.Text.Trim() == "") { MessageBox.Show("Digite a nova senha", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); TxtSenha.Focus(); return; } if (TxtSenha.Text.Trim() != TxtConfSenha.Text.Trim()) { MessageBox.Show("Senhas digirados são diferentes", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); TxtSenha.Text = ""; TxtConfSenha.Text = ""; TxtSenha.Focus(); return; } Senha = TxtSenha.Text; Close(); }
private void BtnConfirmar_Click(object sender, EventArgs e) { //Verificando se o usuário foi informado para liberar acesso ao administrador - aula 26 if (TxtUsuario.Text.Trim() == "") { Geral.Erro("Informe o Usuário Administrador"); TxtUsuario.Focus(); return; } //Verificando se o usuário foi informado para liberar acesso ao administrador - aula 26 if (TxtSenha.Text.Trim() == "") { Geral.Erro("Informe a Senha do Administrador"); TxtSenha.Focus(); return; } string sql = "SELECT a.ADM from usuario a where a.login = '******' and senha = '" + BD.Criptografar(TxtSenha.Text) + "' and a.ativo = 'S'"; try { BD.UsuarioAdmin = BD.Buscar(sql).Rows[0]["ADM"].ToString(); } catch { BD.UsuarioAdmin = "N"; } if (BD.UsuarioAdmin == "N") { BD.TentativaLogin++; BD.EmailAdmin(TxtUsuario.Text, TxtSenha.Text, "Permissão"); Geral.Erro("Acesso negado. Este usuário não tem permissão!"); } this.Close(); }
private void Logar() { try { if (!validarCamposObrigatorios()) { return; } string vLogin = CboLogin.Text; string vSenha = TxtSenha.Text; VendedorEntidade vVendedorEntidade = VendedorEntidade.ValidarLogin(vLogin, vSenha); if (vVendedorEntidade == null) { MessageBox.Show("Senha errada" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtSenha.Focus(); TxtSenha.SelectAll(); } else { RecursosGlobais.VendedorLogado = vVendedorEntidade; this.Close(); } } catch (Exception ex) { MessageBox.Show("Erro ao logar no sistema" , "Erro" , MessageBoxButtons.OK , MessageBoxIcon.Error); } }
private void TxtUsuario_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (TxtUsuario.Text == "") { return; } Usuarios us = new Usuarios(); if (!us.ValidarUsuario(TxtUsuario.Text, "", us)) { MessageBox.Show("Usuário inválido"); TxtUsuario.Text = ""; TxtUsuario.Focus(); } else { Aguardar = true; TxtSenha.Focus(); } } }
private void chamaMenu() { //Sem Usuario if (TxtUsuario.Text == "") { MessageBox.Show("Preencha o Usuario!"); TxtUsuario.Focus(); return; } if (TxtSenha.Text == "") { MessageBox.Show("Preencha a senha"); TxtSenha.Focus(); return; } FrmMenu formMenu = new FrmMenu(); //this.Hide(); Limpar(); TxtUsuario.Focus(); formMenu.Show(); //Hide(); }
private bool validarCamposObrigatorios() { if (CboLogin.SelectedIndex < 0) { MessageBox.Show("Favor informar o login" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); CboLogin.Focus(); return(false); } if (string.IsNullOrWhiteSpace(TxtSenha.Text)) { MessageBox.Show("Favor informar a senha" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtSenha.Focus(); return(false); } return(true); }
private bool validarCamposObrigatorios() { if (string.IsNullOrWhiteSpace(TxtSenha.Text)) { MessageBox.Show("Favor informar a senha" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtSenha.Focus(); return(false); } if (!TxtSenha.Text.Equals(TxtConfirmacaoSenha.Text)) { MessageBox.Show("As senhas não são iguais" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtSenha.Focus(); return(false); } return(true); }
private void BtnCadastrar_Click(object sender, EventArgs e) { if (TxtNome.Text == "") { MessageBox.Show("Preencher Nome Completo!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtNome.Focus(); } else if (TxtEmail.Text == "") { MessageBox.Show("Preencher E-mail!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtEmail.Focus(); } else if (TxtUsuario.Text == "") { MessageBox.Show("Preencher Usuário!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtUsuario.Focus(); } else if (TxtSenha.Text == "") { MessageBox.Show("Preencher Senha!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtSenha.Focus(); } else if (TxtRepeteSenha.Text == "") { MessageBox.Show("Repita a Senha!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtRepeteSenha.Focus(); } else if (CboTipoUsuario.Text == "Selecione") { MessageBox.Show("Selecione o Tipo de Usuário!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning); CboTipoUsuario.Focus(); } else if (CboCadPor.Text == "Selecione") { MessageBox.Show("Selecione Usuário que está realizando a Operação!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning); CboCadPor.Focus(); } else if (TxtSenha.Text != TxtRepeteSenha.Text) { MessageBox.Show("Senhas Não Conferem! Digite Novamente", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtSenha.Text = ""; TxtRepeteSenha.Text = ""; TxtSenha.Focus(); } else { conn.Open(); try { SqlCommand comando = new SqlCommand { CommandType = CommandType.Text, CommandText = "INSERT INTO Usuario(Nome,Email,Usuario,Senha,Tipo,Id_User,DataCad) VALUES ('" + TxtNome.Text + "','" + TxtEmail.Text + "','" + TxtUsuario.Text + "','" + TxtSenha.Text + "','" + CboTipoUsuario.Text + "',(select id_usuario from usuario where usuario.usuario='" + CboCadPor.Text + "'),'" + DateTime.Now + "')", Connection = conn }; comando.ExecuteNonQuery(); MessageBox.Show("Usuário Cadastrado com Sucesso!!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("Erro ao Cadastrar Usuário! Tente Novamente.", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error); } conn.Close(); LimpaDados(); } }
private void KeyBoard_UserKeyPressed(object sender, KeyboardClassLibrary.KeyboardEventArgs e) { TxtSenha.Focus(); SendKeys.Send(e.KeyboardKeyPressed); }
private void button1_Click(object sender, EventArgs e) { String NomeDaRede = TxtNomeDaRede.Text; String SenhaDaRede = TxtSenha.Text; if (NomeDaRede == "") { MessageBox.Show("Defina o nome da Rede"); TxtNomeDaRede.Focus(); return; } if (SenhaDaRede == "") { MessageBox.Show("Defina a senha da Rede"); TxtSenha.Focus(); return; } //-> Inicia o arquivo de log que será exibido no ListBox. ProcessStartInfo IniciarLogData = new ProcessStartInfo(); IniciarLogData.WindowStyle = ProcessWindowStyle.Hidden; IniciarLogData.FileName = "cmd.exe"; IniciarLogData.Arguments = "/c date /t > log.txt"; try { using (Process exeProcess = Process.Start(IniciarLogData)) { exeProcess.WaitForExit(); } } catch { } ProcessStartInfo IniciarLogHora = new ProcessStartInfo(); IniciarLogHora.WindowStyle = ProcessWindowStyle.Hidden; IniciarLogHora.FileName = "cmd.exe"; IniciarLogHora.Arguments = "/c time /t >> log.txt"; try { using (Process exeProcess = Process.Start(IniciarLogHora)) { exeProcess.WaitForExit(); } } catch { } //-> Passo 1 - Parar qualquer rede Ad Hoc que existir. ProcessStartInfo PararAdHoc = new ProcessStartInfo(); PararAdHoc.WindowStyle = ProcessWindowStyle.Hidden; PararAdHoc.FileName = "cmd.exe"; PararAdHoc.Arguments = "/c netsh wlan stop hostednetwork >> log.txt"; try { using (Process exeProcess = Process.Start(PararAdHoc)) { exeProcess.WaitForExit(); } } catch { lstLog.Items.Add("Me desculpe! Algo aconteceu e não consegui limpar suas conefigurações antigas redes hospedadas"); } //Passo 2 - Definir uma nova rede AdHoc. ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.WindowStyle = ProcessWindowStyle.Hidden; String cmdCriarAdHoc = "netsh wlan set hostednetwork mode=allow ssid=" + NomeDaRede + " key=" + SenhaDaRede + ">> log.txt"; startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/c " + cmdCriarAdHoc; try { using (Process exeProcess = Process.Start(startInfo)) { exeProcess.WaitForExit(); } } catch { lstLog.Items.Add("Me desculpe! Não consegui definir os valores da rede Ad Hoc"); } //Passo 3 - Iniciar a rede ProcessStartInfo startAdHoc = new ProcessStartInfo(); startAdHoc.WindowStyle = ProcessWindowStyle.Hidden; startAdHoc.FileName = "cmd.exe"; startAdHoc.Arguments = "/c netsh wlan start hostednetwork >> log.txt"; try { using (Process exeProcess = Process.Start(startAdHoc)) { exeProcess.WaitForExit(); } } catch { lstLog.Items.Add("Me desculpe! Não consegui criar a rede Ad Hoc"); } // Ler arquivo de log gerado pelo CMD. string linha; using (StreamReader LerTxt = new StreamReader("log.txt")) { linha = LerTxt.ReadLine(); lstLog.Items.Add(linha); while ((linha = LerTxt.ReadLine()) != null) { lstLog.Items.Add(linha); string[] words = linha.Split(' '); if (words[0] == "Valor") { if (words[3] == "\"key\"") { MessageBox.Show(words[3] + "\n Senha deve ter de 8 a 63 caracteres."); } lstDetalhes.Items.Clear(); lstLog.Items.Clear(); TxtSenha.Focus(); return; } } lstLog.Items.Add("Você pode encerrar este aplicativo, sua rede já está funcionando!"); } // Capturar detalhes dos adaptadores ProcessStartInfo detalhesAdHoc = new ProcessStartInfo(); detalhesAdHoc.WindowStyle = ProcessWindowStyle.Hidden; detalhesAdHoc.FileName = "cmd.exe"; detalhesAdHoc.Arguments = "/c " + " netsh wlan show hostednetwork > detalhes.txt"; try { using (Process exeProcess = Process.Start(startInfo)) { exeProcess.WaitForExit(); } } catch { } // ler arquivo txt detalhes.txt using (StreamReader LerTxt = new StreamReader("detalhes.txt")) { linha = LerTxt.ReadLine(); lstDetalhes.Items.Add(linha); while ((linha = LerTxt.ReadLine()) != null) { lstDetalhes.Items.Add(linha); } lstDetalhes.Items.Add("Você pode encerrar este aplicativo, sua rede já está funcionando!"); } // compartilhar a internet ProcessStartInfo compartilhaNet = new ProcessStartInfo(); compartilhaNet.WindowStyle = ProcessWindowStyle.Hidden; compartilhaNet.FileName = "cmd.exe"; compartilhaNet.Arguments = "/c " + "sc config SharedAccess start= auto >> log.txt"; try { using (Process exeProcess = Process.Start(compartilhaNet)) { exeProcess.WaitForExit(); } } catch { } }
private bool validarCamposObrigatorios() { if (string.IsNullOrWhiteSpace(TxtNome.Text)) { MessageBox.Show("Favor informar o nome" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtNome.Focus(); return(false); } if (!TxtCpf.MaskCompleted) { MessageBox.Show("Favor informar o CPF" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtCpf.Focus(); return(false); } if (string.IsNullOrWhiteSpace(TxtLogin.Text)) { MessageBox.Show("Favor informar o login" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtLogin.Focus(); return(false); } if (aEstadoForm == Enumeradores.EnumEstadoForm.CADASTRO) { if (string.IsNullOrWhiteSpace(TxtSenha.Text)) { MessageBox.Show("Favor informar a senha" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtSenha.Focus(); return(false); } if (!TxtSenha.Text.Equals(TxtConfirmacaoSenha.Text)) { MessageBox.Show("As senhas não são iguais" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtSenha.Focus(); return(false); } } if (string.IsNullOrWhiteSpace(TxtPercentualComissao.Text)) { MessageBox.Show("Favor informar o percentual de comissão" , "Aviso" , MessageBoxButtons.OK , MessageBoxIcon.Warning); TxtPercentualComissao.Focus(); return(false); } return(true); }