Esempio n. 1
0
        //获取置顶News
        public News GetTopNews()
        {
            //sql语句
            string sql     = "select * from News,NState where News.NState=NState.NStateId and NState.NStateId=2";
            News   topnews = null;

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, sql))
            {
                if (reader.Read())
                {
                    AdminService  adminService  = new AdminService();
                    NStateService nstateService = new NStateService();

                    topnews               = new News();
                    topnews.id            = (int)reader["id"];
                    topnews.NewsTitle     = (string)reader["NewsTitle"];
                    topnews.NewsMain      = (string)reader["NewsMain"];
                    topnews.NewsDate      = reader["NewsDate"] != DBNull.Value ? (DateTime?)reader["NewsDate"] : null;
                    topnews.NewsPublisher = adminService.GetAdminById((int)reader["NewsPublisher"]);
                    topnews.NState        = nstateService.GetNStateById((int)reader["NState"]);
                    topnews.NewsHits      = (int)reader["NewsHits"];
                }
            }
            return(topnews);
        }
Esempio n. 2
0
        //获取置顶Notices
        public Notices GetTopNotices()
        {
            //sql语句
            string  sql        = "select * from Notices,NState where Notices.NState=NState.NStateId and NState.NStateId=2";
            Notices topnotices = null;

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, sql))
            {
                if (reader.Read())
                {
                    AdminService      adminService      = new AdminService();
                    DepartmentService departmentService = new DepartmentService();
                    NStateService     nstateService     = new NStateService();

                    topnotices                 = new Notices();
                    topnotices.id              = (int)reader["id"];
                    topnotices.NoticeTitle     = (string)reader["NoticeTitle"];
                    topnotices.NoticeMain      = (string)reader["NoticeMain"];
                    topnotices.NoticeDate      = reader["NoticeDate"] != DBNull.Value ? (DateTime?)reader["NoticeDate"] : null;
                    topnotices.NoticePublisher = adminService.GetAdminById((int)reader["NoticePublisher"]);
                    topnotices.NoticeBelong    = departmentService.GetDepartmentById((int)reader["NoticeBelong"]);
                    topnotices.NState          = nstateService.GetNStateById((int)reader["NState"]);
                    topnotices.NoticeHits      = (int)reader["NoticeHits"];
                }
            }
            return(topnotices);
        }
Esempio n. 3
0
        //获取Newsbyid
        public News GetNewsById(int id)
        {
            //sql语句
            string sql  = "select * from News where ID=@id";
            News   news = new News();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, sql, new SqlParameter("@id", id)))
            {
                if (reader.Read())
                {
                    AdminService  adminService  = new AdminService();
                    NStateService nstateService = new NStateService();

                    news               = new News();
                    news.id            = (int)reader["id"];
                    news.NewsTitle     = (string)reader["NewsTitle"];
                    news.NewsMain      = (string)reader["NewsMain"];
                    news.NewsDate      = reader["NewsDate"] != DBNull.Value ? (DateTime?)reader["NewsDate"] : null;
                    news.NewsPublisher = adminService.GetAdminById((int)reader["NewsPublisher"]);
                    news.NState        = nstateService.GetNStateById((int)reader["NState"]);
                    news.NewsHits      = (int)reader["NewsHits"];
                }
            }
            return(news);
        }
Esempio n. 4
0
        //获取公告byid
        public Notices GetNoticeById(int id)
        {
            Notices notices = new Notices();
            //sql语句
            string sql = "select * from Notices where ID=@id";

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, sql, new SqlParameter("@id", id)))
            {
                if (reader.Read())
                {
                    AdminService      adminService      = new AdminService();
                    DepartmentService departmentService = new DepartmentService();
                    NStateService     nstateService     = new NStateService();

                    notices                 = new Notices();
                    notices.id              = (int)reader["id"];
                    notices.NoticeTitle     = (string)reader["NoticeTitle"];
                    notices.NoticeMain      = (string)reader["NoticeMain"];
                    notices.NoticeDate      = reader["NoticeDate"] != DBNull.Value ? (DateTime?)reader["NoticeDate"] : null;
                    notices.NoticePublisher = adminService.GetAdminById((int)reader["NoticePublisher"]);
                    notices.NoticeBelong    = departmentService.GetDepartmentById((int)reader["NoticeBelong"]);
                    notices.NState          = nstateService.GetNStateById((int)reader["NState"]);
                    notices.NoticeHits      = (int)reader["NoticeHits"];
                }
            }
            return(notices);
        }