| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1438 人关注过本帖
标题:请教下面的代码是什么意思?
只看楼主 加入收藏
asdasdqaz
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-3-26
收藏
 问题点数:0 回复次数:1 
请教下面的代码是什么意思?
Dim CurrentIndex As Integer
            CurrentIndex = 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
搜索更多相关主题的帖子: ListView Dim 意思 CurrentIndex 代码 
2008-05-19 21:57
asdasdqaz
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-3-26
收藏
得分:0 
要是哪位兄台知道意思的麻烦解释下,谢谢
2008-05-19 21:58
快速回复:请教下面的代码是什么意思?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018933 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved