Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Topicsys.Model.t_select model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_select(");
            strSql.Append("select_id,select_student_xh,select_topic_id,select_stat)");
            strSql.Append(" values (");
            strSql.Append("@select_id,@select_student_xh,@select_topic_id,@select_stat)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@select_id",         MySqlDbType.VarChar, 40),
                new MySqlParameter("@select_student_xh", MySqlDbType.VarChar, 20),
                new MySqlParameter("@select_topic_id",   MySqlDbType.VarChar, 40),
                new MySqlParameter("@select_stat",       MySqlDbType.Int32, 1)
            };
            parameters[0].Value = model.select_id;
            parameters[1].Value = model.select_student_xh;
            parameters[2].Value = model.select_topic_id;
            parameters[3].Value = model.select_stat;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Topicsys.Model.t_select DataRowToModel(DataRow row)
 {
     Topicsys.Model.t_select model = new Topicsys.Model.t_select();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["select_id"] != null)
         {
             model.select_id = row["select_id"].ToString();
         }
         if (row["select_student_xh"] != null)
         {
             model.select_student_xh = row["select_student_xh"].ToString();
         }
         if (row["select_topic_id"] != null)
         {
             model.select_topic_id = row["select_topic_id"].ToString();
         }
         if (row["select_stat"] != null && row["select_stat"].ToString() != "")
         {
             model.select_stat = int.Parse(row["select_stat"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Topicsys.Model.t_select model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_select set ");
            strSql.Append("select_topic_id=@select_topic_id,");
            strSql.Append("select_stat=@select_stat");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@select_topic_id",   MySqlDbType.VarChar, 40),
                new MySqlParameter("@select_stat",       MySqlDbType.Int32,    1),
                new MySqlParameter("@id",                MySqlDbType.Int32,   11),
                new MySqlParameter("@select_id",         MySqlDbType.VarChar, 40),
                new MySqlParameter("@select_student_xh", MySqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.select_topic_id;
            parameters[1].Value = model.select_stat;
            parameters[2].Value = model.id;
            parameters[3].Value = model.select_id;
            parameters[4].Value = model.select_student_xh;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Topicsys.Model.t_select GetModel(string id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,select_id,select_student_xh,select_topic_id,select_stat from t_select ");
            strSql.Append(" where select_id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.VarChar)
            };
            parameters[0].Value = id;

            Topicsys.Model.t_select model = new Topicsys.Model.t_select();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }