📄 notesread.aspx.vb
字号:
Public Class NotesRead
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents btnAddNotes As System.Web.UI.WebControls.Button
Protected WithEvents dgUserNotes As System.Web.UI.WebControls.DataGrid
Protected WithEvents lblFeedback As System.Web.UI.WebControls.Label
Protected WithEvents btnAddNotesTop As System.Web.UI.WebControls.Button
Protected WithEvents hidDoc As System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents lblDoc As System.Web.UI.WebControls.Label
Protected WithEvents btnNotesAddTop As System.Web.UI.WebControls.Button
Protected WithEvents btnNotesAdd As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Page.IsPostBack Then Exit Sub
Dim dacc As New DataAccessBase
Dim sSQL As String
Dim ds As DataSet
Dim sDoc As String, iPos As Integer
Try
dacc.IsFillSchema = False
dacc.Open(Session("connDbNotices"))
'050331 CHN, NICK
'050520 JPC
hidDoc.Value = Request.QueryString("doc")
'Friendly display name for this document.
iPos = InStrRev(hidDoc.Value, "/")
lblDoc.Text = Mid(hidDoc.Value, iPos + 1)
sSQL = "SELECT DateAdded, AuthorName, Notes FROM UserNotes " _
& "WHERE DocumentName ='" & Request.QueryString("doc") & "' " _
& "ORDER BY DateAdded DESC;"
ds = dacc.GetData("UserNotes", sSQL)
dgUserNotes.DataSource = ds.Tables("UserNotes")
dgUserNotes.DataBind()
If ds.Tables("UserNotes").Rows.Count = 0 Then
lblFeedback.ForeColor = Color.Firebrick
lblFeedback.Text = "There are no User-Contributed Comments or Notes yet about this current page."
End If
'050520 JPC only need bottom button if table getting big
If ds.Tables("Usernotes").Rows.Count >= 5 Then
Me.btnNotesAdd.Visible = True
Else
Me.btnNotesAdd.Visible = False
End If
'Nicer looking date
For Each xitem As DataGridItem In dgUserNotes.Items
If IsDate(xitem.Cells(0).Text) Then
xitem.Cells(0).Text = Format(CDate(xitem.Cells(0).Text), "dd MMM yyyy") _
& "<br>" & Format(CDate(xitem.Cells(0).Text), "HH:mm")
End If
Next
'
'050520 JPC feedback across pages
If Request.QueryString("notesadd") = "true" Then
lblFeedback.ForeColor = Color.Green
lblFeedback.Text = "You have successfully added your note."
ElseIf Not (Session("StateMessage") Is Nothing) Then
'050626 JPC backstop permission denied
' if INTRANET and not Privileged Group
lblFeedback.ForeColor = Color.Red
lblFeedback.Text = Session("StateMessage")
Session("StateMessage") = Nothing
End If
Catch ex As Exception
lblFeedback.ForeColor = Color.Red
lblFeedback.Text = "ERROR: " & ex.Message
Finally
dacc.Close()
End Try
End Sub
Private Sub btnNotesAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnNotesAdd.Click, btnNotesAddTop.Click
'Security is also handled in NotesAdd Page_Load
Dim sPrivilegedGroup As String
sPrivilegedGroup = ConfigurationSettings.AppSettings("privilegedGroup")
If (Request.IsAuthenticated Or sPrivilegedGroup > "") Then
'INTRANET situation or Windows Authentication used on Server
If Not (User.IsInRole(sPrivilegedGroup)) _
And Not (LCase(sPrivilegedGroup) = "test") Then
lblFeedback.ForeColor = Color.Red
lblFeedback.Text = "You are not authorised to add Comments and Notes. If you believe you should be, then please contact your systems people."
Exit Sub
End If
End If
Server.Transfer("NotesAdd.aspx?doc=" & hidDoc.Value)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -