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

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

mysql=”insert into tb_componentversioninformation(componentid,componentversion,componentcreator,creationtime,maintechnique,operationsystemid,presupposition,Componentupdate)VALUES(’”+lblcompid.Text+”’,’”+version+”’,’”+ddlcompauth.SelectedItem.Text+”’,’”+txtcretime.Text+”’,’”+txtmaintech.Text+”’,’”+os+”’,’”+txtpre.Text+”’,’”+update+”’)”

mycomd=New SqlCommand(mysql,myconn)

mycomd.ExecuteNonQuery()

mysql=”select versionid from tb_componentversioninformation where(componentid=’”+lblcompid.Text+”’and componentversion=’”+version+”’)”

mycomd=New SqlCommand(mysql,myconn)

myrd=mycomd.ExecuteReader

myrd.Read()

versionid=myrd.Item(”versionid”)

myrd.Close()

mysql=”insert into tb_componentusageinformation(componentid,componentversion,componentinstruction,componentexample,componentpath,codefilepath,versionid)VALUES(’”+lblcompid.Text+”’,’”+version+”’,’”+txtinstr.Text+”’,’”+txtexam.Text+”’,’”+txtcomppath.Value()+”’,’”+txtcodefp.Value()+”’,’”+versionid+”’)”

mycomd=New SqlCommand(mysql,myconn)

mycomd.ExecuteNonQuery()

Response.Redirect(”success.aspx”)

End If

myconn.Close()

End Sub

End Class

3.构件更新信息页面

说明:以下代码为更新构件版本页面的vb代码。

Imports System.Data

Imports System.Data.SqlClient

Public Class componentupdate

Inherits System.Web.UI.Page

Protected WithEvents rfv11 As System.Web.UI.WebControls.RequiredFieldValidator

Protected WithEvents rfv14 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

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

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

Protected WithEvents txtcomppath As System.Web.UI.HtmlControls.HtmlInputFile

Protected WithEvents txtcodefp As System.Web.UI.HtmlControls.HtmlInputFile

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

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

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

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

Protected WithEvents ddlcompauth As System.Web.UI.WebControls.DropDownList

Protected WithEvents ddlos As System.Web.UI.WebControls.DropDownList

Protected WithEvents Image1 As System.Web.UI.WebControls.Image

Protected WithEvents rfv18 As System.Web.UI.WebControls.RequiredFieldValidator

#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 Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)

Handles MyBase.Load

If Not(Page.IsPostBack)Then

Dim conn As SqlConnection

Dim cmd As SqlCommand

Dim rd As SqlDataReader

Dim sql As String

Dim now As DateTime

Dim compid As String

conn=New SqlConnection(”server=(local);database=Componentsystem;Trusted_Connection=yes”)

conn.Open()

lblcompid.Text=Session(”compid”)

sql=”select componentName from tb_ComponentBasicInformation where ComponentID=’”+lblcompid.Text+”’”

cmd=New SqlCommand(sql,conn)

lblCompName.Text=CType(cmd.ExecuteScalar(),String)

now=DateTime.Now

txtcretime.Text=now.ToString()

sql=”Select operationsystemname From tb_operationsystem”

cmd=New SqlCommand(sql,conn)

rd=cmd.ExecuteReader

ddlos.Items.Clear()

Do While rd.Read

ddlos.Items.Add(rd(”operationsystemname”))

Loop

rd.Close()

sql=”Select authorname From tb_author”

cmd=New SqlCommand(sql,conn)

rd=cmd.ExecuteReader

ddlcompauth.Items.Clear()

Do While rd.Read

ddlcompauth.Items.Add(rd(”authorname”))

Loop

rd.Close()

conn.Close()

End If

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

End Sub

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

Dim mysql As String

Dim mycomd As SqlCommand

Dim myconn As SqlConnection

Dim myrd As SqlDataReader

Dim os As String

Dim versionid As String

Dim compid As String

myconn=New SqlConnection(”server=(local);database=componentsystem;Trusted_Connection=yes”)

myconn.Open()

compid=Session(”compid”)

mysql=”select componentversion from tb_componentversioninformation where(componentversion=’”+txtversion.Text+”’and componentid=’”+compid+”’)”

mycomd=New SqlCommand(mysql,myconn)

myrd=mycomd.ExecuteReader

If myrd.Read()Then

lblmessage.Text=”该版本号已存在”

myrd.Close()

Exit Sub

Else

myrd.Close()

mysql=”select operationsystemid from tb_operationsystem where(operationsystemname=’”+ddlos.SelectedItem.Text+”’)”

mycomd=New SqlCommand(mysql,myconn)

myrd=mycomd.ExecuteReader

myrd.Read()

os=myrd.Item(”operationsystemid”)

myrd.Close()