Exemplo n.º 1
0
        public void Insertar(SocioEntity socio)
        {
            try
            {
                using (SqlConnection conexion = ConexionDA.ObtenerConexion())
                {
                    using (SqlCommand comando = new SqlCommand("SocioInsert", conexion))
                    {
                        comando.CommandType = CommandType.StoredProcedure;
                        SqlCommandBuilder.DeriveParameters(comando);

                        comando.Parameters["@Dni"].Value                      = socio.dni;
                        comando.Parameters["@Nombre"].Value                   = socio.Nombre.Trim();
                        comando.Parameters["@Apellido"].Value                 = socio.Apellido.Trim();
                        comando.Parameters["@Telefono"].Value                 = socio.Telefono;
                        comando.Parameters["@Email"].Value                    = socio.Email.Trim();
                        comando.Parameters["@Password"].Value                 = socio.Password.Trim();
                        comando.Parameters["@FechaNacimiento"].Value          = socio.FechaNacimiento;
                        comando.Parameters["@Sexo"].Value                     = socio.Sexo;
                        comando.Parameters["@TipoPersona"].Value              = socio.tipoPersona;
                        comando.Parameters["@NroTarjetaIdentificacion"].Value = socio.NroTarjetaIdentificacion;
                        comando.Parameters["@idEstado"].Value                 = socio.IdEstado;
                        comando.Parameters["@ListActividad"].Value            = socio.actividad;
                        comando.ExecuteNonQuery();
                    }

                    conexion.Close();
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDA("Se produjo un error al insertar el socio.", ex);
            }
        }
Exemplo n.º 2
0
        public SocioEntity BuscarSocio(string email, string password)
        {
            try
            {
                SocioEntity socio = null;

                using (SqlConnection conexion = ConexionDA.ObtenerConexion())
                {
                    using (SqlCommand comando = new SqlCommand("SocioBuscarPorMailPassword", conexion))
                    {
                        comando.CommandType = CommandType.StoredProcedure;
                        SqlCommandBuilder.DeriveParameters(comando);

                        comando.Parameters["@Email"].Value    = email.Trim();
                        comando.Parameters["@Password"].Value = password.Trim();

                        using (SqlDataReader cursor = comando.ExecuteReader())
                        {
                            if (cursor.Read())
                            {
                                socio = CrearSocio(cursor);
                            }
                            cursor.Close();
                        }
                    }
                    conexion.Close();
                }
                return(socio);
            }
            catch (Exception ex)
            {
                throw new ExcepcionDA("Se produjo un error al buscar por email y contraseña.", ex);
            }
        }
Exemplo n.º 3
0
        public SocioEntity BuscarSocio(int idPersona)
        {
            try
            {
                SocioEntity socio = null;

                using (SqlConnection conexion = ConexionDA.ObtenerConexion())
                {
                    using (SqlCommand comando = new SqlCommand("SocioBuscarPorId", conexion))
                    {
                        comando.CommandType = CommandType.StoredProcedure;
                        SqlCommandBuilder.DeriveParameters(comando);

                        comando.Parameters["@idPersona"].Value = idPersona;

                        using (SqlDataReader cursor = comando.ExecuteReader())
                        {
                            if (cursor.Read())
                            {
                                socio = CrearSocio(cursor);
                            }
                            cursor.Close();
                        }
                    }
                    conexion.Close();
                }
                return(socio);
            }
            catch (Exception ex)
            {
                throw new ExcepcionDA("Se produjo un error al buscar por ID.", ex);
            }
        }
Exemplo n.º 4
0
    protected void btn_saveProfile(object sender, EventArgs e)
    {
        PersonaEntity personaSend;

        if (persona.tipoPersona == 'S')
        {
            personaSend = new SocioEntity();
        }
        else
        {
            personaSend = new EmpleadoEntity();
        }
        personaSend.Id              = persona.Id;
        personaSend.Nombre          = nombre.Value;
        personaSend.Apellido        = apellido.Value;
        personaSend.dni             = dni.Value;
        personaSend.FechaNacimiento = DateTime.Parse(fechanacimiento.Attributes["value"]);
        personaSend.Password        = contrasenia.Attributes["value"];
        if (genderM.Checked)
        {
            personaSend.Sexo = 'M';
        }
        else
        {
            personaSend.Sexo = 'F';
        }

        personaBo.saveProfile(personaSend);
        SessionHelper.AlmacenarPersonaAutenticada(personaBo.Autenticar(persona.Email, personaSend.Password));
        System.Web.Security.FormsAuthentication.RedirectFromLoginPage(SessionHelper.PersonaAutenticada.Email, false);
        Response.Redirect("Profile.aspx");
    }
Exemplo n.º 5
0
    protected SocioEntity generarNuevoEntity(SocioEntity anterior)
    {
        int         estado      = (activo.Checked) ? 1 : 2;
        SocioEntity nuevoEntity = new SocioEntity(anterior.NroTarjetaIdentificacion, estado);

        try
        {
            nuevoEntity.Id          = anterior.Id;
            nuevoEntity.tipoPersona = anterior.tipoPersona;
            nuevoEntity.Nombre      = nombre.Text;
            nuevoEntity.Telefono    = System.Convert.ToInt32(telefono.Text);
            nuevoEntity.Apellido    = apellido.Text;
            nuevoEntity.dni         = dni.Text;
            nuevoEntity.Email       = email.Text.ToLower();
            nuevoEntity.Password    = (passw1.Text.Equals(passw2.Text) & !passw1.Text.Equals("********")) ? passw1.Text: anterior.Password;

            string[] fechaArr = fechaNacimiento.Value.Split('-');
            nuevoEntity.FechaNacimiento = Util.ObtenerFecha(
                int.Parse(fechaArr[0]),
                int.Parse(fechaArr[1]),
                int.Parse(fechaArr[2]));

            char gen;
            if (masculino.Checked)
            {
                gen = 'M';
            }
            else
            {
                gen = 'F';
            }

            nuevoEntity.Sexo = gen;
            nuevoEntity.Foto = null;
            nuevoEntity.FechaRegistracion  = anterior.FechaRegistracion;
            nuevoEntity.FechaActualizacion = DateTime.Now;

            /*
             * foreach (ListItem item in actividades.Items)
             * {
             *  if (item.Selected)
             *  {
             *      nuevoEntity.actividad = string.Concat(nuevoEntity.actividad, item.Value + ",");
             *      Console.WriteLine(item.Text);
             *  }
             * }*/
        }
        catch (AutenticacionExcepcionBO ex)
        {
            WebHelper.MostrarMensaje(Page, ex.Message);
            nuevoEntity = null;
        }
        catch (Exception ex)
        {
            WebHelper.MostrarMensaje(Page, ex.Message);
            nuevoEntity = null;
        }
        return(nuevoEntity);
    }
Exemplo n.º 6
0
 public void ActualizarSocio(SocioEntity socio)
 {
     try
     {
         daSocio.ActualizarSocio(socio);
     }
     catch (ExcepcionDA ex)
     {
         throw new ExcepcionBO("No se pudo realizar listar socios.", ex);
     }
 }
Exemplo n.º 7
0
        public PersonaEntity factoryPersona(Char type)
        {
            PersonaEntity person;

            switch (type)
            {
            case 'S':
                person = new SocioEntity();
                break;

            default:
                person = new EmpleadoEntity();
                break;
            }
            return(person);
        }
Exemplo n.º 8
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                SocioEntity entitySocio = new SocioEntity(new Random().Next(1, 99999), 1);
                entitySocio = (SocioEntity)popularEntity(entitySocio);
                foreach (ListItem item in actividades.Items)
                {
                    if (item.Selected)
                    {
                        entitySocio.actividad = string.Concat(entitySocio.actividad, item.Value + ",");
                    }
                }

                boSocio.Registrar(entitySocio, entitySocio.Email.Trim());
                WebHelper.MostrarMensaje(Page, ("Socio " + entitySocio.Nombre + " " + entitySocio.Apellido + " creado con exito."));
            }
        }
        catch (ActividadSinLugarExceptionBO ex)
        {
            WebHelper.MostrarMensaje(Page, ex.Message);
        }
        catch (ValidacionExcepcionAbstract ex)
        {
            WebHelper.MostrarMensaje(Page, ex.Message);
        }
        catch (FormatException ex)
        {
            //WebHelper.MostrarMensaje(Page, ex.Message);
            WebHelper.MostrarMensaje(Page, ("Error en ingreso de datos: " + ex));
        }
        catch (Exception ex)
        {
            //WebHelper.MostrarMensaje(Page, ex.Message);
            WebHelper.MostrarMensaje(Page, ("Error en ingreso de datos: " + ex));
        }
        finally
        {
            //Response.Redirect("../socios/ViewSocios.aspx");
        }
    }
