CeErpUserPost.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using Castle.ActiveRecord;
  2. using NHibernate.Criterion;
  3. using System;
  4. using System.Text;
  5. namespace BizCom
  6. {
  7. [ActiveRecord("CE_ErpUserPost")]
  8. public class CeErpUserPost : ComBase<CeErpUserPost>
  9. {
  10. /// <summary>
  11. ///
  12. /// </summary>
  13. [PrimaryKey(PrimaryKeyType.Native)]
  14. public int ID { get; set; }
  15. private int _userID = 0;
  16. /// <summary>
  17. ///
  18. /// </summary>
  19. [Property]
  20. public int UserID
  21. {
  22. get { return _userID; }
  23. set { _userID = value; }
  24. }
  25. private int _orgID = 0;
  26. /// <summary>
  27. ///
  28. /// </summary>
  29. [Property]
  30. public int OrgID
  31. {
  32. get { return _orgID; }
  33. set { _orgID = value; }
  34. }
  35. private CeErpPost _post;
  36. [BelongsTo("PostID", Insert = false, NotFoundBehaviour = NotFoundBehaviour.Ignore, Cascade = CascadeEnum.None, Update = false)]
  37. public CeErpPost Post
  38. {
  39. get { return _post; }
  40. set { _post = value; }
  41. }
  42. private int _postID = 0;
  43. /// <summary>
  44. ///
  45. /// </summary>
  46. [Property]
  47. public int PostID
  48. {
  49. get { return _postID; }
  50. set { _postID = value; }
  51. }
  52. public static void Del(object id)
  53. {
  54. StringBuilder sql = new StringBuilder();
  55. sql.AppendFormat("delete from CE_ErpUserPost where id=" + id);
  56. ExecuteNonQuery(sql.ToString());
  57. }
  58. public static void Del(object id, string personId)
  59. {
  60. StringBuilder sql = new StringBuilder();
  61. sql.AppendFormat("delete from CE_ErpUserPost where id={0} and UserID={1}", id, personId);
  62. ExecuteNonQuery(sql.ToString());
  63. }
  64. public static CeErpUserPost Get(int personId, object id)
  65. {
  66. return FindFirst(Expression.And(Expression.Eq("UserID", personId), Expression.Eq("ID", Convert.ToInt32(id))));
  67. //Expression.Sql(string.Format("PersonID={0} and ID={1}", personId, id)));
  68. }
  69. public static CeErpUserPost GetByUserID(int uid)
  70. {
  71. return FindFirst(Expression.Eq("UserID", uid));
  72. //Expression.Sql(string.Format("PersonID={0} and ID={1}", personId, id)));
  73. }
  74. }
  75. }