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_productupd
    {
        public etw_productupd()
        {
        }
        private int etw_id;
        private int etw_userid;
        private string etw_url;
        private string etw_content;
        private string etw_edittime;
        private string etw_etwinfo;
        private string etw_achivetime;
        private int etw_isread;
        private string etw_fujian;
        private int etw_phreply;
        private int etw_web;

        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public int userid
        {
            set { etw_userid = value; }
            get { return etw_userid; }
        }
        public string url
        {
            set { etw_url = value; }
            get { return etw_url; }
        }
        public string content
        {
            set { etw_content = value; }
            get { return etw_content; }
        }
        public string edittime
        {
            set { etw_edittime = value; }
            get { return etw_edittime; }
        }
        public string etwinfo
        {
            set { etw_etwinfo = value; }
            get { return etw_etwinfo; }
        }
        public string achivetime
        {
            set { etw_achivetime = value; }
            get { return etw_achivetime; }
        }
        public int isread
        {
            set { etw_isread = value; }
            get { return etw_isread; }
        }
        public string fujian
        {
            set { etw_fujian = value; }
            get { return etw_fujian; }
        }
        public int phreply
        {
            set { etw_phreply = value; }
            get { return etw_phreply; }
        }
        public int web
        {
            set { etw_web = value; }
            get { return etw_web; }
        }
        public bool exists()
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select count(id) from etw_productupd");
            strsql.Append("where id=" + id + "");
            return DbHelperSQL.Exists(strsql.ToString());

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_productupd](");
            strSql.Append("userid,url,content,edittime,isread,fujian");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + userid + ",");
            strSql.Append("N'" + url + "',");
            strSql.Append("N'" + content + "',");
            strSql.Append("N'" + edittime + "',");
            strSql.Append("" + isread + ",");
            strSql.Append("N'" + fujian + "'");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_productupd set ");
            strSql.Append("url=N'" + url + "',");
            strSql.Append("content=N'" + content + "',");
            strSql.Append("edittime=N'" + edittime + "',");
            strSql.Append("etwinfo=N'" + etwinfo + "',");
            strSql.Append("achivetime=N'" + achivetime + "',");
            strSql.Append("isread=" + isread + ",");
            strSql.Append("fujian=N'" + fujian + "',");
            strSql.Append("phreply=" + phreply + ",");
            strSql.Append("web=" + web + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update_web()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_productupd set ");
            strSql.Append("web="+web+"");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Update_etwinfo()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_productupd set ");
            strSql.Append("achivetime=N'" + achivetime + "',");
            strSql.Append("phreply=" + phreply + ",");
            strSql.Append("etwinfo=N'" + etwinfo + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[userid],[url],[content],[edittime],[etwinfo],[achivetime],[isread],[fujian],[phreply],[web]");
            strSql.Append(" from etw_productupd ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                userid = Convert.ToInt32(ds.Tables[0].Rows[0]["userid"]);
                url = ds.Tables[0].Rows[0]["url"].ToString();
                content = ds.Tables[0].Rows[0]["content"].ToString();
                edittime = ds.Tables[0].Rows[0]["edittime"].ToString();
                etwinfo = ds.Tables[0].Rows[0]["etwinfo"].ToString();
                achivetime = ds.Tables[0].Rows[0]["achivetime"].ToString();
                isread = Convert.ToInt32(ds.Tables[0].Rows[0]["isread"]);
                fujian = ds.Tables[0].Rows[0]["fujian"].ToString();
                phreply = Convert.ToInt32(ds.Tables[0].Rows[0]["phreply"]);
                web = Convert.ToInt32(ds.Tables[0].Rows[0]["web"]);

            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("[id],[userid],[url],[content],[edittime],[etwinfo],[achivetime],[isread],[fujian],[phreply],[web]");
            strSql.Append(" FROM etw_productupd ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
