예제 #1
0
        private void ValidaLogin()
        {
            try
            {
                string usuarioadmin = "admin";
                string senhaadmin   = "123";
                usuario.Usuario1 = tx_usuario.Text;
                usuario.Senha    = tx_senha.Text;


                // Valida se os campos estao vazios.
                if (tx_usuario.Text.Length == 0 && tx_senha.Text.Length == 0 || tx_usuario.Text.Length == 0 || tx_senha.Text.Length == 0)
                {
                    lb_alerta.Text = "Dados Inválidos !";
                    lb_alerta.Show();
                    tx_senha.Clear();
                }
                else
                {
                    if (usuarioLogado(Banco.Listausuarios))
                    {
                        formprincipal homeForm = new formprincipal();
                        this.Visible = false;
                        this.Close();
                    }



                    else
                    {
                        if (usuario.Usuario1 == usuarioadmin && usuario.Senha == senhaadmin)
                        {
                            formprincipal homeForm = new formprincipal();
                            this.Visible = false;
                            this.Close();
                        }

                        else
                        {
                            lb_alerta.Text = "Dados Inválidos !";
                            lb_alerta.Show();
                            tx_senha.Clear();
                        }
                    }
                }
            }


            catch (Exception)
            {
                lb_alerta.Text = "Há algo de errado que não está certo !";
                lb_alerta.Show();
                tx_senha.Clear();
            }
        }
예제 #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            formprincipal TelaPrincipal = new formprincipal();

            TelaPrincipal.Show();
            login loginForm = new login();

            loginForm.ShowDialog(); // Run Login Form.

            Application.Run();
        }