using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; namespace Lskj.Business.Impl { public class BaseSpecImpl : BaseImpl { /// /// 说明:删除节点 /// 创建人:龚宇超 /// 创建日期:2018-01-04 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// Name of the table. /// The key. /// The value. /// System.Int32. public static int DeleteNode(string tableName, string key, string value) { string sqlValue = string.Format("delete from {0} where {1}='{2}'", tableName, key, value); return ExecSqlValue(sqlValue); } /// /// 说明:获取子节点个数 /// 创建人:龚宇超 /// 创建日期:2018-01-04 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// Name of the table. /// The key. /// The value. /// System.Int32. public static int GetNodeChildCount(string tableName,string key,string value) { string sqlValue = string.Format("select count(1) from {0} where {1} like '{2}%'", tableName, key, value); return Convert.ToInt32(GetResult(sqlValue)); } /// /// 说明:获取最大节点号 /// 创建人:龚宇超 /// 创建日期:2018-01-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// Name of the table. /// The parent identifier. /// System.String. /// public static string GetMaxSpeciesNo(string tableName, string parentKey, string parentValue,string firstNode) { if (string.IsNullOrWhiteSpace(tableName) || string.IsNullOrWhiteSpace(parentKey) || string.IsNullOrWhiteSpace(parentValue)) return "01"; string maxdivision = string.Empty; string PrefixNum = string.Empty; string maxNum = string.Empty; for (int i = 0; i < firstNode.Length; i++) { maxdivision += "_"; if (i != 0) PrefixNum += "0"; maxNum += "9"; } string sqlValue = string.Format("select max(cast({1} as bigint))+1 from {0} where {1} like '{2}{3}'", tableName, parentKey, parentValue, maxdivision); string maxNo = GetResult(sqlValue) + ""; if (string.IsNullOrWhiteSpace(maxNo)) maxNo = parentValue + PrefixNum+"1"; maxNo = maxNo.PadLeft(parentValue.Length + firstNode.Length, '0'); if ((PrefixNum + "0").Equals(maxNo.Substring(maxNo.Length - firstNode.Length))) { sqlValue = string.Format("select count(1) as cnt from {0} where {1} like '{2}{3}'", tableName, parentKey, parentValue, maxdivision); if (GetResult(sqlValue) + "" == maxNum) return maxNum; // 取未使用的编号 sqlValue = string.Format("select cast({1} as bigint) as SpeciesNo from {0} where {1} like '{2}{