Fecha Inicial : 12/04/2018
Fecha Final : 12/04/2018
Hora Inicio: 08:29 PM
Hora Final: 10:24PM
Horas invertidas(Minutos): 115
Colaboradores: Oscar Cortés, Wilson Lopez
Actividad:
Solucionar problema de conexión entre SMSS y Visual Studio

Ingresar datos completos a la BD (check)
Validación de los datos para inicio de sesión


Comentarios:
"¿Actividad? Paranormal." Referencias:
Codigo:
Conexión SSMS a VS y validación de datos de usuarios:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace ProyectoEvaluaciones_BDI
{
public partial class LogIn : System.Web.UI.Page
{
String connection = "Data Source=Backbone;Initial Catalog=algoDePrueba;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
protected void Page_Load(object sender, EventArgs e)
{
Session["Tipo"] = "";
Session["ID"] = "";
Session["Nombre"] = "";
}
protected bool loginProfesor()
{
bool flag = false;
SqlConnection sqlConnection1 = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
cmd.CommandText = "validarUsuario_Profesor '" + TB_User.Text + "', '" + TB_Password.Text +"'";
sqlConnection1.Open();
SqlDataReader reader;
reader = cmd.ExecuteReader();
reader.Read();
if (reader.HasRows)
{
Session["Tipo"] = "Profesor";
Session["ID"] = reader.GetInt32(0).ToString();
flag = true;
}
reader.Close();
sqlConnection1.Close();
return flag;
}
protected bool loginEstudiante()
{
bool flag = false;
SqlConnection sqlConnection1 = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
cmd.CommandText = "validarUsuario_Estudiante '" + TB_User.Text + "', '" + TB_Password.Text + "'";
sqlConnection1.Open();
SqlDataReader reader;
reader = cmd.ExecuteReader();
reader.Read();
if (reader.HasRows)
{
Session["Tipo"] = "Estudiante";
Session["ID"] = reader.GetInt32(0).ToString();
flag = true;
}
reader.Close();
sqlConnection1.Close();
return flag;
}
protected void Btn_IniciarSesion_Click(object sender, EventArgs e)
{
if (loginProfesor() || loginEstudiante())
LB_Notificador.Text = "Sesión: " +Session["Tipo"] + "\nLos datos ingresados son correctos. Espere un momento.";
else
{
LB_Notificador.Text = "Los datos ingresados no corresponden a ningún usuario registrado.";
//LB_Notificador.Font //Turn this red
}
}
}
}
Fecha Final : 12/04/2018
Hora Inicio: 08:29 PM
Hora Final: 10:24PM
Horas invertidas(Minutos): 115
Colaboradores: Oscar Cortés, Wilson Lopez
Actividad:
Solucionar problema de conexión entre SMSS y Visual Studio
Ingresar datos completos a la BD (check)
Validación de los datos para inicio de sesión
Comentarios:
"¿Actividad? Paranormal." Referencias:
Codigo:
Conexión SSMS a VS y validación de datos de usuarios:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace ProyectoEvaluaciones_BDI
{
public partial class LogIn : System.Web.UI.Page
{
String connection = "Data Source=Backbone;Initial Catalog=algoDePrueba;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
protected void Page_Load(object sender, EventArgs e)
{
Session["Tipo"] = "";
Session["ID"] = "";
Session["Nombre"] = "";
}
protected bool loginProfesor()
{
bool flag = false;
SqlConnection sqlConnection1 = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
cmd.CommandText = "validarUsuario_Profesor '" + TB_User.Text + "', '" + TB_Password.Text +"'";
sqlConnection1.Open();
SqlDataReader reader;
reader = cmd.ExecuteReader();
reader.Read();
if (reader.HasRows)
{
Session["Tipo"] = "Profesor";
Session["ID"] = reader.GetInt32(0).ToString();
flag = true;
}
reader.Close();
sqlConnection1.Close();
return flag;
}
protected bool loginEstudiante()
{
bool flag = false;
SqlConnection sqlConnection1 = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
cmd.CommandText = "validarUsuario_Estudiante '" + TB_User.Text + "', '" + TB_Password.Text + "'";
sqlConnection1.Open();
SqlDataReader reader;
reader = cmd.ExecuteReader();
reader.Read();
if (reader.HasRows)
{
Session["Tipo"] = "Estudiante";
Session["ID"] = reader.GetInt32(0).ToString();
flag = true;
}
reader.Close();
sqlConnection1.Close();
return flag;
}
protected void Btn_IniciarSesion_Click(object sender, EventArgs e)
{
if (loginProfesor() || loginEstudiante())
LB_Notificador.Text = "Sesión: " +Session["Tipo"] + "\nLos datos ingresados son correctos. Espere un momento.";
else
{
LB_Notificador.Text = "Los datos ingresados no corresponden a ningún usuario registrado.";
//LB_Notificador.Font //Turn this red
}
}
}
}
Comentarios
Publicar un comentario