Exemple #1
0
        public SqlDataReader ObtenerCantidadProducto(String producto)
        {
            ConexionDAOS  conexion = new ConexionDAOS();
            SqlCommand    command  = new SqlCommand();
            SqlDataReader tabla    = null;

            try
            {
                conexion.AbrirConexion();

                command.Connection     = conexion.ObjetoConexion();
                command.CommandType    = System.Data.CommandType.StoredProcedure;
                command.CommandText    = "[dbo].[SumarCantidadProducto]";
                command.CommandTimeout = 10;
                command.Parameters.AddWithValue("@nombreProducto", producto);

                tabla = command.ExecuteReader();
            }
            catch (SqlException e)
            {
                throw new ExcepcionInventario("Error de conexión con la base de datos", e);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(tabla);
        }
Exemple #2
0
        /// <summary>
        /// Este metodo se encarga de insertar una nueva Cuenta Por Pagar en la base de datos.
        /// </summary>
        public bool InsertarCuentasPorPagar(Entidad miCuentaPorPagar)
        {
            // Se Instancia un objeto conexion y otro Sqlcommand para la BD:
            ConexionDAOS miConexion = new ConexionDAOS();
            SqlCommand   command    = new SqlCommand();
            //SqlDataReader reader = null;
            List <Entidad> listaCuentasPorPagar = new List <Entidad>();

            //Variable de control del exito de la Insercion:
            bool fueInsertado = false;

            try
            {
                //Se abre la conexion a la base de datos:
                miConexion.AbrirConexion();
                command.Connection  = miConexion.ObjetoConexion();
                command.CommandType = System.Data.CommandType.StoredProcedure;

                // Aqui debo poner el nombre del storeProcedure..:
                command.CommandText    = "[dbo].[InsertarCuentaPorPagar]";
                command.CommandTimeout = 10;

                // Variables a insertar, pasando al Stored Procedure de sql server
                command.Parameters.AddWithValue("@nroCtaBancaria_entra", (miCuentaPorPagar as CuentaPorPagar).ListaNumeroCuentaBanco.ElementAt(0).NroCuentaBanco);
                command.Parameters.AddWithValue("@fechaEmisionPP", (miCuentaPorPagar as CuentaPorPagar).FechaEmision);
                command.Parameters.AddWithValue("@fechaVencimientoPP", (miCuentaPorPagar as CuentaPorPagar).FechaVencimiento);
                command.Parameters.AddWithValue("@tipoPagoPP", (miCuentaPorPagar as CuentaPorPagar).TipoPago);
                command.Parameters.AddWithValue("@estatusPP", (miCuentaPorPagar as CuentaPorPagar).Estatus);
                command.Parameters.AddWithValue("@tipoDeudaPP", (miCuentaPorPagar as CuentaPorPagar).TipoDeuda);
                command.Parameters.AddWithValue("@detallePP", (miCuentaPorPagar as CuentaPorPagar).Detalle);
                command.Parameters.AddWithValue("@montoPP", (miCuentaPorPagar as CuentaPorPagar).MontoInicialDeuda);

                //Se indica LA DIRECCION de ENTRADA o SALIDA de los Parametros:
                //Son de ENTRADA, por ser un INSERT:

                command.Parameters["@nroCtaBancaria_entra"].Direction = ParameterDirection.Input;
                command.Parameters["@fechaEmisionPP"].Direction       = ParameterDirection.Input;
                command.Parameters["@fechaVencimientoPP"].Direction   = ParameterDirection.Input;
                command.Parameters["@tipoPagoPP"].Direction           = ParameterDirection.Input;
                command.Parameters["@estatusPP"].Direction            = ParameterDirection.Input;
                command.Parameters["@tipoDeudaPP"].Direction          = ParameterDirection.Input;
                command.Parameters["@detallePP"].Direction            = ParameterDirection.Input;
                command.Parameters["@montoPP"].Direction = ParameterDirection.Input;

                //Se ejecuta la insercion de la Cuenta Por Pagar:
                command.ExecuteReader();
            }
            catch (SqlException)
            {
                fueInsertado = false;
                throw new Exception("Error en la conexion a la Base de Datos al Insertar una Cuenta Por Pagar");
            }
            finally
            {
                miConexion.CerrarConexion();
                fueInsertado = true;
            }

            return(fueInsertado);
        }
Exemple #3
0
        //metodo con todos los filtros
        #region MostrarListadoCuentasPorPagar todos los filtros
        public List <CuentaPorPagar> ListaCuentasPorPagarTodosFiltros(string proveedor, string fechaInicio, string fechaFin, string tipoDeuda)
        {
            {
                // instancio un objeto conexion y otro Sqlcommand para la BD
                ConexionDAOS          conex   = new ConexionDAOS();
                SqlCommand            command = new SqlCommand();
                SqlDataReader         reader  = null;
                List <CuentaPorPagar> listaCuentasPorPagar = new List <CuentaPorPagar>();

                try
                {
                    conex.AbrirConexion();
                    command.Connection  = conex.ObjetoConexion();
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    // Aqui debo poner el nombre del storeProcedure que no esta hecho
                    command.CommandText    = "[dbo].[ConsultarCuentasPorPagarFechasProveedor]";
                    command.CommandTimeout = 10;

                    //Aqui van los parametros del store procesure
                    command.Parameters.AddWithValue("@proveedor", proveedor);
                    command.Parameters.AddWithValue("@fechaInicio", fechaInicio);
                    command.Parameters.AddWithValue("@fechaFin", fechaFin);
                    command.Parameters.AddWithValue("@tipoDeuda", tipoDeuda);
                    //Se indica que es un parametro de entrada
                    command.Parameters["@Proveedor"].Direction   = ParameterDirection.Input;
                    command.Parameters["@fechaInicio"].Direction = ParameterDirection.Input;
                    command.Parameters["@fechaFin"].Direction    = ParameterDirection.Input;
                    command.Parameters["@tipoDeuda"].Direction   = ParameterDirection.Input;
                    reader = command.ExecuteReader();
                    // guarda registro a registro cada objeto de tipo cuentaPorPagar
                    while (reader.Read())
                    {
                        CuentaPorPagar cuentaPP = new CuentaPorPagar();
                        cuentaPP.IdCuentaPorPagar = reader.GetString(3);
                        cuentaPP.FechaEmision     = String.Format("{0:yyyy/MM/dd}", reader.GetDateTime(1));
                        cuentaPP.FechaVencimiento = String.Format("{0:yyyy/MM/dd}", reader.GetDateTime(2));
                        cuentaPP.MontoActualDeuda = reader.GetInt32(0);


                        //Lleno la lista de cuentas por pagar
                        listaCuentasPorPagar.Add(cuentaPP);
                    }

                    return(listaCuentasPorPagar);
                }
                catch (SqlException)
                {
                    throw new Exception();
                }

                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    conex.CerrarConexion();
                }
            }
        }
