Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)
Handles MyBase.Load
If Not IsPostBack Then
startIndex=0
End If
MYbind()
lblError.Text=””
lblSave.Text=””
txtAuthName.Enabled=True
txtAuthDes.Enabled=True
’在此处放置初始化页的用户代码
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)
Handles btnAdd.Click
Dim myConn As New SqlConnection(”server=(local);database=ComponentSystem;
Trusted_Connection=yes”)
myConn.Open()
Dim StrSQL As String
StrSQL=”Select count(AuthorID)as exper1 FROM tb_Author”
Dim countComm As SqlCommand=New SqlCommand(StrSQL,myConn)
If(CType(countComm.ExecuteScalar(),Integer)=0)Then
lblAuthID.Text=”AU100001”
Else
StrSQL=”SELECT MAX(RIGHT(AuthorID,6))as exper1 FROM tb_Author”
Dim myCommand As SqlCommand=New SqlCommand(StrSQL,myConn)
Dim id As Integer
id=CType(myCommand.ExecuteScalar(),Integer)
id=id+1
lblAuthID.Text=”AU”+CType(id,String)
End If
txtAuthName.Text=””
txtAuthDes.Text=””
txtAuthName.ReadOnly=False
txtAuthDes.ReadOnly=False
lblSave.Text=””
lblError.Text=””
btnSave.CommandArgument=”Add”
btnEdit.Enabled=False
btnAdd.Enabled=False
btnSave.Enabled=True
btnCancel.Enabled=True
lblMessage.Visible=False
End Sub
Private Sub btnSave_Click (ByVal sender As System.Object,ByVal e As System.EventArgs)Handles btnSave.Click
If((Trim(txtAuthName.Text))=””)Then
lblError.Text=”*输入作者名”
Exit Sub
ElseIf((Trim(txtAuthDes.Text)=””))Then
txtAuthDes.Text=”[null]”
End If
If(btnSave.CommandArgument=”Add”)Then
save()
ElseIf(btnSave.CommandArgument=”Update”)Then
update()
End If
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles btnCancel.Click
lblAuthID.Text=””
txtAuthName.Text=””
txtAuthDes.Text=””
lblSave.Text=””
txtBox_init()
End Sub
Private Sub MydataGrid_ItemCommand(ByVal source As Object,ByVal e As System.Web.UI.
WebControls.DataGridCommandEventArgs)Handles Mydatagrid.ItemCommand
If e.Item.ItemType=ListItemType.Pager Or_e.Item.ItemType=ListItemType.Header
Then Exit Sub
If e.CommandName=”Select”Then
lblAuthID.Text=e.Item.Cells(0).Text
txtAuthName.Text=e.Item.Cells(1).Text
Dim myConn As New SqlConnection(”server=(local);database=ComponentSystem;Trusted_Connection=yes”)
myConn.Open()
Dim StrSQL As String
StrSQL=”SELECT AuthorInstruction as exper1 FROM tb_Author where AuthorID=’”
+lblAuthID.Text+”’”
Dim myCommand As SqlCommand=New SqlCommand(StrSQL,myConn)
Dim desp As String
desp=CType(myCommand.ExecuteScalar(),String)
txtAuthDes.Text=desp
btnSave.CommandArgument=”Update”
lblMessage.Text=”单击修改更新作者”
lblMessage.Visible=True
txtAuthName.ReadOnly=True
txtAuthDes.ReadOnly=True
btnAdd.Enabled=False
btnEdit.Enabled=True
btnSave.Enabled=False
btnCancel.Enabled=True
End If
End Sub
Private Sub btnEdit_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles btnEdit.Click
txtAuthName.Enabled=False
txtAuthDes.ReadOnly=False
lblSave.Text=””
btnSave.CommandArgument=”Update”
btnEdit.Enabled=False
btnAdd.Enabled=False
btnSave.Enabled=True
btnCancel.Enabled=True
lblMessage.Visible=False
End Sub
Private Sub Mydatagrid_PageIndexChanged(ByVal source As Object,ByVal e As System.Web. UI.WebControls.DataGridPageChangedEventArgs)Handles Mydatagrid.
PageIndexChanged
startIndex=e.NewPageIndex*Mydatagrid.PageSize
Mydatagrid.CurrentPageIndex=e.NewPageIndex
MYbind()
End Sub
End Class
2.构件注册信息页面
说明:以下代码为注册构件页面的vb代码。
Imports System.Data
Imports System.Data.SqlClient
Public Class componentregister1
Inherits System.Web.UI.Page
Protected WithEvents lblcompid As System.Web.UI.WebControls.Label
Protected WithEvents txtcompname As System.Web.UI.WebControls.TextBox
Protected WithEvents rfv1 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents lblmessage As System.Web.UI.WebControls.Label
Protected WithEvents ddlcompcate As System.Web.UI.WebControls.DropDownList
Protected WithEvents ddltool As System.Web.UI.WebControls.DropDownList
Protected WithEvents ddlprodtype As System.Web.UI.WebControls.DropDownList
Protected WithEvents ddlcompauth As System.Web.UI.WebControls.DropDownList
Protected WithEvents ddlos As System.Web.UI.WebControls.DropDownList
Protected WithEvents txtcompvers As System.Web.UI.WebControls.TextBox
Protected WithEvents txtcretime As System.Web.UI.WebControls.TextBox
Protected WithEvents rfv11 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents rfv14 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents txtcompintro As System.Web.UI.WebControls.TextBox
Protected WithEvents rfv10 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents txtfuncintro As System.Web.UI.WebControls.TextBox
Protected WithEvents rfv16 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents txtinstr As System.Web.UI.WebControls.TextBox
Protected WithEvents rfv13 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents txtexam As System.Web.UI.WebControls.TextBox
Protected WithEvents rfv12 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents txtmaintech As System.Web.UI.WebControls.TextBox
Protected WithEvents rfv15 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents txtpre As System.Web.UI.WebControls.TextBox
Protected WithEvents rfd17 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents btnfinish As System.Web.UI.WebControls.Button