基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
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(SpeciesNo 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}{3}' order by {1}", tableName, parentKey, parentValue,maxdivision);
|
||||
DataTable table = GetDataTableResult(sqlValue);
|
||||
|
||||
Int64 speciesNo = table.Rows.Count > 0 ? Convert.ToInt64(table.Rows[0]["SpeciesNo"] + "") : 0;
|
||||
if (speciesNo != Int64.Parse(parentValue + PrefixNum+"1"))
|
||||
return parentValue +PrefixNum+"1";;
|
||||
|
||||
foreach (DataRow item in table.Rows)
|
||||
{
|
||||
Int64 rowSpeciesNo = Convert.ToInt64(item["SpeciesNo"] + "");
|
||||
if (speciesNo == rowSpeciesNo) continue;
|
||||
|
||||
if (rowSpeciesNo != speciesNo + 1)
|
||||
{
|
||||
maxNo = (speciesNo + 1).ToString();
|
||||
maxNo = maxNo.PadLeft(parentValue.Length + firstNode.Length, '0');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
speciesNo = rowSpeciesNo;
|
||||
}
|
||||
}
|
||||
|
||||
return maxNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user