Beispiel #1
0
        public static rrNews GetNews(int NewsId)
        {
            rrNews result = null;

            using (SqlConnection conn = new SqlConnection(SQL.RifleRange))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("dbo.usp_GetNews", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@NewsId", NewsId);
                    conn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null && !reader.IsClosed)
                    {
                        while (reader.Read())
                        {
                            result = new rrNews(reader);
                        }
                        reader.Close();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message, ex);
                }
            }
            return(result);
        }
Beispiel #2
0
        public static LinkedList <rrNews> GetNewsList()
        {
            LinkedList <rrNews> result = new LinkedList <rrNews>();

            using (SqlConnection conn = new SqlConnection(SQL.RifleRange))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("dbo.usp_GetNews", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    conn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null && !reader.IsClosed)
                    {
                        result = new LinkedList <rrNews>();
                        while (reader.Read())
                        {
                            rrNews obj = new rrNews(reader);
                            result.AddLast(obj);
                        }
                        reader.Close();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message, ex);
                }
            }
            return(result);
        }