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

📄 frmgoodstrans.vb

📁 这是一个关于图书仓库管理系统的程序源代码。是我的毕业设计的作品
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Me.Label4.Location = New System.Drawing.Point(32, 128)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(60, 17)
        Me.Label4.TabIndex = 6
        Me.Label4.Text = "仓库编号:"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(32, 96)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(60, 17)
        Me.Label3.TabIndex = 4
        Me.Label3.Text = "交易编号:"
        '
        'cboGoodsTransType
        '
        Me.cboGoodsTransType.Items.AddRange(New Object() {"采购入库", "采购退货", "销售出库", "销售退货"})
        Me.cboGoodsTransType.Location = New System.Drawing.Point(96, 64)
        Me.cboGoodsTransType.Name = "cboGoodsTransType"
        Me.cboGoodsTransType.Size = New System.Drawing.Size(104, 20)
        Me.cboGoodsTransType.TabIndex = 3
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(32, 64)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(60, 17)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "库存类型:"
        '
        'txtGoodsTransID
        '
        Me.txtGoodsTransID.Location = New System.Drawing.Point(96, 32)
        Me.txtGoodsTransID.Name = "txtGoodsTransID"
        Me.txtGoodsTransID.ReadOnly = True
        Me.txtGoodsTransID.Size = New System.Drawing.Size(104, 21)
        Me.txtGoodsTransID.TabIndex = 1
        Me.txtGoodsTransID.Text = ""
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(32, 32)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(60, 17)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "库存编号:"
        '
        'frmGoodsTrans
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(648, 430)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.btnAdd)
        Me.Controls.Add(Me.btnUpdate)
        Me.Controls.Add(Me.btnDel)
        Me.Controls.Add(Me.btnOK)
        Me.Controls.Add(Me.btnCancel)
        Me.Name = "frmGoodsTrans"
        Me.Text = "图书流通信息管理"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmGoodsTrans_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        MDIGoodsTrans = Me
        ' txtUserID.Text = STRUSERID
        ' txtUserID.ReadOnly = True

        strSQL = "SELECT WarehouseID, WarehouseName FROM Warehouse"
        myDataObj.ExecuteSQL(strSQL, drSqlServer)
        While drSqlServer.Read()
            cboWarehouseID.Items.Add(drSqlServer("WarehouseID"))
            cboWarehouseName.Items.Add(drSqlServer("WarehouseName"))
        End While
        drSqlServer.Close()

        strSQL = "SELECT TransactionID FROM TransInfo"
        myDataObj.ExecuteSQL(strSQL, drSqlServer)
        While drSqlServer.Read()
            cboTransactionID.Items.Add(drSqlServer("TransactionID"))
        End While
        drSqlServer.Close()

        strSQL = "SELECT g.*, w.WarehouseName FROM GoodsTrans g " & _
                 "INNER JOIN Warehouse w ON g.WarehouseID=w.WarehouseID"

        freshData()
    End Sub

    Private Sub freshData()
        Dim myValues(7) As String
        Dim myListItem As ListViewItem

        myDataObj.ExecuteSQL(strSQL, drSqlServer)

        lstGoodsTrans.Items.Clear()
        While drSqlServer.Read()
            myValues(0) = drSqlServer("GoodsTransID").ToString()
            myValues(1) = drSqlServer("GoodsTransType").ToString()
            myValues(2) = drSqlServer("TransactionID").ToString()
            myValues(3) = drSqlServer("WarehouseID").ToString()
            myValues(4) = drSqlServer("Warehousename").ToString()
            myValues(5) = drSqlServer("Modifydate").ToString()
            myValues(6) = drSqlServer("UserID").ToString()

            myListItem = New ListViewItem(myValues)

            lstGoodsTrans.Items.Add(myListItem)
        End While

        drSqlServer.Close()

    End Sub

    Private Sub showData()
        With lstGoodsTrans.SelectedItems
            txtGoodsTransID.Text = .Item(0).SubItems(0).Text
            cboGoodsTransType.Text = .Item(0).SubItems(1).Text
            'txtTransactionID.Text = .Item(0).SubItems(2).Text
            cboTransactionID.Text = .Item(0).SubItems(2).Text
            cboWarehouseID.Text = .Item(0).SubItems(3).Text
            cboWarehouseName.Text = .Item(0).SubItems(4).Text
            txtModifyDate.Text = .Item(0).SubItems(5).Text
            txtUserID.Text = .Item(0).SubItems(6).Text
        End With
    End Sub

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        GroupBox2.Enabled = True
        txtGoodsTransID.Text = ""
        cboGoodsTransType.Text = ""
        'txtTransactionID.ReadOnly = False
        cboTransactionID.Text = ""
        cboWarehouseID.Text = ""
        txtUserID.ReadOnly = False
        txtUserID.Text = STRUSERID
        txtUserID.ReadOnly = True

        cboGoodsTransType.Text = ""
        'txtTransactionID.Text = ""
        cboWarehouseID.Text = ""
        txtModifyDate.Text = ""

        strCommand = "add"
        btnUpdate.Enabled = False
        btnDel.Enabled = False

    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        'cboGoodsTransType.Enabled = True
        'txtTransactionID.ReadOnly = False
        'cboWarehouseID.Enabled = True
        'txtUserID.ReadOnly = False
        'cboTransactionID.Enabled = True
        GroupBox2.Enabled = True


        strCommand = "update"
        btnAdd.Enabled = False
        btnDel.Enabled = False

    End Sub

    Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
        If MsgBox("确定要删除记录:" & txtGoodsTransID.Text & "?", MsgBoxStyle.Question + MsgBoxStyle.OKCancel) = MsgBoxResult.OK Then
            Dim Params() As SqlParameter = {New SqlParameter("@GOODSTRANSID", SqlDbType.Int)}
            Params(0).Value = txtGoodsTransID.Text
            myDataObj.ExecuteSP("sp_DelGoodsTrans", Params)
            MsgBox("删除完毕", MsgBoxStyle.Information)
            freshData()
        End If
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
       
        Dim NEXTNUM, NEXTLOW, NEXTHIGH, NEXTID As Integer
        Dim typenew As String

        If strCommand = "add" Then
            If cboGoodsTransType.Text = "" Or cboWarehouseID.Text.Trim() = "" Or txtUserID.Text.Trim() = "" Then
                MsgBox("请填写完整详细", MsgBoxStyle.Exclamation)
                Exit Sub
            End If
            Dim Params() As SqlParameter = _
                        {New SqlParameter("@GoodsTransType", SqlDbType.VarChar), _
                          New SqlParameter("@TransactionID", SqlDbType.Int), _
                          New SqlParameter("@WarehouseID", SqlDbType.Int), _
                          New SqlParameter("@UserID", SqlDbType.VarChar)}

            Params(0).Value = cboGoodsTransType.Text
            Params(1).Value = Val(cboTransactionID.Text)
            Params(2).Value = Val(cboWarehouseID.Text)
            Params(3).Value = txtUserID.Text

            myDataObj.ExecuteSP("sp_InsertGoodsTrans", Params, drSqlServer)
            drSqlServer.Read()
            typenew = drSqlServer("status").ToString()
            NEXTID = drSqlServer("GOODSID")
            drSqlServer.Close()
            If typenew = "退单" Then
                MsgBox("库存量太少,出库不成功", MsgBoxStyle.Exclamation)
                Exit Sub
            End If
            Dim strSQL = "SELECT * FROM GOODS WHERE GOODSID=" & NEXTID
            myDataObj.ExecuteSQL(strSQL, drSqlServer)
            drSqlServer.Read()
            NEXTNUM = drSqlServer("STOCKNUM")
            NEXTLOW = drSqlServer("NUMLOW")
            NEXTHIGH = drSqlServer("NUMHIGH")
            drSqlServer.Close()
            If NEXTNUM > NEXTHIGH Then
                MsgBox("提示:库存量已超出上界!", MsgBoxStyle.Exclamation)

            ElseIf NEXTNUM < NEXTLOW Then
                MsgBox("提示:库存量已低于下界!", MsgBoxStyle.Exclamation)

            Else
                MsgBox("添加完毕", MsgBoxStyle.Information)

            End If


            'freshData()
        ElseIf strCommand = "update" Then

                Dim Params() As SqlParameter = _
                            {New SqlParameter("@GoodsTransID", SqlDbType.Int), _
                              New SqlParameter("@GoodsTransType", SqlDbType.VarChar), _
                              New SqlParameter("@TransactionID", SqlDbType.Int), _
                              New SqlParameter("@WarehouseID", SqlDbType.Int), _
                              New SqlParameter("@UserID", SqlDbType.VarChar)}

                params(0).Value = txtGoodsTransID.Text
                Params(1).Value = cboGoodsTransType.Text
                Params(2).Value = Val(cboTransactionID.Text)
                Params(3).Value = Val(cboWarehouseID.Text)
                Params(4).Value = txtUserID.Text

                myDataObj.ExecuteSP("sp_UpdateGoodsTrans", Params)

                MsgBox("更新完毕", MsgBoxStyle.Information)
            Else
                Me.Close()
            End If

            freshData()
            strCommand = ""
            btnAdd.Enabled = True
            btnUpdate.Enabled = True
            btnDel.Enabled = True
            'cboGoodsTransType.Enabled = False
            'cboTransactionID.Enabled = False
            'cboWarehouseID.Enabled = False
            'txtModifyDate.ReadOnly = True
            'txtUserID.ReadOnly = True
            GroupBox2.Enabled = False


    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        If strCommand = "add" Or strCommand = "update" Then
            strCommand = ""

            btnAdd.Enabled = True
            btnUpdate.Enabled = True
            btnDel.Enabled = True
            'cboGoodsTransType.Enabled = False
            'txtTransactionID.ReadOnly = True
            'cboTransactionID.Enabled = False
            'cboWarehouseID.Enabled = False
            'txtModifyDate.ReadOnly = True
            'txtUserID.ReadOnly = True
            GroupBox2.Enabled = False

        Else
            Me.Close()
        End If
    End Sub

    Private Sub cboOrderByType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboOrderByType.SelectedIndexChanged
        strSQL = "SELECT g.*, w.WarehouseName FROM GoodsTrans g " & _
                 "INNER JOIN Warehouse w ON g.WarehouseID=w.WarehouseID " & _
                 "WHERE g.GoodsTransType='" & cboOrderByType.Text & "'"

        freshData()
    End Sub

    Private Sub lstGoodsTrans_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstGoodsTrans.Click
        showData()
    End Sub

    Private Sub cboWarehouseID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboWarehouseID.SelectedIndexChanged
        cboWarehouseName.SelectedIndex = cboWarehouseID.SelectedIndex
    End Sub

    Private Sub btnTrans_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTrans.Click
        Dim MDITrans As New frmTransInfo()
        MDITrans.MdiParent = MDIMain
        MDITrans.Show()
    End Sub

    Private Sub txtUserID_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtUserID.TextChanged

    End Sub
End Class

⌨️ 快捷键说明

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