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_translate
    {
        public etw_translate()
        {
        }
        private int etw_id;
        private int etw_chatid;
        private int etw_userid;
        private string etw_language;
        private string etw_target;
        private string etw_source_content;
        private string etw_trans_content;
        private string etw_receivetime;
        private string etw_achivetime;
        private int etw_isread;
        private int etw_type;
        private int etw_personid;
        private string etw_fujian;
        private string etw_trans_fujian;
        private int etw_priority;
        private int etw_ischild;

        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }

        public int priority
        {
            set { etw_priority = value; }
            get { return etw_priority; }
        }

        public int chatid
        {
            set { etw_chatid = value; }
            get { return etw_chatid; }
        }
        public int userid
        {
            set { etw_userid = value; }
            get { return etw_userid; }
        }
        public string language
        {
            set { etw_language = value; }
            get { return etw_language; }
        }
        public string target
        {
            set { etw_target = value; }
            get { return etw_target; }
        }
        public string source_content
        {
            set { etw_source_content = value; }
            get { return etw_source_content; }
        }
        public string trans_content
        {
            set { etw_trans_content = value; }
            get { return etw_trans_content; }
        }
        public string receivetime
        {
            set { etw_receivetime = value; }
            get { return etw_receivetime; }
        }
        public string achivetime
        {
            set { etw_achivetime = value; }
            get { return etw_achivetime; }
        }
        public int isread
        {
            set { etw_isread = value; }
            get { return etw_isread; }
        }
        public int type
        {
            set { etw_type = value; }
            get { return etw_type; }
        }
        public int personid
        {
            set { etw_personid = value; }
            get { return etw_personid; }
        }

        public string fujian
        {
            set { etw_fujian = value; }
            get { return etw_fujian; }
        }
        public string trans_fujian
        {
            set { etw_trans_fujian = value; }
            get { return etw_trans_fujian; }
        }
        public int ischild
        {
            set { etw_ischild = value; }
            get { return etw_ischild; }
        }

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

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_translate](");
            strSql.Append("chatid,userid,language,target,source_content,trans_content,receivetime,achivetime,isread,type,personid,fujian,trans_fujian,priority,ischild");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + chatid + ",");
            strSql.Append("" + userid + ",");
            strSql.Append("N'" + language + "',");
            strSql.Append("N'" + target + "',");
            strSql.Append("N'" + source_content + "',");
            strSql.Append("N'" + trans_content + "',");
            strSql.Append("N'" + receivetime + "',");
            strSql.Append("N'" + achivetime + "',");
            strSql.Append("" + isread + ",");
            strSql.Append("" + type + ",");
            strSql.Append("" + personid + ",");
            strSql.Append("N'" + fujian + "',");
            strSql.Append("N'" + trans_fujian + "',");
            strSql.Append("" + priority + ",");
            strSql.Append("" + ischild + "");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void newAdd()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_translate](");
            strSql.Append("chatid,userid,language,target,source_content,receivetime,type,fujian,priority,ischild");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + chatid + ",");
            strSql.Append("" + userid + ",");
            strSql.Append("N'" + language + "',");
            strSql.Append("N'" + target + "',");
            strSql.Append("N'" + source_content + "',");
            strSql.Append("N'" + receivetime + "',");
            strSql.Append("" + type + ",");
            strSql.Append("N'" + fujian + "',");
            strSql.Append("" + priority + ",");
            strSql.Append("" + ischild + "");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_translate set ");
            strSql.Append("chatid=" + chatid + ",");
            strSql.Append("language=N'" + language + "',");
            strSql.Append("target=N'" + target + "',");
            strSql.Append("source_content=N'" + source_content + "',");
            strSql.Append("trans_content=N'" + trans_content + "',");
            strSql.Append("receivetime=N'" + receivetime + "',");
            strSql.Append("achivetime=N'" + achivetime + "',");
            strSql.Append("isread=" + isread + ",");
            strSql.Append("type=" + type + ",");
            strSql.Append("personid=" + personid + ",");
            strSql.Append("fujian=N'" + fujian + "',");
            strSql.Append("trans_fujian=N'" + trans_fujian + "',");
            strSql.Append("priority=" + priority + "',");
            strSql.Append("ischild=" + ischild + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[chatid],[userid],[language],[target],[source_content],[trans_content],[receivetime],[achivetime],[isread],[type],[personid],[fujian],[trans_fujian],[priority],[ischild]");
            strSql.Append(" from etw_translate ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                chatid = Convert.ToInt32(ds.Tables[0].Rows[0]["chatid"]);
                userid = Convert.ToInt32(ds.Tables[0].Rows[0]["userid"]);
                language = ds.Tables[0].Rows[0]["language"].ToString();
                target = ds.Tables[0].Rows[0]["target"].ToString();
                source_content = ds.Tables[0].Rows[0]["source_content"].ToString();
                trans_content = ds.Tables[0].Rows[0]["trans_content"].ToString();
                receivetime = ds.Tables[0].Rows[0]["receivetime"].ToString();
                achivetime = ds.Tables[0].Rows[0]["achivetime"].ToString();
                isread = Convert.ToInt32(ds.Tables[0].Rows[0]["isread"]);
                type = Convert.ToInt32(ds.Tables[0].Rows[0]["type"]);
                if (ds.Tables[0].Rows[0]["personid"].ToString() != null && ds.Tables[0].Rows[0]["personid"].ToString() != "" && ds.Tables[0].Rows[0]["personid"].ToString() != "0")
                {
                    personid = Convert.ToInt32(ds.Tables[0].Rows[0]["personid"]);
                }
                if (ds.Tables[0].Rows[0]["priority"].ToString() != "" && ds.Tables[0].Rows[0]["priority"].ToString() != null)
                {
                    priority = Convert.ToInt32(ds.Tables[0].Rows[0]["priority"]);
                }
                fujian = ds.Tables[0].Rows[0]["fujian"].ToString();
                trans_fujian = ds.Tables[0].Rows[0]["trans_fujian"].ToString();
                ischild = Convert.ToInt32(ds.Tables[0].Rows[0]["ischild"]);
            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("[id],[chatid],[userid],[language],[target],[source_content],[trans_content],[receivetime],[achivetime],[isread],[type],[personid],[fujian],[trans_fujian],[priority],[ischild]");
            strSql.Append(" FROM etw_translate ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            strSql.Append(" order by id desc");
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
