Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Xml.Linq;
- using LN;
- public partial class _Default : System.Web.UI.Page
- {
- static String password;
- static String usuario;
- static int idUser;
- static worldJobs wJ;
- static DataSet ds;
- static DataTable tabla;
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Page.IsPostBack)
- {
- LoginMenu.UserName = "";
- wJ = new worldJobs();
- ds = wJ.getBaseDatosDesc().getDataSet();
- tabla = new DataTable();
- }
- }
- protected void LoginMenu_Authenticate(object sender, AuthenticateEventArgs e)
- {
- usuario = LoginMenu.UserName.ToString();
- password = LoginMenu.Password.ToString();
- if (!usuario.Equals("") && !password.Equals(""))
- {
- #region Comprobamos
- String user = "";
- String pass = "";
- String tipo = "";
- Boolean existe = false;
- tabla = ds.Tables["Usuario"];
- for (int i = 0; i < tabla.Rows.Count; i++)
- {
- idUser = int.Parse(tabla.Rows[i][0].ToString());
- user = tabla.Rows[i][1].ToString();
- pass = tabla.Rows[i][2].ToString();
- if (user.Equals(usuario) && pass.Equals(password))
- {
- tipo = tabla.Rows[i][3].ToString();
- existe = true;
- break;
- }
- }
- #endregion
- if (existe == true)
- {
- #region Si existe y es de tipo Persona
- if (tipo.Equals("Persona"))
- {
- // El usuario que se conecta es de tipo Persona Normal
- Response.Cookies["NombreUsuario"].Value = usuario;
- Session["NombreUsuario"] = usuario;
- Session["Usuario"] = idUser;
- LoginMenu.UserName = "";
- Response.Redirect("usuario.aspx");
- }
- #endregion
- #region Si existe y es de tipo Empresa
- else if (tipo.Equals("Empresa"))
- {
- // El usuario que se conecta es de tipo Persona Normal
- Response.Cookies["NombreUsuario"].Value = usuario;
- Session["NombreUsuario"] = usuario;
- Session["Usuario"] = idUser;
- LoginMenu.UserName = "";
- Response.Redirect("empresa.aspx");
- }
- #endregion
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment