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_web
    {
        public etw_web()
        {
        }
        private int etw_webid;
        private string etw_website;
        private int etw_usernameid;
        private int etw_jsqid;
        private int etw_langId;
        private int etw_istrade;
        private int etw_isnews;

        public int webid
        {
            set { etw_webid = value; }
            get { return etw_webid; }
        }
        public string website
        {
            set { etw_website = value; }
            get { return etw_website; }
        }
        public int usernameid
        {
            set { etw_usernameid = value; }
            get { return etw_usernameid; }
        }
        public int jsqid
        {
            set { etw_jsqid = value; }
            get { return etw_jsqid; }
        }
        public int langId
        {
            set { etw_langId = value; }
            get { return etw_langId; }
        }
        public int istrade
        {
            set { etw_istrade = value; }
            get { return etw_istrade; }
        }
        public int isnews
        {
            set { etw_isnews = value; }
            get { return etw_isnews; }
        }

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

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_web](");
            strSql.Append("website,usernameid,jsqid,langId,istrade,isnews");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("N'" + website + "',");
            strSql.Append("" + usernameid + ",");
            strSql.Append("" + jsqid + ",");
            strSql.Append("" + langId + ",");
            strSql.Append("" + istrade + ",");
            strSql.Append("" + isnews + "");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_web set ");
            strSql.Append("website=N'" + website + "',");
            //strSql.Append("usernameid=" + usernameid + ",");
            strSql.Append("jsqid=" + jsqid + ",");
            strSql.Append("langId=" + langId + "");
            //strSql.Append("istrade=" + istrade + ",");
            //strSql.Append("isnews=" + isnews + "");
            strSql.Append(" where webid=" + webid + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Uptrdae()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_web set ");
            strSql.Append("istrade=" + istrade + "");
            strSql.Append(" where webid=" + webid + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Upnews()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_web set ");
            strSql.Append("isnews=" + isnews + "");
            strSql.Append(" where webid=" + webid + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[webid],[website],[usernameid],[jsqid],[langId],[istrade],[isnews]");
            strSql.Append(" from etw_web ");
            strSql.Append("where webid=" + webid + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                website = ds.Tables[0].Rows[0]["website"].ToString();
                usernameid = Convert.ToInt32(ds.Tables[0].Rows[0]["usernameid"]);
                jsqid = Convert.ToInt32(ds.Tables[0].Rows[0]["jsqid"]);
                if (ds.Tables[0].Rows[0]["langId"].ToString() != null && ds.Tables[0].Rows[0]["langId"].ToString() != "")
                {
                    langId = Convert.ToInt32(ds.Tables[0].Rows[0]["langId"]);
                }
                istrade = Convert.ToInt32(ds.Tables[0].Rows[0]["istrade"]);
                isnews = Convert.ToInt32(ds.Tables[0].Rows[0]["isnews"]);
            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [webid],[website],[usernameid],[jsqid],[langId],[istrade],[isnews]");
            strSql.Append(" FROM etw_web ");
            if (strWhere != 0)
            {
                strSql.Append(" where  webid=" + webid);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }
        public DataSet GetwebList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [webid],[website],[usernameid],[jsqid],[langId],[istrade],[isnews]");
            strSql.Append(" FROM etw_web ");
            if (strWhere != 0)
            {
                strSql.Append(" where  usernameid=" + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
