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

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

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

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

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

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

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

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

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

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