Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(StudentMS.Model.Tree model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Tree set ");
            strSql.Append("TName=@TName,");
            strSql.Append("TNOParent=@TNOParent");
            strSql.Append(" where TNO=@TNO ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TNO",       SqlDbType.VarChar, 10),
                new SqlParameter("@TName",     SqlDbType.VarChar, 50),
                new SqlParameter("@TNOParent", SqlDbType.VarChar, 10)
            };
            parameters[0].Value = model.TNO;
            parameters[1].Value = model.TName;
            parameters[2].Value = model.TNOParent;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public StudentMS.Model.Tree GetModel(string TNO)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 TNO,TName,TNOParent from Tree ");
            strSql.Append(" where TNO=@TNO ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TNO", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = TNO;

            StudentMS.Model.Tree model = new StudentMS.Model.Tree();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.TNO       = ds.Tables[0].Rows[0]["TNO"].ToString();
                model.TName     = ds.Tables[0].Rows[0]["TName"].ToString();
                model.TNOParent = ds.Tables[0].Rows[0]["TNOParent"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(StudentMS.Model.Tree model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Tree(");
            strSql.Append("TNO,TName,TNOParent)");
            strSql.Append(" values (");
            strSql.Append("@TNO,@TName,@TNOParent)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TNO",       SqlDbType.VarChar, 10),
                new SqlParameter("@TName",     SqlDbType.VarChar, 50),
                new SqlParameter("@TNOParent", SqlDbType.VarChar, 10)
            };
            parameters[0].Value = model.TNO;
            parameters[1].Value = model.TName;
            parameters[2].Value = model.TNOParent;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }