书城计算机网络综合应用软件设计
8724600000045

第45章 软件工程实例——构件库管理系统(9)

hlkSuper.Target=”_self”

hlkAttribute.Visible=True

hlkEvent.Visible=True

hlkMethod.Visible=True

hlkBase.Visible=True

hlkSuper.Visible=True

End Sub

Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)

Handles MyBase.Load

ComponentName=Request.QueryString.Item(”ComponentName”)

lblComName.Text=ComponentName

ComponentVersion=Request.QueryString.Item(”ComponentVersion”)

lblVersion.Text=ComponentVersion

VersionID=Request.QueryString.Item(”VersionId”)

Dim myConn As New SqlConnection (”server=(local);database=ComponentSystem;Trusted_Connection=yes”)

myConn.Open()

Dim StrSQL As String

If Not(Page.IsPostBack)Then

StrSQL=”Select count(ClassID)as exper1 FROM tb_ClassInformation”

Dim countComm As SqlCommand=New SqlCommand(StrSQL,myConn)

If(CType(countComm.ExecuteScalar(),Integer)=0)Then

lblClassID.Text=”CL100001”

Else

StrSQL=”SELECT MAX(RIGHT(ClassID,6))as exper1 FROM tb_ClassInformation”

Dim myCommand As SqlCommand=New SqlCommand(StrSQL,myConn)

Dim id As Integer

id=CType(myCommand.ExecuteScalar(),Integer)

id=id+1

lblClassID.Text=”CL”+CType(id,String)

btnSave.CommandArgument=”Add”

End If

txtClassName.Text=””

txtClassDes.Text=””

txtClassName.ReadOnly=False

txtClassDes.ReadOnly=False

txtClassName.BorderStyle=BorderStyle.NotSet

txtClassName.BorderStyle=BorderStyle.NotSet

btnAdd.Enabled=False

btnSave.Enabled=True

hlkAttribute.Visible=False

hlkEvent.Visible=False

hlkMethod.Visible=False

hlkBase.Visible=False

hlkSuper.Visible=False

End If

btnSave.CommandArgument=”add”

’在此处放置初始化页的用户代码

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(ClassID)as exper1 FROM tb_ClassInformation”

Dim countComm As SqlCommand=New SqlCommand(StrSQL,myConn)

If(CType(countComm.ExecuteScalar(),Integer)=0)Then

lblClassID.Text=”CL100001”

Else

StrSQL=”SELECT MAX(RIGHT(ClassID,6))as exper1 FROM tb_ClassInformation”

Dim myCommand As SqlCommand=New SqlCommand(StrSQL,myConn)

Dim id As Integer

id=CType(myCommand.ExecuteScalar(),Integer)

id=id+1

lblClassID.Text=”CL”+CType(id,String)

End If

btnSave.CommandArgument=”Add”

txtClassName.Text=””

txtClassName.ReadOnly=False

txtClassDes.Text=””

txtClassDes.ReadOnly=False

txtClassName.BorderStyle=BorderStyle.NotSet

txtClassDes.BorderStyle=BorderStyle.NotSet

btnAdd.Enabled=False

btnSave.Enabled=True

lblSave.Text=””

lblError.Text=””

End Sub

Private Sub btnSave_Click(ByVal sender As System.Object,ByVal e AsSystem.EventArgs)Handles btnSave.Click

If(btnSave.CommandArgument=”add”)Then

save(VersionID)

End If

End Sub

End Class

6.属性,方法,事件,参数信息添加修改删除页面

说明:以下代码为添加,修改,删除属性信息页面的vb代码。方法,事件,参数信息页面的vb代码与之相仿。

Imports System.Data

Imports System.Data.SqlClient

Public Class wfrmAttribute

Inherits System.Web.UI.PageProtected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents lblClassID As System.Web.UI.WebControls.Label

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents lblAttriID As System.Web.UI.WebControls.Label

Protected WithEvents Label3 As System.Web.UI.WebControls.Label

Protected WithEvents txtAttriName As System.Web.UI.WebControls.TextBox

Protected WithEvents Label4 As System.Web.UI.WebControls.Label

Protected WithEvents txtAttriType As System.Web.UI.WebControls.TextBox

Protected WithEvents Label5 As System.Web.UI.WebControls.Label

Protected WithEvents txtAttriIns As System.Web.UI.WebControls.TextBox

Protected WithEvents txtAttriEg As System.Web.UI.WebControls.TextBox

Protected WithEvents btnSave As System.Web.UI.WebControls.Button

Protected WithEvents MydataGrid As System.Web.UI.WebControls.DataGrid

Protected WithEvents lblSave As System.Web.UI.WebControls.Label

Protected WithEvents hlkEvent As System.Web.UI.WebControls.HyperLink

Protected WithEvents hlkMethod As System.Web.UI.WebControls.HyperLink

Protected WithEvents hlkBase As System.Web.UI.WebControls.HyperLink

Protected WithEvents hlkSuper As System.Web.UI.WebControls.HyperLink

Protected WithEvents hlkClass As System.Web.UI.WebControls.HyperLink

Protected WithEvents lblClassName As System.Web.UI.WebControls.Label

Protected WithEvents Label7 As System.Web.UI.WebControls.Label

Protected WithEvents lblError As System.Web.UI.WebControls.Label

Protected WithEvents Label6 As System.Web.UI.WebControls.Label

Protected WithEvents btnAdd As System.Web.UI.WebControls.Button

Protected WithEvents lblMessage As System.Web.UI.WebControls.Label

Protected WithEvents btnEdit As System.Web.UI.WebControls.Button

Protected WithEvents btnCancel As System.Web.UI.WebControls.Button

Protected WithEvents Label8 As System.Web.UI.WebControls.Label

Protected WithEvents lblErrType As System.Web.UI.WebControls.Label

#Region”Web窗体设计器生成的代码”

’该调用是Web窗体设计器所必需的。

Private Sub InitializeComponent()End Sub

Private Sub Page_Init(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Init

’CODEGEN:此方法调用是Web窗体设计器所必需的

’不要使用代码编辑器修改它。

InitializeComponent()

End Sub

#End Region

Private ClassID As String

Private VersionId As String

Private startIndex As Integer

Private Sub MYbind(ByVal CLassID As String)

Dim MyConnection As SqlConnection

Dim MyCommand As SqlDataAdapter

MyConnection=New SqlConnection(”server=(local);database=ComponentSystem;