using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;

namespace etw
{
    public class etw_gonggao
    {
        public etw_gonggao()
        {
        }
        private int etw_id;
        private string etw_subject;
        private string etw_content;
        private string etw_edittime;
        private int etw_iscommend;

        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public string subject
        {
            set { etw_subject = value; }
            get { return etw_subject; }
        }
        public string content
        {
            set { etw_content = value; }
            get { return etw_content; }
        }
        public string edittime
        {
            set { etw_edittime = value; }
            get { return etw_edittime; }
        }
        public int iscommend
        {
            set { etw_iscommend = value; }
            get { return etw_iscommend; }
        }

        public bool exists()
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select count(id) from etw_gonggao");
            strsql.Append("where id=" + id + "");
            return DbHelperSQL.Exists(strsql.ToString());

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_gonggao](");
            strSql.Append("subject,content,edittime,iscommend");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("N'" + subject + "',");
            strSql.Append("N'" + content + "',");
            strSql.Append("N'" + edittime + "',");
            strSql.Append("" + iscommend + "");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_gonggao set ");
            strSql.Append("subject=N'" + subject + "',");
            strSql.Append("content=N'" + content + "'");
            //strSql.Append("edittime=N'" + edittime + "',");
            //strSql.Append("iscommend=" + iscommend + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Delete()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from etw_gonggao ");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[subject],[content],[edittime],[iscommend]");
            strSql.Append(" from etw_gonggao ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                subject = ds.Tables[0].Rows[0]["subject"].ToString();
                content = ds.Tables[0].Rows[0]["content"].ToString();
                edittime = ds.Tables[0].Rows[0]["edittime"].ToString();
                iscommend = Convert.ToInt32(ds.Tables[0].Rows[0]["iscommend"]);

            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [id],[subject],[content],[edittime],[iscommend]");
            strSql.Append(" FROM etw_gonggao ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }


    }
}