Exemple #4
0
        public Entidad llenarAbonarCpp2(string nombreProveedor, Int64 codigoCuenta)
        {
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS  conex    = new ConexionDAOS();
            SqlCommand    command  = new SqlCommand();
            SqlDataReader reader   = null;
            Entidad       cuentaPP = FabricaEntidad.CrearCuentaPorPagar();

            try
            {
                conex.AbrirConexion();
                command.Connection     = conex.ObjetoConexion();
                command.CommandType    = System.Data.CommandType.StoredProcedure;
                command.CommandText    = "[dbo].[llenarAbonoCpp2]";
                command.CommandTimeout = 10;

                //Aqui van los parametros del store procesure
                command.Parameters.AddWithValue("@proveedor", nombreProveedor);
                command.Parameters.AddWithValue("@idCuentaPP", codigoCuenta);
                //Se indica que es un parametro de entrada
                command.Parameters["@proveedor"].Direction  = ParameterDirection.Input;
                command.Parameters["@idCuentaPP"].Direction = ParameterDirection.Input;

                //CuentaPorPagar cuentaPP = new CuentaPorPagar();
                reader = command.ExecuteReader();
                // guarda registro a registro cada objeto de tipo cuentaPorPagar
                if (reader.Read())
                {
                    NumeroCuentaBanco miNumeroCuentaBanco = new NumeroCuentaBanco();
                    miNumeroCuentaBanco.NroCuentaBanco = reader.GetString(0);
                    (cuentaPP as CuentaPorPagar).ListaNumeroCuentaBanco.Add(miNumeroCuentaBanco);

                    Banco miBanco = new Banco();
                    miBanco.NombreBanco = reader.GetString(1);
                    (cuentaPP as CuentaPorPagar).ListaNumeroCuentaBanco.ElementAt(0).Banco = miBanco;

                    (cuentaPP as CuentaPorPagar).TipoPago = reader.GetString(2);

                    Entidad miabono = FabricaEntidad.CrearAbono();
                    (miabono as Abono).MontoAbono = reader.GetDouble(3);
                    (cuentaPP as CuentaPorPagar).ListaAbono.Add(miabono as Abono);
                }
            }
            catch (SqlException)
            {
                throw new Exception();
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conex.CerrarConexion();
            }
            return(cuentaPP);
        }
Exemple #5
0
        public Usuario TraerUsuario(string Loggin)
        {
            Usuario Us = new Usuario();
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS  conex   = new ConexionDAOS();
            SqlCommand    command = new SqlCommand();
            SqlDataReader reader  = null;


            try
            {
                conex.AbrirConexion();
                command.Connection  = conex.ObjetoConexion();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                // Aqui debo poner el nombre del storeProcedure que no esta hecho
                command.CommandText    = "[dbo].[ConsultarUsuario]";
                command.CommandTimeout = 50;

                //Aqui van los parametros del store procesure
                command.Parameters.AddWithValue("@loggin", Loggin);
                //Se indica que es un parametro de entrada
                command.Parameters["@loggin"].Direction = ParameterDirection.Input;
                reader = command.ExecuteReader();
                // guarda registro a registro cada objeto
                while (reader.Read())
                {
                    Us.Login              = reader.GetString(0);
                    Us.PrimerNombre       = reader.GetString(1);
                    Us.SegundoNombre      = reader.GetValue(2).ToString();
                    Us.PrimerApellido     = reader.GetString(3);
                    Us.SegundoApellido    = reader.GetValue(4).ToString();
                    Us.TipoIdentificacion = reader.GetString(5);
                    Us.Identificacion     = reader.GetValue(6).ToString();
                    Us.FechaNace          = reader.GetDateTime(7);
                    Us.Rol.NombreRol      = reader.GetString(8);
                    Us.Sexo    = reader.GetString(9);
                    Us.Foto    = reader.GetString(10);
                    Us.Estatus = reader.GetString(11).Equals("ACTIVO");
                    Us.Correo  = reader.GetString(12);
                }
                Us = TraerUsuarioDireccion(Us, Loggin);
                Us = TraerUsuarioTelefono(Us, Loggin);
                return(Us);
            }
            catch (SqlException)
            {
                throw new Exception();
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conex.CerrarConexion();
            }
        }
Exemple #6
0
        public List <Entidad> AbonarConsultarCuentasPorPagarFechas(string fechaInicio, string fechaFin)
        {
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS   conex   = new ConexionDAOS();
            SqlCommand     command = new SqlCommand();
            SqlDataReader  reader  = null;
            List <Entidad> listaCuentasPorPagar = new List <Entidad>();

            try
            {
                conex.AbrirConexion();
                command.Connection  = conex.ObjetoConexion();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                // Aqui debo poner el nombre del storeProcedure que no esta hecho
                command.CommandText    = "[dbo].[AbonarConsultarCuentasPorPagarFechas]";
                command.CommandTimeout = 10;

                //Aqui van los parametros del store procesure
                command.Parameters.AddWithValue("@fechaInicio", fechaInicio);
                command.Parameters.AddWithValue("@fechaFin", fechaFin);
                //Se indica que es un parametro de entrada
                command.Parameters["@fechaInicio"].Direction = ParameterDirection.Input;
                command.Parameters["@fechaFin"].Direction    = ParameterDirection.Input;
                reader = command.ExecuteReader();
                // guarda registro a registro cada objeto de tipo cuentaPorPagar



                while (reader.Read())
                {
                    Entidad _cuentaPorPagar = Entidades.FabricasEntidad.FabricaEntidad.CrearCuentaPorPagar();
                    (_cuentaPorPagar as CuentaPorPagar).IdCuentaPorPagar = Convert.ToString(reader.GetInt64(0));
                    (_cuentaPorPagar as CuentaPorPagar).FechaEmision     = String.Format("{0:yyyy/MM/dd}", reader.GetDateTime(1));
                    (_cuentaPorPagar as CuentaPorPagar).FechaVencimiento = String.Format("{0:yyyy/MM/dd}", reader.GetDateTime(2));
                    Proveedor miProveedor = new Proveedor();
                    miProveedor.Nombre = reader.GetString(3);
                    (_cuentaPorPagar as CuentaPorPagar).ListaProveedor.Add(miProveedor);
                    (_cuentaPorPagar as CuentaPorPagar).MontoActualDeuda = Convert.ToDouble(reader.GetFloat(4));

                    //Lleno la lista de cuentas por pagar
                    listaCuentasPorPagar.Add(_cuentaPorPagar);
                }
            }
            catch (SqlException)
            {
                throw new Exception();
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conex.CerrarConexion();
            }
            return(listaCuentasPorPagar);
        }
