Public Class CLogManage 'Dim m_SQL As New CMSQL_Interface Public Const cst_TABLE_NAME As String = "系统记录表" Public Shared m_COLS_NAME() As String = { "序号", "日期", "时间", "操作对象", "操作内容", "帐号", "PC名称", "IP地址"} Public Enum COLS 序号 日期 时间 操作对象 操作内容 帐号 PC名称 IP地址 End Enum '权限 Public Shared AccessRight As Integer = RIGHTS.NONE Public Sub New() End Sub Public Function AddItem(ByVal 操作对象 As String, ByVal 操作内容 As String, ByVal 帐号 As String ) As ERROR_CODE 'If CBool(AccessRight And RIGHTS.WRITE) = False Then ' Return ERROR_CODE.NORIGHT 'End If Dim 时间 As Date = Now Dim PC名称 As String = My.Computer.Name Dim IP地址 As String = GetLocalIPAddress() Dim strSql As String = "INSERT INTO `" & cst_TABLE_NAME & "`(" '加入列名 For i As Integer = 1 To m_COLS_NAME.Length - 1 If i > 1 Then strSql &= "," End If strSql &= "`" & m_COLS_NAME(i) & "`" Next strSql &= ") VALUES (" strSql &= "'" & 时间.ToString("yyyy-MM-dd") & "'" strSql &= ",'" & 时间.ToString("HH:mm:ss") & "'" strSql &= $",'{操作对象}'" '", @objName" strSql &= $",'{操作内容}'" '", @objContent" strSql &= ",'" & 帐号 & "'" strSql &= ",'" & PC名称 & "'" strSql &= ",'" & IP地址 & "'" strSql &= ")" Dim paramName() As String = {操作对象, 操作内容} Dim paramValue() As Object = {操作对象, 操作内容} If m_SQL.ExeCommandWithParamters(strSql, paramName, paramValue) = True Then Return ERROR_CODE.SUCCESS End If Return ERROR_CODE.ACCESS End Function 'Public Function DeleteItem(ByVal index As Long) As ERROR_CODE ' 'If CBool(AccessRight And RIGHTS.WRITE) = False Then ' ' Return ERROR_CODE.NORIGHT ' 'End If ' Dim strSql As String = "DELETE FROM " & cst_TABLE_NAME & " WHERE " ' strSql &= m_COLS_NAME(COLS.序号) & "=" & index ' If m_SQL.ExeCommand(strSql) = True Then ' Return ERROR_CODE.SUCCESS ' End If ' Return ERROR_CODE.ACCESS 'End Function 'Public Function QueryItem(ByVal index As Long, ' ByRef 时间 As Date, ' ByRef 操作对象 As String, ' ByRef 操作内容 As String, ' ByRef 帐号 As String, ' ByRef PC名称 As String, ' ByRef IP地址 As String) As ERROR_CODE ' 'If CBool(AccessRight And RIGHTS.READ) = False Then ' ' Return ERROR_CODE.NORIGHT ' 'End If ' Dim strSql As String = "SELECT * FROM " & cst_TABLE_NAME & " WHERE " ' strSql &= m_COLS_NAME(COLS.序号) & "=" & index ' Dim rValue(0) As Object ' If m_SQL.DataReader(strSql, rValue) = True Then ' 时间 = rValue(COLS.时间) ' 操作对象 = rValue(COLS.操作对象) ' 操作内容 = rValue(COLS.操作内容) ' 帐号 = rValue(COLS.帐号) ' PC名称 = rValue(COLS.PC名称) ' IP地址 = rValue(COLS.IP地址) ' Return ERROR_CODE.SUCCESS ' End If ' Return ERROR_CODE.ACCESS 'End Function Public Function GetLogCounts(ByRef Count As Long) As Boolean 'If CBool(AccessRight And RIGHTS.READ) = False Then ' Return ERROR_CODE.NORIGHT 'End If 'SELECT COUNT(22) FROM [TABLE1] Dim strSql As String = "SELECT COUNT(" & m_COLS_NAME(COLS.序号) & ") FROM " & cst_TABLE_NAME Dim rTable As New System.Data.DataTable If m_SQL.Query(strSql, rTable) = True Then Try Count = rTable.Rows(0).Item(0) Return ERROR_CODE.SUCCESS Catch ex As Exception End Try End If Return ERROR_CODE.ACCESS End Function End Class