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_admin
    {
        public etw_admin()
        {
        }
        private int etw_id;
        private int etw_roleid;
        private string etw_etwadminname;
        private string etw_etwadminpwd;
        private string etw_realname;
        private string etw_position;
        private string etw_Purview;
        private int etw_transid;
        private int etw_translation;
        private int etw_person;
        private int etw_newcustomer;
        private int etw_customerweb;
        private int etw_webmodify;
        private int etw_faq;
        private int etw_mobilemsg;
        private int etw_gathernews;
        private int etw_trade;
        private int etw_khgl;

        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public int roleid
        {
            set { etw_roleid = value; }
            get { return etw_roleid; }
        }
        public string etwadminname
        {
            set { etw_etwadminname = value; }
            get { return etw_etwadminname; }
        }
        public string Purview
        {
            set { etw_Purview = value; }
            get { return etw_Purview; }
        }
        public string etwadminpwd
        {
            set { etw_etwadminpwd = value; }
            get { return etw_etwadminpwd; }
        }
        public string realname
        {
            set { etw_realname = value; }
            get { return etw_realname; }
        }
        public string position
        {
            set { etw_position = value; }
            get { return etw_position; }
        }
        public int transid
        {
            set { etw_transid = value; }
            get { return etw_transid; }
        }
        public int translation
        {
            set { etw_translation = value; }
            get { return etw_translation; }
        }
        public int person
        {
            set { etw_person = value; }
            get { return etw_person; }
        }
        public int newcustomer
        {
            set { etw_newcustomer = value; }
            get { return etw_newcustomer; }
        }
        public int customerweb
        {
            set { etw_customerweb = value; }
            get { return etw_customerweb; }
        }
        public int webmodify
        {
            set { etw_webmodify = value; }
            get { return etw_webmodify; }
        }
        public int faq
        {
            set { etw_faq = value; }
            get { return etw_faq; }
        }
        public int mobilemsg
        {
            set { etw_mobilemsg = value; }
            get { return etw_mobilemsg; }
        }
        public int gathernews
        {
            set { etw_gathernews = value; }
            get { return etw_gathernews; }
        }
        public int trade
        {
            set { etw_trade = value; }
            get { return etw_trade; }
        }
        public int khgl
        {
            set { etw_khgl = value; }
            get { return etw_khgl; }
        }
        public bool exists()
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select count(id) from etw_admin");
            strsql.Append("where id=" + id + "");
            return DbHelperSQL.Exists(strsql.ToString());

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_admin](");
            strSql.Append("roleid,etwadminname,etwadminpwd,realname,position,transid");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + roleid + ",");
            strSql.Append("N'" + etwadminname + "',");
            strSql.Append("N'" + etwadminpwd + "',");
            strSql.Append("N'" + realname + "',");
            strSql.Append("N'" + position + "',");
            strSql.Append("" + transid + "");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_admin set ");
            strSql.Append("roleid=" + roleid + ",");
            strSql.Append("etwadminname=N'" + etwadminname + "',");
            strSql.Append("etwadminpwd=N'" + etwadminpwd + "',");
            strSql.Append("realname=N'" + realname + "',");
            strSql.Append("position=N'" + position + "',");
            strSql.Append("transid=" + transid + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Uppurview()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_admin set ");
            strSql.Append("Purview=N'" + Purview + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Delete()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from etw_admin ");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[roleid],[etwadminname],[etwadminpwd],[realname],[position],[transid],[translation],[person],[newcustomer],[customerweb],[webmodify],[faq],[mobilemsg],[gathernews],[trade],[khgl]");
            strSql.Append(" from etw_admin ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                roleid = Convert.ToInt32(ds.Tables[0].Rows[0]["roleid"]);
                etwadminname = ds.Tables[0].Rows[0]["etwadminname"].ToString();
                etwadminpwd = ds.Tables[0].Rows[0]["etwadminpwd"].ToString();
                realname = ds.Tables[0].Rows[0]["realname"].ToString();
                position = ds.Tables[0].Rows[0]["position"].ToString();
                transid = Convert.ToInt32(ds.Tables[0].Rows[0]["transid"]);
                translation = Convert.ToInt32(ds.Tables[0].Rows[0]["translation"]);
                person = Convert.ToInt32(ds.Tables[0].Rows[0]["person"]);
                newcustomer = Convert.ToInt32(ds.Tables[0].Rows[0]["newcustomer"]);
                customerweb = Convert.ToInt32(ds.Tables[0].Rows[0]["customerweb"]);
                webmodify = Convert.ToInt32(ds.Tables[0].Rows[0]["webmodify"]);
                faq = Convert.ToInt32(ds.Tables[0].Rows[0]["faq"]);
                mobilemsg = Convert.ToInt32(ds.Tables[0].Rows[0]["mobilemsg"]);
                gathernews = Convert.ToInt32(ds.Tables[0].Rows[0]["gathernews"]);
                trade = Convert.ToInt32(ds.Tables[0].Rows[0]["trade"]);
                khgl = Convert.ToInt32(ds.Tables[0].Rows[0]["khgl"]);

            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [id],[roleid],[etwadminname],[etwadminpwd],[realname],[position],[transid],[translation],[person],[newcustomer],[customerweb],[webmodify],[faq],[mobilemsg],[gathernews],[trade],[khgl]");
            strSql.Append(" FROM etw_admin ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
