CapDemo.BL.RoundBL.GetRound C# (CSharp) Method

GetRound() public method

public GetRound ( ) : List
return List
        public List<Round> GetRound()
        {
            List<Round> RoundList = new List<Round>();
            string query = "SELECT [Round_ID],[Competition_ID],[Round_Name]"
                            + " FROM [Round]";
            DataTable dt = DA.SelectDatabase(query);
            if (dt!= null)
            {
                foreach (DataRow item in dt.Rows)
                {
                    Round Round = new Round();
                    Round.IDRound = Convert.ToInt32(item["Round_ID"].ToString());
                    Round.IDCompetition = Convert.ToInt32(item["Competition_ID"].ToString());
                    Round.NameRound = item["Round_Name"].ToString();
                    RoundList.Add(Round);
                }
            }
            return RoundList;
        }

Usage Example

 //Get Id Round
 public void GetIDround()
 {
     RoundBL RoundBl = new RoundBL();
     List<Round> ListRound;
     ListRound = RoundBl.GetRound();
     if (ListRound != null)
     {
         for (int i = 0; i < ListRound.Count; i++)
         {
             if (cmb_Round.SelectedItem.ToString() == ListRound.ElementAt(i).NameRound && ListRound.ElementAt(i).IDCompetition == idCompetition)
             {
                 idRound = ListRound.ElementAt(i).IDRound;
             }
         }
     }
 }