Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Security
Imports System.Security.Cryptography
Imports System.Text
Public Class PartsPrep
    Private _date As DateTime
    Private _partNo As String
    Private _quantity As Double
    Private _lotNumber As String
    Private _invoice As String
    Private _operator As String
    Private cnstr As String

#Region "Properties"
    Public Property mDate As DateTime
        Get
            Return _date
        End Get
        Set(ByVal value As DateTime)
            _date = Value
        End Set
    End Property

    Public Property partNo As String
        Get
            Return _partNo
        End Get
        Set(ByVal value As String)
            _partNo = value
        End Set
    End Property

    Public Property quantity As Double
        Get
            Return _quantity
        End Get
        Set(ByVal value As Double)
            _quantity = value
        End Set
    End Property

    Public Property lotNumber As String
        Get
            Return _lotNumber
        End Get
        Set(ByVal value As String)
            _lotNumber = value
        End Set
    End Property

    Public Property invoice As String
        Get
            Return _invoice
        End Get
        Set(ByVal value As String)
            _invoice = value
        End Set
    End Property

    Public Property mOperator As String
        Get
            Return _operator
        End Get
        Set(ByVal value As String)
            _operator = Value
        End Set
    End Property
#End Region

#Region "Methods"

    Public Sub New()
        cnstr = mainForm.cnstr
    End Sub

    Public Sub add()
        Dim conn As New SqlConnection(cnstr)
        Dim myQuery As String

        myQuery = "INSERT INTO kparts_pp VALUES (" & _
                  "'" & Me.mDate & "'," & _
                  "'" & Me.partNo & "'," & _
                  Me.quantity & "," & _
                  "'" & Me.lotNumber & "'," & _
                  "'" & Me.invoice & "'," & _
                  "'" & Me.mOperator & "')"

        Dim mycommand As SqlCommand
        mycommand = New SqlCommand(myQuery, conn)

        Try
            conn.Open()
            mycommand.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            conn.Close()
            conn.Dispose()
        End Try
    End Sub
#End Region
End Class
