📄 friendgroupclass.vb
字号:
Imports System.Data
Imports System.Data.OleDb
Imports System.Collections.Generic
Public Class FriendGroupClass
Private m_ID As Integer
Public Property ID() As Integer
Get
Return m_ID
End Get
Set(ByVal value As Integer)
m_ID = value
End Set
End Property
Private m_GroupName As String
Public Property GroupName() As String
Get
Return m_GroupName
End Get
Set(ByVal value As String)
m_GroupName = value
End Set
End Property
Private Shared Function GetEntry(ByVal odr As OleDbDataReader) As FriendGroupClass
Dim entry As FriendGroupClass = New FriendGroupClass()
Try
entry.ID = odr.GetInt32(0)
entry.GroupName = odr.GetString(1)
Catch ex As Exception
Throw ex
End Try
Return entry
End Function
''' <summary>
''' 获取所有分组
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function GetAllFriendGroup() As List(Of FriendGroupClass)
Dim result As List(Of FriendGroupClass) = New List(Of FriendGroupClass)()
Try
Using conn As OleDbConnection = New OleDbConnection(Common.StrConn)
Using cmd As OleDbCommand = conn.CreateCommand()
cmd.CommandText = "select [id],groupname from friendgroup"
conn.Open()
Using odr As OleDbDataReader = cmd.ExecuteReader
If (odr.HasRows) Then
While (odr.Read())
result.Add(GetEntry(odr))
End While
End If
End Using
End Using
End Using
Catch ex As Exception
Throw ex
End Try
Return result
End Function
''' <summary>
''' 删除分组
''' </summary>
''' <param name="GroupId"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function DeleteGroupById(ByVal GroupId As Integer) As Boolean
Try
Using conn As OleDbConnection = New OleDbConnection(Common.StrConn)
Using cmd As OleDbCommand = conn.CreateCommand()
cmd.CommandText = "delete from friendgroup where [id]=?"
cmd.Parameters.Add("@id", OleDbType.Integer).Value = GroupId
conn.Open()
Return cmd.ExecuteNonQuery() > -1
End Using
End Using
Catch ex As Exception
Throw ex
End Try
End Function
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -