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
{
///
/// 获取单据号
///
///
///
///
///
///
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();
}
///
///copy相同字段的数据
public static D Mapper(S s)
{
D d = Activator.CreateInstance();
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;
}
}
}