/// <summary> /// addTreeNode: 添加树节点 /// </summary> /// <param name="_table">表名</param> /// <param name="_pid">父节点ID</param> /// <param name="_keys">字段列表</param> /// <param name="_values">值列表</param> /// <returns>返回当前树节点ID</returns> public string addTreeNode(string _table, int _pid, string _keys, string _values) { string _val = String.Empty; if (_pid == 0) { return(execScalar(MySqlString.getInsertStr(_table, _keys, _values, true))); } Json _pre = execJson(MySqlString.getSelectStr(_table, "*", "id=" + _pid)); if (_pre != null) { string _treeOrder = execScalar("select max(treeOrder)+1 from {0} where delFlag='0' and pid={1};", _table, _pid).ToString(); if (Native.isNullEmpty(_treeOrder) || _treeOrder.ToLower() == "null") { _treeOrder = "1"; } string _k = _keys + ",parentPath,treeOrder,depth"; string _v = _values + ",'" + _pre.getString("parentPath") + _pid + ",'," + _treeOrder + "," + (_pre.getInt("depth") + 1); if (_k.IndexOf("pid") == -1) { _k += ",pid"; _v += "," + _pid; } _val = execScalar(MySqlString.getInsertStr(_table, _k, _v, true)); execNonQuery(MySqlString.getUpdateStr(_table, "sons=sons+1", "id=" + _pid)); } else { _val = Native.getErrorMsg("在表({0})中pid={1}的节点不存在", _table, _pid); } return(_val); }
public string updateTreeNode(string _table, string _update, string _condition) { return(execTrans(MySqlString.getUpdateStr(_table, _update, _condition))); }
/// <summary> /// update: 根据表名(table), 修改结果(updateSql), 修改条件(whereCondition)进行修改数据 /// </summary> /// <param name="table">表名(table)</param> /// <param name="updateSql">修改结果(updateSql)</param> /// <param name="id">对应的ID值</param> /// <returns></returns> public string updateById(string table, string updateSql, int id) { return(execQuery(MySqlString.getUpdateStr(table, updateSql, "id=" + id))); }
/// <summary> /// deleteTreeNode: 删除树节点 /// </summary> /// <param name="_table">表名</param> /// <param name="_id">要删除的节点ID</param> /// <returns>操作结果</returns> public string updateTreeNode(string _table, string _update, int _id) { return(execTrans(MySqlString.getUpdateStr(_table, _update, _id))); }
/// <summary> /// update: 根据表名(table), 修改结果(updateSql), 修改条件(whereCondition)进行修改数据 /// </summary> /// <param name="table">表名(table)</param> /// <param name="updateSql">修改结果(updateSql)</param> /// <param name="whereCondiction">修改条件(whereCondition)</param> /// <returns></returns> public string update(string table, string updateSql, string whereCondiction) { return(execQuery(MySqlString.getUpdateStr(table, updateSql, whereCondiction))); }