示例#1
0
        public static List <FuncionDTO> ListaPermisos(string Usuario)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("PermisosUsuario", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;

            myCommand.Parameters.Add("@usuario", SqlDbType.VarChar).Value = Usuario;
            SqlDataReader datos;
            FuncionDTO    theFuncionDTO;

            List <FuncionDTO> funciones = new List <FuncionDTO>();

            try
            {
                myConnection.Open();
                datos = myCommand.ExecuteReader();
                while (datos.Read())
                {
                    theFuncionDTO = new FuncionDTO();

                    if (!datos.IsDBNull(0))
                    {
                        theFuncionDTO.FuncionNombre = datos.GetString(0);
                    }
                    if (!datos.IsDBNull(1))
                    {
                        theFuncionDTO.FuncionCod = datos.GetInt32(1).ToString();
                    }
                    if (!datos.IsDBNull(2))
                    {
                        theFuncionDTO.EnviaCorreo = datos.GetString(2);
                    }
                    //if (!datos.IsDBNull(2))
                    //{
                    //    theFuncionDTO.Estado = datos.GetString(3);
                    //}
                    funciones.Add(theFuncionDTO);
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            finally
            {
                myConnection.Close();
            }

            return(funciones);
        }
示例#2
0
        public static void DeletePermisos(PermisoDTO thePermisoDTO)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("DEL_Permisos", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;

            myCommand.Parameters.Add("@usuario", SqlDbType.Int).Value = thePermisoDTO.Usuario;

            try
            {
                myConnection.Open();
                myCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#3
0
        /// <summary>
        /// lista Funciones Asociadas a Grupo para el perfilamiento de usuario
        /// </summary>
        /// <returns></returns>
        public static List <FuncionDTO> ListaFunciones(int FuncionGrupo)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("QRY_listaFuncionesGrupo", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;

            myCommand.Parameters.Add("@FuncionGrupoCod", SqlDbType.Int).Value = FuncionGrupo;
            SqlDataReader     datos;
            FuncionDTO        theFuncionDTO;
            List <FuncionDTO> funciones = new List <FuncionDTO>();

            try
            {
                myConnection.Open();
                datos = myCommand.ExecuteReader();
                while (datos.Read())
                {
                    theFuncionDTO = new FuncionDTO();

                    if (!datos.IsDBNull(0))
                    {
                        theFuncionDTO.FuncionCod = datos.GetInt32(0).ToString();
                    }
                    if (!datos.IsDBNull(1))
                    {
                        theFuncionDTO.FuncionNombre = datos.GetString(1);
                    }
                    funciones.Add(theFuncionDTO);
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            finally
            {
                myConnection.Close();
            }

            return(funciones);
        }
示例#4
0
        /// <summary>
        /// Desactiva una empresa y todos los usuario asociados
        /// </summary>
        /// <param name="theEmpresaDTO"></param>
        /// <returns></returns>
        public static int DeleteCondominio(CondominioDTO theCondominioDTO)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("ACT_CONDOMINIO", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;

            myCommand.Parameters.Add("@idCondominio", SqlDbType.Int).Value = theCondominioDTO.IdCondominio;

            try
            {
                myConnection.Open();
                myCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
            return(0);
        }
示例#5
0
        /// <summary>
        /// Inserta los permisos para las funcionalidades al Usuario asignado
        /// </summary>
        public static void InsertaPermisos(PermisoDTO thePermisoDTO)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("INS_Permiso", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;

            myCommand.Parameters.Add("@pGrupoCod", SqlDbType.VarChar).Value   = thePermisoDTO.Empresa;
            myCommand.Parameters.Add("@pRolCod", SqlDbType.VarChar).Value     = thePermisoDTO.Usuario;
            myCommand.Parameters.Add("@pFuncionCod", SqlDbType.VarChar).Value = thePermisoDTO.Funcion;

            try
            {
                myConnection.Open();
                myCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#6
0
        /// <summary>
        /// Activa o Desactiva Usuarios
        /// </summary>
        /// <param name="UsuarioDTO"></param>
        /// <returns></returns>
        public static int ActivaDesactivaUsuario(UsuarioDTO UsuarioDTO)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("activaDesactivaUsuario", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;

            //myCommand.Parameters.Add("@rut", SqlDbType.Int).Value = UsuarioDTO.Rut;
            //myCommand.Parameters.Add("@usuarioModificacion", SqlDbType.VarChar).Value = UsuarioDTO.UsuarioModificacion;
            //myCommand.Parameters.Add("@estado", SqlDbType.Int).Value = UsuarioDTO.Estado;

            try
            {
                myConnection.Open();
                myCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
            return(0);
        }
示例#7
0
        /// <summary>
        /// Actualiza Intentos Fallidos
        /// </summary>
        /// <param name="mvarUsuarioCod"></param>
        /// <param name="pvarIntentoFallidoCant"></param>
        private static void ActIntentoFallidos(string mvarUsuarioCod, short pvarIntentoFallidoCant)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("UPD_Operador1", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;
            SqlDataReader datos;
            string        idEmpleado = string.Empty;

            myCommand.Parameters.Add("@pUsu_Rut", SqlDbType.VarChar).Value             = mvarUsuarioCod;
            myCommand.Parameters.Add("@pIntentoFallidoFecha", SqlDbType.VarChar).Value = "";
            myCommand.Parameters.Add("@pIntentoFallidoCant", SqlDbType.VarChar).Value  = pvarIntentoFallidoCant;


            try
            {
                myConnection.Open();
                datos = myCommand.ExecuteReader();
                while (datos.Read())
                {
                    idEmpleado = datos.GetString(0);
                }
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                myConnection.Close();
            }
        }
示例#8
0
        public static YouCom.DTO.Seguridad.UsuarioDTO AuntetificaUsuario(string usuario, string password)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("QRY_Operador", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;
            SqlDataReader datos;

            YouCom.DTO.Seguridad.UsuarioDTO theOperadorDTO = new YouCom.DTO.Seguridad.UsuarioDTO();
            string idEmpleado = string.Empty;

            myCommand.Parameters.Add("@pUsuario", SqlDbType.VarChar).Value = usuario;

            try
            {
                myConnection.Open();
                datos = myCommand.ExecuteReader();
                while (datos.Read())
                {
                    if (!datos.IsDBNull(0))
                    {
                        theOperadorDTO.OperadorNro = int.Parse(datos.GetString(0).ToString().Substring(0, datos.GetString(0).ToString().Length - 1));
                        theOperadorDTO.Usuario     = datos.GetString(0).ToString();
                    }

                    if (!datos.IsDBNull(1))
                    {
                        theOperadorDTO.Password = datos.GetString(1);
                    }
                    if (!datos.IsDBNull(2))
                    {
                        theOperadorDTO.Fechapass = datos.GetDateTime(2);
                    }

                    if (!datos.IsDBNull(3))
                    {
                        theOperadorDTO.IntentoFallidoFecha = datos.GetDateTime(3);
                    }
                    if (!datos.IsDBNull(4))
                    {
                        theOperadorDTO.IntentoFallidoCant = datos.GetInt32(4);
                    }

                    if (!datos.IsDBNull(5))
                    {
                        theOperadorDTO.Nombres = datos.GetString(5).ToString();
                    }

                    if (!datos.IsDBNull(6))
                    {
                        theOperadorDTO.Paterno = datos.GetString(6).ToString();
                    }

                    if (!datos.IsDBNull(7))
                    {
                        theOperadorDTO.Materno = datos.GetString(7).ToString();
                    }
                }
                if (theOperadorDTO.Password == password)
                {
                    if (theOperadorDTO.IntentoFallidoCant >= 3)
                    {
                        throw new Exception("4|Estimado Cliente, Supero reintentos permitidos Usuario Bloqueado");
                    }
                    else
                    {
                        ActIntentoFallidos(usuario, 0);
                    }
                }
                else
                {
                    theOperadorDTO.IntentoFallidoCant = theOperadorDTO.IntentoFallidoCant + 1;
                    ActIntentoFallidos(usuario, Convert.ToInt16(theOperadorDTO.IntentoFallidoCant));
                    throw new Exception("2|El usuario o la contraseña son incorrectos.");
                    ///usuario pass erroneas
                    //return false
                }
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                myConnection.Close();
            }

            return(theOperadorDTO);
        }
示例#9
0
        public static YouCom.DTO.Seguridad.OperadorDTO GetGrupos(string pvarUsuarioCod)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("QRY_Permiso3", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;
            SqlDataReader          datos;
            List <FuncionGrupoDTO> ListfuncionGrupo = new List <FuncionGrupoDTO>();
            FuncionGrupoDTO        theFuncionGrupo;
            FuncionDTO             theFuncionDTO;

            YouCom.DTO.Seguridad.OperadorDTO theOperador = new YouCom.DTO.Seguridad.OperadorDTO();
            theOperador.Grupo = new List <FuncionGrupoDTO>();

            myCommand.Parameters.Add("@pUSU_RUT", SqlDbType.VarChar).Value = pvarUsuarioCod;

            try
            {
                myConnection.Open();
                datos = myCommand.ExecuteReader();
                while (datos.Read())
                {
                    theFuncionDTO             = new FuncionDTO();
                    theFuncionGrupo           = new FuncionGrupoDTO();
                    theFuncionGrupo.Funciones = new List <FuncionDTO>();
                    ListfuncionGrupo          = new List <FuncionGrupoDTO>();
                    ///Carga Grupo
                    theFuncionGrupo.FuncionGrupoCod    = datos.GetInt32(0).ToString();
                    theFuncionGrupo.FuncionGrupoNombre = datos.GetString(1);
                    theFuncionGrupo.FuncionGrupoTipo   = datos.GetString(5);

                    ///Carga Funcionalidades de Grupo y Funcionalidades Internas del Negocio
                    theFuncionDTO.FuncionCod = datos.GetInt32(2).ToString();

                    if (!datos.IsDBNull(3))
                    {
                        theFuncionDTO.PadreCod = datos.GetInt32(3);
                    }

                    theFuncionDTO.FuncionNombre        = datos.GetString(4);
                    theFuncionDTO.Url                  = datos.GetString(5);
                    theFuncionDTO.FuncionalidadNegocio = datos.GetString(6);
                    theFuncionGrupo.Funciones.Add(theFuncionDTO);

                    //  ListfuncionGrupo.Add(theFuncionGrupo);
                    theOperador.Grupo.Add(theFuncionGrupo);
                }
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                myConnection.Close();
            }
            return(theOperador);
        }
示例#10
0
        /// <summary>
        /// Lista todos los administradores
        /// </summary>
        /// <returns></returns>
        public static List <UsuarioDTO> ListaAdministradores()
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("QRY_listaAdministradores", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;
            SqlDataReader     datos;
            UsuarioDTO        theUsuarioDTO;
            List <UsuarioDTO> usuario = new List <UsuarioDTO>();

            try
            {
                myConnection.Open();
                datos = myCommand.ExecuteReader();
                while (datos.Read())
                {
                    theUsuarioDTO = new UsuarioDTO();

                    //if (!datos.IsDBNull(0))
                    //{
                    //    theUsuarioDTO.Rut = datos.GetInt32(0).ToString();
                    //}
                    //if (!datos.IsDBNull(1))
                    //{
                    //    theUsuarioDTO.UsuarioIngreso = datos.GetString(1);
                    //}
                    //if (!datos.IsDBNull(2))
                    //{
                    //    theUsuarioDTO.FechaIngreso = datos.GetDateTime(2).ToString();
                    //}
                    //if (!datos.IsDBNull(3))
                    //{
                    //    theUsuarioDTO.Estado = datos.GetString(3);
                    //}
                    //if (!datos.IsDBNull(4))
                    //{
                    //    theUsuarioDTO.Nombres = datos.GetString(4);
                    //}
                    //if (!datos.IsDBNull(5))
                    //{
                    //    theUsuarioDTO.Empresa = datos.GetInt32(5).ToString();
                    //}
                    //if (!datos.IsDBNull(6))
                    //{
                    //    theUsuarioDTO.OperadorDescripcion = datos.GetString(6);
                    //}
                    //if (!datos.IsDBNull(7))
                    //{
                    //    theUsuarioDTO.Paterno = datos.GetString(7);
                    //}
                    //if (!datos.IsDBNull(8))
                    //{
                    //    theUsuarioDTO.Materno = datos.GetString(8);
                    //}
                    //if (!datos.IsDBNull(9))
                    //{
                    //    theUsuarioDTO.Mail = datos.GetString(9);
                    //}
                    //if (!datos.IsDBNull(10))
                    //{
                    //    theUsuarioDTO.Password = datos.GetString(10);
                    //}
                    //if (!datos.IsDBNull(11))
                    //{
                    //    theUsuarioDTO.UsuarioModificacion = datos.GetString(11);
                    //}
                    //if (!datos.IsDBNull(12))
                    //{
                    //    theUsuarioDTO.FechaModificacion = datos.GetDateTime(12).ToString();
                    //}
                    //usuario.Add(theUsuarioDTO);
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            finally
            {
                myConnection.Close();
            }

            return(usuario);
        }
示例#11
0
        /// <summary>
        /// Lista todas las empresas creadas
        /// </summary>
        /// <returns></returns>
        public static List <CondominioDTO> ListaCondominios()
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("QRY_ListaCondominios", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;
            SqlDataReader        datos;
            CondominioDTO        theCondominioDTO;
            List <CondominioDTO> condominio = new List <CondominioDTO>();

            try
            {
                myConnection.Open();
                datos = myCommand.ExecuteReader();
                while (datos.Read())
                {
                    theCondominioDTO = new CondominioDTO();

                    if (!datos.IsDBNull(0))
                    {
                        theCondominioDTO.IdCondominio = datos.GetDecimal(0);
                    }
                    if (!datos.IsDBNull(1))
                    {
                        theCondominioDTO.RutCondominio = datos.GetString(1);
                    }
                    if (!datos.IsDBNull(2))
                    {
                        theCondominioDTO.NombreCondominio = datos.GetString(2);
                    }
                    if (!datos.IsDBNull(3))
                    {
                        theCondominioDTO.TelefonoCondominio = datos.GetString(3);
                    }
                    if (!datos.IsDBNull(4))
                    {
                        theCondominioDTO.EmailCondominio = datos.GetString(4);
                    }
                    if (!datos.IsDBNull(5))
                    {
                        theCondominioDTO.DireccionCondominio = datos.GetString(5);
                    }
                    if (!datos.IsDBNull(6))
                    {
                        theCondominioDTO.UsuarioIngreso = datos.GetString(6);
                    }
                    if (!datos.IsDBNull(7))
                    {
                        theCondominioDTO.FechaIngreso = datos.GetDateTime(7).ToShortDateString();
                    }
                    if (!datos.IsDBNull(8))
                    {
                        theCondominioDTO.UsuarioModificacion = datos.GetString(8);
                    }
                    if (!datos.IsDBNull(9))
                    {
                        theCondominioDTO.FechaModificacion = datos.GetDateTime(9).ToString();
                    }
                    if (!datos.IsDBNull(10))
                    {
                        theCondominioDTO.Estado = datos.GetInt32(10).ToString();
                    }
                    condominio.Add(theCondominioDTO);
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            finally
            {
                myConnection.Close();
            }

            return(condominio);
        }