Jump to content


Photo

Area De Login Com Cadastro De Usuários.


  • Faça o login para participar
Nenhuma resposta neste tópico

#1 rafael200

rafael200

    Novato no fórum

  • Usuários
  • 3 posts
  • Sexo:Masculino

Posted 30/11/2011, 18:31

Boa Tarde...

Eu estou desenvolvendo uma aplicação e gostaria de saber, se é possível fazer um cadastro onde que o usuário cadastre e depois ele loga com o usuário cadastrado.
Se precisar segue o código, se tiver certo:
Este é do formulário de login.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Sistema_e_Learning_Advanced_Plus
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void lblCad_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            CadastroUsuario cser = new CadastroUsuario();
            cser.Show();
        }

        private void btnAcessa_Click(object sender, EventArgs e)
        {
            frmPrincipal princ = new frmPrincipal();
            SqlConnection con = new SqlConnection("Data Source = Nome-PC\\SQLEXPRESS; Initial Catalog = table; Integrated Security = true;");
            SqlDataAdapter da = new SqlDataAdapter("SELECT Usuario, Senha FROM dbo.CadUser", con);
            con.Open();
            if (txtUser.Text == "")
            {

                da.SelectCommand.CommandText = txtUser.Text;
            }
            else if (txtPass.Text == "")
            {
                da.SelectCommand.CommandText = txtPass.Text;
            }
            else
            {
                MessageBox.Show("Bem Vindo Usuário.");
            }

           
        }
    }
}

este é do cadastro de usuários.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Sistema_e_Learning_Advanced_Plus
{
    public partial class CadastroUsuario : Form
    {
        public CadastroUsuario()
        {
            InitializeComponent();
        }

        private void btnCad_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("Data Source = Nome-PC\\SQLEXPRESS; Initial Catalog = table; Integrated Security = true;");
            SqlCommand cmd = new SqlCommand("INSERT INTO dbo.CadUser VALUES(@usuario, @Senha)", con);
            con.Open();
            try
            {
                cmd.Parameters.AddWithValue("@Usuario", txtUser.Text);
                cmd.Parameters.AddWithValue("@Senha", txtPass.Text);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Usuário e/ou Senha Incorreta!" + ex);
            }
            finally
            {
                cmd.ExecuteNonQuery();
                con.Close();
            }
        }
    }
}


Obrigado pela atenção.




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq