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_client
    {
        public etw_client()
        {
        }
        private int etw_id;
        private int etw_userid;
        private string etw_a_client;
        private string etw_b_client;
        private string etw_c_client;

        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public int userid
        {
            set { etw_userid = value; }
            get { return etw_userid; }
        }
        public string a_client
        {
            set { etw_a_client = value; }
            get { return etw_a_client; }
        }
        public string b_client
        {
            set { etw_b_client = value; }
            get { return etw_b_client; }
        }
        public string c_client
        {
            set { etw_c_client = value; }
            get { return etw_c_client; }
        }

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

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_client](");
            strSql.Append("userid,a_client,b_client,c_client");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + userid + ",");
            strSql.Append("N'" + a_client + "',");
            strSql.Append("N'" + b_client + "',");
            strSql.Append("N'" + c_client + "'");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_client set ");
            strSql.Append("userid=" + userid + ",");
            strSql.Append("a_client=N'" + a_client + "',");
            strSql.Append("b_client=N'" + b_client + "',");
            strSql.Append("c_client=N'" + c_client + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[userid],[a_client],[b_client],[c_client]");
            strSql.Append(" from etw_client ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                userid = Convert.ToInt32(ds.Tables[0].Rows[0]["userid"]);
                a_client = ds.Tables[0].Rows[0]["a_client"].ToString();
                b_client = ds.Tables[0].Rows[0]["b_client"].ToString();
                c_client = ds.Tables[0].Rows[0]["c_client"].ToString();

            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [id],[userid],[a_client],[b_client],[c_client]");
            strSql.Append(" FROM etw_client ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
