⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmstoretable.vb

📁 VB写的进销存管理系统
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(80, 24)
        Me.Label5.TabIndex = 102
        Me.Label5.Text = "※商品编号:"
        '
        'Label2
        '
        Me.Label2.ForeColor = System.Drawing.Color.Red
        Me.Label2.Location = New System.Drawing.Point(16, 24)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(80, 24)
        Me.Label2.TabIndex = 101
        Me.Label2.Text = "※库存编号:"
        '
        'frmStoreTable
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(432, 190)
        Me.Controls.Add(Me.bunPrevious)
        Me.Controls.Add(Me.bunDelete)
        Me.Controls.Add(Me.bunSave)
        Me.Controls.Add(Me.bunSearch)
        Me.Controls.Add(Me.bunAdd)
        Me.Controls.Add(Me.bunUpdate)
        Me.Controls.Add(Me.bunNext)
        Me.Controls.Add(Me.bunCancel)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.txtSCount)
        Me.Controls.Add(Me.txtSPrice)
        Me.Controls.Add(Me.txtPId)
        Me.Controls.Add(Me.txtSId)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label2)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmStoreTable"
        Me.Text = "库存数据表"
        Me.ResumeLayout(False)

    End Sub

#End Region
    Private myDataAdapter As New SqlClient.SqlDataAdapter
    Private myDataReader As SqlClient.SqlDataReader
    Private myDataSet As DataSet = New DataSet("store")
    Private TableName As String
    Private myIndex As Integer = 0
    Private RowsMax As Integer
    Private Sub Sshowfield()
        If myIndex >= 0 Then
            Dim currRows() As DataRow = myDataSet.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
            Dim myRow As DataRow = currRows(myIndex)
            txtSId.Text = myRow(0)
            txtPId.Text = myRow(1)
            txtSPrice.Text = myRow(2)
            txtSCount.Text = myRow(3)
        End If
    End Sub
    Private Sub bunCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunCancel.Click
        On Error GoTo ErrorHandle
        If RowsMax < 0 Then
            txtSId.Text = ""
            txtPId.Text = ""
            txtSPrice.Text = ""
            txtSCount.Text = ""
        End If
        Sshowfield()
        Exit Sub
ErrorHandle:
        ShowErr()
    End Sub
    Private Sub bunDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunDelete.Click
        On Error GoTo ErrorHandle
        If RowsMax < 0 Then
            MsgBox("库中没有可删除的记录!", , "库存数据表")
            Exit Sub
        End If
        If MsgBox("是否删除?", 36, "提示") = vbYes Then
            Dim myRow As DataRow = myDataSet.Tables(0).Rows(myIndex)
            Dim strsql As String = "delete from store where s_id='" & myRow("s_id") & "'"
            Dim mycommand As New SqlClient.SqlCommand(strsql, db)
            db.Open()
            mycommand.ExecuteNonQuery()
            db.Close()
            myRow.Delete()
            myDataSet.AcceptChanges()
            RowsMax = RowsMax - 1
            If RowsMax >= 0 Then
                myIndex = myIndex - 1
                Sshowfield()
                Exit Sub
            Else
                txtSId.Text = ""
                txtPId.Text = ""
                txtSPrice.Text = ""
                txtSCount.Text = ""
                bunPrevious.Enabled = False
                bunDelete.Enabled = False
                bunSearch.Enabled = False
                bunSave.Enabled = False
                bunNext.Enabled = False
                Exit Sub
            End If
        Else
            Exit Sub
        End If
        Exit Sub
ErrorHandle:
        ShowErr()
    End Sub
    Private Sub bunNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunNext.Click
        On Error Resume Next
        If myIndex < RowsMax Then
            myIndex = myIndex + 1
        End If
        Sshowfield()
    End Sub
    Private Sub bunPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunPrevious.Click
        On Error Resume Next
        If myIndex > 0 Then
            myIndex = myIndex - 1
        End If
        Sshowfield()
    End Sub
    Private Sub bunSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunSave.Click
        On Error GoTo ErrorHandle
        Dim myRow As DataRow = myDataSet.Tables(0).Rows(myIndex)
        myRow("s_inprice") = txtSPrice.Text
        myRow("s_count") = txtSCount.Text
        myDataSet.AcceptChanges()
        Dim strsql As String = "update store set s_inprice='" & myRow("s_inprice") & "', s_count='" & myRow("s_count") & "' where s_id='" & myRow("s_id") & "'"
        Dim mycommand As New SqlClient.SqlCommand(strsql, db)
        db.Open()
        mycommand.ExecuteNonQuery()
        db.Close()
        MsgBox("已经保存修改", , "库存数据表")
        Exit Sub
ErrorHandle:
        ShowErr()
    End Sub
    Private Sub bunSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunSearch.Click
        On Error GoTo ErrorHandle
        Dim IDQuery As String
        Dim myRow As DataRow
        myIndex = 0
        IDQuery = InputBox("输入要搜索的库存编号", "按库存编号搜索")
        Dim currRows() As DataRow = myDataSet.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
        For Each myRow In currRows
            If myRow("s_id") Like "*" & LCase(IDQuery) & "*" Then
                Sshowfield()
                Exit Sub
            Else
                myIndex = myIndex + 1
            End If
        Next
        MsgBox("没有找到符合条件的记录", , "库存数据表")
        Exit Sub
ErrorHandle:
        ShowErr()
    End Sub
    Private Sub frmFactory_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
        ShowStatus("数据管理--", "库存数据表")
    End Sub

    Private Sub frmFactory_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
        Me.Dispose()
        Me.Close()
        ShowStatus("", "")
        StoreTableOpened = False
        TableMenuEnable()
    End Sub
    Private Sub bunUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunUpdate.Click
        db.Open()
        myDataAdapter.Update(myDataSet)
        db.Close()
        MsgBox("已经更新到数据库", , "库存数据表")
    End Sub
    Private Sub frmProduct_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TableName = CurrentTable
        Dim strSelectStore As String = "select * from Store"
        Dim cmdSelectStore As New SqlClient.SqlCommand(strSelectStore, db)
        myDataAdapter.SelectCommand = cmdSelectStore
        Dim xx As SqlCommandBuilder = New SqlCommandBuilder(myDataAdapter)
        db.Open()
        myDataAdapter.Fill(myDataSet)
        db.Close()
        bunAdd.Enabled = False
        Dim currRows() As DataRow = myDataSet.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
        RowsMax = currRows.Length - 1
        If RowsMax < 0 Then
            myIndex = -1
            MsgBox("数据库中没有记录", , "库存数据表")
            bunPrevious.Enabled = False
            bunDelete.Enabled = False
            bunSearch.Enabled = False
            bunSave.Enabled = False
            bunNext.Enabled = False
        Else
            Sshowfield()
        End If
    End Sub

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -