Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Security
Imports System.Security.Cryptography
Imports System.Text
Public Class Mounting
    Private _date As DateTime
    Private _sequence As String
    Private _revision As String
    Private _feeder As String
    Private _partNo As String
    Private _quantity As Double
    Private _operator As String
    Private _verify As Integer
    Private _3pL As String
    Private cnstr As String

    Public Property mDate() As DateTime
        Get
            Return _date
        End Get
        Set(ByVal value As DateTime)
            _date = value
        End Set
    End Property

    Public Property sequence() As String
        Get
            Return _sequence
        End Get
        Set(ByVal value As String)
            _sequence = value
        End Set
    End Property

    Public Property revision() As String
        Get
            Return _revision
        End Get
        Set(ByVal value As String)
            _revision = value
        End Set
    End Property

    Public Property feeder() As String
        Get
            Return _feeder
        End Get
        Set(ByVal value As String)
            _feeder = 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 mOperator() As String
        Get
            Return _operator
        End Get
        Set(ByVal value As String)
            _operator = value
        End Set
    End Property

    Public Property verify() As Integer
        Get
            Return _verify
        End Get
        Set(ByVal value As Integer)
            _verify = value
        End Set
    End Property

    Public Property threePL() As String
        Get
            Return _3pL
        End Get
        Set(ByVal value As String)
            _3pL = value
        End Set
    End Property

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

    Public Sub add(ByVal reload As Boolean)
        Dim conn As New SqlConnection(cnstr)
        Dim active As Integer = 0

        Dim myQuery As String

        If reload = True Then
            myQuery = "INSERT INTO kmounting VALUES (" & _
                  "'" & Me.mDate & "'," & _
                  "'" & Me.sequence & "'," & _
                  "'" & Me.revision & "'," & _
                  "'" & Me.feeder & "'," & _
                  "'" & Me.partno & "'," & _
                  Me.quantity & "," & _
                  "'" & Me.mOperator & "'," & _
                  Me.verify & "," & _
                  "'reload')"
        Else
            myQuery = "INSERT INTO kmounting VALUES (" & _
                  "'" & Me.mDate & "'," & _
                  "'" & Me.sequence & "'," & _
                  "'" & Me.revision & "'," & _
                  "'" & Me.feeder & "'," & _
                  "'" & Me.partno & "'," & _
                  Me.quantity & "," & _
                  "'" & Me.mOperator & "'," & _
                  Me.verify & "," & _
                  "'" & Me.threePL & "')"
        End If
        

        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 Class
