📄 notice.vb
字号:
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Public Class Notice
#Region "属性"
Dim NoticeNoValue As String
Dim NoticeTitleValue, NoticeObjectValue, ContentValue As String
Dim DateTimeValue As System.DateTime
Public Property NoticeNo() '通知编号
Get
Return NoticeNoValue
End Get
Set(ByVal value)
NoticeNoValue = value
End Set
End Property
Public Property NoticeTitle() '通知标题
Get
Return NoticeTitleValue
End Get
Set(ByVal value)
NoticeTitleValue = value
End Set
End Property
Public Property NoticeObject() '通知对象(学生或教师)
Get
Return NoticeObjectValue
End Get
Set(ByVal value)
NoticeObjectValue = value
End Set
End Property
Public Property NoticeContent() '通知内容
Get
Return ContentValue
End Get
Set(ByVal value)
ContentValue = value
End Set
End Property
Public Property DateTime() '通知日期
Get
Return DateTimeValue
End Get
Set(ByVal value)
DateTimeValue = value
End Set
End Property
#End Region
Dim cn As SqlConnection = New SqlConnection("server=localhost\sqlexpress;integrated security=sspi;database=GDMS")
Dim cmd As New SqlCommand
Dim cmdText As String
Dim dr As SqlDataReader
Dim db As New DBObject
#Region "方法"
'发布新通知
Public Function ReleaseNotice() As Integer
db.cmdText = "insert into notice (NoticeNo,Date,NoticeTitle,NoticeObject,NoticeContent)" _
+ "values ('" + NoticeNo + "','" + DateTime + "','" + NoticeTitle + "','" + NoticeObject + "','" + NoticeContent + "')"
ReleaseNotice = db.SQL()
End Function
'删除通知
Public Sub DeleteNotice(ByVal NoticeNo As Integer)
cn.Open()
cmd.Connection = cn
cmdText = "delete from notice where NoticeNo='" + NoticeNo + "'"
cmd.CommandText = cmdText
cmd.ExecuteNonQuery()
cn.Close()
End Sub
'查看学生通知
Public Sub NoticeToStudent(ByVal NoticeTitle As String)
cn.Open()
cmd.Connection = cn
cmdText = "select * from notice where (NoticeObject='student') and (NoticeTitle='" + NoticeTitle + "')"
cmd.CommandText = cmdText
dr = cmd.ExecuteReader()
If dr.Read() Then
DateTime = dr("Date")
NoticeContent = dr("NoticeContent")
End If
cn.Close()
End Sub
'查看教师通知
Public Sub NoticeToTeacher(ByVal NoticeTitle As String)
cn.Open()
cmd.Connection = cn
cmdText = "select * from notice where (NoticeObject='教师') and (NoticeTitle='" + NoticeTitle + "')"
cmd.CommandText = cmdText
dr = cmd.ExecuteReader()
If dr.Read() Then
DateTime = dr("Date")
NoticeContent = dr("NoticeContent")
End If
cn.Close()
End Sub
#End Region
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -