纽威
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

1 year ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Reflection;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace NFine.Data.Extensions
  9. {
  10. public class PublicMethod
  11. {
  12. /// <summary>
  13. /// 获取单据号
  14. /// </summary>
  15. /// <param name="tbName"></param>
  16. /// <param name="colName"></param>
  17. /// <param name="Pre"></param>
  18. /// <param name="numLen"></param>
  19. /// <returns></returns>
  20. public static string GetSerialCode( string tbName, string colName, string Pre, int numLen)
  21. {
  22. string sql = "EXEC Addins_GetSerialCode '0001','{0}','{1}','{2}',{3}";
  23. sql = string.Format(sql, new object[] { tbName, colName, Pre, numLen });
  24. return SqlHelper.ExecuteScalar(sql).ToString();
  25. }
  26. ///<summary>
  27. ///copy相同字段的数据
  28. public static D Mapper<D, S>(S s)
  29. {
  30. D d = Activator.CreateInstance<D>();
  31. try
  32. {
  33. var Types = s.GetType();//获得类型
  34. var Typed = typeof(D);
  35. foreach (PropertyInfo sp in Types.GetProperties())//获得类型的属性字段
  36. {
  37. foreach (PropertyInfo dp in Typed.GetProperties())
  38. {
  39. if (dp.Name == sp.Name)//判断属性名是否相同
  40. {
  41. dp.SetValue(d, sp.GetValue(s, null), null);//获得s对象属性的值复制给d对象的属性
  42. }
  43. }
  44. }
  45. }
  46. catch (Exception ex)
  47. {
  48. throw ex;
  49. }
  50. return d;
  51. }
  52. }
  53. }