-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login.aspx.cs
50 lines (38 loc) · 1.31 KB
/
Login.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["cve"] = "";
Session["nombre"] = "";
Session["logged"] = false;
}
[WebMethod]
public static bool validarUsuario(string email, string password){
storedProcedure sp = new storedProcedure("ConnectionString");
bool resultado = true;
string query = "select idAlumno,nombreCompleto from alumno as al inner join"+
" usuarioRol as ur on ur.idUsuario = al.idAlumno"+
" where al.usuario = '"+email+"'and contrasena = '"+password+"'";
List<string> listaUser = sp.recuperaRegistros(query);
if (listaUser.Count > 0)
{
int idUser = int.Parse(listaUser[0]);
string emailq = listaUser[1];
HttpContext.Current.Session["cve"] = idUser;
HttpContext.Current.Session["nombre"] = emailq;
HttpContext.Current.Session["logged"] = true;
resultado = true;
}
else {
resultado = false;
}
return resultado;
}
}