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_question
    {
        public etw_question()
        {
        }
        private int etw_id;
        private string etw_question1;

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

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

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_question](");
            strSql.Append("question");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("N'" + question + "'");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_question set ");
            strSql.Append("question=N'" + question + "'");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[question]");
            strSql.Append(" from etw_question ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                question = ds.Tables[0].Rows[0]["question"].ToString();

            }
        }
        public DataSet GetList()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [id],[question]");
            strSql.Append(" FROM etw_question ");
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
