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

            strSql.Append("update TreeNote set ");
            strSql.Append("NoteName=@NoteName,");
            strSql.Append("FatherNoteId=@FatherNoteId,");
            strSql.Append("Url=@Url,");
            strSql.Append("ImgUrl=@ImgUrl,");
            strSql.Append("Status=@Status,");
            strSql.Append("WebId=@WebId,");
            strSql.Append("Code=@Code,");
            strSql.Append("TOrder=@TOrder,");
            strSql.Append("price=@price");
            strSql.Append(" where TreeNodeId=@TreeNodeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NoteName",     SqlDbType.VarChar,   50),
                new SqlParameter("@FatherNoteId", SqlDbType.Int,        4),
                new SqlParameter("@Url",          SqlDbType.VarChar,  500),
                new SqlParameter("@ImgUrl",       SqlDbType.VarChar,   50),
                new SqlParameter("@Status",       SqlDbType.VarChar,   50),
                new SqlParameter("@WebId",        SqlDbType.Int,        4),
                new SqlParameter("@Code",         SqlDbType.NVarChar,  50),
                new SqlParameter("@TOrder",       SqlDbType.Int,        4),
                new SqlParameter("@price",        SqlDbType.Money,      8),
                new SqlParameter("@TreeNodeId",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.NoteName;
            parameters[1].Value = model.FatherNoteId;
            parameters[2].Value = model.Url;
            parameters[3].Value = model.ImgUrl;
            parameters[4].Value = model.Status;
            parameters[5].Value = model.WebId;
            parameters[6].Value = model.Code;
            parameters[7].Value = model.TOrder;
            parameters[8].Value = model.price;
            parameters[9].Value = model.TreeNodeId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Learning.Model.TreeNote DataRowToModel(DataRow row)
 {
     Learning.Model.TreeNote model = new Learning.Model.TreeNote();
     if (row != null)
     {
         if (row["TreeNodeId"] != null && row["TreeNodeId"].ToString() != "")
         {
             model.TreeNodeId = int.Parse(row["TreeNodeId"].ToString());
         }
         if (row["NoteName"] != null)
         {
             model.NoteName = row["NoteName"].ToString();
         }
         if (row["FatherNoteId"] != null && row["FatherNoteId"].ToString() != "")
         {
             model.FatherNoteId = int.Parse(row["FatherNoteId"].ToString());
         }
         if (row["Url"] != null)
         {
             model.Url = row["Url"].ToString();
         }
         if (row["ImgUrl"] != null)
         {
             model.ImgUrl = row["ImgUrl"].ToString();
         }
         if (row["Status"] != null)
         {
             model.Status = row["Status"].ToString();
         }
         if (row["WebId"] != null && row["WebId"].ToString() != "")
         {
             model.WebId = int.Parse(row["WebId"].ToString());
         }
         if (row["Code"] != null)
         {
             model.Code = row["Code"].ToString();
         }
         if (row["TOrder"] != null && row["TOrder"].ToString() != "")
         {
             model.TOrder = int.Parse(row["TOrder"].ToString());
         }
         if (row["price"] != null && row["price"].ToString() != "")
         {
             model.price = decimal.Parse(row["price"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Learning.Model.TreeNote model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TreeNote(");
            strSql.Append("NoteName,FatherNoteId,Url,ImgUrl,Status,WebId,Code,TOrder,price)");
            strSql.Append(" values (");
            strSql.Append("@NoteName,@FatherNoteId,@Url,@ImgUrl,@Status,@WebId,@Code,@TOrder,@price)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NoteName",     SqlDbType.VarChar,   50),
                new SqlParameter("@FatherNoteId", SqlDbType.Int,        4),
                new SqlParameter("@Url",          SqlDbType.VarChar,  500),
                new SqlParameter("@ImgUrl",       SqlDbType.VarChar,   50),
                new SqlParameter("@Status",       SqlDbType.VarChar,   50),
                new SqlParameter("@WebId",        SqlDbType.Int,        4),
                new SqlParameter("@Code",         SqlDbType.NVarChar,  50),
                new SqlParameter("@TOrder",       SqlDbType.Int,        4),
                new SqlParameter("@price",        SqlDbType.Money, 8)
            };
            parameters[0].Value = model.NoteName;
            parameters[1].Value = model.FatherNoteId;
            parameters[2].Value = model.Url;
            parameters[3].Value = model.ImgUrl;
            parameters[4].Value = model.Status;
            parameters[5].Value = model.WebId;
            parameters[6].Value = model.Code;
            parameters[7].Value = model.TOrder;
            parameters[8].Value = model.price;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Learning.Model.TreeNote GetModel(int TreeNodeId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 TreeNodeId,NoteName,FatherNoteId,Url,ImgUrl,Status,WebId,Code,TOrder,price from TreeNote ");
            strSql.Append(" where TreeNodeId=@TreeNodeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TreeNodeId", SqlDbType.Int, 4)
            };
            parameters[0].Value = TreeNodeId;

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

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