示例#1
0
        private void verificaLogin()
        {
            try
            {
                ApiService           apiserv  = new ApiService();
                var                  json     = apiserv.fazRequisicaoPOST("https://slimws.tk/desktop/administradorExiste", "email=" + txtEmail.Text + "&senha=" + txtSenha.Text);
                JavaScriptSerializer js       = new JavaScriptSerializer();
                Mensagem             mensagem = js.Deserialize <Mensagem>(json);

                if (mensagem.code == 1)
                {
                    this.Hide();
                    FormPrincipal f = new FormPrincipal(mensagem.msg);
                    f.Closed += (s, args) => this.Close();
                    f.Show();
                }
                else
                {
                    txtEmail.Text = "";
                    txtSenha.Text = "";
                    txtEmail.Focus();
                    MessageBox.Show(mensagem.msg);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Houve um erro ao tentar se conectar com o servidor. " + err);
            }
        }
示例#2
0
        private void BTTornar_Click(object sender, EventArgs e)
        {
            this.Close();
            FormPrincipal mostraprincipal = new FormPrincipal();

            mostraprincipal.Show();
        }
示例#3
0
 private void BtnAcceder_Click(object sender, EventArgs e)
 {
     if (ValidarTxtUserContra())
     {
         if (Consulta.ValidarUsuario(TxtUsuario.Text, Encryption.Encrypt(TxtContraseña.Text)))
         {
             FormPrincipal  formPrincipal  = new FormPrincipal();
             FormBienvenida formBienvenida = new FormBienvenida();
             this.Hide();
             GuadarParaLog();
             InsertarLog();
             formBienvenida.ShowDialog();
             formPrincipal.Show();//Mostramos el Form Principal
             formPrincipal.FormClosed += CerrarFormPrincipal;
         }
         else
         {
             Soporte.MsgInformacion("Usuario o Contraseña es incorrecto intente nuevamente.");
             TxtContraseña.Text                  = "CONTRASEÑA";
             TxtContraseña.ForeColor             = Color.FromArgb(216, 27, 96);
             TxtContraseña.UseSystemPasswordChar = false;
             BtnTeclado.Text          = "Teclado en Pantalla";
             PanelTeclado.Visible     = false;
             LbMostrarPasword.Visible = false;
             PctbxOjo.Image           = Properties.Resources.ojo;
             TxtUsuario.Focus();
         }
     }
 }
示例#4
0
        private void _formLogin_button_login_Click(object sender, EventArgs e)
        {
            try {
                byte[] encodedPassword = new UTF8Encoding().GetBytes(_formLogin_textBox_password.Text);
                byte[] hash            = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(encodedPassword);
                string password_md5    = BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();

                dynamic resp = LoginService.Instance.Login(_formLogin_textBox_username.Text, password_md5);
                if (resp.code == 1)
                {
                    this.Hide();
                    var _formPrincipal = new FormPrincipal();
                    _formPrincipal.Closed += (s, args) => this.Close();
                    _formPrincipal.Show();
                }
                else
                {
                    MessageBox.Show((String)resp.msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            } catch (CustomException cex) {
                throw cex;
            } catch (Exception ex) {
                throw new CustomException(ex);
            }
        }
示例#5
0
        private void ACCEDER_Click(object sender, EventArgs e)
        {
            FormPrincipal frm = new FormPrincipal();

            frm.Show();
            //FormPrincipal.ActiveForm.Visible = false;
        }
示例#6
0
        public void btnIngresar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUserName.Text != "" && txtPassword.Text != "")
                {
                    // Armo usuario
                    Usuario user = new Usuario(txtUserName.Text);
                    if (txtUserName.Text == "admin")
                    {
                        // Pass hashing
                        UTF8Encoding  encoderHash   = new UTF8Encoding();
                        SHA256Managed hasher        = new SHA256Managed();
                        byte[]        bytesDeHasheo = hasher.ComputeHash(encoderHash.GetBytes(txtPassword.Text));
                        string        pass          = bytesDeHasheoToString(bytesDeHasheo);

                        if (!user.Password.Equals(pass))
                        {
                            // llamar a VIDA_ESTATICA.updateIntentos
                            user.ActualizarFallidos();
                            MessageBox.Show("Usuario y contraseña no validos", "Error!", MessageBoxButtons.OK);
                            txtPassword.Text = "";
                        }
                        else
                        {
                            // Está activo?
                            if (!user.Activo)
                            {
                                MessageBox.Show("Usuario inactivo para acceder al sistema", "Error!", MessageBoxButtons.OK);
                            }
                            else
                            {
                                user.ReiniciarFallidos();

                                // Paso al form Principal (requiere user siempre)
                                FormPrincipal formPrincipal = new FormPrincipal(user);
                                this.Hide();
                                formPrincipal.Show();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Usuario y contraseña no validos", "Error!", MessageBoxButtons.OK);
                        txtPassword.Text = "";
                    }
                }
                else
                {
                    MessageBox.Show("Complete todos los campos", "Error!", MessageBoxButtons.OK);
                }
            } catch {
                MessageBox.Show("Usuario y contraseña no validos", "Error!", MessageBoxButtons.OK);
                txtPassword.Text = "";
            }
        }
        public void btnIngresar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUserName.Text != "" && txtPassword.Text != "")
                {
                    // Armo usuario
                    Usuario user = new Usuario(txtUserName.Text);
                    if (txtUserName.Text == "admin")
                    {
                        // Pass hashing
                        UTF8Encoding encoderHash = new UTF8Encoding();
                        SHA256Managed hasher = new SHA256Managed();
                        byte[] bytesDeHasheo = hasher.ComputeHash(encoderHash.GetBytes(txtPassword.Text));
                        string pass = bytesDeHasheoToString(bytesDeHasheo);

                        if (!user.Password.Equals(pass))
                        {
                            // llamar a VIDA_ESTATICA.updateIntentos
                            user.ActualizarFallidos();

                            MessageBox.Show("Usuario y contraseña no validos", "Error!", MessageBoxButtons.OK);
                            txtPassword.Text = "";
                        }
                        else
                        {
                            // Está activo?
                            if (!user.Activo)
                                MessageBox.Show("Usuario inactivo para acceder al sistema", "Error!", MessageBoxButtons.OK);
                            else
                            {
                                user.ReiniciarFallidos();

                                // Paso al form Principal (requiere user siempre)
                                FormPrincipal formPrincipal = new FormPrincipal(user);
                                this.Hide();
                                formPrincipal.Show();
                            }
                        }
                    }
                    else
                    {

                        MessageBox.Show("Usuario y contraseña no validos", "Error!", MessageBoxButtons.OK);
                        txtPassword.Text = "";
                    }

                }
                else MessageBox.Show("Complete todos los campos", "Error!", MessageBoxButtons.OK);
            } catch {

                MessageBox.Show("Usuario y contraseña no validos", "Error!", MessageBoxButtons.OK);
                txtPassword.Text = "";
            }
        }
