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_onlines
    {
        public etw_onlines()
        {
        }
        private int etw_id;
        private int etw_yid;
        private int etw_classid;
        private string etw_title;
        private string etw_contacter;
        private string etw_telephone;
        private string etw_fax;
        private string etw_email;
        private string etw_address;
        private string etw_content;
        private string etw_language;
        private string etw_senddate;
        private string etw_url;
        private int etw_usernameid;
        private string etw_translate;
        private string etw_childtranslate;
        private string etw_reply;
        private int etw_replycounts;
        private int etw_ishandle;
        private int etw_isdelete;
        private string etw_ip;
        private int etw_readed;
        private int etw_childreaded;
        private int etw_childuserid;
        private int etw_biaoji;
        private string etw_edittime;
        private string etw_definesubject;

        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public int yid
        {
            set { etw_yid = value; }
            get { return etw_yid; }
        }
        public int classid
        {
            set { etw_classid = value; }
            get { return etw_classid; }
        }
        public string title
        {
            set { etw_title = value; }
            get { return etw_title; }
        }
        public string contacter
        {
            set { etw_contacter = value; }
            get { return etw_contacter; }
        }
        public string telephone
        {
            set { etw_telephone = value; }
            get { return etw_telephone; }
        }
        public string fax
        {
            set { etw_fax = value; }
            get { return etw_fax; }
        }
        public string email
        {
            set { etw_email = value; }
            get { return etw_email; }
        }
        public string address
        {
            set { etw_address = value; }
            get { return etw_address; }
        }
        public string content
        {
            set { etw_content = value; }
            get { return etw_content; }
        }
        public string language
        {
            set { etw_language = value; }
            get { return etw_language; }
        }
        public string senddate
        {
            set { etw_senddate = value; }
            get { return etw_senddate; }
        }
        public string url
        {
            set { etw_url = value; }
            get { return etw_url; }
        }
        public int usernameid
        {
            set { etw_usernameid = value; }
            get { return etw_usernameid; }
        }
        public string translate
        {
            set { etw_translate = value; }
            get { return etw_translate; }
        }
        public string childtranslate
        {
            set { etw_childtranslate = value; }
            get { return etw_childtranslate; }
        }
        public string reply
        {
            set { etw_reply = value; }
            get { return etw_reply; }
        }
        public int replycounts
        {
            set { etw_replycounts = value; }
            get { return etw_replycounts; }
        }
        public int ishandle
        {
            set { etw_ishandle = value; }
            get { return etw_ishandle; }
        }
        public int isdelete
        {
            set { etw_isdelete = value; }
            get { return etw_isdelete; }
        }
        public string ip
        {
            set { etw_ip = value; }
            get { return etw_ip; }
        }
        public int readed
        {
            set { etw_readed = value; }
            get { return etw_readed; }
        }
        public int childreaded
        {
            set { etw_childreaded = value; }
            get { return etw_childreaded; }
        }
        public int childuserid
        {
            set { etw_childuserid = value; }
            get { return etw_childuserid; }
        }
        public int biaoji
        {
            set { etw_biaoji = value; }
            get { return etw_biaoji; }
        }
        public string edittime
        {
            set { etw_edittime = value; }
            get { return etw_edittime; }
        }
        public string definesubject
        {
            set { etw_definesubject = value; }
            get { return etw_definesubject; }
        }
        public bool exists()
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select count(id) from etw_onlines");
            strsql.Append("where id=" + id + "");
            return DbHelperSQL.Exists(strsql.ToString());

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_onlines](");
            strSql.Append("yid,classid,title,contacter,telephone,fax,email,address,content,language,senddate,url,usernameid,translate,childtranslate,reply,replycounts,ishandle,isdelete,ip,readed,childreaded,childuserid,biaoji,edittime,definesubject");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + yid + ",");
            strSql.Append("" + classid + ",");
            strSql.Append("N'" + title + "',");
            strSql.Append("N'" + contacter + "',");
            strSql.Append("N'" + telephone + "',");
            strSql.Append("N'" + fax + "',");
            strSql.Append("N'" + email + "',");
            strSql.Append("N'" + address + "',");
            strSql.Append("N'" + content + "',");
            strSql.Append("N'" + language + "',");
            strSql.Append("N'" + senddate + "',");
            strSql.Append("N'" + url + "',");
            strSql.Append("" + usernameid + ",");
            strSql.Append("N'" + translate + "',");
            strSql.Append("N'" + childtranslate + "',");
            strSql.Append("N'" + reply + "',");
            strSql.Append("" + replycounts + ",");
            strSql.Append("" + ishandle + ",");
            strSql.Append("" + isdelete + ",");
            strSql.Append("N'" + ip + "',");
            strSql.Append("" + readed + ",");
            strSql.Append("" + childreaded + ",");
            strSql.Append("" + childuserid + ",");
            strSql.Append("" + biaoji + ",");
            strSql.Append("N'" + edittime + "',");
            strSql.Append("N'" + definesubject + "'");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_onlines set ");
            strSql.Append("yid=" + yid + ",");
            strSql.Append("classid=" + classid + ",");
            strSql.Append("title=N'" + title + "',");
            strSql.Append("contacter=N'" + contacter + "',");
            strSql.Append("telephone=N'" + telephone + "',");
            strSql.Append("fax=N'" + fax + "',");
            strSql.Append("email=N'" + email + "',");
            strSql.Append("address=N'" + address + "',");
            strSql.Append("content=N'" + content + "',");
            strSql.Append("language=N'" + language + "',");
            strSql.Append("senddate=N'" + senddate + "',");
            strSql.Append("url=N'" + url + "',");
            strSql.Append("usernameid=" + usernameid + ",");
            strSql.Append("translate=N'" + translate + "',");
            strSql.Append("childtranslate=" + childtranslate + ",");
            strSql.Append("reply=" + reply + ",");
            strSql.Append("replycounts=" + replycounts + ",");
            strSql.Append("ishandle=" + ishandle + ",");
            strSql.Append("isdelete=" + isdelete + ",");
            strSql.Append("ip=N'" + ip + "',");
            strSql.Append("readed=" + readed + ",");
            strSql.Append("childreaded=" + childreaded + ",");
            strSql.Append("childuserid=" + childuserid + ",");
            strSql.Append("biaoji=" + biaoji + ",");
            strSql.Append("edittime=N'" + edittime + "',");
            strSql.Append("definesubject=N'" + definesubject + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Uplang()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_onlines set ");
            strSql.Append("language=N'" + language + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void UpTop()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_onlines set ");
            strSql.Append("biaoji=" + biaoji + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Upreaded()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_onlines set ");
            strSql.Append("readed=1");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Upaddress()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_onlines set ");
            strSql.Append("address=N'" + address + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Upchildreaded()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_onlines set ");
            strSql.Append("childreaded=1");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Delete()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from etw_onlines ");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[yid],[classid],[title],[contacter],[telephone],[fax],[email],[address],[content],[language],[senddate],[url],[usernameid],[translate],[childtranslate],[reply],[replycounts],[ishandle],[isdelete],[ip],[readed],[childreaded],[childuserid],[biaoji],[edittime],[definesubject]");
            strSql.Append(" from etw_onlines ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                yid = Convert.ToInt32(ds.Tables[0].Rows[0]["yid"]);
                classid = Convert.ToInt32(ds.Tables[0].Rows[0]["classid"]);
                title = ds.Tables[0].Rows[0]["title"].ToString();
                contacter = ds.Tables[0].Rows[0]["contacter"].ToString();
                telephone = ds.Tables[0].Rows[0]["telephone"].ToString();
                fax = ds.Tables[0].Rows[0]["fax"].ToString();
                email = ds.Tables[0].Rows[0]["email"].ToString();
                address = ds.Tables[0].Rows[0]["address"].ToString();
                content = ds.Tables[0].Rows[0]["content"].ToString();
                language = ds.Tables[0].Rows[0]["language"].ToString();
                senddate = ds.Tables[0].Rows[0]["senddate"].ToString();
                url = ds.Tables[0].Rows[0]["url"].ToString();
                usernameid = Convert.ToInt32(ds.Tables[0].Rows[0]["usernameid"]);
                translate = ds.Tables[0].Rows[0]["translate"].ToString();
                childtranslate = ds.Tables[0].Rows[0]["childtranslate"].ToString();
                reply = ds.Tables[0].Rows[0]["reply"].ToString();
                replycounts = Convert.ToInt32(ds.Tables[0].Rows[0]["replycounts"]);
                ishandle = Convert.ToInt32(ds.Tables[0].Rows[0]["ishandle"]);
                isdelete = Convert.ToInt32(ds.Tables[0].Rows[0]["isdelete"]);
                ip = ds.Tables[0].Rows[0]["ip"].ToString();
                readed = Convert.ToInt32(ds.Tables[0].Rows[0]["readed"]);
                childreaded = Convert.ToInt32(ds.Tables[0].Rows[0]["childreaded"]);
                if (ds.Tables[0].Rows[0]["childuserid"].ToString() != null && ds.Tables[0].Rows[0]["childuserid"].ToString() != "")
                {
                    childuserid = Convert.ToInt32(ds.Tables[0].Rows[0]["childuserid"]);
                }
                biaoji = Convert.ToInt32(ds.Tables[0].Rows[0]["biaoji"]);
                edittime = ds.Tables[0].Rows[0]["edittime"].ToString();
                definesubject = ds.Tables[0].Rows[0]["definesubject"].ToString();
            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [id],[yid],[classid],[title],[contacter],[telephone],[fax],[email],[address],[content],[language],[senddate],[url],[usernameid],[translate],[childtranslate],[reply],[replycounts],[ishandle],[isdelete],[ip],[readed],[childreaded],[childuserid],[biaoji],[edittime],[definesubject]");
            strSql.Append(" FROM etw_onlines ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }


    }
}
