Example #1
0
 internal static News GetNews(int newsId ,int hits)
 {
     News m = new News(newsId);
     if (newsId > 0)
     {
         SafeProcedure.ExecuteAndMapRecords(
                 Database.GetDatabase(D4DDefine.DBInstanceName),
              "dbo.News_Get",
              delegate(IRecord record)
              {
                  m.Title = record.GetStringOrEmpty(1);
                  m.Body = record.GetStringOrEmpty(2);
                  m.Preview = record.GetStringOrEmpty(3);
                  m.SImage = record.GetStringOrEmpty(4);
                  m.LImage = record.GetStringOrEmpty(5);
                  m.NewsType = record.GetInt32OrDefault(6, 0);
                  m.Hits = record.GetInt32OrDefault(7, 0);
                  m.PublishDate = record.GetDateTime(8);
                  m.AddUserID = record.GetInt32OrDefault(9, 0);
                  m.AddDate = record.GetDateTime(10);
                  m.Status = (PublishStatus)(record.GetInt32OrDefault(11, 0));
                  m.Remark = record.GetStringOrEmpty(12);
              },
              newsId,hits);
     }
     return m;
 }
Example #2
0
        internal static int SetNews(News m)
        {
            if (m == null) return -1;

            SafeProcedure.ExecuteNonQuery(
             Database.GetDatabase(D4DDefine.DBInstanceName),
             "dbo.News_Set",
             delegate(IParameterSet parameters)
             {
                 parameters.AddWithValue("@NewsId", m.NewsId);
                 parameters.AddWithValue("@Title", m.Title);
                 parameters.AddWithValue("@Body", m.Body);
                 parameters.AddWithValue("@Preview", m.Preview);
                 parameters.AddWithValue("@SImage", m.SImage);
                 parameters.AddWithValue("@LImage", m.LImage);
                 parameters.AddWithValue("@NewsType", m.NewsType);
                 parameters.AddWithValue("@Hits", m.Hits);
                 parameters.AddWithValue("@PublishDate", m.PublishDate);
                 parameters.AddWithValue("@AddUserId", m.AddUserID);
                 parameters.AddWithValue("@Status", (int)(m.Status));
                 parameters.AddWithValue("@Remark", m.Remark);
                 parameters.AddWithValue("@RetVal", DBNull.Value, ParameterDirectionWrap.ReturnValue);

             },
             delegate(IParameterSet outputParameters)
             {
                 m.NewsId = Convert.ToInt32(outputParameters.GetValue("@RetVal"));
             });

            return m.NewsId;
        }
Example #3
0
        internal static void MapList(IRecord record, List<News> list)
        {
            News m = new News();
            m.NewsId = record.GetInt32OrDefault(0, 0);
            m.Title = record.GetStringOrEmpty(1);
            m.Body = record.GetStringOrEmpty(2);
            m.Preview = record.GetStringOrEmpty(3);
            m.SImage = record.GetStringOrEmpty(4);
            m.LImage = record.GetStringOrEmpty(5);
            m.NewsType = record.GetInt32OrDefault(6, 0);
            m.Hits = record.GetInt32OrDefault(7, 0);
            m.PublishDate = record.GetDateTime(8);
            m.AddUserID = record.GetInt32OrDefault(9, 0);
            m.AddDate = record.GetDateTime(10);
            m.Status = (PublishStatus)(record.GetInt32OrDefault(11, 0));
            m.Remark = record.GetStringOrEmpty(12);

            list.Add(m);
        }
Example #4
0
 public int SetNews(News m)
 {
     return NewsDao.SetNews(m);
 }