Exemple #7
0
        public bool ModificarCuentaPorPagar(Entidad cuentaPP)
        {
            // se instancian conexion y sqlcomand para poder abrir la conexion
            ConexionDAOS miConexion    = new ConexionDAOS();
            SqlCommand   command       = new SqlCommand();
            bool         fueModificado = false;


            try
            {
                //se abre una conexion a base de datos
                miConexion.AbrirConexion();
                command.Connection  = miConexion.ObjetoConexion();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                // nombre del store procedure
                command.CommandText    = "[dbo].[ModificarCuentaPorPagar]";
                command.CommandTimeout = 10;

                //variables de entrada del stored procedure
                command.Parameters.AddWithValue("@idCuentaPP", (cuentaPP as CuentaPorPagar).IdCuentaPorPagar);
                command.Parameters.AddWithValue("@fechaEmision", String.Format(String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime((cuentaPP as CuentaPorPagar).FechaEmision).Date)));
                command.Parameters.AddWithValue("@fechaVencimiento", String.Format("{0:yyyy/MM/dd}", String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime((cuentaPP as CuentaPorPagar).FechaVencimiento).Date)));
                //construir la fecha, dia mes ano, o no funcionara

                command.Parameters.AddWithValue("@tipoPago", (cuentaPP as CuentaPorPagar).TipoPago);
                command.Parameters.AddWithValue("@tipoDeuda", (cuentaPP as CuentaPorPagar).TipoDeuda);
                command.Parameters.AddWithValue("@detalle", (cuentaPP as CuentaPorPagar).Detalle);
                command.Parameters.AddWithValue("@MontoCPP", (cuentaPP as CuentaPorPagar).MontoInicialDeuda);
                command.Parameters.AddWithValue("@numeroCuentaBancaria", (cuentaPP as CuentaPorPagar).ListaNumeroCuentaBanco.ElementAt(0).NroCuentaBanco);
                //parametros de entrada
                command.Parameters["@idCuentaPP"].Direction           = ParameterDirection.Input;
                command.Parameters["@fechaEmision"].Direction         = ParameterDirection.Input;
                command.Parameters["@fechaVencimiento"].Direction     = ParameterDirection.Input;
                command.Parameters["@tipoPago"].Direction             = ParameterDirection.Input;
                command.Parameters["@tipoDeuda"].Direction            = ParameterDirection.Input;
                command.Parameters["@detalle"].Direction              = ParameterDirection.Input;
                command.Parameters["@MontoCPP"].Direction             = ParameterDirection.Input;
                command.Parameters["@numeroCuentaBancaria"].Direction = ParameterDirection.Input;
                //se ejecuta el comando para captar los resultados que devuelva el store procedure
                command.ExecuteReader();

                fueModificado = true;
            }
            catch (SqlException)
            {
                fueModificado = false;
                throw new Exception();
            }

            // se cierra la conexion independientemente si fue exitosa o no la eliminacion.
            finally
            {
                miConexion.CerrarConexion();
            }

            return(fueModificado);
        }
Exemple #8
0
        public void CerrarConexionPrueba()
        {
            IConexionDAOS bd       = new ConexionDAOS();
            String        esperado = "Closed";

            bd.AbrirConexion();
            bd.CerrarConexion();
            Assert.AreEqual(esperado, bd.ObjetoConexion().State.ToString());
        }
Exemple #9
0
        public void PruebaAbrirConexionPrueba()
        {
            IConexionDAOS bd       = new ConexionDAOS();
            SqlConnection conexion = new SqlConnection();
            String        esperado = "Open";

            bd.AbrirConexion();
            Assert.AreEqual(esperado, bd.ObjetoConexion().State.ToString());
        }
Exemple #10
0
        public List <NumeroCuentaBanco> ListaConsultaCuentasBancarias()
        {
            {
                // instancio un objeto conexion y otro Sqlcommand para la BD
                ConexionDAOS             conex   = new ConexionDAOS();
                SqlCommand               command = new SqlCommand();
                SqlDataReader            reader  = null;
                List <NumeroCuentaBanco> listaDatosCuentaBancarias = new List <NumeroCuentaBanco>();

                try
                {
                    conex.AbrirConexion();
                    command.Connection  = conex.ObjetoConexion();
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    // Aqui debo poner el nombre del storeProcedure que no esta hecho
                    command.CommandText    = "[dbo].[consultaBancos]";
                    command.CommandTimeout = 10;
                    reader = command.ExecuteReader();

                    //Aqui van los parametros del store procesure
                    //command.Parameters.AddWithValue("@tipoCuenta", nombreTipoCuenta);
                    //Se indica que es un parametro de entrada
                    //command.Parameters["@tipoCuenta"].Direction = ParameterDirection.Input;
                    //reader = command.ExecuteReader();


                    while (reader.Read())
                    {
                        NumeroCuentaBanco infoCuentaBancaria = new NumeroCuentaBanco();

                        infoCuentaBancaria.NomBanco        = reader.GetString(0);
                        infoCuentaBancaria.TipoCuentaBanco = reader.GetString(1);
                        infoCuentaBancaria.NroCuentaBanco  = reader.GetString(2);


                        //Lleno la lista de cuentas por pagar
                        listaDatosCuentaBancarias.Add(infoCuentaBancaria);
                    }

                    return(listaDatosCuentaBancarias);
                }
                catch (SqlException)
                {
                    throw new Exception();
                }

                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    conex.CerrarConexion();
                }
            }
        }
