public List <EntityLayers.RoomType> BookNowDDLWCF() { try { SqlCommand _cmd = new SqlCommand("select RoomType, RoomTypeID from RoomType", _conObj); _conObj.Open(); SqlDataReader dr = _cmd.ExecuteReader(); List <EntityLayers.RoomType> _listObj1 = new List <EntityLayers.RoomType>(); if (dr.HasRows) { while (dr.Read()) { EntityLayers.RoomType _menuIDObj = new EntityLayers.RoomType() { _roomType = dr[0].ToString(), _roomTypeID = int.Parse(dr[1].ToString()) }; _listObj1.Add(_menuIDObj); } } return(_listObj1); } catch (Exception) { throw; } finally { _conObj.Close(); } }
/// <summary> /// Method for Retreving values for Drop Down List for displaying Room Type /// </summary> /// <returns>Returns the list of Roomtype and RomTypeID</returns> public List <EntityLayers.RoomType> RoomTypes() { SqlConnection _conobj = new SqlConnection(constr); try { SqlCommand _cmd = new SqlCommand("select RoomType,RoomTypeID from RoomType", _conobj); _conobj.Open(); SqlDataReader dr = _cmd.ExecuteReader(); List <EntityLayers.RoomType> _listObj = new List <EntityLayers.RoomType>(); if (dr.HasRows) { while (dr.Read()) { EntityLayers.RoomType _roomtypeObj = new EntityLayers.RoomType() { _roomType = dr[0].ToString(), _roomTypeID = int.Parse(dr[1].ToString()) }; _listObj.Add(_roomtypeObj); } } _cmd.Dispose(); return(_listObj); } catch (SqlException) { throw; } finally { _conobj.Close(); } }