Sys_AttachTables_info.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5. using SysBaseLibs;
  6. using System.Web.Script.Serialization;
  7. namespace SysDataLibs.TableClass
  8. {
  9. #region Sys_AttachTables
  10. public class Sys_AttachTables_info : ITableInfo
  11. {
  12. #region Sys_AttachTables表 字段信息
  13. /// <summary>
  14. /// 为关键字段: N ;
  15. /// 自动增长: N;
  16. /// 数据类型: nvarchar;
  17. /// 数据长度: 300;
  18. /// 是否允许为空: N;
  19. /// 默认值: ;
  20. /// 描述: Actiion;
  21. /// </summary>
  22. public const string cActiion = "Actiion";
  23. /// <summary>
  24. /// 为关键字段: N ;
  25. /// 自动增长: N;
  26. /// 数据类型: smalldatetime;
  27. /// 数据长度: 4;
  28. /// 是否允许为空: N;
  29. /// 默认值: (getdate());
  30. /// 描述: ActionTime;
  31. /// </summary>
  32. public const string cActionTime = "ActionTime";
  33. /// <summary>
  34. /// 为关键字段: N ;
  35. /// 自动增长: N;
  36. /// 数据类型: int;
  37. /// 数据长度: 4;
  38. /// 是否允许为空: N;
  39. /// 默认值: ((0));
  40. /// 描述: ActionTimes;
  41. /// </summary>
  42. public const string cActionTimes = "ActionTimes";
  43. /// <summary>
  44. /// 为关键字段: N ;
  45. /// 自动增长: N;
  46. /// 数据类型: nvarchar;
  47. /// 数据长度: 160;
  48. /// 是否允许为空: N;
  49. /// 默认值: ;
  50. /// 描述: ColumnId;
  51. /// </summary>
  52. public const string cColumnId = "ColumnId";
  53. /// <summary>
  54. /// 为关键字段: Y --- PrimaryKey;
  55. /// 自动增长: N;
  56. /// 数据类型: varchar;
  57. /// 数据长度: 250;
  58. /// 是否允许为空: N;
  59. /// 默认值: ;
  60. /// 描述: SourceKey;
  61. /// </summary>
  62. public const string cSourceKey = "SourceKey";
  63. /// <summary>
  64. /// 为关键字段: Y --- PrimaryKey;
  65. /// 自动增长: N;
  66. /// 数据类型: nvarchar;
  67. /// 数据长度: 160;
  68. /// 是否允许为空: N;
  69. /// 默认值: ;
  70. /// 描述: TableId;
  71. /// </summary>
  72. public const string cTableId = "TableId";
  73. /// <summary>
  74. /// 为关键字段: Y --- PrimaryKey;
  75. /// 自动增长: N;
  76. /// 数据类型: varchar;
  77. /// 数据长度: 30;
  78. /// 是否允许为空: N;
  79. /// 默认值: ;
  80. /// 描述: UserID;
  81. /// </summary>
  82. public const string cUserID = "UserID";
  83. #endregion
  84. public Sys_AttachTables_info() { }
  85. public Sys_AttachTables_info(DataRow poRow)
  86. {
  87. CreateTableInfo(poRow);
  88. }
  89. public void CreateTableInfo(DataRow poRow)
  90. {
  91. _Actiion = UtilStr.StrFromObj(poRow[cActiion]);
  92. _ActionTime = UtilStr.StrFromObj(poRow[cActionTime]);
  93. _ActionTimes = UtilStr.StrFromObj(poRow[cActionTimes]);
  94. _ColumnId = UtilStr.StrFromObj(poRow[cColumnId]);
  95. _SourceKey = UtilStr.StrFromObj(poRow[cSourceKey]);
  96. _TableId = UtilStr.StrFromObj(poRow[cTableId]);
  97. _UserID = UtilStr.StrFromObj(poRow[cUserID]);
  98. }
  99. public Sys_AttachTables_info(string pcSourceKey, string pcTableId, string pcUserID, DBConnSql poDBConn)
  100. {
  101. if (pcSourceKey.Trim().Length > 0 && pcTableId.Trim().Length > 0 && pcUserID.Trim().Length > 0 && poDBConn != null)
  102. {
  103. string lcSql = "select * from " + Tn.Sys_AttachTables + " where SourceKey='" + pcSourceKey + "' and TableId='" + pcTableId + "' and UserID='" + pcUserID + "'";
  104. rsQuery loQuery = poDBConn.OpenQuery(lcSql);
  105. if (loQuery != null && loQuery.IsOpened && loQuery.RecCount == 1)
  106. {
  107. loQuery.MoveFirst();
  108. CreateTableInfo(loQuery.CurrentRow);
  109. }
  110. }
  111. }
  112. private string _Actiion = "";
  113. public string Actiion
  114. {
  115. get { return _Actiion; }
  116. set { _Actiion = value; }
  117. }
  118. private string _ActionTime = "";
  119. public string ActionTime
  120. {
  121. get { return _ActionTime; }
  122. set { _ActionTime = value; }
  123. }
  124. private string _ActionTimes = "";
  125. public string ActionTimes
  126. {
  127. get { return _ActionTimes; }
  128. set { _ActionTimes = value; }
  129. }
  130. private string _ColumnId = "";
  131. public string ColumnId
  132. {
  133. get { return _ColumnId; }
  134. set { _ColumnId = value; }
  135. }
  136. private string _SourceKey = "";
  137. public string SourceKey
  138. {
  139. get { return _SourceKey; }
  140. set { _SourceKey = value; }
  141. }
  142. private string _TableId = "";
  143. public string TableId
  144. {
  145. get { return _TableId; }
  146. set { _TableId = value; }
  147. }
  148. private string _UserID = "";
  149. public string UserID
  150. {
  151. get { return _UserID; }
  152. set { _UserID = value; }
  153. }
  154. [ScriptIgnore]
  155. public rsXmlNode DataXMLNode
  156. {
  157. get
  158. {
  159. rsXmlNode loMainNode = new rsXmlNode("Sys_AttachTablesRecord", "");
  160. rsXmlNode loNode = null;
  161. loNode = new rsXmlNode(cActiion, Actiion);
  162. loMainNode.AddChild(loNode);
  163. loNode = new rsXmlNode(cActionTime, ActionTime);
  164. loMainNode.AddChild(loNode);
  165. loNode = new rsXmlNode(cActionTimes, ActionTimes);
  166. loMainNode.AddChild(loNode);
  167. loNode = new rsXmlNode(cColumnId, ColumnId);
  168. loMainNode.AddChild(loNode);
  169. loNode = new rsXmlNode(cSourceKey, SourceKey);
  170. loMainNode.AddChild(loNode);
  171. loNode = new rsXmlNode(cTableId, TableId);
  172. loMainNode.AddChild(loNode);
  173. loNode = new rsXmlNode(cUserID, UserID);
  174. loMainNode.AddChild(loNode);
  175. return loMainNode;
  176. }
  177. }
  178. public string InsertSql()
  179. {
  180. return " insert into " + Tn.Sys_AttachTables + " " +
  181. " (" + cActiion + "," + cActionTime + "," + cActionTimes + "," + cColumnId + "," + cSourceKey + "," + cTableId + "," + cUserID + ") " +
  182. " values ('" + _Actiion + "',getdate(),'1','" + _ColumnId + "','" + _SourceKey + "','" + _TableId + "','" + _UserID + "') ";
  183. }
  184. public string UpdateSql()
  185. {
  186. return " update " + Tn.Sys_AttachTables + " " +
  187. " set " + cActionTime + "=getdate() ," + cActionTimes + "=" + cActionTimes + "+1 " +
  188. " where " + cSourceKey + "='" + _SourceKey + "' and " + cTableId + "='" + _TableId + "' and " + cUserID + "='" + _UserID + "'";
  189. }
  190. public string DeleteSql()
  191. {
  192. return "Delete " + Tn.Sys_AttachTables + " where " + cSourceKey + "='" + _SourceKey + "' and " + cTableId + "='" + _TableId + "' and " + cUserID + "='" + _UserID + "'";
  193. }
  194. public bool Update(UserSession poSession)
  195. {
  196. string lcSlq = " if( Exists (select * from Sys_AttachTables where SourceKey ='" + _SourceKey + "' and TableId='" + _TableId + "' and UserID ='" + _UserID + "')) \r\n " +
  197. UpdateSql() + " \r\n " +
  198. " else \r\n " +
  199. InsertSql();
  200. return poSession.DBConn.ExcuteSqlTran(lcSlq);
  201. }
  202. }
  203. #endregion
  204. #region
  205. public class Sys_AttachTables_Qry : rsQuery
  206. {
  207. public String Actiion
  208. {
  209. get { return GetString(Sys_AttachTables_info.cActiion); }
  210. // set { SetField(Sys_AttachTables_info.cActiion, value); }
  211. }
  212. public DateTime ActionTime
  213. {
  214. get { return GetDateTime(Sys_AttachTables_info.cActionTime); }
  215. // set { SetField(Sys_AttachTables_info.cActionTime, value); }
  216. }
  217. public Int64 ActionTimes
  218. {
  219. get { return GetInt(Sys_AttachTables_info.cActionTimes); }
  220. // set { SetField(Sys_AttachTables_info.cActionTimes, value); }
  221. }
  222. public String ColumnId
  223. {
  224. get { return GetString(Sys_AttachTables_info.cColumnId); }
  225. // set { SetField(Sys_AttachTables_info.cColumnId, value); }
  226. }
  227. public String SourceKey
  228. {
  229. get { return GetString(Sys_AttachTables_info.cSourceKey); }
  230. // set { SetField(Sys_AttachTables_info.cSourceKey, value); }
  231. }
  232. public String TableId
  233. {
  234. get { return GetString(Sys_AttachTables_info.cTableId); }
  235. // set { SetField(Sys_AttachTables_info.cTableId, value); }
  236. }
  237. public String UserID
  238. {
  239. get { return GetString(Sys_AttachTables_info.cUserID); }
  240. // set { SetField(Sys_AttachTables_info.cUserID, value); }
  241. }
  242. }
  243. #endregion
  244. }