Exemple #11
0
        public List <NumeroCuentaBanco> ListaNumeroCuentaBancariaProveedores(string nombreProveedor, string nombreBanco)
        {
            {
                // instancio un objeto conexion y otro Sqlcommand para la BD
                ConexionDAOS             conex       = new ConexionDAOS();
                SqlCommand               command     = new SqlCommand();
                SqlDataReader            reader      = null;
                List <NumeroCuentaBanco> listaCuenta = new List <NumeroCuentaBanco>();

                try
                {
                    conex.AbrirConexion();
                    command.Connection  = conex.ObjetoConexion();
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    // Aqui debo poner el nombre del storeProcedure que no esta hecho
                    command.CommandText    = "[dbo].[BuscarCuentaProveedor]";
                    command.CommandTimeout = 10;

                    //Aqui van los parametros del store procesure
                    command.Parameters.AddWithValue("@nombreProveedor", nombreProveedor);
                    command.Parameters.AddWithValue("@nombreBanco", nombreBanco);
                    //Se indica que es un parametro de entrada
                    command.Parameters["@nombreProveedor"].Direction = ParameterDirection.Input;
                    command.Parameters["@nombreBanco"].Direction     = ParameterDirection.Input;
                    reader = command.ExecuteReader();
                    // guarda registro a registro cada objeto de tipo cuentaPorPagar

                    while (reader.Read())
                    {
                        NumeroCuentaBanco cuenta = new NumeroCuentaBanco();
                        cuenta.NroCuentaBanco = reader.GetString(0);

                        //Lleno la lista de cuentas por pagar
                        listaCuenta.Add(cuenta);
                    }
                }
                catch (SqlException)
                {
                    throw new Exception();
                }

                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    conex.CerrarConexion();
                }

                return(listaCuenta);
            }
        }
Exemple #12
0
        public List <Entidad> llenarGridAbonos(string nombreProveedor, Int64 codigoCuenta)
        {
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS   conex      = new ConexionDAOS();
            SqlCommand     command    = new SqlCommand();
            SqlDataReader  reader     = null;
            List <Entidad> listaAbono = new List <Entidad>();

            try
            {
                conex.AbrirConexion();
                command.Connection  = conex.ObjetoConexion();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                // Aqui debo poner el nombre del storeProcedure que no esta hecho
                command.CommandText    = "[dbo].[llenarGridAbonos]";
                command.CommandTimeout = 10;

                //Aqui van los parametros del store procesure
                command.Parameters.AddWithValue("@proveedor", nombreProveedor);
                command.Parameters.AddWithValue("@idCuentaPP", codigoCuenta);
                //Se indica que es un parametro de entrada
                command.Parameters["@proveedor"].Direction  = ParameterDirection.Input;
                command.Parameters["@idCuentaPP"].Direction = ParameterDirection.Input;

                reader = command.ExecuteReader();
                // guarda registro a registro cada objeto de tipo cuentaPorPagar
                while (reader.Read())
                {
                    //Abono abonos = new Abono();
                    Entidad _abonos = FabricaEntidad.CrearAbono();
                    (_abonos as Abono).FechaAbono = String.Format("{0:dd/MM/yyyy}", reader.GetDateTime(0));
                    (_abonos as Abono).MontoAbono = reader.GetFloat(1);
                    (_abonos as Abono).Deuda      = reader.GetFloat(2);

                    //Lleno la lista de cuentas por pagar
                    listaAbono.Add(_abonos);
                }
            }
            catch (SqlException)
            {
                throw new Exception();
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conex.CerrarConexion();
            }
            return(listaAbono);
        }
Exemple #13
0
        //public Boolean AgregarBancoBD(string nombreBanco, string numeroCuenta, string tipoCuenta, Boolean estado)
        public Boolean AgregarBancoBD(string nombreBanco, string numeroCuenta, string tipoCuenta, int tipoAgregacion)
        {
            {
                // instancio un objeto conexion y otro Sqlcommand para la BD
                ConexionDAOS  conex   = new ConexionDAOS();
                SqlCommand    command = new SqlCommand();
                SqlDataReader reader  = null;
                // List<Banco> listaBanco = new List<Banco>();

                try
                {
                    conex.AbrirConexion();
                    command.Connection  = conex.ObjetoConexion();
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    // Aqui debo poner el nombre del storeProcedure que no esta hecho
                    if (tipoAgregacion == 1)
                    {
                        command.CommandText = "[dbo].[agregarBancos]";
                    }
                    if (tipoAgregacion == 2)
                    {
                        command.CommandText = "[dbo].[agregarBancosViejos]";
                    }
                    command.CommandTimeout = 10;
                    //Aqui van los parametros del store procesure
                    command.Parameters.AddWithValue("@nombreBanco", nombreBanco);
                    command.Parameters.AddWithValue("@numeroCuenta", numeroCuenta);
                    command.Parameters.AddWithValue("@tipoCuenta", tipoCuenta);
                    //Se indica que es un parametro de entrada
                    // command.Parameters["@nombreBanco"].Direction = ParameterDirection.Input;
                    command.ExecuteReader();
                    // guarda registro a registro cada objeto de tipo cuentaPorPagar

                    return(true);
                }
                catch (SqlException)
                {
                    return(false);

                    throw new Exception();
                }

                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    conex.CerrarConexion();
                }
            }
        }
Exemple #14
0
        //Para el agregar una fecha


        #region ConsultarHorarioMedicoUnafecha


        public int[] ConsultarHorarioMedicoUnaFecha(String nombremedico, String apellidomedico, String diaSemana, String tratamiento)
        {
            //Se instancia un objeto conexion
            ConexionDAOS  miConexion = new ConexionDAOS();
            SqlCommand    command    = new SqlCommand();
            SqlDataReader reader     = null;

            int[] _horariomedico = new int[8];
            try
            {
                //Se abre la conexion a la base de datos
                miConexion.AbrirConexion();
                command.Connection     = miConexion.ObjetoConexion();
                command.CommandType    = System.Data.CommandType.StoredProcedure;
                command.CommandText    = "[dbo].[ConsultarHorarioMedico]";
                command.CommandTimeout = 10;
                command.Parameters.AddWithValue("@nombremedico", nombremedico);
                command.Parameters.AddWithValue("@apellidomedico", apellidomedico);
                command.Parameters.AddWithValue("@tratamiento", tratamiento);
                command.Parameters.AddWithValue("@diaSemana", diaSemana);


                //se ejecuta el metodo del store procedure que busca todos las del sistema
                reader = command.ExecuteReader();

                //Se asigna cada atributo al arregloque tiene el horario del medico
                while (reader.Read())
                {
                    _horariomedico[0] = Convert.ToInt32(reader.GetInt32(0));
                    _horariomedico[1] = Convert.ToInt32(reader.GetInt32(1));
                    _horariomedico[2] = Convert.ToInt32(reader.GetInt32(2));
                }
            }
            catch (SqlException error)
            {
                //En caso de que se viole alguna restriccion sobre la BD
                throw (new ExcepcionCita(("Error: " + error.Message), error));
            }
            catch (Exception errorGeneral)
            {
                //uso interno del grupo 7, para capturar cualquier excepcion y posterior estudio para solventar el problema
                throw (new ExcepcionCita(("Error: " + errorGeneral.Message), errorGeneral));
            }

            finally
            {
                // se cierra la conexion
                miConexion.CerrarConexion();
            }

            return(_horariomedico);
        }
