Imports System.Data.OleDb
Imports System.Object
Public Class frmEdetproducts

    Private Sub frmEdetproducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call connectDatabase()
        Call loadPublishers()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If MsgBox("Save Changes?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "WARNING") = MsgBoxResult.Yes Then
            Dim oleDC As New OleDbCommand
            With oleDC
                .Connection = conn
                .CommandText = "UPDATE tblStock SET Category='" & CategoryComboBox.Text & _
            "',ItemName='" & ItemNameTextBox.Text & _
            "',ItemDescription='" & ItemDescriptionTextBox.Text & _
            "',QtyonHand='" & QtyonHandTextBox.Text & _
            "',Price='" & PriceTextBox.Text & _
            "',Amount='" & AmountTextBox.Text & _
             "',DateAdded='" & DateAddedLabel1.Text & _
            "',ActiveStatus=" & CheckBox1.Checked & "  WHERE ItemID='" & ItemIDLabel1.Text & "'"
                .ExecuteNonQuery()
                MsgBox("Record Updated!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "SUCCESS")
            End With
            Me.Close()
        End If
    End Sub
    Private Sub clears()
        CategoryComboBox.Text = ""
        ItemNameTextBox.Text = ""
        ItemDescriptionTextBox.Text = ""
        
        QtyonHandTextBox.Text = ""
        PriceTextBox.Text = ""
        AmountTextBox.Text = ""

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Call DisconnectDatabase()
        Me.Close()

    End Sub

    

    Private Sub QtyonHandTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QtyonHandTextBox.TextChanged
        If IsNumeric(QtyonHandTextBox.Text) Then
        Else
            QtyonHandTextBox.Focus()
            QtyonHandTextBox.Text = ""
        End If
    End Sub

    Private Sub PriceTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PriceTextBox.TextChanged
        If IsNumeric(PriceTextBox.Text) Then
        Else
            PriceTextBox.Focus()
            PriceTextBox.Text = ""
        End If
    End Sub
    Private Sub loadPublishers()
        Dim OleDBC As New OleDbCommand
        Dim OleDBDR As OleDbDataReader
        With OleDBC
            .Connection = conn
            .CommandText = "SELECT CategoryName FROM tblCategory"
        End With
        OleDBDR = OleDBC.ExecuteReader
        CategoryComboBox.Items.Clear()
        If OleDBDR.HasRows Then
            While OleDBDR.Read
                CategoryComboBox.Items.Add(OleDBDR.Item(0))
            End While
        End If
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

    End Sub

    Private Sub AmountLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
End Class