using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Components;
using System.Data;

/// <summary>
/// Summary description for NewsContents
/// </summary>
namespace Maticsoft.DAL
{

    public class NewsContents
    {
        public NewsContents()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        OracleHelper oraCle = new OracleHelper();

        #region  成员方法


        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int id)
        {
            string sql = "select count(*) from DHU_NEWSCONTENT where NID='" + id + "'";
            int k = int.Parse(oraCle.RunSqlReturn(sql));
            if (k > 0)
                return true;
            else
                return false;
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Maticsoft.Model.newscontent model)
        {

        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Maticsoft.Model.newscontent model)
        {

        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(int id)
        {
            string sql = "delete from DHU_NEWSCONTENT where NID='" + id + "'";
            oraCle.RunSql(sql);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.newscontent GetModel(int id)
        {
            string sql = "select * from DHU_NEWSCONTENT where NID='" + id + "'";
            Maticsoft.Model.newscontent model = new Maticsoft.Model.newscontent();
            DataSet ds = oraCle.GetDs(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["nid"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["nid"].ToString());
                }
                model.title = ds.Tables[0].Rows[0]["title"].ToString();
                model.faburen = ds.Tables[0].Rows[0]["faburen"].ToString();
                if (ds.Tables[0].Rows[0]["ftime"].ToString() != "")
                {
                    model.time = DateTime.Parse(ds.Tables[0].Rows[0]["ftime"].ToString());
                }
                model.content = ds.Tables[0].Rows[0]["content"].ToString();
                if (ds.Tables[0].Rows[0]["hit"].ToString() != "")
                {
                    model.hit = int.Parse(ds.Tables[0].Rows[0]["hit"].ToString());
                }
                model.keywords = ds.Tables[0].Rows[0]["keywords"].ToString();
                model.ClassId = int.Parse(ds.Tables[0].Rows[0]["CLASSID"].ToString());
                return model;
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {

            string sql = "select  * from DHU_NEWSCONTENT ";


            if (strWhere.Trim() != "")
            {
                sql = sql + " where " + strWhere;
            }
            return oraCle.GetDs(sql);
        }
        public DataTable GetAll(int id, int top)
        {
            string sql = "select  * from DHU_NEWSCONTENT where nid='" + id + "'";
            return oraCle.GetTable(sql);
        }
        public DataTable GetAllbyid(int id)
        {

            string sql = "select  * from DHU_NEWSCONTENT where nid='" + id + "'";
            return oraCle.GetTable(sql);
        }
        public DataSet GetListbytop(string strWhere, int top)
        {
            string sql = "select  * from DHU_NEWSCONTENT ";


            if (strWhere.Trim() != "")
            {
                sql = sql + " where " + strWhere;
            }
            return oraCle.GetDs(sql);
        }
        /*
        */

        #endregion  成员方法
    }
}