Exemple #15
0
        public Usuario ConfirmacionLoggin(string Loggin, string password)
        {
            {
                // instancio un objeto conexion y otro Sqlcommand para la BD
                ConexionDAOS  conex             = new ConexionDAOS();
                SqlCommand    command           = new SqlCommand();
                SqlDataReader reader            = null;
                Usuario       usuarioConfirmado = new Usuario();

                try
                {
                    conex.AbrirConexion();
                    command.Connection  = conex.ObjetoConexion();
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    // Aqui debo poner el nombre del storeProcedure que no esta hecho
                    command.CommandText    = "[dbo].[BuscarLogin]";
                    command.CommandTimeout = 10;

                    //Aqui van los parametros del store procesure
                    command.Parameters.AddWithValue("@nombreUsuario", Loggin);
                    command.Parameters.AddWithValue("@contraseña", password);
                    //Se indica que es un parametro de entrada
                    command.Parameters["@nombreUsuario"].Direction = ParameterDirection.Input;
                    command.Parameters["@contraseña"].Direction    = ParameterDirection.Input;
                    reader = command.ExecuteReader();
                    // guarda registro a registro cada objeto
                    while (reader.Read())
                    {
                        usuarioConfirmado.Login    = reader.GetString(0);
                        usuarioConfirmado.Password = reader.GetString(1);
                        usuarioConfirmado.Estatus  = reader.GetString(2).ToLower().Equals("activado");
                    }

                    return(usuarioConfirmado);
                }
                catch (SqlException)
                {
                    throw new Exception();
                }

                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    conex.CerrarConexion();
                }
            }
        }
Exemple #16
0
        public List <Privilegio> ListadoPrivilegiosUsuario(string Loggin, string password)
        {
            {
                // instancio un objeto conexion y otro Sqlcommand para la BD
                ConexionDAOS      conex           = new ConexionDAOS();
                SqlCommand        command         = new SqlCommand();
                SqlDataReader     reader          = null;
                List <Privilegio> listaPrivilegio = new List <Privilegio>();

                try
                {
                    conex.AbrirConexion();
                    command.Connection  = conex.ObjetoConexion();
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    // Aqui debo poner el nombre del storeProcedure que no esta hecho
                    command.CommandText    = "[dbo].[BuscarPrivilegios]";
                    command.CommandTimeout = 10;

                    //Aqui van los parametros del store procesure
                    command.Parameters.AddWithValue("@nombreUsuario", Loggin);
                    //Se indica que es un parametro de entrada
                    command.Parameters["@nombreUsuario"].Direction = ParameterDirection.Input;
                    reader = command.ExecuteReader();
                    // guarda registro a registro cada objeto
                    Privilegio privilegio = new Privilegio();
                    while (reader.Read())
                    {
                        privilegio.IdPrivilegio = Convert.ToInt32(reader.GetString(0));
                        listaPrivilegio.Add(privilegio);
                    }

                    return(listaPrivilegio);
                }
                catch (SqlException)
                {
                    throw new Exception();
                }

                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    conex.CerrarConexion();
                }
            }
        }
Exemple #17
0
        public bool ConfirmarCita(int idCita)
        {
            //se instancia un objeto de tipo conexion y sqlCommand
            //estos se utilizan para acceder a base de datos y ejecutar el stored procedure en sql server
            ConexionDAOS miConexion = new ConexionDAOS();
            SqlCommand   command    = new SqlCommand();

            try
            {
                miConexion.AbrirConexion(); //se abre una conexion a base de datos

                // se completa el objeto comando, con la informacion de la conexion , variables, y nombre del stored procedure.
                command.Connection     = miConexion.ObjetoConexion();
                command.CommandType    = System.Data.CommandType.StoredProcedure;
                command.CommandText    = "[dbo].[ConfirmarCita]"; // nombre del StoreProcedure "modificarInvolucrado"
                command.CommandTimeout = 10;

                //variables del stored procedure de sql server.
                command.Parameters.AddWithValue("@idcita", idCita);


                command.Parameters["@idcita"].Direction = ParameterDirection.Input;


                //se ejecuta el comando
                command.ExecuteReader();

                // hacemos el return del ID del cliente para verficar que efectivamente se inserto el cliente
                return(true);
            }
            catch (SqlException error)
            {
                //En caso de que se viole alguna restriccion sobre la BD
                throw (new ExcepcionCita(("Error: " + error.Message), error));
                return(false);
            }
            catch (Exception errorGeneral)
            {
                //uso interno del grupo 7, para capturar cualquier excepcion y posterior estudio para solventar el problema
                throw (new ExcepcionCita(("Error: " + errorGeneral.Message), errorGeneral));
                return(false);
            }

            finally
            {
                miConexion.CerrarConexion();
            }
        }
Exemple #18
0
        public List <string> ListaEstado(string nombrePais)
        {
            {
                // instancio un objeto conexion y otro Sqlcommand para la BD
                ConexionDAOS  conex   = new ConexionDAOS();
                SqlCommand    command = new SqlCommand();
                SqlDataReader reader  = null;


                try
                {
                    conex.AbrirConexion();
                    command.Connection  = conex.ObjetoConexion();
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    // Aqui debo poner el nombre del storeProcedure que no esta hecho
                    command.CommandText    = "[dbo].[ComboEstadoPais]";
                    command.CommandTimeout = 10;

                    command.Parameters.AddWithValue("@parametro", nombrePais);
                    command.Parameters["@parametro"].Direction = ParameterDirection.Input;

                    reader = command.ExecuteReader();

                    List <string> ListaCiudades = new List <string>();
                    while (reader.Read())
                    {
                        ListaCiudades.Add(reader.GetString(0));
                    }

                    return(ListaCiudades);
                }
                catch (SqlException)
                {
                    throw new Exception();
                }

                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    conex.CerrarConexion();
                }
            }
        }