示例#8
0
        private void buttonEntrar_Click(object sender, EventArgs e)
        {
            progressBarLogin.Value = 0;

            while (progressBarLogin.Value < 100)
            {
                progressBarLogin.Value = progressBarLogin.Value + 2;
            }

            FormPrincipal frmp = new FormPrincipal();

            frmp.Show();
            this.Visible = false;
        }
示例#9
0
        private void TxtPassword_TextChanged(object sender, EventArgs e)
        {
            if (ValidarUsuario())
            {
                FormPrincipal  formPrincipal  = new FormPrincipal();
                FormBienvenida formBienvenida = new FormBienvenida();
                this.Hide();
                GuadarParaLog();
                InsertarLog();
                formBienvenida.ShowDialog();
                formPrincipal.Show();

                formPrincipal.FormClosed += CerrarFormPrincipal;
            }
        }
        private void btn_logar_Click(object sender, EventArgs e)
        {
            UsuarioModel uso = new UsuarioModel();

            uso = UsuarioDao.login(text_userName.Text, text_senha.Text);
            if (uso.Id > 0)
            {
                UsuarioLogado.usuario = uso;
                MessageBox.Show("Bem vindo " + uso.Nome);
                this.Dispose();
                form.Show();
            }
            else
            {
                MessageBox.Show("Usuario ou senha incoretos");
            }
        }
