Private Sub UpdateInfo(ByVal table As DataTable, ByVal index As Integer) txtname.Text = table.Rows(index)("项目名") txtnumber.Text = table.Rows(index)("控制编号") txtcname.Text = table.Rows(index)("摄像机名") MyDateSet.Text = table.Rows(index)("日期") MyTimeSet.Text = table.Rows(index)("录像起始时间") txtGname.Text = table.Rows(index)("工况名") '就在这行提示,当从一个数字执行强制转换时,值必须出现是一个小于无限大的数字 txtBFB.Text = table.Rows(index)("破坏时的荷载百分数") txtxs.Text = table.Rows(index)("破坏形式") txtwz.Text = table.Rows(index)("破坏位置") txtcl.Text = table.Rows(index)("破坏材料") txtfap.Text = table.Rows(index)("文件名称及路径") txtother.Text = table.Rows(index)("试验情况概述") End Sub
Private Sub EditBase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load lbUserName.Items.Clear() Dim SQLString As String = "SELECT * FROM VideoDataBase" Dim user As ManageDB = New ManageDB() 'SQL查询语句 Dim UserTable As DataTable = user.SearchData(SQLString) Dim userRow As DataRow For Each userRow In UserTable.Rows lbUserName.Items.Add(userRow("项目名")) Next lbUserName.SelectedIndex = 0
UpdateInfo(UserTable, 0) End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Me.Hide() End Sub
Private Sub lbUserName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbUserName.SelectedIndexChanged Dim Name As String = lbUserName.SelectedItem().ToString Dim SQLString As String = "SELECT * FROM VideoDataBase where 项目名 ='" & Name & "'" Dim user As ManageDB = New ManageDB() Dim table As DataTable = user.SearchData(SQLString) UpdateInfo(table, 0) End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click '判断控制编号的长度是否合法 Dim EDdata As New ManageDB(lbUserName.SelectedItem, txtnumber.Text) If txtnumber.Text.Length < 8 Then MsgBox("输入的控制编号长度太短!请按照格式返回重新填写,正确控制编号格式为[##T##-##],其中#号代表任意数字。", MsgBoxStyle.Exclamation, "信息框") Exit Sub End If If txtnumber.Text.Length > 8 Then MsgBox("输入的控制编号长度太长!请按照格式返回重新填写,正确控制编号格式为[##T##-##],其中#号代表任意数字。", MsgBoxStyle.Exclamation, "信息框") Exit Sub End If If txtnumber.Text.Length = "" Then MsgBox("输入的控制编号长度不能为空!请按照格式返回重新填写,正确控制编号格式为[##T##-##],其中#号代表任意数字。", MsgBoxStyle.Exclamation, "信息框") Exit Sub End If Dim strEDIT As String = " 控制编号 = '" & Trim(txtnumber.Text) & "',摄像机名 = '" & Trim(txtcname.Text) & "' ,日期 = '" & Trim(MyDateSet.Text) & " ',录像起始时间 = '" & Trim(MyTimeSet.Text) & "', 工况名 = '" & Trim(txtGname.Text) & "' ,破坏时荷载百分数 = '" & Trim(txtBFB.Text) & "' ,破坏形式 = '" & Trim(txtxs.Text) & "' ,破坏位置 = '" & Trim(txtwz.Text) & "' ,破坏材料 = '" & Trim(txtcl.Text) & "' ,文件名称及路径 = '" & Trim(txtfap.Text) & "' ,试验情况概述 = '" & Trim(txtother.Text) & "'" EDdata.EditData("VideoDataBase", strEDIT, "项目名", txtname.Text)