public string guardar(string nombre, string apellido, string cedula,string pass, string tel, string dir, string email, int activo) { Entidades.Mozo mozo = new Entidades.Mozo(); mozo.Nombre = nombre; mozo.Apellido = apellido; mozo.Cedula = cedula; mozo.Telefono = tel; mozo.Direccion = dir; mozo.Email = email; mozo.Activo = activo; Entidades.LogIn log = new Entidades.LogIn(); log.Usuario = cedula; log.Password = pass; log.Tipo = 4; log.Persist = PersistenciaOleDb.PersistenciaOleDbLogIn.getInstancia(); log.guardar(log); return PersistenciaOleDb.PersistenciaOleDbMozo.getInstancia().guardar(mozo); }
protected void btnIniciar_Click(object sender, ImageClickEventArgs e) { log = fachadaLogIn.buscar(txtUsuario.Text); if (log != null) { if (log.Password == txtPass.Text) { lblMensaje.Text = "Bienvenido " + log.Usuario; txtUsuario.Enabled = false; txtUsuario.Text = ""; txtPass.Enabled = false; btnIniciar.Enabled = false; btnSalir.Visible = true; cambiarMenu(log.Tipo); } else { lblMensaje.Text = "Contraseña incorrecta"; txtPass.Focus(); } } }
public override Entidades.LogIn buscar(string usuario) { Entidades.LogIn log = null; try { OleDbConnection conexion = Entidades.Conexion.GetInstancia().crearConexion(); OleDbCommand cmdBuscar = new OleDbCommand("Select * From LogIn Where Usuario = @usuario", conexion); cmdBuscar.Parameters.AddWithValue("@usuario", usuario); OleDbDataReader datos = cmdBuscar.ExecuteReader(); if (datos.Read()) { log = new Entidades.LogIn(); log.Usuario = datos["Usuario"].ToString(); log.Password = datos["Password"].ToString(); log.Tipo = Convert.ToInt32(datos["Tipo"]); } } catch (Exception ex) { throw new Exception("Ocurrio un problema al buscar " + ex.Message); } return log; }
protected void btnSalir_Click(object sender, ImageClickEventArgs e) { log = null; cambiarMenu(0); txtUsuario.Enabled = true; txtPass.Enabled = true; lblMensaje.Text = ""; btnSalir.Visible = false; btnIniciar.Enabled = true; }