Exemple #19
0
        private Usuario TraerUsuarioDireccion(Usuario Us, string Loggin)
        {
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS  conex   = new ConexionDAOS();
            SqlCommand    command = new SqlCommand();
            SqlDataReader reader  = null;

            try
            {
                conex.AbrirConexion();
                command.Connection     = conex.ObjetoConexion();
                command.CommandType    = System.Data.CommandType.StoredProcedure;
                command.CommandText    = "[dbo].[ConsultarUsuarioDireccion]";
                command.CommandTimeout = 50;
                command.Parameters.AddWithValue("@loggin", Loggin);
                //Se indica que es un parametro de entrada
                command.Parameters["@loggin"].Direction = ParameterDirection.Input;
                reader = command.ExecuteReader();
                // guarda registro a registro cada objeto
                while (reader.Read())
                {
                    Us.Direccion.Edificio  = reader.GetString(0);
                    Us.Direccion.Calle     = reader.GetString(1);
                    Us.Direccion.Municipio = reader.GetString(2);
                    Us.Direccion.Ciudad    = reader.GetString(3);
                    Us.Direccion.Estado    = reader.GetString(4);
                    Us.Direccion.Pais      = reader.GetString(5);
                }

                return(Us);
            }
            catch (SqlException)
            {
                throw new Exception();
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conex.CerrarConexion();
            }
        }
Exemple #20
0
        public bool agregarAbono(Entidad miAbono, Int64 idCuentaPP)
        {
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS  conex        = new ConexionDAOS();
            SqlCommand    command      = new SqlCommand();
            SqlDataReader reader       = null;
            bool          fueInsertado = false;

            try
            {
                conex.AbrirConexion();
                command.Connection     = conex.ObjetoConexion();
                command.CommandType    = System.Data.CommandType.StoredProcedure;
                command.CommandText    = "[dbo].[abonoCuentaPorPagar]";
                command.CommandTimeout = 10;

                //Aqui van los parametros del store procesure
                command.Parameters.AddWithValue("@fechaAbono", (miAbono as Abono).FechaAbono);
                command.Parameters.AddWithValue("@montoAbono", (miAbono as Abono).MontoAbono);
                command.Parameters.AddWithValue("@deuda", (miAbono as Abono).Deuda);
                command.Parameters.AddWithValue("@idCuentaPP", idCuentaPP);

                //Se indica que es un parametro de entrada
                command.Parameters["@fechaAbono"].Direction = ParameterDirection.Input;
                command.Parameters["@montoAbono"].Direction = ParameterDirection.Input;
                command.Parameters["@deuda"].Direction      = ParameterDirection.Input;
                command.Parameters["@idCuentaPP"].Direction = ParameterDirection.Input;

                reader = command.ExecuteReader();
            }
            catch (SqlException)
            {
                fueInsertado = false;
                throw new Exception("Error en la conexion a la Base de Datos al Insertar una Cuenta Por Pagar");
            }

            finally
            {
                conex.CerrarConexion();
                fueInsertado = true;
            }
            return(fueInsertado);
        }
Exemple #21
0
        public List <string> ListaPaises()
        {
            {
                // instancio un objeto conexion y otro Sqlcommand para la BD
                ConexionDAOS  conex   = new ConexionDAOS();
                SqlCommand    command = new SqlCommand();
                SqlDataReader reader  = null;
                // List<Banco> listaBanco = new List<Banco>();

                try
                {
                    conex.AbrirConexion();
                    command.Connection  = conex.ObjetoConexion();
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    // Aqui debo poner el nombre del storeProcedure que no esta hecho
                    command.CommandText    = "[dbo].[ComboPais]";
                    command.CommandTimeout = 10;
                    reader = command.ExecuteReader();

                    List <string> ListaPaises = new List <string>();
                    while (reader.Read())
                    {
                        ListaPaises.Add(reader.GetString(0));
                    }

                    return(ListaPaises);
                }
                catch (SqlException)
                {
                    throw new Exception();
                }

                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    conex.CerrarConexion();
                }
            }
        }
Exemple #22
0
        public bool CambiarEstatusCpp(Entidad miCuenta)
        {
            {
                // instancio un objeto conexion y otro Sqlcommand para la BD
                ConexionDAOS conex        = new ConexionDAOS();
                SqlCommand   command      = new SqlCommand();
                bool         fueInsertado = false;

                try
                {
                    conex.AbrirConexion();
                    command.Connection  = conex.ObjetoConexion();
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    // Aqui debo poner el nombre del storeProcedure que no esta hecho
                    command.CommandText    = "[dbo].[CambiarEstatusCpp]";
                    command.CommandTimeout = 10;

                    //Aqui van los parametros del store procesure
                    command.Parameters.AddWithValue("@estatusPP", (miCuenta as CuentaPorPagar).Estatus);
                    command.Parameters.AddWithValue("@idCuentaPP", (miCuenta as CuentaPorPagar).IdCuentaPorPagar);
                    //Se indica que es un parametro de entrada
                    command.Parameters["@estatusPP"].Direction  = ParameterDirection.Input;
                    command.Parameters["@idCuentaPP"].Direction = ParameterDirection.Input;

                    command.ExecuteReader();
                }
                catch (SqlException)
                {
                    fueInsertado = false;
                    throw new Exception("Error en la conexion a la Base de Datos al Modificar el Estatus de una Cuenta Por Pagar");
                }
                finally
                {
                    conex.CerrarConexion();
                    fueInsertado = true;
                }

                return(fueInsertado);
            }
        }
Exemple #23
0
        public void ObjetoConexionPrueba()
        {
            IConexionDAOS bd = new ConexionDAOS();

            Assert.Null(bd.ObjetoConexion());
        }
