Exemplo n.º 1
0
        public List <Rank> GetAll()
        {
            var        categoryList = new List <Rank>();
            SqlCommand cmd          = new SqlCommand("Select * from Ranks");

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Rank category = new Rank()
                {
                    RankId   = Convert.ToInt32(reader[0]),
                    RankName = reader[1].ToString(),
                };

                categoryList.Add(category);
            }
            return(categoryList);
        }
Exemplo n.º 2
0
        public Rank Get(int id)
        {
            SqlCommand cmd = new SqlCommand("Select * from Ranks where Id = @RankId");

            cmd.Parameters.AddWithValue("RankId", id);

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Rank category = new Rank()
                {
                    RankId   = Convert.ToInt32(reader[0]),
                    RankName = reader[1].ToString(),
                };

                return(category);
            }
            return(null);
        }
Exemplo n.º 3
0
        public List <Employee> GetAll()
        {
            var        empList = new List <Employee>();
            SqlCommand cmd     = new SqlCommand("Select * from Employees");

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Employee emp = new Employee
                {
                    Id        = Convert.ToInt32(reader[0]),
                    FirstName = reader[1].ToString(),
                    LastName  = reader[2].ToString(),
                    Salary    = Convert.ToDecimal(reader[3]),
                    RankId    = Convert.ToInt32(reader[4]),
                };

                empList.Add(emp);
            }
            return(empList);
        }
Exemplo n.º 4
0
        public Employee Get(int id)
        {
            SqlCommand cmd = new SqlCommand("Select * from Employees where Id = @Id");

            cmd.Parameters.AddWithValue("Id", id);

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Employee emp = new Employee
                {
                    Id        = Convert.ToInt32(reader[0]),
                    FirstName = reader[1].ToString(),
                    LastName  = reader[2].ToString(),
                    Salary    = Convert.ToDecimal(reader[3]),
                    RankId    = Convert.ToInt32(reader[4]),
                };

                return(emp);
            }
            return(null);
        }