Esempio n. 1
0
        public List <GestCorProfile> GetProfiles()
        {
            Connection      conn    = new Connection();
            OleDbConnection objConn = conn.Conn();

            string commText = "select * from YTBL_PROFILEGESTCOR order by id desc";

            objConn.Open();
            OleDbCommand cmd = new OleDbCommand();

            cmd.Connection  = objConn;
            cmd.CommandText = commText;
            cmd.CommandType = CommandType.Text;
            OleDbDataReader myReader = cmd.ExecuteReader();

            List <GestCorProfile> ProfilesList = new List <GestCorProfile>();

            try
            {
                if (myReader.HasRows)
                {
                    while (myReader.Read())
                    {
                        GestCorProfile Profile = new GestCorProfile();

                        Profile.Id          = int.Parse(myReader.GetDecimal(0).ToString());
                        Profile.NameProfile = myReader.GetString(1);
                        Profile.RolId       = int.Parse(myReader.GetDecimal(2).ToString());
                        Profile.NameRol     = getNameRol(int.Parse(myReader.GetDecimal(2).ToString()));
                        Profile.IdModule    = int.Parse(myReader.GetDecimal(3).ToString());
                        Profile.NameModule  = getNameModule(int.Parse(myReader.GetDecimal(3).ToString()));
                        Profile.IsValid     = myReader.GetString(4);

                        ProfilesList.Add(Profile);
                    }
                }

                return(ProfilesList);
            }
            catch (Exception ex)
            {
                myReader.Close();
                objConn.Close();
                Logs.WriteErrorLog("Error en la consulta de datos||" + ex.ToString());
                return(ProfilesList);
            }
            finally
            {
                myReader.Close();
                objConn.Close();
            }
        }
Esempio n. 2
0
        public UserGestCor GetUsersById(int id)
        {
            conn = new Connection();
            OleDbConnection objConn = conn.Conn();

            string commText = "select * from YTBL_USERSGESTCOR where id =" + id;

            objConn.Open();
            OleDbCommand cmd = new OleDbCommand();

            cmd.Connection  = objConn;
            cmd.CommandText = commText;
            cmd.CommandType = CommandType.Text;
            OleDbDataReader myReader = cmd.ExecuteReader();

            UserGestCor    User    = new UserGestCor();
            GestCorProfile RolName = new GestCorProfile();

            try
            {
                if (myReader.HasRows)
                {
                    while (myReader.Read())
                    {
                        User.Id       = int.Parse(myReader.GetDecimal(2).ToString());
                        User.NickUser = myReader.GetString(1);
                        User.IdRol    = int.Parse(myReader.GetDecimal(2).ToString());
                        User.NameRol  = RolName.getNameRol(int.Parse(myReader.GetDecimal(2).ToString()));
                        User.IsValid  = myReader.GetString(3);
                        try
                        {
                            User.DateFrom = myReader.GetDateTime(4);
                        }
                        catch (Exception ex)
                        {
                            User.DateFrom = null;
                        }
                        try
                        {
                            User.DateTo = myReader.GetDateTime(5);
                        }
                        catch (Exception ex)
                        {
                            User.DateTo = null;
                        }
                    }
                }

                return(User);
            }
            catch (Exception ex)
            {
                myReader.Close();
                objConn.Close();
                Logs.WriteErrorLog("Error en la consulta de datos||" + ex.ToString());
                return(User);
            }
            finally
            {
                myReader.Close();
                objConn.Close();
            }
        }