/// <summary> /// Trả về tất cả các seccerLive /// </summary> /// <returns>List</returns> public List <clsSoccerLive> getAll() { try { List <clsSoccerLive> objList = new List <clsSoccerLive>(); SqlCommand com = new SqlCommand("iBet_tblSoccerLive_Gets", conn.GetConn()); com.CommandType = System.Data.CommandType.StoredProcedure; conn.OpenConn(); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { clsSoccerLive obj = new clsSoccerLive(); if (dr["ID"] != DBNull.Value) { obj.Id = Convert.ToInt32(dr["ID"]); } if (dr["AccID"] != DBNull.Value) { obj.AccId = Convert.ToInt64(dr["AccID"]); } if (dr["Handi_NG"] != DBNull.Value) { obj.Handi_NG = Convert.ToDecimal(dr["Handi_NG"]); } if (dr["Over_Under"] != DBNull.Value) { obj.Over_Under = Convert.ToDecimal(dr["Over_Under"]); } if (dr["FirtHandicap"] != DBNull.Value) { obj.FirtHandicap = Convert.ToDecimal(dr["FirtHandicap"]); } if (dr["FirtOverUnder"] != DBNull.Value) { obj.FirtOverUnder = Convert.ToDecimal(dr["FirtOverUnder"]); } objList.Add(obj); } return(objList); } catch (Exception) { throw; } finally { conn.CloseConn(); } }
/// <summary> /// Trả về theo ID /// </summary> /// <param name="id">ID cần tìm</param> /// <returns>đối tượng SoccerLive</returns> public clsSoccerLive getById(int id) { try { clsSoccerLive obj = new clsSoccerLive(); SqlCommand com = new SqlCommand("iBet_tblSoccerLive_Get", conn.GetConn()); com.CommandType = System.Data.CommandType.StoredProcedure; com.Parameters.AddWithValue("@Id", id); conn.OpenConn(); SqlDataReader dr = com.ExecuteReader(); if (dr.Read()) { if (dr["ID"] != DBNull.Value) { obj.Id = Convert.ToInt32(dr["ID"]); } if (dr["AccID"] != DBNull.Value) { obj.AccId = Convert.ToInt64(dr["AccID"]); } if (dr["Handi_NG"] != DBNull.Value) { obj.Handi_NG = Convert.ToDecimal(dr["Handi_NG"]); } if (dr["Over_Under"] != DBNull.Value) { obj.Over_Under = Convert.ToDecimal(dr["Over_Under"]); } if (dr["FirtHandicap"] != DBNull.Value) { obj.FirtHandicap = Convert.ToDecimal(dr["FirtHandicap"]); } if (dr["FirtOverUnder"] != DBNull.Value) { obj.FirtOverUnder = Convert.ToDecimal(dr["FirtOverUnder"]); } } return(obj); } catch (Exception) { throw; } finally { conn.CloseConn(); } }