Exemple #24
0
        //consultar detalle
        #region Consultar una CuentaPorPagar
        public Entidad ConsultarCuentaPorPagar(string idCuentaPorPagar)
        {
            //  instancia de un objeto de tipo conexion para acceder a la bd
            //  instancia de un objeto de tipo sqlCommand
            ConexionDAOS  miConexion = new ConexionDAOS();
            SqlCommand    command    = new SqlCommand();
            SqlDataReader reader     = null;

            //se carga la informacion consultada en un objeto de tipo cuenta por pagar

            try
            {
                //  se abre la conexion a bd vudu
                miConexion.AbrirConexion();
                command.Connection  = miConexion.ObjetoConexion();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                //nombre del stored Procedure que aun no esta hecho
                command.CommandText    = "[dbo].[ConsultarCuentaPorPagar]";
                command.CommandTimeout = 10;

                //  variables del stored procedure de sql server.
                command.Parameters.AddWithValue("@idCuentaPorPagar", idCuentaPorPagar);

                // Se indica que es un parametro de entrada
                command.Parameters["@idCuentaPorPagar"].Direction = ParameterDirection.Input;

                reader = command.ExecuteReader();

                if (reader.Read())
                {
                    (_cuentaPorPagar as CuentaPorPagar).IdCuentaPorPagar = Convert.ToString(reader.GetInt64(0));
                    (_cuentaPorPagar as CuentaPorPagar).FechaEmision     = String.Format("{0:yyyy/MM/dd}", Convert.ToString(reader.GetDateTime(1)));
                    (_cuentaPorPagar as CuentaPorPagar).FechaVencimiento = String.Format("{0:yyyy/MM/dd}", Convert.ToString(reader.GetDateTime(2)));
                    (_cuentaPorPagar as CuentaPorPagar).TipoPago         = reader.GetString(3);
                    (_cuentaPorPagar as CuentaPorPagar).Estatus          = reader.GetString(4);
                    (_cuentaPorPagar as CuentaPorPagar).TipoDeuda        = reader.GetString(5);

                    //Puede dar error si los inserts son nulos:
                    if (!reader.IsDBNull(6))
                    {
                        (_cuentaPorPagar as CuentaPorPagar).Detalle = reader.GetString(6);
                    }
                    else
                    {
                        (_cuentaPorPagar as CuentaPorPagar).Detalle = "";
                    }

                    (_cuentaPorPagar as CuentaPorPagar).MontoInicialDeuda = Convert.ToDouble(reader.GetFloat(7));

                    Proveedor miProveedor = new Proveedor();
                    miProveedor.Nombre = reader.GetString(8);
                    (_cuentaPorPagar as CuentaPorPagar).ListaProveedor.Add(miProveedor);

                    NumeroCuentaBanco miNumeroCuentaBanco = new NumeroCuentaBanco();
                    miNumeroCuentaBanco.NroCuentaBanco = reader.GetString(9);
                    (_cuentaPorPagar as CuentaPorPagar).ListaNumeroCuentaBanco.Add(miNumeroCuentaBanco);

                    Banco miBanco = new Banco();
                    miBanco.NombreBanco = reader.GetString(10);
                    (_cuentaPorPagar as CuentaPorPagar).ListaNumeroCuentaBanco.ElementAt(0).Banco = miBanco;
                }
            }
            catch (SqlException)
            {
                throw new Exception();
            }

            //se cierra la conexion independientemente de que se haya detectado o no una excepcion.
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                miConexion.CerrarConexion();
            }

            return(_cuentaPorPagar);
        }
