Exemplo n.º 1
0
        public UsuarioBE Login(String p_Usuario, String p_Password)
        {
            DataBaseDA dbRRHH         = new DataBaseDA();
            UsuarioBE  usuarioLogeado = null;

            try
            {
                qSQL = "SP_LOGIN";
                using (MySqlCommand cmd = new MySqlCommand(qSQL, dbRRHH.getConnectionMysql()))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@usuario", p_Usuario);
                    cmd.Parameters.AddWithValue("@pass", p_Password);
                    cmd.Connection.Open();
                    MySqlDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        usuarioLogeado = new UsuarioBE();
                        usuarioLogeado.CodigoUsuario = (Int32)rd[0];
                        usuarioLogeado.NombreUsuario = rd[1].ToString();

                        PerfilBE perfil = new PerfilBE();
                        perfil.CodPerfil         = (Int32)rd[2];
                        perfil.Perfil            = rd[3].ToString();
                        perfil.DescripcionPerfil = rd[10].ToString();

                        ExamenBE examen = new ExamenBE();
                        examen.ID             = (Int32)rd[8];
                        perfil.Examen         = examen;
                        usuarioLogeado.Perfil = perfil;

                        AreaTiendaBE area = new AreaTiendaBE();
                        area.CodArea        = (Int32)rd[4];
                        area.Descripcion    = rd[5].ToString();
                        usuarioLogeado.Area = area;

                        TiendaBE tienda = new TiendaBE();
                        tienda.CodTienda     = (Int32)rd[6];
                        tienda.NombreTienda  = rd[7].ToString();
                        usuarioLogeado.Local = tienda;

                        usuarioLogeado.RindioExamen = rd[9].ToString() != "" ? (Int32)rd[9] : 0;
                    }
                    rd.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally {
                dbRRHH = null;
            }

            return(usuarioLogeado);
        }
Exemplo n.º 2
0
        public List <ExamenPreguntaBE> Listar(int codigoExamen)
        {
            dbRRHH = new DataBaseDA();
            List <ExamenPreguntaBE>      lista = new List <ExamenPreguntaBE>();
            List <PreguntaAlternativaBE> listaAlternativas;

            try
            {
                qSQL = "SPS_PREGUNTAEXAMEN";

                using (MySqlCommand cmd = new MySqlCommand(qSQL, dbRRHH.getConnectionMysql()))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@CODIGO", codigoExamen);
                    cmd.Connection.Open();
                    MySqlDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        ExamenBE exam = new ExamenBE();
                        exam.ID            = (Int32)rd[0];
                        exam.NombreEx      = rd[1].ToString();
                        exam.DescripcionEx = rd[2].ToString();

                        ExamenPreguntaBE item = new ExamenPreguntaBE();
                        int codigo            = (Int32)rd[3];
                        item.ID         = codigo;
                        item.PreguntaEx = rd[4].ToString();

                        ParametroBE tipoPregunta = new ParametroBE();
                        tipoPregunta.Codigo      = (Int32)rd[5];
                        tipoPregunta.Descripcion = rd[9].ToString();
                        item.TipoPreguntaEx      = tipoPregunta;

                        item.ImagenEx  = rd[6].ToString();
                        item.PuntajeEx = (Int32)rd[7];
                        int tipoControl = (Int32)rd[8];
                        item.TipoControlEx = tipoControl;

                        //Opciones de las preguntas
                        if (tipoControl == 1)
                        {
                            listaAlternativas = new PreguntaAlternativaDA().Listar(codigo);
                        }
                        else
                        {
                            listaAlternativas = new List <PreguntaAlternativaBE>();
                        }

                        item.listaOpciones = listaAlternativas;

                        lista.Add(item);
                    }

                    if (rd != null && rd.IsClosed == false)
                    {
                        rd.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbRRHH = null;
            }

            return(lista);
        }