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_biaoji
    {
        public etw_biaoji()
        {
        }
        private int etw_id;
        private int etw_online_id;
        private int etw_tran_id;
        private int etw_usernameid;
        private int etw_is_tran;
        private int etw_istop;
        private string etw_color;
        private string etw_flag;
        private int etw_priority;

        public int id
        {
            set { etw_id = value; }
            get { return etw_id; }
        }
        public int online_id
        {
            set { etw_online_id = value; }
            get { return etw_online_id; }
        }
        public int tran_id
        {
            set { etw_tran_id = value; }
            get { return etw_tran_id; }
        }
        public int usernameid
        {
            set { etw_usernameid = value; }
            get { return etw_usernameid; }
        }
        public int is_tran
        {
            set { etw_is_tran = value; }
            get { return etw_is_tran; }
        }
        public int istop
        {
            set { etw_istop = value; }
            get { return etw_istop; }
        }
        public string color
        {
            set { etw_color = value; }
            get { return etw_color; }
        }
        public string flag
        {
            set { etw_flag = value; }
            get { return etw_flag; }
        }
        public int priority
        {
            set { etw_priority = value; }
            get { return etw_priority; }
        }
        
        public bool exists()
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select count(id) from etw_biaoji");
            strsql.Append("where id=" + id + "");
            return DbHelperSQL.Exists(strsql.ToString());

        }
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [etw_biaoji](");
            strSql.Append("online_id,tran_id,usernameid,is_tran,istop,color,flag,priority");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + online_id + ",");
            strSql.Append("" + tran_id + ",");
            strSql.Append("" + usernameid + ",");
            strSql.Append("" + is_tran + ",");
            strSql.Append("" + istop + ",");
            strSql.Append("N'" + color + "',");
            strSql.Append("N'" + flag + "',");
            strSql.Append("N'" + priority + "'");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_biaoji set ");
            strSql.Append("online_id=" + online_id + ",");
            strSql.Append("tran_id=" + tran_id + ",");
            strSql.Append("usernameid=" + usernameid + ",");
            strSql.Append("is_tran=" + is_tran + ",");
            strSql.Append("istop=" + istop + ",");
            strSql.Append("color=N'" + color + "',");
            strSql.Append("flag=N'" + flag + "',");
            strSql.Append("priority=" + priority + "");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Upcolor()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_biaoji set ");
            strSql.Append("color=N'" + color + "'");
            strSql.Append(" where online_id=" + online_id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void Upistop()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update etw_biaoji set ");
            strSql.Append("istop=" + istop + "");
            strSql.Append(" where online_id=" + online_id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        public void Delete()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from etw_biaoji ");
            strSql.Append(" where id=" + id + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("[id],[online_id],[tran_id],[usernameid],[is_tran],[istop],[color],[flag],[priority]");
            strSql.Append(" from etw_biaoji ");
            strSql.Append("where id=" + id + "");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                online_id = Convert.ToInt32(ds.Tables[0].Rows[0]["online_id"]);
                tran_id = Convert.ToInt32(ds.Tables[0].Rows[0]["tran_id"]);
                usernameid = Convert.ToInt32(ds.Tables[0].Rows[0]["usernameid"]);
                is_tran = Convert.ToInt32(ds.Tables[0].Rows[0]["is_tran"]);
                istop = Convert.ToInt32(ds.Tables[0].Rows[0]["istop"]);
                color = ds.Tables[0].Rows[0]["color"].ToString();
                flag = ds.Tables[0].Rows[0]["flag"].ToString();
                priority = Convert.ToInt32(ds.Tables[0].Rows[0]["priority"]);
            }
        }
        public DataSet GetList(int strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [id],[online_id],[tran_id],[usernameid],[is_tran],[istop],[color],[flag],[priority]");
            strSql.Append(" FROM etw_biaoji ");
            if (strWhere != 0)
            {
                strSql.Append(" where  id=" + id);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
