爱思开
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

73 lines
1.8 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace NFine.Data.Extensions
{
public class PublicMethod
{
/// <summary>
/// 获取单据号
/// </summary>
/// <param name="tbName"></param>
/// <param name="colName"></param>
/// <param name="Pre"></param>
/// <param name="numLen"></param>
/// <returns></returns>
public static string GetSerialCode( string tbName, string colName, string Pre, int numLen)
{
string sql = "EXEC Addins_GetSerialCode '0001','{0}','{1}','{2}',{3}";
sql = string.Format(sql, new object[] { tbName, colName, Pre, numLen });
return SqlHelper.ExecuteScalar(sql).ToString();
}
///<summary>
///copy相同字段的数据
public static D Mapper<D, S>(S s)
{
D d = Activator.CreateInstance<D>();
try
{
var Types = s.GetType();//获得类型
var Typed = typeof(D);
foreach (PropertyInfo sp in Types.GetProperties())//获得类型的属性字段
{
foreach (PropertyInfo dp in Typed.GetProperties())
{
if (dp.Name == sp.Name)//判断属性名是否相同
{
dp.SetValue(d, sp.GetValue(s, null), null);//获得s对象属性的值复制给d对象的属性
}
}
}
}
catch (Exception ex)
{
throw ex;
}
return d;
}
}
}