Example #1
0
        /// <summary>
        ///[NoticeInfo]表查询实体的方法
        /// </summary>
        public static NoticeInfo getNoticeInfoById(int noticeid)
        {
            NoticeInfo noticeinfo = null;

            string sql = "select * from NoticeInfo where noticeid=@noticeid";

            SqlParameter[] sp = new SqlParameter[]
            {
                new SqlParameter("@noticeid", noticeid)
            };
            DataTable dt = DBHelper.GetDataSet(sql, sp);

            if (dt.Rows.Count > 0)
            {
                noticeinfo = new NoticeInfo();
                foreach (DataRow dr in dt.Rows)
                {
                    noticeinfo.Noticeid   = Convert.ToInt32(dr["noticeid"]);
                    noticeinfo.Title      = Convert.ToString(dr["title"]);
                    noticeinfo.Sortid     = SortInfoService.getSortInfoById((int)dr["sortid"]);
                    noticeinfo.Ifpublic   = Convert.ToInt32(dr["ifpublic"]);
                    noticeinfo.Fromuser   = Convert.ToString(dr["fromuser"]);
                    noticeinfo.Begintime  = Convert.ToDateTime(dr["begintime"]);
                    noticeinfo.Endtime    = Convert.ToDateTime(dr["endtime"]);
                    noticeinfo.Attribute  = Convert.ToInt32(dr["attribute"]);
                    noticeinfo.Accressory = Convert.ToString(dr["accressory"]);
                    noticeinfo.Context    = Convert.ToString(dr["context"]);
                }
            }

            return(noticeinfo);
        }
Example #2
0
        /// <summary>
        ///根据SQL语句获取集合
        /// </summary>
        public static IList <NoticeInfo> getNoticeInfosBySql(string sql)
        {
            IList <NoticeInfo> list = new List <NoticeInfo>();
            DataTable          dt   = DBHelper.GetDataSet(sql);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    NoticeInfo noticeinfo = new NoticeInfo();
                    noticeinfo.Noticeid   = Convert.ToInt32(dr["noticeid"]);
                    noticeinfo.Title      = Convert.ToString(dr["title"]);
                    noticeinfo.Sortid     = SortInfoService.getSortInfoById((int)dr["sortid"]);
                    noticeinfo.Ifpublic   = Convert.ToInt32(dr["ifpublic"]);
                    noticeinfo.Fromuser   = Convert.ToString(dr["fromuser"]);
                    noticeinfo.Begintime  = Convert.ToDateTime(dr["begintime"]);
                    noticeinfo.Endtime    = Convert.ToDateTime(dr["endtime"]);
                    noticeinfo.Attribute  = Convert.ToInt32(dr["attribute"]);
                    noticeinfo.Accressory = Convert.ToString(dr["accressory"]);
                    noticeinfo.Context    = Convert.ToString(dr["context"]);
                    list.Add(noticeinfo);
                }
            }
            return(list);
        }