public ActionResult Nuevo()
        {
            Ent_Usuario _usuario = (Ent_Usuario)Session[Ent_Constantes.NameSessionUser];

            string actionName     = this.ControllerContext.RouteData.GetRequiredString("action");
            string controllerName = this.ControllerContext.RouteData.GetRequiredString("controller");
            string return_view    = actionName + "|" + controllerName;

            if (_usuario == null)
            {
                return(RedirectToAction("Login", "Control", new { returnUrl = return_view }));
            }
            else
            {
                #region <VALIDACION DE ROLES DE USUARIO>
                Boolean valida_rol         = true;
                Basico  valida_controller  = new Basico();
                List <Ent_Menu_Items> menu = (List <Ent_Menu_Items>)Session[Ent_Global._session_menu_user];
                valida_rol = valida_controller.AccesoMenu(menu, this);
                #endregion
                if (valida_rol)
                {
                    Ent_Promotor_Maestros maestros = datUtil.ListarEnt_Maestros_Promotor(_usuario.usu_id);

                    List <Ent_Combo> listobj = new List <Ent_Combo>();
                    Ent_Combo        cbo     = new Ent_Combo();
                    cbo.codigo      = "-1";
                    cbo.descripcion = "------Selecccione------";
                    listobj.Add(cbo);

                    ViewBag.listDepartamento = maestros.combo_ListDepartamento;
                    ViewBag.listLider        = maestros.combo_ListLider;
                    ViewBag.listTipoDoc      = maestros.combo_ListTipoDoc;
                    ViewBag.listTipoPersona  = maestros.combo_ListTipoPersona;
                    ViewBag.listTipoUsuario  = maestros.combo_ListTipoUsuario;

                    ViewBag.General = listobj;


                    return(View());
                }
                else
                {
                    return(RedirectToAction("Login", "Control", new { returnUrl = return_view }));
                }
            }
        }
        public ActionResult ListaPromotor()
        {
            Ent_Usuario _usuario       = (Ent_Usuario)Session[Ent_Constantes.NameSessionUser];
            string      actionName     = this.ControllerContext.RouteData.GetRequiredString("action");
            string      controllerName = this.ControllerContext.RouteData.GetRequiredString("controller");
            string      return_view    = actionName + "|" + controllerName;

            if (_usuario == null)
            {
                return(RedirectToAction("Login", "Control", new { returnUrl = return_view }));
            }

            Ent_Promotor_Maestros maestros = datUtil.ListarEnt_Maestros_Promotor(_usuario.usu_id);

            ViewBag.listLider = maestros.combo_ListLider;

            return(View());
        }
Exemple #3
0
        public Ent_Promotor_Maestros ListarEnt_Maestros_Promotor(decimal usuarioId)
        {
            DataSet               dsReturn         = new DataSet();
            string                sqlquery         = "USP_LEER_DATOS_MAESTROS_MVC";
            List <Ent_Combo>      listaDep         = null;
            List <Ent_Combo>      listaTipoPersona = null;
            List <Ent_Combo>      listaTipoUsuario = null;
            List <Ent_Combo>      listaTipoDoc     = null;
            List <Ent_Combo>      listaLider       = null;
            Ent_Promotor_Maestros Maestro          = new Ent_Promotor_Maestros();

            try
            {
                using (SqlConnection cn = new SqlConnection(Ent_Conexion.conexion))
                {
                    using (SqlCommand cmd = new SqlCommand(sqlquery, cn))
                    {
                        SqlParameter oCodUsuario = cmd.Parameters.Add("@IdUsuario", SqlDbType.Decimal);
                        oCodUsuario.Direction = ParameterDirection.Input;
                        oCodUsuario.Value     = usuarioId;

                        cmd.CommandTimeout = 0;
                        cmd.CommandType    = CommandType.StoredProcedure;
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(dsReturn);
                            listaDep = new List <Ent_Combo>();
                            listaDep = (from DataRow dr in dsReturn.Tables[0].Rows
                                        select new Ent_Combo()
                            {
                                codigo = dr["Dep_Id"].ToString(),
                                descripcion = dr["Dep_Descripcion"].ToString(),
                            }).ToList();

                            listaTipoPersona = new List <Ent_Combo>();
                            listaTipoPersona = (from DataRow dr in dsReturn.Tables[1].Rows
                                                select new Ent_Combo()
                            {
                                codigo = dr["per_tip_id"].ToString(),
                                descripcion = dr["per_tip_descripcion"].ToString(),
                            }).ToList();

                            listaTipoUsuario = new List <Ent_Combo>();
                            listaTipoUsuario = (from DataRow dr in dsReturn.Tables[2].Rows
                                                select new Ent_Combo()
                            {
                                codigo = dr["Usu_Tip_Id"].ToString(),
                                descripcion = dr["Usu_Tip_Nombre"].ToString(),
                            }).ToList();

                            listaTipoDoc = new List <Ent_Combo>();
                            listaTipoDoc = (from DataRow dr in dsReturn.Tables[3].Rows
                                            select new Ent_Combo()
                            {
                                codigo = dr["Doc_Tip_Id"].ToString(),
                                descripcion = dr["Doc_Tip_Descripcion"].ToString(),
                            }).ToList();

                            listaLider = new List <Ent_Combo>();
                            listaLider = (from DataRow dr in dsReturn.Tables[4].Rows
                                          select new Ent_Combo()
                            {
                                codigo = dr["Are_Id"].ToString(),
                                descripcion = dr["Are_Descripcion"].ToString(),
                            }).ToList();
                        }
                    }
                }

                Maestro.combo_ListDepartamento = listaDep;
                Maestro.combo_ListTipoPersona  = listaTipoPersona;
                Maestro.combo_ListTipoUsuario  = listaTipoUsuario;
                Maestro.combo_ListTipoDoc      = listaTipoDoc;
                Maestro.combo_ListLider        = listaLider;
            }
            catch (Exception exc)
            {
                Maestro = null;
            }
            return(Maestro);
        }