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_html
    {
        public etw_html()
        {
        }
        private int etw_id;
        private string etw_title;
        private string etw_url;

        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public string title
        {
            set { etw_title = value; }
            get { return etw_title; }
        }
        public string url
        {
            set { etw_url = value; }
            get { return etw_url; }
        }
        public bool exists()
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select count(id) from etw_html");
            strsql.Append("where id=" + id + "");
            return DbHelperSQL.Exists(strsql.ToString());

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_html](");
            strSql.Append("title,url");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("N'" + title + "',");
            strSql.Append("N'" + url + "'");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_html set ");
            strSql.Append("title=N'" + title + "',");
            strSql.Append("url=N'" + url + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[title],[url]");
            strSql.Append(" from etw_html ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                title = ds.Tables[0].Rows[0]["title"].ToString();
                url = ds.Tables[0].Rows[0]["url"].ToString();

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

    }
}