Exemplo n.º 9
0
        public PersonaEntity CrearPersona(SqlDataReader cursor)
        {
            PersonaEntity persona;

            int    tipoPersonaOrdinal = cursor.GetOrdinal("TipoPersona");
            string tipoPersona        = cursor.GetString(tipoPersonaOrdinal).ToUpper();

            switch (tipoPersona[0])
            {
            case 'S':
                persona = new SocioEntity();
                break;

            default:
                persona = new EmpleadoEntity();
                break;
            }

            // si  el cursor no contiene el campo especificado (lo tiene en NULL), lanza excepcion

            persona.Id              = cursor.GetInt32(cursor.GetOrdinal("idPersona"));
            persona.tipoPersona     = cursor.GetString(cursor.GetOrdinal("TipoPersona"))[0];
            persona.Telefono        = cursor.GetInt32(cursor.GetOrdinal("Telefono"));
            persona.Nombre          = cursor.GetString(cursor.GetOrdinal("Nombre"));
            persona.Apellido        = cursor.GetString(cursor.GetOrdinal("Apellido"));
            persona.dni             = cursor.GetString(cursor.GetOrdinal("Dni"));
            persona.Email           = cursor.GetString(cursor.GetOrdinal("Email"));
            persona.Password        = cursor.GetString(cursor.GetOrdinal("Password"));
            persona.FechaNacimiento = cursor.GetDateTime(cursor.GetOrdinal("FechaNacimiento"));
            persona.Sexo            = cursor.GetString(cursor.GetOrdinal("Sexo"))[0];
            if (!cursor.IsDBNull(cursor.GetOrdinal("Foto")))
            {
                persona.Foto = cursor.GetString(cursor.GetOrdinal("Foto"));
            }
            persona.FechaRegistracion = cursor.GetDateTime(cursor.GetOrdinal("FechaRegistracion"));

            if (!cursor.IsDBNull(cursor.GetOrdinal("FechaActualizacion")))
            {
                persona.FechaActualizacion = cursor.GetDateTime(cursor.GetOrdinal("FechaActualizacion"));
            }
            return((PersonaEntity)persona);
        }
