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_history
    {
        public etw_history()
        {
        }
        private int etw_id;
        private string etw_subject;
        private string etw_content;
        private string etw_company;
        private string etw_edittime;
        private string etw_categoryname;
        private int etw_changestate;
        private string etw_uploadfilename;
        private int etw_usernameid;
        private int etw_onlineid;
        private string etw_onlineemail;
        private int etw_ishuifu;

        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 company
        {
            set { etw_company = value; }
            get { return etw_company; }
        }
        public string edittime
        {
            set { etw_edittime = value; }
            get { return etw_edittime; }
        }
        public string categoryname
        {
            set { etw_categoryname = value; }
            get { return etw_categoryname; }
        }
        public int changestate
        {
            set { etw_changestate = value; }
            get { return etw_changestate; }
        }
        public string uploadfilename
        {
            set { etw_uploadfilename = value; }
            get { return etw_uploadfilename; }
        }
        public int usernameid
        {
            set { etw_usernameid = value; }
            get { return etw_usernameid; }
        }
        public int onlineid
        {
            set { etw_onlineid = value; }
            get { return etw_onlineid; }
        }
        public string onlineemail
        {
            set { etw_onlineemail = value; }
            get { return etw_onlineemail; }
        }
        public int ishuifu
        {
            set { etw_ishuifu = value; }
            get { return etw_ishuifu; }
        }
        public bool exists()
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select count(id) from etw_history");
            strsql.Append("where id=" + id + "");
            return DbHelperSQL.Exists(strsql.ToString());

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_history](");
            strSql.Append("subject,content,company,edittime,categoryname,changestate,uploadfilename,usernameid,onlineid,onlineemail,ishuifu");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("N'" + subject + "',");
            strSql.Append("N'" + content + "',");
            strSql.Append("N'" + company + "',");
            strSql.Append("N'" + edittime + "',");
            strSql.Append("N'" + categoryname + "',");
            strSql.Append("" + changestate + ",");
            strSql.Append("N'" + uploadfilename + "',");
            strSql.Append("" + usernameid + ",");
            strSql.Append("" + onlineid + ",");
            strSql.Append("N'" + onlineemail + "',");
            strSql.Append("" + ishuifu + "");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_history set ");
            strSql.Append("subject=N'" + subject + "',");
            strSql.Append("content=N'" + content + "',");
            strSql.Append("company=N'" + company + "',");
            strSql.Append("edittime=N'" + edittime + "',");
            strSql.Append("categoryname=N'" + categoryname + "',");
            strSql.Append("changestate=" + changestate + ",");
            strSql.Append("uploadfilename=N'" + uploadfilename + "',");
            strSql.Append("usernameid=" + usernameid + ",");
            strSql.Append("onlineid=" + onlineid + ",");
            strSql.Append("onlineemail=N'" + onlineemail + "',");
            strSql.Append("ishuifu=" + ishuifu + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[subject],[content],[company],[edittime],[categoryname],[changestate],[uploadfilename],[usernameid],[onlineid],[onlineemail],[ishuifu]");
            strSql.Append(" from etw_history ");
            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();
                company = ds.Tables[0].Rows[0]["company"].ToString();
                edittime = ds.Tables[0].Rows[0]["edittime"].ToString();
                categoryname = ds.Tables[0].Rows[0]["categoryname"].ToString();
                changestate = Convert.ToInt32(ds.Tables[0].Rows[0]["changestate"]);
                uploadfilename = ds.Tables[0].Rows[0]["uploadfilename"].ToString();
                usernameid = Convert.ToInt32(ds.Tables[0].Rows[0]["usernameid"]);
                onlineid = Convert.ToInt32(ds.Tables[0].Rows[0]["onlineid"]);
                onlineemail = ds.Tables[0].Rows[0]["onlineemail"].ToString();
                ishuifu = Convert.ToInt32(ds.Tables[0].Rows[0]["ishuifu"]);

            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [id],[subject],[content],[company],[edittime],[categoryname],[changestate],[uploadfilename],[usernameid],[onlineid],[onlineemail],[ishuifu]");
            strSql.Append(" FROM etw_history ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }


    }
}
