/// <summary> /// orderTreeNode: 根据升序或降序尽心修改顺序 /// </summary> /// <param name="_table">表名</param> /// <param name="_id">要排序操作的ID值</param> /// <param name="_ifAsc">是否按照升序方式排序, true: 升序, false: 降序</param> /// <returns></returns> public string orderTreeNode(string _table, int _id, bool _ifAsc) { MySqlTrans _trans = new MySqlTrans(this); string _val = String.Empty, _sign = ">", _fn = "min"; if (_ifAsc) { _sign = "<"; _fn = "max"; } try { Json _node = _trans.execJson(MySqlString.getSelectStr(_table, "pid, treeOrder", "id=" + _id)); if (_node != null) { int _pid = _node.getInt("pid"), _treeOrder = _node.getInt("treeOrder"); Json _target = _trans.execJson("select top 1 id,treeOrder from {0} where pid={1} and treeOrder=(select {2}(treeOrder) from {0} where pid={1} and treeOrder{3}{4});", _table, _pid, _fn, _sign, _treeOrder); if (_target != null) { string _sql = "update {0} set treeOrder={1} where id={2};"; _sql = MySqlString.format(_sql, _table, _target.getValue("treeOrder"), _id); _sql += "update {0} set treeOrder={1} where id={2};"; _sql = MySqlString.format(_sql, _table, _treeOrder, _target.getValue("id")); _trans.execNonQuery(_sql); } else { Native.writeToPage(Native.getErrorMsg("id是{0}的记录指针已经是第一行或最后一行", _id)); } } else { Native.writeToPage(Native.getErrorMsg("在表({0})中不存在id是{1}的记录", _table, _id)); } _trans.commit(); } catch (Exception e) { _val = Native.getErrorMsg(e.Message); _trans.rollback(); } finally { _trans.close(); } return(_val); }
public ArrayList execJsonList(string sql, params object[] args) { return(execJsonList(MySqlString.format(sql, args))); }
public Json execJson(string sql, params object[] args) { return(execJson(MySqlString.format(sql, args))); }
public DataSet execDataSet(string sql, params object[] args) { return(execDataSet(MySqlString.format(sql, args))); }
public string execScalar(string sql, Json json) { return(execScalar(MySqlString.format(sql, json))); }
public string execScalar(string sql, params object [] args) { return(execScalar(MySqlString.format(sql, args))); }
public int execNonQuery(string sql, Json json) { return(execNonQuery(MySqlString.format(sql, json))); }
public int execNonQuery(string sql, params object [] args) { return(execNonQuery(MySqlString.format(sql, args))); }
public string execSqlByProc(string sql, Json json) { return(execSqlByProc(MySqlString.format(sql, json))); }
public string execQuery(string sql, Json json) { return(execQuery(MySqlString.format(sql, json))); }