📄 notesadd.aspx.vb
字号:
Public Class NotesAdd
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 reqNotes As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents txtNotes As System.Web.UI.WebControls.TextBox
Protected WithEvents lblNotes As System.Web.UI.WebControls.Label
Protected WithEvents lblOrganisation As System.Web.UI.WebControls.Label
Protected WithEvents reqAuthorName As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents txtAuthorName As System.Web.UI.WebControls.TextBox
Protected WithEvents lblAuthorName As System.Web.UI.WebControls.Label
Protected WithEvents lblFeedback As System.Web.UI.WebControls.Label
Protected WithEvents lblDocumentName As System.Web.UI.WebControls.Label
Protected WithEvents btnReset As System.Web.UI.WebControls.Button
Protected WithEvents btnAdd As System.Web.UI.WebControls.Button
Protected WithEvents lblDoc As System.Web.UI.WebControls.Label
Protected WithEvents hidDoc As System.Web.UI.HtmlControls.HtmlInputHidden
'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
Dim sPrivilegedGroup As String
sPrivilegedGroup = ConfigurationSettings.AppSettings("privilegedGroup")
If Request.IsAuthenticated Or sPrivilegedGroup > "" Then
'This is an INTRANET App
If Not (User.IsInRole(sPrivilegedGroup)) _
And Not (LCase(sPrivilegedGroup) = "test") Then
Session("StateMessage") = "You are not authorised to add comments and notes. If you believe you should be, then please contact your systems people."
Server.Transfer("NotesRead.aspx?doc=" & Request.QueryString("doc") & "¬esadd=false")
End If
Else
'This is PUBLIC INTERNET relying on this internal coding to run
'a custom security system
If Not (Session("Username") > "") Then
Session("StateMessage") = "You need to be logged-in to add comments and notes."
Session("LoginNeed") = "NotesAdd.aspx?doc=" & Request.QueryString("doc")
Server.Transfer("members.aspx")
End If
End If
'Cover case of returning from members.aspx
If Not Session("StateMessage") Is Nothing Then
lblFeedback.ForeColor = Color.Green
lblFeedback.Text = Session("StateMessage")
Session("StateMessage") = Nothing
End If
If Page.IsPostBack Then Exit Sub
'050331 CHN, NICK
'050520 JPC
hidDoc.Value = Request.QueryString("doc")
'Friendly display name for this document.
Dim iPos As Integer
iPos = InStrRev(hidDoc.Value, "/")
lblDoc.Text = Mid(hidDoc.Value, iPos + 1)
Me.lblDocumentName.Text = Mid(hidDoc.Value, iPos + 1)
Me.txtAuthorName.Text = Session("Username")
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim ds As DataSet
Dim dacc As New DataAccessBase
Dim sSQL As String
'Dim sNewNotesID As String, sNewPersonIdStart As String, sNewPassword As String
Dim dr As DataRow
Try
'050611 JPC Connection Strings now initialised in Sub Session_onLoad
dacc.Open(Session("connDbNotices"))
dacc.IsFillSchema = True
'050520 JPC note trick to get empty dataset for new addition
sSQL = "SELECT * FROM UserNotes WHERE 1 = 0;"
ds = dacc.GetData("UserNotes", sSQL)
dacc.IsWrapBrackets = True
dr = ds.Tables("UserNotes").NewRow
dr.Item("DateAdded") = Now()
dr.Item("AuthorName") = txtAuthorName.Text
dr.Item("DocumentName") = hidDoc.Value
dr.Item("Notes") = txtNotes.Text
'
'This is a new row, so after building it, we need to Add it
ds.Tables("UserNotes").Rows.Add(dr)
dacc.PutData(ds, "UserNotes")
dacc.Close()
Server.Transfer("NotesRead.aspx?doc=" & hidDoc.Value & "¬esadd=true")
Catch ex As Exception
dacc.Close()
lblFeedback.ForeColor = Color.Red
lblFeedback.Text = "ERROR: " & ex.Message
End Try
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
txtAuthorName.Text = Session("Username")
txtNotes.Text = ""
'Believed to be no viewstate on htmlcontrols so refresh
hidDoc.Value = hidDoc.Value
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -