Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TSIMSServer.Model.t_major model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_major set ");
            strSql.Append("major_name=@major_name,");
            strSql.Append("department_num=@department_num");
            strSql.Append(" where major_num=@major_num ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@major_name",     MySqlDbType.VarChar, 100),
                new MySqlParameter("@department_num", MySqlDbType.VarChar,  50),
                new MySqlParameter("@major_num",      MySqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.major_name;
            parameters[1].Value = model.department_num;
            parameters[2].Value = model.major_num;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(TSIMSServer.Model.t_major model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_major(");
            strSql.Append("major_num,major_name,department_num)");
            strSql.Append(" values (");
            strSql.Append("@major_num,@major_name,@department_num)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@major_num",      MySqlDbType.VarChar,  50),
                new MySqlParameter("@major_name",     MySqlDbType.VarChar, 100),
                new MySqlParameter("@department_num", MySqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.major_num;
            parameters[1].Value = model.major_name;
            parameters[2].Value = model.department_num;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public TSIMSServer.Model.t_major DataRowToModel(DataRow row)
 {
     TSIMSServer.Model.t_major model = new TSIMSServer.Model.t_major();
     if (row != null)
     {
         if (row["major_num"] != null)
         {
             model.major_num = row["major_num"].ToString();
         }
         if (row["major_name"] != null)
         {
             model.major_name = row["major_name"].ToString();
         }
         if (row["department_num"] != null)
         {
             model.department_num = row["department_num"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TSIMSServer.Model.t_major GetModel(string major_num)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select major_num,major_name,department_num from t_major ");
            strSql.Append(" where major_num=@major_num ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@major_num", MySqlDbType.VarChar, 50)
            };
            parameters[0].Value = major_num;

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

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