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); }
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); }
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); }
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); }