コード例 #1
0
ファイル: t_college.cs プロジェクト: bruceyu1994/TSIMSServer
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TSIMSServer.Model.t_college model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_college set ");
            strSql.Append("college_name=@college_name");
            strSql.Append(" where college_num=@college_num ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@college_name", MySqlDbType.VarChar, 100),
                new MySqlParameter("@college_num",  MySqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.college_name;
            parameters[1].Value = model.college_num;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: t_college.cs プロジェクト: bruceyu1994/TSIMSServer
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(TSIMSServer.Model.t_college model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_college(");
            strSql.Append("college_num,college_name)");
            strSql.Append(" values (");
            strSql.Append("@college_num,@college_name)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@college_num",  MySqlDbType.VarChar, 50),
                new MySqlParameter("@college_name", MySqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.college_num;
            parameters[1].Value = model.college_name;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: t_college.cs プロジェクト: bruceyu1994/TSIMSServer
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public TSIMSServer.Model.t_college DataRowToModel(DataRow row)
 {
     TSIMSServer.Model.t_college model = new TSIMSServer.Model.t_college();
     if (row != null)
     {
         if (row["college_num"] != null)
         {
             model.college_num = row["college_num"].ToString();
         }
         if (row["college_name"] != null)
         {
             model.college_name = row["college_name"].ToString();
         }
     }
     return(model);
 }
コード例 #4
0
ファイル: t_college.cs プロジェクト: bruceyu1994/TSIMSServer
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TSIMSServer.Model.t_college GetModel(string college_num)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select college_num,college_name from t_college ");
            strSql.Append(" where college_num=@college_num ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@college_num", MySqlDbType.VarChar, 50)
            };
            parameters[0].Value = college_num;

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

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