public object Gettbl_Personal(int opcion, string filtro) { Resultado res = new Resultado(); Proveedor_BL obj_negocio = new Proveedor_BL(); object resul = null; try { if (opcion == 1) { res.ok = true; res.data = (from a in db.tbl_Estados select new { a.id_Estado, a.descripcion_estado }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 2) { res.ok = true; res.data = (from a in db.tbl_Empresas where a.estado == 1 select new { a.id_Empresa, a.razonSocial_Empresa }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 3) { res.ok = true; res.data = (from a in db.tbl_Servicios where a.estado == 1 select new { checkeado = false, a.id_Servicios, a.nombreServicio }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 4) { string[] parametros = filtro.Split('|'); int idEmpresa = Convert.ToInt32(parametros[0].ToString()); int idArea = Convert.ToInt32(parametros[1].ToString()); int idEstado = Convert.ToInt32(parametros[2].ToString()); //res.ok = true; //res.data = (from a in db.tbl_Usuarios // join b in db.tbl_Perfil on a.id_Perfil equals b.id_perfil // join c in db.tbl_Personal on a.nrodoc_usuario equals c.nroDocumento_Personal // join d in db.tbl_Empresas on c.id_Empresa equals d.id_Empresa // select new // { // a.id_Usuario, // a.nrodoc_usuario, // a.apellidos_usuario, // a.nombres_usuario, // id_empresa = c.id_Empresa, // empresa_usuario = d.razonSocial_Empresa, // a.email_usuario, // a.id_TipoUsuario, // a.id_Perfil, // b.descripcion_perfil, // a.fotourl, // a.login_usuario, // a.contrasenia_usuario, // a.estado, // descripcion_estado = a.estado == 0 ? "INACTIVO" : "ACTIVO", // a.usuario_creacion // }).ToList(); //res.totalpage = 0; //resul = res; Usuarios_BL objNegocio = new Usuarios_BL(); res.ok = true; res.data = objNegocio.get_usuariosMantenimiento(idEmpresa, idArea, idEstado); res.totalpage = 0; resul = res; } else if (opcion == 5) { string[] parametros = filtro.Split('|'); int idUsuario = Convert.ToInt32(parametros[0].ToString()); tbl_Usuarios objReemplazar; objReemplazar = db.tbl_Usuarios.Where(u => u.id_Usuario == idUsuario).FirstOrDefault <tbl_Usuarios>(); objReemplazar.estado = 0; db.Entry(objReemplazar).State = EntityState.Modified; try { db.SaveChanges(); res.ok = true; res.data = "OK"; res.totalpage = 0; } catch (DbUpdateConcurrencyException ex) { res.ok = false; res.data = ex.InnerException.Message; res.totalpage = 0; } resul = res; } else if (opcion == 6) { string[] parametros = filtro.Split('|'); string nroDoc = parametros[0].ToString(); if (db.tbl_Usuarios.Count(e => e.nrodoc_usuario == nroDoc) > 0) { resul = true; } else { resul = false; } } else if (opcion == 7) /// perfil { res.ok = true; res.data = (from a in db.tbl_Perfil where a.estado == 1 select new { a.id_perfil, a.descripcion_perfil }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 8) /// buscar por dni { string[] parametros = filtro.Split('|'); string nroDoc = parametros[0].ToString(); res.ok = true; res.data = (from a in db.tbl_Personal join b in db.tbl_Empresas on a.id_Empresa equals b.id_Empresa where a.nroDocumento_Personal == nroDoc && a.estado == 1 select new { a.id_Personal, a.id_Empresa, b.razonSocial_Empresa, a.nombres_Personal, a.apellidos_Personal }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 9) { string[] parametros = filtro.Split('|'); string loggin = parametros[0].ToString(); if (db.tbl_Usuarios.Count(e => e.login_usuario == loggin) > 0) { resul = true; } else { resul = false; } } else if (opcion == 10) { string[] parametros = filtro.Split('|'); int idUsuarioBD = Convert.ToInt32(parametros[0].ToString()); string areasMasivo = parametros[1].ToString(); int idusuarioLoggin = Convert.ToInt32(parametros[2].ToString()); res.ok = true; res.data = obj_negocio.set_grabar_areasMasivas(idUsuarioBD, areasMasivo, idusuarioLoggin); res.totalpage = 0; resul = res; } else if (opcion == 11) { string[] parametros = filtro.Split('|'); int idUsuarioBD = Convert.ToInt32(parametros[0].ToString()); res.ok = true; res.data = (from a in db.tbl_Usuarios_Servicios where a.id_usuario == idUsuarioBD select new { a.id_servicio }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 12) { string[] parametros = filtro.Split('|'); int idUsuarioBD = Convert.ToInt32(parametros[0].ToString()); res.ok = true; res.data = obj_negocio.get_generarDescargar_CodigoQR(idUsuarioBD); res.totalpage = 0; resul = res; } else if (opcion == 13) { res.ok = true; res.data = (from a in db.tbl_Usuarios where a.estado == 1 orderby a.id_Usuario ascending select new { checkeado = false, a.id_Usuario, a.nrodoc_usuario, apellidos_usuario = a.apellidos_usuario + " " + a.nombres_usuario, a.nombres_usuario }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 14) { string[] parametros = filtro.Split('|'); string idOpciones = parametros[0].ToString(); Usuarios_BL obj_negocios = new Usuarios_BL(); res.ok = true; res.data = obj_negocios.get_usuariosAccesos(idOpciones); res.totalpage = 0; resul = res; } else if (opcion == 15) { string[] parametros = filtro.Split('|'); string idOpciones = parametros[0].ToString(); int idUsuario = Convert.ToInt32(parametros[1].ToString()); Usuarios_BL obj_negocios = new Usuarios_BL(); res.ok = true; res.data = obj_negocios.get_eventosUsuarioMarcados(idOpciones, idUsuario); res.totalpage = 0; resul = res; } else if (opcion == 16) { string[] parametros = filtro.Split('|'); string idOpciones = parametros[0].ToString(); string idEventos = parametros[1].ToString(); int idPrincipal = Convert.ToInt32(parametros[2].ToString()); string modalElegido = parametros[3].ToString(); Usuarios_BL obj_negocios = new Usuarios_BL(); res.ok = true; if (modalElegido == "usuarios") { res.data = obj_negocios.set_grabandoEventos(idOpciones, idEventos, idPrincipal); } if (modalElegido == "perfiles") { res.data = obj_negocios.set_grabandoEventosPerfiles(idOpciones, idEventos, idPrincipal); } res.totalpage = 0; resul = res; //res.ok = true; //res.data = obj_negocios.set_grabandoEventos(idOpciones, idEventos, idUsuario); //res.totalpage = 0; //resul = res; } else if (opcion == 17) //----- PERFILES { res.ok = true; res.data = (from a in db.tbl_Perfil where a.estado == 1 select new { checkeando = false, a.id_perfil, a.descripcion_perfil }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 18) { string[] parametros = filtro.Split('|'); string idOpciones = parametros[0].ToString(); Usuarios_BL obj_negocios = new Usuarios_BL(); res.ok = true; res.data = obj_negocios.get_perfilAccesos(idOpciones); res.totalpage = 0; resul = res; } else if (opcion == 19) { string[] parametros = filtro.Split('|'); string idOpciones = parametros[0].ToString(); int idPerfil = Convert.ToInt32(parametros[1].ToString()); Usuarios_BL obj_negocios = new Usuarios_BL(); res.ok = true; res.data = obj_negocios.get_eventosPerfilMarcados(idOpciones, idPerfil); res.totalpage = 0; resul = res; } else if (opcion == 20) { string[] parametros = filtro.Split('|'); string idOpciones = parametros[0].ToString(); int idUsuario = Convert.ToInt32(parametros[1].ToString()); Usuarios_BL obj_negocios = new Usuarios_BL(); res.ok = true; res.data = obj_negocios.set_eliminarAccesos(idOpciones, idUsuario); res.totalpage = 0; resul = res; } else { res.ok = false; res.data = "Opcion seleccionada invalida"; res.totalpage = 0; resul = res; } } catch (Exception ex) { res.ok = false; res.data = ex.Message; res.totalpage = 0; resul = res; } return(resul); }
public object Gettbl_Empresas(int opcion, string filtro) { Resultado res = new Resultado(); Proveedor_BL obj_negocio = new Proveedor_BL(); object resul = null; try { if (opcion == 1) { res.ok = true; res.data = (from a in db.tbl_Estados select new { a.id_Estado, a.descripcion_estado, a.tipoproceso_estado }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 2) { string[] parametros = filtro.Split('|'); int idEstado = Convert.ToInt32(parametros[0].ToString()); int idUsuario = Convert.ToInt32(parametros[1].ToString()); res.ok = true; res.data = (from a in db.tbl_Empresas select new { a.id_Empresa, a.ruc_Empresa, a.razonSocial_Empresa, a.direccion_Empresa, a.id_Icono, a.esProveedor, a.estado, descripcion_estado = a.estado == 0 ? "INACTIVO" : "ACTIVO", a.usuario_creacion }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 3) { string[] parametros = filtro.Split('|'); int idEmpresa = Convert.ToInt32(parametros[0].ToString()); tbl_Empresas objReemplazar; objReemplazar = db.tbl_Empresas.Where(u => u.id_Empresa == idEmpresa).FirstOrDefault <tbl_Empresas>(); objReemplazar.estado = 0; db.Entry(objReemplazar).State = EntityState.Modified; try { db.SaveChanges(); res.ok = true; res.data = "OK"; res.totalpage = 0; } catch (DbUpdateConcurrencyException ex) { res.ok = false; res.data = ex.InnerException.Message; res.totalpage = 0; } resul = res; } else if (opcion == 4) { string[] parametros = filtro.Split('|'); string nroRuc = parametros[0].ToString(); if (db.tbl_Empresas.Count(e => e.ruc_Empresa == nroRuc) > 0) { resul = true; } else { resul = false; } } else if (opcion == 5) { string[] parametros = filtro.Split('|'); string razonSocial = parametros[0].ToString(); if (db.tbl_Empresas.Count(e => e.razonSocial_Empresa == razonSocial) > 0) { resul = true; } else { resul = false; } } else if (opcion == 6) { string[] parametros = filtro.Split('|'); int idIcon = Convert.ToInt32(parametros[0].ToString()); int idser = Convert.ToInt32(parametros[1].ToString()); res.ok = true; res.data = obj_negocio.get_DatosGenerales_Iconos(idIcon); res.totalpage = 0; resul = res; } else if (opcion == 7) { res.ok = true; res.data = (from a in db.tbl_Empresas where a.estado == 1 select new { a.id_Empresa, a.razonSocial_Empresa, a.esProveedor }).ToList(); res.totalpage = 0; resul = res; } else { res.ok = false; res.data = "Opcion seleccionada invalida"; res.totalpage = 0; resul = res; } } catch (Exception ex) { res.ok = false; res.data = ex.Message; res.totalpage = 0; resul = res; } return(resul); }
public object Gettbl_Personal(int opcion, string filtro) { Resultado res = new Resultado(); Proveedor_BL obj_negocio = new Proveedor_BL(); object resul = null; try { if (opcion == 1) { res.ok = true; res.data = (from a in db.tbl_Estados select new { a.id_Estado, a.descripcion_estado }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 2) { res.ok = true; res.data = (from a in db.tbl_Empresas where a.estado == 1 select new { a.id_Empresa, a.razonSocial_Empresa }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 3) { string[] parametros = filtro.Split('|'); int idEmpresa = Convert.ToInt32(parametros[0].ToString()); int idEstado = Convert.ToInt32(parametros[1].ToString()); if (idEmpresa == 0) { res.ok = true; res.data = (from a in db.tbl_Personal join b in db.tbl_Cargo_Personal on a.id_Cargo equals b.id_Cargo join c in db.tbl_Empresas on a.id_Empresa equals c.id_Empresa join d in db.tbl_Distritos on a.id_Distrito equals d.id_Distrito where a.estado == idEstado select new { a.id_Personal, a.id_Empresa, c.razonSocial_Empresa, a.id_TipoDoc, a.nroDocumento_Personal, a.apellidos_Personal, a.nombres_Personal, a.id_Cargo, b.nombreCargo, a.id_Distrito, d.nombreDistrito, a.direccion_Personal, a.estado, descripcion_estado = a.estado == 0 ? "INACTIVO" : "ACTIVO", a.usuario_creacion }).ToList(); res.totalpage = 0; } else { res.ok = true; res.data = (from a in db.tbl_Personal join b in db.tbl_Cargo_Personal on a.id_Cargo equals b.id_Cargo join c in db.tbl_Empresas on a.id_Empresa equals c.id_Empresa join d in db.tbl_Distritos on a.id_Distrito equals d.id_Distrito where a.estado == idEstado && a.id_Empresa == idEmpresa select new { a.id_Personal, a.id_Empresa, c.razonSocial_Empresa, a.id_TipoDoc, a.nroDocumento_Personal, a.apellidos_Personal, a.nombres_Personal, a.id_Cargo, b.nombreCargo, a.id_Distrito, d.nombreDistrito, a.direccion_Personal, a.estado, descripcion_estado = a.estado == 0 ? "INACTIVO" : "ACTIVO", a.usuario_creacion }).ToList(); res.totalpage = 0; } resul = res; } else if (opcion == 4) { string[] parametros = filtro.Split('|'); int idPersonal = Convert.ToInt32(parametros[0].ToString()); tbl_Personal objReemplazar; objReemplazar = db.tbl_Personal.Where(u => u.id_Personal == idPersonal).FirstOrDefault <tbl_Personal>(); objReemplazar.estado = 0; db.Entry(objReemplazar).State = EntityState.Modified; try { db.SaveChanges(); res.ok = true; res.data = "OK"; res.totalpage = 0; } catch (DbUpdateConcurrencyException ex) { res.ok = false; res.data = ex.InnerException.Message; res.totalpage = 0; } resul = res; } else if (opcion == 5) { string[] parametros = filtro.Split('|'); string nroDoc = parametros[0].ToString(); if (db.tbl_Personal.Count(e => e.nroDocumento_Personal == nroDoc) > 0) { resul = true; } else { resul = false; } } else if (opcion == 6) /// tipo trabajo { string[] parametros = filtro.Split('|'); int idGrupo = Convert.ToInt32(parametros[0].ToString()); res.ok = true; res.data = (from a in db.tbl_GrupoTabla_Det where a.id_grupoTabla == idGrupo && a.estado == 1 select new { a.id_detalleTabla, a.descripcion_grupoTabla }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 7) /// tipo cargo { res.ok = true; res.data = (from a in db.tbl_Cargo_Personal where a.estado == 1 select new { a.id_Cargo, a.nombreCargo }).ToList(); res.totalpage = 0; resul = res; } else if (opcion == 8) { string[] parametros = filtro.Split('|'); int idUsuario = Convert.ToInt32(parametros[0].ToString()); res.ok = true; res.data = obj_negocio.set_grabar_ImportacionPersonal(idUsuario); res.totalpage = 0; resul = res; } else if (opcion == 9) /// --- distritos { res.ok = true; res.data = (from a in db.tbl_Distritos where a.estado == 1 select new { a.id_Distrito, a.nombreDistrito }).ToList(); res.totalpage = 0; resul = res; } else { res.ok = false; res.data = "Opcion seleccionada invalida"; res.totalpage = 0; resul = res; } } catch (Exception ex) { res.ok = false; res.data = ex.Message; res.totalpage = 0; resul = res; } return(resul); }