请教下面的代码是什么意思?
Dim CurrentIndex As IntegerCurrentIndex = ListView1.SelectedIndices(0) '获取当前控件的索引值
ListView_BookID = Val(ListView1.Items(CurrentIndex).SubItems(0).Text)
Dim StudentsSID1 As New SqlParameter("@StudentsSID1", SqlDbType.Int)
Dim ListView_BookID1 As New SqlParameter("@ListView_BookID1", SqlDbType.Int)
StudentsSID1.Value = StudentsSID
ListView_BookID1.Value = ListView_BookID
Dim sqlstr As String = "Exec Lend @SID=@StudentsSID1,@ID=@ListView_BookID1" '此处的代码可能有问题
Dim mycom1 As New SqlCommand(sqlstr, mycon)
mycom1.Parameters.Add(StudentsSID1)
mycom1.Parameters.Add(ListView_BookID1)
mycom1.ExecuteNonQuery()
FillDataToListView2()
FillDataToListView1()
MessageBox.Show("借阅成功!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Warning)
mycon.Close()
'完成向数据库中的Book_HisTory完成插入操作
mycon.Open()
StudentsSID1 = New SqlParameter("@StudentsSID1", SqlDbType.Int)
ListView_BookID1 = New SqlParameter("@ListView_BookID1", SqlDbType.Int)
StudentsSID1.Value = StudentsSID
ListView_BookID1.Value = ListView_BookID
sqlstr = "Exec Book_HisTory_Insert @SID=@StudentsSID1,@ID=@Listview_BookID1"
Dim mycom2 As New SqlCommand(sqlstr, mycon)
mycom2.Parameters.Add(StudentsSID1)
mycom2.Parameters.Add(ListView_BookID1)
mycom2.ExecuteNonQuery()
mycon.Close()
'MessageBox.Show("请选择你要借阅的书籍!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'归还按钮的代码
If CheckButton3() = False Then
MessageBox.Show("请选种你要归还的书籍", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Exit Sub
End If
Try '由Sno到SID的转变
If mycon.State = ConnectionState.Closed Then
mycon.Open()
End If
Dim myreader1 As SqlDataReader
Dim mycom1 As New SqlCommand("Select SID From Students Where Sno='" & TextBox1.Text & "'", mycon)
myreader1 = mycom1.ExecuteReader
While myreader1.Read
StudentsSID = Val(myreader1.Item("SID"))
End While
mycon.Close()
myreader1.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Dim CurrentIndex As Integer
CurrentIndex = ListView2.SelectedIndices(0)
ListView_BookID = Val(ListView2.Items(CurrentIndex).SubItems(0).Text)
Try '实现归还书籍的功能
If mycon.State = ConnectionState.Closed Then
mycon.Open()
End If
Dim StudentsSID1 As New SqlParameter("@StudentsSID1", SqlDbType.Int)
Dim ListView_BookID1 As New SqlParameter("@ListView_bookID1", SqlDbType.Int)
StudentsSID1.Value = StudentsSID
ListView_BookID1.Value = ListView_BookID
Dim sqlstr As String = "Exec guihuan @SID=@StudentsSID1,@ID=@ListView_BookID1"
Dim mycom2 As New SqlCommand(sqlstr, mycon)
mycom2.Parameters.Add(StudentsSID1)
mycom2.Parameters.Add(ListView_BookID1)
mycom2.ExecuteNonQuery()
FillDataToListView1()
FillDataToListView2()
MessageBox.Show("归还成功,谢谢使用!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning)
mycon.Close()
'实现向Book_History中更新数据
mycon.Open()
StudentsSID1 = New SqlParameter("@StudentsSID1", SqlDbType.Int)
ListView_BookID1 = New SqlParameter("@ListView_BookID1", SqlDbType.Int)
StudentsSID1.Value = StudentsSID
ListView_BookID1.Value = ListView_BookID
sqlstr = "Exec Book_HisTory_Update @SID=@StudentsSID1,@ID=@ListView_BookID1"
Dim mycom3 As New SqlCommand(sqlstr, mycon)
mycom3.Parameters.Add(StudentsSID1)
mycom3.Parameters.Add(ListView_BookID1)
mycom3.ExecuteNonQuery()
mycon.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try