Exemplo n.º 10
0
        public void Registrar(SocioEntity socio, string emailVerificacion)
        {
            try
            {
                socio.ValidarDatos();

                if (daSocio.ExisteEmail(socio.Email))
                {
                    throw new EmailExisteExcepcionBO();
                }

                if (socio.Email != emailVerificacion.Trim())
                {
                    throw new VerificacionEmailExcepcionBO();
                }

                daSocio.Insertar(socio);
            }
            catch (ExcepcionDA ex)
            {
                throw new ExcepcionBO("No se pudo realizar la registración del usuario.", ex);
            }
        }
Exemplo n.º 11
0
        private SocioEntity CrearSocio(SqlDataReader cursor)
        {
            SocioEntity socio = new SocioEntity();

            socio.Id              = cursor.GetInt32(cursor.GetOrdinal("idPersona"));
            socio.tipoPersona     = cursor.GetString(cursor.GetOrdinal("TipoPersona"))[0];
            socio.Telefono        = cursor.GetInt32(cursor.GetOrdinal("Telefono"));
            socio.Nombre          = cursor.GetString(cursor.GetOrdinal("Nombre"));
            socio.Apellido        = cursor.GetString(cursor.GetOrdinal("Apellido"));
            socio.dni             = cursor.GetString(cursor.GetOrdinal("Dni"));
            socio.Email           = cursor.GetString(cursor.GetOrdinal("Email"));
            socio.Password        = cursor.GetString(cursor.GetOrdinal("Password"));
            socio.FechaNacimiento = cursor.GetDateTime(cursor.GetOrdinal("FechaNacimiento"));
            socio.Sexo            = cursor.GetString(cursor.GetOrdinal("Sexo"))[0];
            if (ColumExist(cursor, "idEstado"))
            {
                socio.IdEstado = cursor.GetInt32(cursor.GetOrdinal("idEstado"));
            }
            if (ColumExist(cursor, "nroTarjetaIdentificacion"))
            {
                socio.NroTarjetaIdentificacion = cursor.GetInt32(cursor.GetOrdinal("nroTarjetaIdentificacion"));
            }

            if (!cursor.IsDBNull(cursor.GetOrdinal("Foto")))
            {
                socio.Foto = cursor.GetString(cursor.GetOrdinal("Foto"));
            }
            socio.FechaRegistracion = cursor.GetDateTime(cursor.GetOrdinal("FechaRegistracion"));

            if (!cursor.IsDBNull(cursor.GetOrdinal("FechaActualizacion")))
            {
                socio.FechaActualizacion = cursor.GetDateTime(cursor.GetOrdinal("FechaActualizacion"));
            }

            return(socio);
        }
