6245aa0768
SVN-Revision: r1189
90 lines
3.9 KiB
C#
90 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
|
|
namespace Lskj.Business.Impl
|
|
{
|
|
public class BaseSpecImpl : BaseImpl
|
|
{
|
|
/// <summary>
|
|
/// <para>说明:删除节点</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="key">The key.</param>
|
|
/// <param name="value">The value.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
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);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取子节点个数</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="key">The key.</param>
|
|
/// <param name="value">The value.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
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));
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取最大节点号</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-03 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="parentId">The parent identifier.</param>
|
|
/// <returns>System.String.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
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}{
|