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_repeat
    {
        public etw_repeat()
        {
        }
        private int etw_id;
        private int etw_onlines_id;
        private int etw_usernameid;

        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public int onlines_id
        {
            set { etw_onlines_id = value; }
            get { return etw_onlines_id; }
        }
        public int usernameid
        {
            set { etw_usernameid = value; }
            get { return etw_usernameid; }
        }
        public bool exists()
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select count(id) from etw_repeat");
            strsql.Append("where id=" + id + "");
            return DbHelperSQL.Exists(strsql.ToString());

        }

        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_repeat](");
            strSql.Append("onlines_id,usernameid");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + onlines_id + ",");
            strSql.Append("" + usernameid + "");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_repeat set ");
            strSql.Append("onlines_id=" + onlines_id + ",");
            strSql.Append("usernameid=" + usernameid + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

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

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

            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [id],[onlines_id],[usernameid]");
            strSql.Append(" FROM etw_repeat ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }
        public DataSet Getonlines_id(int usernameid)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [onlines_id]");
            strSql.Append(" FROM etw_repeat ");
            if (usernameid != 0)
            {
                strSql.Append(" where  usernameid=" + usernameid);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