Exemplo n.º 12
0
    protected void PopularView(SocioEntity socio, Boolean origen)
    {
        try
        {
            nombre.Attributes.Add("Value", socio.Nombre);
            apellido.Attributes.Add("Value", socio.Apellido);
            dni.Attributes.Add("Value", Convert.ToString(socio.dni));
            email.Attributes.Add("Value", socio.Email);
            telefono.Attributes.Add("Value", Convert.ToString(socio.Telefono));

            string[] fechaArr = socio.FechaNacimiento.ToString("dd'/'MM'/'yyyy").Split('/');
            fechaNacimiento.Attributes.Add("value", (fechaArr[2] + "-" + fechaArr[1] + "-" + fechaArr[0]));


            if (socio.Sexo == 'm' || socio.Sexo == 'M')
            {
                masculinoLbl.Attributes.Remove("class");
                masculinoLbl.Attributes.Add("class", "btn btn-default active");
                masculino.Attributes.Add("checked", "checked");

                femeninoLbl.Attributes.Remove("class");
                femenino.Attributes.Remove("checked");
                femeninoLbl.Attributes.Add("class", "btn btn-default");
            }
            if (socio.Sexo == 'f' || socio.Sexo == 'F')
            {
                femeninoLbl.Attributes.Remove("class");
                femeninoLbl.Attributes.Add("class", "btn btn-default active");
                femenino.Attributes.Add("checked", "checked");

                masculinoLbl.Attributes.Remove("class");
                masculino.Attributes.Remove("checked");
                masculinoLbl.Attributes.Add("class", "btn btn-default");
            }


            if (socio.IdEstado == 1)
            {
                activoLbl.Attributes.Remove("class");
                activoLbl.Attributes.Add("class", "btn btn-default active");
                activo.Attributes.Add("checked", "checked");

                inactivoLbl.Attributes.Remove("class");
                inactivo.Attributes.Remove("checked");
                inactivoLbl.Attributes.Add("class", "btn btn-default");
            }
            if (socio.IdEstado == 2)
            {
                inactivoLbl.Attributes.Remove("class");
                inactivoLbl.Attributes.Add("class", "btn btn-default active");
                inactivo.Attributes.Add("checked", "checked");

                activoLbl.Attributes.Remove("class");
                activo.Attributes.Remove("checked");
                activoLbl.Attributes.Add("class", "btn btn-default");
            }
        }
        catch (AutenticacionExcepcionBO ex)
        {
            WebHelper.MostrarMensaje(Page, ex.Message);
        }
        catch (Exception ex)
        {
            WebHelper.MostrarMensaje(Page, ex.Message);
        }
    }