Exemple #25
0
        /*
         * public Entidad ConsultarUsuarioPorIdentificador(int identificador)
         * {
         *  // instancio un objeto conexion y otro Sqlcommand para la BD
         *  ConexionDAOS conex = new ConexionDAOS();
         *  SqlCommand command = new SqlCommand();
         *  SqlDataReader reader = null;
         *
         *  try
         *  {
         *      conex.AbrirConexion();
         *      command.Connection = conex.ObjetoConexion();
         *      command.CommandType = System.Data.CommandType.StoredProcedure;
         *      // Aqui debo poner el nombre del storeProcedure que no esta hecho
         *      command.CommandText = "[dbo].[ConsultarUsuarioPorIdentificador]";
         *      command.CommandTimeout = 50;
         *      reader = command.ExecuteReader();
         *
         *      if (reader.Read())
         *      {
         *          Entidad _miUsuario = FabricaEntidad.NuevaUsuario();
         *          (_miUsuario as Usuario).IdUsuario = Int32.Parse(reader.GetValue(0).ToString());;
         *          (_miUsuario as Usuario).Identificacion = reader.GetValue(1).ToString();
         *          (_miUsuario as Usuario).TipoIdentificacion = reader.GetString(2);
         *          (_miUsuario as Usuario).PrimerNombre = reader.GetString(3);
         *          (_miUsuario as Usuario).PrimerApellido = reader.GetString(4);
         *          (_miUsuario as Usuario).SegundoApellido = reader.GetValue(5).ToString();
         *          return _miUsuario;
         *      }
         *  }
         *  catch (SqlException)
         *  {
         *
         *      throw new Exception();
         *  }
         *
         *  finally
         *  {
         *      if (reader != null)
         *          reader.Close();
         *      conex.CerrarConexion();
         *  }
         *  return null;
         * }
         *
         * }*/

        #endregion

        #region Agregar Usuario
        public bool AgregarUsuario(Entidad usuario)
        {
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS conex2   = new ConexionDAOS();
            SqlCommand   command2 = new SqlCommand();

            try
            {
                SqlConnection conexion = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnUricao"].ToString());
                conexion.Open();

                /*cmd = new SqlCommand("dbo.AgregarEmpleado", conexion);
                 * cmd.CommandType = CommandType.StoredProcedure;
                 *
                 * db.AbrirConexion();*/


                conex2.AbrirConexion();
                command2.Connection     = conexion;
                command2.CommandType    = System.Data.CommandType.StoredProcedure;
                command2.CommandText    = "[dbo].[AgregarUsuario]";
                command2.CommandTimeout = 50;
                //Aqui van los parametros del store procesure
                //command.Parameters.AddWithValue("@loggin", Loggin);
                //Se indica que es un parametro de entrada
                //command.Parameters["@loggin"].Direction = ParameterDirection.Input;

                command2.Parameters.AddWithValue("@login", (usuario as Usuario).Login);
                command2.Parameters.AddWithValue("@password", (usuario as Usuario).Password);
                command2.Parameters.AddWithValue("@tipoCi", (usuario as Usuario).TipoIdentificacion);
                command2.Parameters.AddWithValue("@cedula", (usuario as Usuario).Identificacion);
                command2.Parameters.AddWithValue("@primerNombre", (usuario as Usuario).PrimerNombre);
                command2.Parameters.AddWithValue("@segundoNombre", "NULL");
                command2.Parameters.AddWithValue("@primerApellido", (usuario as Usuario).PrimerApellido);
                command2.Parameters.AddWithValue("@segundoApellido", "NULL");
                command2.Parameters.AddWithValue("@fechaNace", "12/12/12");
                command2.Parameters.AddWithValue("@fechaIngreso", "12/12/12");
                command2.Parameters.AddWithValue("@sexo", (usuario as Usuario).Sexo);
                command2.Parameters.AddWithValue("@correo", (usuario as Usuario).Correo);
                //cmd.Parameters.AddWithValue("@ocupacion", null);
                command2.Parameters.AddWithValue("@foto", "NULL");

                command2.Parameters.AddWithValue("@estado", "activo");
                ///command.Parameters.AddWithValue("@estado", (usuario as Usuario).Estado);


                //cmd.Parameters.AddWithValue("@sueldo", (usuario as Usuario).Sueldo);
                //cmd.Parameters.AddWithValue("@cargo", (usuario as Usuario).Especialidad);
                command2.Parameters.AddWithValue("@codigotlf", "212");
                command2.Parameters.AddWithValue("@numtelefono", (usuario as Usuario).Telefono.ElementAt(0));
                command2.Parameters.AddWithValue("@tipotelefono", "Movil");

                command2.Parameters.AddWithValue("@ciudad", "Caracas");

                // command.Parameters.AddWithValue("@ciudad", (usuario as Usuario).Direccion.Ciudad);
                command2.Parameters.AddWithValue("@municipio", (usuario as Usuario).Direccion.Municipio);
                command2.Parameters.AddWithValue("@calle", (usuario as Usuario).Direccion.Calle);
                command2.Parameters.AddWithValue("@edificio", (usuario as Usuario).Direccion.Edificio);

                command2.ExecuteNonQuery();

                //command.ExecuteNonQuery();

                /*dr = cmd.ExecuteReader();
                 *
                 * db.AbrirConexion();
                 *
                 * while (dr.Read())
                 * {
                 *  objetoEmpleado = new Empleado();
                 *  objetoEmpleado.Identificacion = dr.GetValue(0).ToString();
                 *  objetoEmpleado.PrimerNombre = dr.GetValue(1).ToString();
                 *  objetoEmpleado.PrimerApellido = dr.GetValue(2).ToString();
                 *  objetoEmpleado.Especialidad = dr.GetValue(3).ToString();
                 *
                 *  miListaEmpleado.Add(objetoEmpleado);
                 * }*/

                //db.CerrarConexion();
                conexion.Close();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
            finally
            {
                //db.CerrarConexion();
                conex.CerrarConexion();
            }

            return(true);
        }
Exemple #26
0
        public List <Entidad> ConsultarUsuarioParametrizado(string parametro, int seleccion)
        {
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS  conex   = new ConexionDAOS();
            SqlCommand    command = new SqlCommand();
            SqlDataReader reader  = null;

            try
            {
                conex.AbrirConexion();
                command.Connection  = conex.ObjetoConexion();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                switch (seleccion)
                {
                case 1:
                    command.CommandText = "[dbo].[ConsultarUsuarioNombre]";
                    break;

                case 2:
                    command.CommandText = "[dbo].[ConsultarUsuarioApellido]";
                    break;

                case 3:
                    command.CommandText = "[dbo].[ConsultarUsuarioIdentificacion]";
                    break;

                case 4:
                    command.CommandText = "[dbo].[ConsultarUsuarioRol]";
                    break;

                case 5:
                    command.CommandText = "[dbo].[ConsultarUsuarioUsuario]";
                    break;
                }


                command.CommandTimeout = 50;

                //Aqui van los parametros del store procesure
                command.Parameters.AddWithValue("@parametro", parametro + "%_%");
                //Se indica que es un parametro de entrada
                command.Parameters["@parametro"].Direction = ParameterDirection.Input;
                reader = command.ExecuteReader();
                // guarda registro a registro cada objeto
                List <Entidad> ListaUs = new List <Entidad>();
                while (reader.Read())
                {
                    /*Usuario Us = new Usuario();
                     * Us.Login = reader.GetString(0);
                     * Us.PrimerNombre = reader.GetString(1);
                     * Us.SegundoNombre = reader.GetValue(2).ToString();
                     * Us.PrimerApellido = reader.GetString(3);
                     * Us.SegundoApellido = reader.GetValue(4).ToString();
                     * Us.TipoIdentificacion = reader.GetString(5);
                     * Us.Identificacion = reader.GetValue(6).ToString();
                     * Us.FechaNace = reader.GetDateTime(7);
                     * Us.Rol.NombreRol = reader.GetString(8);
                     * Us.Sexo = reader.GetString(9);
                     * Us.Foto = reader.GetValue(10).ToString();
                     * Us.Estatus = reader.GetString(11).ToUpper().Contains("ACTIVO");
                     * Us.Correo = reader.GetValue(12).ToString();
                     * Us = TraerUsuarioDireccion(Us, Us.Login);
                     * Us = TraerUsuarioTelefono(Us, Us.Login);
                     * ListaUs.Add(Us);*/

                    Entidad _usuario = FabricaEntidad.NuevaUsuario();
                    //Entidad Us = new FabricaEntidad.NuevaUsuario();
                    //Us = FabricaEntidad.NuevaUsuario();
                    (_usuario as Usuario).Login              = reader.GetString(0);
                    (_usuario as Usuario).PrimerNombre       = reader.GetString(1);
                    (_usuario as Usuario).SegundoNombre      = reader.GetValue(2).ToString();
                    (_usuario as Usuario).PrimerApellido     = reader.GetString(3);
                    (_usuario as Usuario).SegundoApellido    = reader.GetValue(4).ToString();
                    (_usuario as Usuario).TipoIdentificacion = reader.GetString(5);
                    (_usuario as Usuario).Identificacion     = reader.GetValue(6).ToString();
                    (_usuario as Usuario).FechaNace          = reader.GetDateTime(7);
                    (_usuario as Usuario).Rol.NombreRol      = reader.GetString(8);
                    (_usuario as Usuario).Sexo      = reader.GetString(9);
                    (_usuario as Usuario).Foto      = reader.GetValue(10).ToString();
                    (_usuario as Usuario).Estatus   = reader.GetString(11).ToUpper().Contains("ACTIVO");
                    (_usuario as Usuario).Correo    = reader.GetValue(12).ToString();
                    (_usuario as Usuario).Direccion = TraerUsuarioDireccion((_usuario as Usuario), (_usuario as Usuario).Login).Direccion;
                    (_usuario as Usuario).Telefono  = TraerUsuarioTelefono((_usuario as Usuario), (_usuario as Usuario).Login).Telefono;
                    ListaUs.Add(_usuario);
                }

                return(ListaUs);
            }
            catch (SqlException)
            {
                throw new Exception();
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conex.CerrarConexion();
            }
        }