示例#11
0
        private void Ingresar()
        {
            if (txtUsername.Text != "USUARIO")
            {
                if (txtPassword.Text != "CONTRASEÑA")
                {
                    NUser user         = new NUser();
                    bool  validarLogin = user.LoginUser(txtUsername.Text, txtPassword.Text);

                    if (validarLogin)
                    {
                        if (UserCache.Estado == "A")
                        {
                            FormPrincipal principal = new FormPrincipal();
                            this.Hide();

                            LoginBienvenida bienvenida = new LoginBienvenida();
                            bienvenida.ShowDialog();

                            principal.Show();
                            principal.FormClosed += CerrarSesion;
                        }
                        else
                        {
                            MensajeError("Usuario deshabilitado.\n      Póngase en contacto con el administrador");
                        }
                    }
                    else
                    {
                        MensajeError("Usuario o contraseña incorrecta.\n      Por favor intente otra vez");
                        txtPassword.Clear();
                        txtUsername.SelectAll();
                        txtUsername.Focus();
                    }
                }
                else
                {
                    MensajeError("Por favor ingrese su contraseña");
                }
            }
            else
            {
                MensajeError("Por favor ingrese su usuario");
            }
        }
示例#12
0
        private void OnClickLogar(object sender, EventArgs e)
        {
            try {
                Validate Validate = new Validate(this, ErrorProvider);

                Validate.AddRule(textLogin, "Usuario", "required|email|max:100");
                Validate.AddRule(textSenha, "Senha", "required|min:4|max:20");
                Validate.Validation();

                if (Validate.IsValid())
                {
                    Usuario login = new Usuario();

                    login.Login       = textLogin.Text;
                    login.Senha       = textSenha.Text;
                    login.SalvarSenha = checkSalvarDados.Checked;
                    login.Logar();

                    if (login.Success)
                    {
                        Form FormPrincipal = new FormPrincipal();

                        Hide();

                        FormPrincipal.Closed += (fSender, eSender) => Close();
                        FormPrincipal.Show();
                    }
                    else
                    {
                        throw new Exception(login.Message);
                    }
                }
                else
                {
                    Validate.ErrorProviderShow();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
示例#13
0
        private void tanca()
        {
            FormPrincipal principal = new FormPrincipal();

            principal.Show();
        }
示例#14
0
        private void FEliminarGP_FormClosed(object sender, FormClosedEventArgs e)
        {
            FormPrincipal f = new FormPrincipal();

            f.Show();
        }
示例#15
0
        private void btnCadastrarInicial_Click(object sender, EventArgs e)
        {
            FormPrincipal form = new FormPrincipal();

            form.Show();
        }
示例#16
0
        private void FAfegirPilot_FormClosed(object sender, FormClosedEventArgs e)
        {
            FormPrincipal f = new FormPrincipal();

            f.Show();
        }
        //private void FMostrarEscuderies_Load(object sender, EventArgs e)
        //{
        //    escuderia[] esc = new escuderia[100];
        //    escuderia e1 = new escuderia();
        //    esc = e1.llegeixEscuderies();
        //    int i = 0;

        //    do
        //    {
        //        RTText.Text = RTText.Text + "Escuderia: " + esc[i].Nom
        //            + " (" + esc[i].Any_fundacio + ")"
        //            + "\nPais: " + esc[i].Pais
        //            + "\nMotor: " + esc[i].Motor + "\n\n";
        //        i++;
        //    } while (esc[i] != null);
        //}


        private void FMostrarEscuderia_FormClosing(object sender, FormClosingEventArgs e)
        {
            FormPrincipal f = new FormPrincipal();

            f.Show();
        }
示例#18
0
        private async void btnAcceder_Click(object sender, EventArgs e)  //Metodo asincrono para acceder a pantalla principal
        {
            if (txtUsername.Text != "User name" && txtPassword.Text != "Password")
            {
                string rutaArchivoCompleta = PathA + "Usuarios.xlsx";


                //Ingreso User name y Password
                lblAsteriscoUser.Visible = false;
                txtUsername.ForeColor    = Color.Silver;
                lblArteriscoPass.Visible = false;
                txtPassword.ForeColor    = Color.Silver;
                if (File.Exists(rutaArchivoCompleta)) //Pregrunto si el archivo existe
                {
                    SLDocument ArchivoExcel = new SLDocument(rutaArchivoCompleta);
                    int        iRow         = 2;
                    while (!string.IsNullOrEmpty(ArchivoExcel.GetCellValueAsString(iRow, 1)))
                    {
                        if (txtUsername.Text == ArchivoExcel.GetCellValueAsString(iRow, 2) && txtPassword.Text == ArchivoExcel.GetCellValueAsString(iRow, 3)) //Recorro el archivo y pregunto si existen las credenciales
                        {
                            encontrado = true;
                            IdUser     = ArchivoExcel.GetCellValueAsDouble(iRow, 1); //Obtengo el Id de Usuario
                        }

                        iRow++;
                    }
                    //Verificar si las credenciales son correctas
                    if (encontrado)
                    {
                        loading = new Loading();
                        FormPrincipal frmprincipal = new FormPrincipal(IdUser); //Paso como parametro al Id de usuario al formulario principal

                        //frmprincipal.WindowState = FormWindowState.Maximized;
                        loading.Show(); // Mostrar el loading
                        Task oTask = new Task(TiempoEspera);
                        oTask.Start();  // Se ejecuta el metodo asincrono
                        await oTask;
                        if (loading != null)
                        {
                            loading.Close();
                            frmprincipal.Show();
                            this.Visible = false;
                            frmprincipal.btnPerfil_Click(sender, e);
                        } //Ocultar el loading
                    }
                    else
                    {
                        MessageBox.Show("¡El usuario o contraseña son incorrectos!");
                    }
                }
                else
                {
                    MessageBox.Show("¡Lo sentimos... No hay usuarios registrados!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtUsername.Text = "User name";
                    txtPassword.Text = "Password";
                    txtPassword.UseSystemPasswordChar = false;
                }
            }
            else if (txtUsername.Text == "User name" && txtPassword.Text == "Password")
            {
                lblAsteriscoUser.Visible = true;
                txtUsername.ForeColor    = Color.Red;
                lblArteriscoPass.Visible = true;
                txtPassword.ForeColor    = Color.Red;
            }
            else if (txtUsername.Text == "User name" && txtPassword.Text != "Password")
            {
                lblAsteriscoUser.Visible = true;
                txtUsername.ForeColor    = Color.Red;
                lblArteriscoPass.Visible = false;
            }
            else if (txtUsername.Text != "User name" && txtPassword.Text == "Password")
            {
                lblAsteriscoUser.Visible = false;
                lblArteriscoPass.Visible = true;
                txtPassword.ForeColor    = Color.Red;
            }
            else if (txtUsername.Text == "" && txtPassword.Text == "Password")
            {
                lblAsteriscoUser.Visible = true;
                txtUsername.ForeColor    = Color.Red;
                lblArteriscoPass.Visible = true;
                txtPassword.ForeColor    = Color.Red;
            }
            else if (txtUsername.Text == "User name" && txtPassword.Text == "")
            {
                lblAsteriscoUser.Visible = true;
                txtUsername.ForeColor    = Color.Red;
                lblArteriscoPass.Visible = true;
                txtPassword.ForeColor    = Color.Red;
            }
        }
示例#19
0
        private void FModificarEscuderia_FormClosed(object sender, FormClosedEventArgs e)
        {
            FormPrincipal f = new FormPrincipal();

            f.Show();
        }
示例#20
0
        private void FMostraMecanics_FormClosed(object sender, FormClosedEventArgs e)
        {
            FormPrincipal f = new FormPrincipal();

            f.Show();
        }