using System; using System.Collections.Generic; using System.Text; using System.Data; using SysBaseLibs; using System.Web.Script.Serialization; namespace SysDataLibs.TableClass { #region Sys_AttachTables public class Sys_AttachTables_info : ITableInfo { #region Sys_AttachTables表 字段信息 /// /// 为关键字段: N ; /// 自动增长: N; /// 数据类型: nvarchar; /// 数据长度: 300; /// 是否允许为空: N; /// 默认值: ; /// 描述: Actiion; /// public const string cActiion = "Actiion"; /// /// 为关键字段: N ; /// 自动增长: N; /// 数据类型: smalldatetime; /// 数据长度: 4; /// 是否允许为空: N; /// 默认值: (getdate()); /// 描述: ActionTime; /// public const string cActionTime = "ActionTime"; /// /// 为关键字段: N ; /// 自动增长: N; /// 数据类型: int; /// 数据长度: 4; /// 是否允许为空: N; /// 默认值: ((0)); /// 描述: ActionTimes; /// public const string cActionTimes = "ActionTimes"; /// /// 为关键字段: N ; /// 自动增长: N; /// 数据类型: nvarchar; /// 数据长度: 160; /// 是否允许为空: N; /// 默认值: ; /// 描述: ColumnId; /// public const string cColumnId = "ColumnId"; /// /// 为关键字段: Y --- PrimaryKey; /// 自动增长: N; /// 数据类型: varchar; /// 数据长度: 250; /// 是否允许为空: N; /// 默认值: ; /// 描述: SourceKey; /// public const string cSourceKey = "SourceKey"; /// /// 为关键字段: Y --- PrimaryKey; /// 自动增长: N; /// 数据类型: nvarchar; /// 数据长度: 160; /// 是否允许为空: N; /// 默认值: ; /// 描述: TableId; /// public const string cTableId = "TableId"; /// /// 为关键字段: Y --- PrimaryKey; /// 自动增长: N; /// 数据类型: varchar; /// 数据长度: 30; /// 是否允许为空: N; /// 默认值: ; /// 描述: UserID; /// public const string cUserID = "UserID"; #endregion public Sys_AttachTables_info() { } public Sys_AttachTables_info(DataRow poRow) { CreateTableInfo(poRow); } public void CreateTableInfo(DataRow poRow) { _Actiion = UtilStr.StrFromObj(poRow[cActiion]); _ActionTime = UtilStr.StrFromObj(poRow[cActionTime]); _ActionTimes = UtilStr.StrFromObj(poRow[cActionTimes]); _ColumnId = UtilStr.StrFromObj(poRow[cColumnId]); _SourceKey = UtilStr.StrFromObj(poRow[cSourceKey]); _TableId = UtilStr.StrFromObj(poRow[cTableId]); _UserID = UtilStr.StrFromObj(poRow[cUserID]); } public Sys_AttachTables_info(string pcSourceKey, string pcTableId, string pcUserID, DBConnSql poDBConn) { if (pcSourceKey.Trim().Length > 0 && pcTableId.Trim().Length > 0 && pcUserID.Trim().Length > 0 && poDBConn != null) { string lcSql = "select * from " + Tn.Sys_AttachTables + " where SourceKey='" + pcSourceKey + "' and TableId='" + pcTableId + "' and UserID='" + pcUserID + "'"; rsQuery loQuery = poDBConn.OpenQuery(lcSql); if (loQuery != null && loQuery.IsOpened && loQuery.RecCount == 1) { loQuery.MoveFirst(); CreateTableInfo(loQuery.CurrentRow); } } } private string _Actiion = ""; public string Actiion { get { return _Actiion; } set { _Actiion = value; } } private string _ActionTime = ""; public string ActionTime { get { return _ActionTime; } set { _ActionTime = value; } } private string _ActionTimes = ""; public string ActionTimes { get { return _ActionTimes; } set { _ActionTimes = value; } } private string _ColumnId = ""; public string ColumnId { get { return _ColumnId; } set { _ColumnId = value; } } private string _SourceKey = ""; public string SourceKey { get { return _SourceKey; } set { _SourceKey = value; } } private string _TableId = ""; public string TableId { get { return _TableId; } set { _TableId = value; } } private string _UserID = ""; public string UserID { get { return _UserID; } set { _UserID = value; } } [ScriptIgnore] public rsXmlNode DataXMLNode { get { rsXmlNode loMainNode = new rsXmlNode("Sys_AttachTablesRecord", ""); rsXmlNode loNode = null; loNode = new rsXmlNode(cActiion, Actiion); loMainNode.AddChild(loNode); loNode = new rsXmlNode(cActionTime, ActionTime); loMainNode.AddChild(loNode); loNode = new rsXmlNode(cActionTimes, ActionTimes); loMainNode.AddChild(loNode); loNode = new rsXmlNode(cColumnId, ColumnId); loMainNode.AddChild(loNode); loNode = new rsXmlNode(cSourceKey, SourceKey); loMainNode.AddChild(loNode); loNode = new rsXmlNode(cTableId, TableId); loMainNode.AddChild(loNode); loNode = new rsXmlNode(cUserID, UserID); loMainNode.AddChild(loNode); return loMainNode; } } public string InsertSql() { return " insert into " + Tn.Sys_AttachTables + " " + " (" + cActiion + "," + cActionTime + "," + cActionTimes + "," + cColumnId + "," + cSourceKey + "," + cTableId + "," + cUserID + ") " + " values ('" + _Actiion + "',getdate(),'1','" + _ColumnId + "','" + _SourceKey + "','" + _TableId + "','" + _UserID + "') "; } public string UpdateSql() { return " update " + Tn.Sys_AttachTables + " " + " set " + cActionTime + "=getdate() ," + cActionTimes + "=" + cActionTimes + "+1 " + " where " + cSourceKey + "='" + _SourceKey + "' and " + cTableId + "='" + _TableId + "' and " + cUserID + "='" + _UserID + "'"; } public string DeleteSql() { return "Delete " + Tn.Sys_AttachTables + " where " + cSourceKey + "='" + _SourceKey + "' and " + cTableId + "='" + _TableId + "' and " + cUserID + "='" + _UserID + "'"; } public bool Update(UserSession poSession) { string lcSlq = " if( Exists (select * from Sys_AttachTables where SourceKey ='" + _SourceKey + "' and TableId='" + _TableId + "' and UserID ='" + _UserID + "')) \r\n " + UpdateSql() + " \r\n " + " else \r\n " + InsertSql(); return poSession.DBConn.ExcuteSqlTran(lcSlq); } } #endregion #region public class Sys_AttachTables_Qry : rsQuery { public String Actiion { get { return GetString(Sys_AttachTables_info.cActiion); } // set { SetField(Sys_AttachTables_info.cActiion, value); } } public DateTime ActionTime { get { return GetDateTime(Sys_AttachTables_info.cActionTime); } // set { SetField(Sys_AttachTables_info.cActionTime, value); } } public Int64 ActionTimes { get { return GetInt(Sys_AttachTables_info.cActionTimes); } // set { SetField(Sys_AttachTables_info.cActionTimes, value); } } public String ColumnId { get { return GetString(Sys_AttachTables_info.cColumnId); } // set { SetField(Sys_AttachTables_info.cColumnId, value); } } public String SourceKey { get { return GetString(Sys_AttachTables_info.cSourceKey); } // set { SetField(Sys_AttachTables_info.cSourceKey, value); } } public String TableId { get { return GetString(Sys_AttachTables_info.cTableId); } // set { SetField(Sys_AttachTables_info.cTableId, value); } } public String UserID { get { return GetString(Sys_AttachTables_info.cUserID); } // set { SetField(Sys_AttachTables_info.cUserID, value); } } } #endregion }