Esempio n. 1
0
        public List <Usuario> GetUsuarios(
            string cuenta,
            string nombres,
            string apellidos,
            int idCargo,
            Constants.Perfiles perfilToFind,
            bool showAllPerfiles,
            bool finalizaHistoria,
            bool showAllFinalizaHistoria,
            bool isAdministrador,
            bool showAllAdministrador,
            bool activo,
            bool showAllActivo)
        {
            List <Usuario> usuarioList = new List <Usuario>();

            try
            {
                foreach (DataRow row in (InternalDataCollectionBase)this.GetList(cuenta, nombres, apellidos, idCargo, perfilToFind, showAllPerfiles, finalizaHistoria, showAllFinalizaHistoria, isAdministrador, showAllAdministrador, activo, showAllActivo).Rows)
                {
                    Usuario objToLoad = new Usuario();
                    this.LoadFromDataRow(ref objToLoad, row);
                    usuarioList.Add(objToLoad);
                }
            }
            catch (Exception ex)
            {
                this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
            }
            return(usuarioList);
        }
        public List <Usuario> GetUsuarios(
            string cuenta,
            string nombres,
            string apellidos,
            int idCargo,
            Constants.Perfiles perfilToFind,
            bool showAllPerfiles,
            bool finalizaHistoria,
            bool showAllfinalizaHistoria,
            bool administrador,
            bool showAllAdministrador,
            bool activo,
            bool showAllActivo)
        {
            UsuarioDao     usuarioDao = new UsuarioDao();
            List <Usuario> usuarios   = usuarioDao.GetUsuarios(cuenta, nombres, apellidos, idCargo, perfilToFind, showAllPerfiles, finalizaHistoria, showAllfinalizaHistoria, administrador, showAllAdministrador, activo, showAllActivo);

            this.error = usuarioDao.Error;
            return(usuarios);
        }
Esempio n. 3
0
        public DataTable GetList(
            string cuenta,
            string nombres,
            string apellidos,
            int idCargo,
            Constants.Perfiles perfilToFind,
            bool showAllPerfiles,
            bool finalizaHistoria,
            bool showAllFinalizaHistoria,
            bool isAdministrador,
            bool showAllAdministrador,
            bool activo,
            bool showAllActivo)
        {
            DataTable dtEstructure = UsuarioDao.DtEstructure;

            try
            {
                DbConnection connection = this.instance.CreateConnection();
                try
                {
                    connection.Open();
                    DbCommand storedProcCommand = this.instance.GetStoredProcCommand("PA_USUARIO_GET_LIST");
                    storedProcCommand.Connection = connection;
                    if (cuenta != string.Empty)
                    {
                        this.instance.AddInParameter(storedProcCommand, "@CUENTA", DbType.String, (object)cuenta);
                    }
                    else
                    {
                        this.instance.AddInParameter(storedProcCommand, "@CUENTA", DbType.String, (object)DBNull.Value);
                    }
                    if (nombres != string.Empty)
                    {
                        this.instance.AddInParameter(storedProcCommand, "@NOMBRES", DbType.String, (object)nombres);
                    }
                    else
                    {
                        this.instance.AddInParameter(storedProcCommand, "@NOMBRES", DbType.String, (object)DBNull.Value);
                    }
                    if (apellidos != string.Empty)
                    {
                        this.instance.AddInParameter(storedProcCommand, "@APELLIDOS", DbType.String, (object)apellidos);
                    }
                    else
                    {
                        this.instance.AddInParameter(storedProcCommand, "@APELLIDOS", DbType.String, (object)DBNull.Value);
                    }
                    if (idCargo != int.MinValue)
                    {
                        this.instance.AddInParameter(storedProcCommand, "@ID_CARGO", DbType.Int32, (object)idCargo);
                    }
                    else
                    {
                        this.instance.AddInParameter(storedProcCommand, "@ID_CARGO", DbType.Int32, (object)DBNull.Value);
                    }
                    if (!showAllPerfiles)
                    {
                        this.instance.AddInParameter(storedProcCommand, "@ID_PERFIL", DbType.Int32, (object)Convert.ToInt32((object)perfilToFind));
                    }
                    else
                    {
                        this.instance.AddInParameter(storedProcCommand, "@ID_PERFIL", DbType.Int32, (object)DBNull.Value);
                    }
                    if (!showAllFinalizaHistoria)
                    {
                        this.instance.AddInParameter(storedProcCommand, "@FINALIZA_HISTORIA", DbType.Boolean, (object)finalizaHistoria);
                    }
                    else
                    {
                        this.instance.AddInParameter(storedProcCommand, "@FINALIZA_HISTORIA", DbType.Boolean, (object)DBNull.Value);
                    }
                    if (!showAllAdministrador)
                    {
                        this.instance.AddInParameter(storedProcCommand, "@ADMINISTRADOR", DbType.Boolean, (object)isAdministrador);
                    }
                    else
                    {
                        this.instance.AddInParameter(storedProcCommand, "@ADMINISTRADOR", DbType.Boolean, (object)DBNull.Value);
                    }
                    if (!showAllActivo)
                    {
                        this.instance.AddInParameter(storedProcCommand, "@ACTIVO", DbType.Boolean, (object)activo);
                    }
                    else
                    {
                        this.instance.AddInParameter(storedProcCommand, "@ACTIVO", DbType.Boolean, (object)DBNull.Value);
                    }
                    DbDataAdapter dataAdapter = this.instance.GetDataAdapter();
                    dataAdapter.SelectCommand = storedProcCommand;
                    dataAdapter.Fill(dtEstructure);
                }
                catch (Exception ex)
                {
                    this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                }
                finally
                {
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
            }
            return(dtEstructure);
        }