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

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

save(lblClassID.Text)

End If

If(btnSave.CommandArgument=”Update”)Then

update(lblClassID.Text)

End If

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

lblAttriID.Text=e.Item.Cells(0).Text

txtAttriName.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 AttributeInstruction as exper1 FROM tb_ClassAttribute whereAttributeID=’”+lblAttriID.Text+”’”

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

Dim desp As String

desp=CType(myCommand.ExecuteScalar(),String)

txtAttriIns.Text=desp

StrSQL=”SELECT AttributeExample as exper1 FROM tb_ClassAttribute where AttributeID=’”+

lblAttriID.Text+”’”

myCommand=New SqlCommand(StrSQL,myConn)

desp=CType(myCommand.ExecuteScalar(),String)

txtAttriEg.Text=desp

StrSQL=”SELECT AttributeType as exper1 FROM tb_ClassAttribute where AttributeID=’”+lblAttriID.Text+”’”

myCommand=New SqlCommand(StrSQL,myConn)

desp=CType(myCommand.ExecuteScalar(),String)

txtAttriType.Text=desp

btnSave.CommandArgument=”Update”

lblMessage.Text=”单击修改更新属性”

lblMessage.Visible=True

txtAttriName.ReadOnly=True

txtAttriIns.ReadOnly=True

txtAttriEg.ReadOnly=True

txtAttriType.ReadOnly=True

btnAdd.Enabled=False

btnEdit.Enabled=True

btnSave.Enabled=False

btnCancel.Enabled=True

ChangeLink()

lblSave.Text=””

End If

If e.CommandName=”Delete”Then

If(e.Item.Cells(0).Text=lblAttriID.Text)Then

lblAttriID.Text=””

txtAttriName.Text=””

txtAttriIns.Text=””

txtAttriEg.Text=””

txtAttriType.Text=””

lblSave.Text=””

txtBox_init()

End If

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

myConn.Open()

Dim StrSQL As String

strSQL=”Delete from tb_ClassAttribute where AttributeID=’”+e.Item.Cells(0).Text+”’”

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

myCommand.ExecuteNonQuery()

MYbind(lblClassID.Text)

txtBox_init()

lblSave.Text=””

End If

End Sub

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

txtAttriName.Enabled=False

txtAttriIns.ReadOnly=False

txtAttriEg.ReadOnly=False

txtAttriType.ReadOnly=False

lblSave.Text=””

btnSave.CommandArgument=”Update”

btnEdit.Enabled=False

btnAdd.Enabled=False

btnSave.Enabled=True

btnCancel.Enabled=True

lblMessage.Visible=False

unable_Link()

lblSave.Text=””

End Sub

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

lblAttriID.Text=””

txtAttriName.Text=””

txtAttriIns.Text=””

txtAttriEg.Text=””

txtAttriType.Text=””

lblSave.Text=””

txtBox_init()

End Sub

Private Sub MydataGrid_PageIndexChanged(ByVal source As Object,ByVal e AsSystem.Web.UI. WebControls.DataGridPageChangedEventArgs)Handles Mydata—Grid.PageIndexChanged

startIndex=e.NewPageIndex*MydataGrid.PageSize

MydataGrid.CurrentPageIndex=e.NewPageIndex

MYbind(lblClassID.Text)

End Sub

End Class

7.基类,父类信息添加,删除页面

说明:以下代码为添加,删除基类信息页面的vb代码。父类信息的添加与之相仿。

页面1

Imports System.Data

Imports System.Data.SqlClient

Public Class wfrmBase

Inherits System.Web.UI.Page

#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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Protected WithEvents hlkEvent 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 Label7 As System.Web.UI.WebControls.Label

Private versionID As String

Private BaseName As String

Private ClassID As String

Private BaseID As String

Private startIndex As Integer

Private Sub ChangeLink()

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

myConn.Open()

Dim StrSQL As String

StrSQL=”Select VersionID FROM tb_ClassInformation where ClassId=’”+ClassID+”’”