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_suggest
    {
        public etw_suggest()
        {
        }
        private int etw_id;
        private int etw_userid;
        private string etw_abouts;
        private string etw_suggest1;
        private string etw_addtime;
        private string etw_etwreply;
        private string etw_replytime;
        private string etw_tel;
        private int etw_phreply;


        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public int userid
        {
            set { etw_userid = value; }
            get { return etw_userid; }
        }
        public string abouts
        {
            set { etw_abouts = value; }
            get { return etw_abouts; }
        }
        public string tel
        {
            set { etw_tel = value; }
            get { return etw_tel; }
        }
        public string suggest
        {
            set { etw_suggest1 = value; }
            get { return etw_suggest1; }
        }
        public string addtime
        {
            set { etw_addtime = value; }
            get { return etw_addtime; }
        }
        public string etwreply
        {
            set { etw_etwreply = value; }
            get { return etw_etwreply; }
        }
        public string replytime
        {
            set { etw_replytime = value; }
            get { return etw_replytime; }
        }

        public int phreply
        {
            set { etw_phreply = value; }
            get { return etw_phreply; }
        }

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

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_suggest](");
            strSql.Append("userid,abouts,suggest,tel,addtime");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + userid + ",");
            strSql.Append("N'" + abouts + "',");
            strSql.Append("N'" + suggest + "',");
            strSql.Append("N'" + tel + "',");
            strSql.Append("N'" + addtime + "'");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_suggest set ");
            strSql.Append("abouts=N'" + abouts + "',");
            strSql.Append("suggest=N'" + suggest + "',");
            strSql.Append("addtime=N'" + addtime + "',");
            strSql.Append("etwreply=N'" + etwreply + "',");
            strSql.Append("replytime=N'" + replytime + "',");
            strSql.Append("tel=N'" + tel + "',");
            strSql.Append("phreply=" + phreply + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update_phreply()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_suggest set ");
            strSql.Append("phreply=" + phreply + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Update_etwreply()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_suggest set ");
            strSql.Append("etwreply=N'" + etwreply + "',");
            strSql.Append("replytime=N'" + replytime + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[userid],[abouts],[suggest],[addtime],[etwreply],[replytime],[tel],[phreply]");
            strSql.Append(" from etw_suggest ");
            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"]);
                abouts = ds.Tables[0].Rows[0]["abouts"].ToString();
                suggest = ds.Tables[0].Rows[0]["suggest"].ToString();
                addtime = ds.Tables[0].Rows[0]["addtime"].ToString();
                etwreply = ds.Tables[0].Rows[0]["etwreply"].ToString();
                replytime = ds.Tables[0].Rows[0]["replytime"].ToString();
                tel = ds.Tables[0].Rows[0]["tel"].ToString();
                phreply = Convert.ToInt32(ds.Tables[0].Rows[0]["phreply"]);

            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("[id],[userid],[abouts],[suggest],[addtime],[etwreply],[replytime],[tel],[phreply]");
            strSql.Append(" FROM etw_suggest ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
