Example #1
0
 // GET: Administrador
 public ActionResult Index()
 {
     try {
         BDWENCOEntities BD = new BDWENCOEntities(CD.ConexDinamica(Session["datasour"].ToString(), Session["catalog"].ToString(), Session["user"].ToString(), Session["password"].ToString()));
         Entidades       db = new Entidades(CD.ConexDinamicaEntidades(Session["datasour"].ToString(), Session["catalog_user"].ToString(), Session["user"].ToString(), Session["password"].ToString()));
         ViewBag.oportunidades     = (from num in db.PROSPECTO select num).Count();
         ViewBag.clientes          = (from num in db.POTENCIALCLI where num.CFLAGPRIN == false select num).Count();
         ViewBag.potencial_cliente = (from num in db.POTENCIALCLI where num.CFLAGPRIN == true select num).Count();
         string codigo = Session["codigo"].ToString();
         ViewBag.vendedores = BD.CRM_Usuarios_Rol.Where(x => x.codigoEmpresa == codigo).Count();
         int cron_retraso = (from num in db.CRONOGRAMA where num.estatus == 2 select num).Count();
         if (cron_retraso < 1)
         {
             cron_retraso = 0;
         }
         int cron_pendiente = (from num in db.CRONOGRAMA where num.estatus == 0 select num).Count();
         if (cron_pendiente < 1)
         {
             cron_pendiente = 0;
         }
         decimal cron_sumn = Convert.ToDecimal((from num in db.PROSPECTO where num.id_estatusProspecto == 1 && num.codigo_tipoMon == "MN" select num.ingreso).Sum());
         decimal cron_sume = Convert.ToDecimal((from num in db.PROSPECTO where num.id_estatusProspecto == 1 && num.codigo_tipoMon == "ME" select num.ingreso).Sum());
         if (cron_sumn < 1)
         {
             cron_sumn = 0;
         }
         if (cron_sume < 1)
         {
             cron_sume = 0;
         }
         ViewBag.cron_retraso   = cron_retraso;
         ViewBag.cron_pendiente = cron_pendiente;
         ViewBag.cron_sume      = cron_sume;
         ViewBag.cron_sumn      = cron_sumn;
         ViewBag.flujo          = "active";
         ViewBag.s = Session.Timeout;
         ViewBag.ListadoCronograma = ListarDatosReportes();
         return(View());
     } catch {
         return(View());
     }
 }
Example #2
0
        public JsonResult ListarUsuarios()
        {
            BDWENCOEntities db = new BDWENCOEntities(CD.ConexDinamica(Session["datasour"].ToString(), Session["catalog"].ToString(), Session["user"].ToString(), Session["password"].ToString()));

            db.Configuration.ProxyCreationEnabled = false;
            string empresa_actual           = Session["codigo"].ToString();
            List <CRM_Usuarios_Rol> listado = db.CRM_Usuarios_Rol.Where(m => m.codigoEmpresa == empresa_actual).OrderBy(m => m.alias).ToList();
            var Resultado = (from N in listado
                             select new { N.ID, N.alias, N.nombreUser, N.Rol });

            return(Json(Resultado, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public void ListarUsuarios()
        {
            BDWENCOEntities db = new BDWENCOEntities(CD.ConexDinamica(Session["datasour"].ToString(), Session["catalog"].ToString(), Session["user"].ToString(), Session["password"].ToString()));

            db.Configuration.ProxyCreationEnabled = false;
            string empresa = Session["codigo"].ToString();

            List <CRM_Usuarios_Rol> listado = db.CRM_Usuarios_Rol.Where(m => m.codigoEmpresa == empresa).OrderBy(m => m.alias).ToList();
            var Resultado = (from N in listado
                             select new { valor = N.alias, texto = string.Format("{0}--{1}", N.alias, N.Rol) }).ToList();

            ViewBag.usuarios = new SelectList(Resultado, "valor", "texto");
        }
Example #4
0
        // GET: RP
        public ActionResult Usuarios()
        {
            try {
                BDWENCOEntities BD = new BDWENCOEntities(CD.ConexDinamica(Session["datasour"].ToString(), Session["catalog"].ToString(), Session["user"].ToString(), Session["password"].ToString()));
                ViewBag.user = "******";
                var usuario = BD.CRM_Usuarios_Rol.OrderByDescending(x => x.ID).Select(x => new { x.ID, x.Rol, x.nombreUser, x.alias, x.email, x.codigoEmpresa });

                ViewBag.Usuarios = usuario;
                return(View());
            } catch {
                return(View());
            }
        }
Example #5
0
        public JsonResult modifict_user(string user, string id, string tip)
        {
            try
            {
                BDWENCOEntities  BD         = new BDWENCOEntities(CD.ConexDinamica(Session["datasour"].ToString(), Session["catalog"].ToString(), Session["user"].ToString(), Session["password"].ToString()));
                JArray           user_array = JArray.Parse(user);
                decimal          ids        = Convert.ToDecimal(id);
                CRM_Usuarios_Rol crm_user   = BD.CRM_Usuarios_Rol.Where(x => x.ID == ids).First();
                User             u          = new User();
                string           codigo     = Convert.ToString(Session["codigo"] != null ? Session["codigo"] : " ");
                string           TIPO       = Convert.ToString(Session["identificador"] != null ? Session["identificador"] : " ");

                foreach (JObject i in user_array)
                {
                    crm_user.nombreUser = i.GetValue("nombre").ToString();
                    crm_user.alias      = i.GetValue("usuario").ToString();
                    crm_user.email      = i.GetValue("email").ToString();

                    if (i.GetValue("password").ToString().Count() > 0)
                    {
                        crm_user.contrase = u.CODIFICA(i.GetValue("password").ToString(), 5);
                    }
                    if (i.GetValue("rol").ToString().Count() > 0)
                    {
                        crm_user.Rol = crm_user.Rol = i.GetValue("rol").ToString();
                    }

                    if (i.GetValue("codigo_empresa").ToString().Count() > 0)
                    {
                        crm_user.codigoEmpresa = i.GetValue("codigo_empresa").ToString();
                    }
                }

                BD.Entry(crm_user).State = EntityState.Modified;
                BD.SaveChanges();

                var jss = new System.Web.Script.Serialization.JavaScriptSerializer();

                if (tip == "1")
                {
                    Session["user_logueado"] = crm_user;
                    var jsonData = new
                    {
                        error = false,
                        user  = crm_user,
                    };
                    return(Json(jsonData, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var jsonData = new
                    {
                        error   = false,
                        mensaje = "Usuario modificado con exito",
                        users   = TIPO == "RP" ? jss.Serialize(BD.CRM_Usuarios_Rol.OrderByDescending(x => x.ID).Select(x => new { x.ID, x.Rol, x.nombreUser, x.alias, x.email, x.codigoEmpresa })) : jss.Serialize(BD.CRM_Usuarios_Rol.OrderByDescending(x => x.ID).Where(x => x.codigoEmpresa == codigo).Select(x => new { x.ID, x.Rol, x.nombreUser, x.alias, x.email, x.codigoEmpresa }))
                    };
                    return(Json(jsonData, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                var jsonData = new
                {
                    error   = true,
                    mensaje = "Ha ocurrido un error" + e.Message
                };
                return(Json(jsonData, JsonRequestBehavior.AllowGet));
            }
        }