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_country
    {//地区
        public etw_country()
        {
        }
        private int etw_id;
        private string etw_country_en;
        private string etw_country_cn;
        private string etw_shortname;
        private int etw_zid;
        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public string country_en
        {
            set { etw_country_en = value; }
            get { return etw_country_en; }
        }
        public string country_cn
        {
            set { etw_country_cn = value; }
            get { return etw_country_cn; }
        }
        public string shortname
        {
            set { etw_shortname = value; }
            get { return etw_shortname; }
        }
        public int zid
        {
            set { etw_zid = value; }
            get { return etw_zid; }
        }
        public bool exists()
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select count(id) from etw_country");
            strsql.Append("where id=" + id + "");
            return DbHelperSQL.Exists(strsql.ToString());

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_country](");
            strSql.Append("country_en,country_cn,shortname,zid");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("N'" + country_en + "',");
            strSql.Append("N'" + country_cn + "',");
            strSql.Append("N'" + shortname + "',");
            strSql.Append("" + zid + "");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_country set ");
            strSql.Append("country_en=N'" + country_en + "',");
            strSql.Append("country_cn=N'" + country_cn + "',");
            strSql.Append("shortname=N'" + shortname + "',");
            strSql.Append("zid=" + zid + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[country_en],[country_cn],[shortname],[zid]");
            strSql.Append(" from etw_country ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                country_en = ds.Tables[0].Rows[0]["country_en"].ToString();
                country_cn = ds.Tables[0].Rows[0]["country_cn"].ToString();
                shortname = ds.Tables[0].Rows[0]["shortname"].ToString();
                zid = Convert.ToInt32(ds.Tables[0].Rows[0]["zid"].ToString());
            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [id],[country_en],[country_cn],[shortname],[zid]");
            strSql.Append(" FROM etw_country ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
