Site Search:
Sign in | Join | Help

Vendor Class

'Back to eConnect 9 Library Classes

Imports Microsoft.VisualBasic
Imports Microsoft.GreatPlains.eConnect
Imports Microsoft.GreatPlains.eConnect.Serialization

Public Class Vendor
    Public Enum ten99typetype
        notATen99Vendor = 1
        dividend = 2
        interest = 3
        miscellaneous = 4
    End Enum
    Public VendorID As String
    Public VendorName As String
    Public Address1 As String
    Public Address2 As String
    Public Address3 As String
    Public City As String
    Public State As String
    Public Zipcode As String
    Public ShipFromAddCode As String
    Public PurchaseAddCode As String
    Public RemitToAddCode As String
    Public PrimaryAddCode As String
    Public Contact As String
    Public TEN99TYPE As ten99typetype = ten99typetype.notATen99Vendor
    Private _phone1 As String
    Private _phone2 As String
    Private _phone3 As String
    Private _fax As String
    Public ACNMVNDR As String 'Vendor Account Number
    Public TXIDNMBR As String 'Tax ID Number
    Public db As String

    Public Property Phone1() As String
        Get
            Return _phone1
        End Get
        Set(ByVal value As String)
            _phone1 = Main.numericOnly(value)
        End Set
    End Property
    Public Property Phone2() As String
        Get
            Return _phone2
        End Get
        Set(ByVal value As String)
            _phone2 = Main.numericOnly(value)
        End Set
    End Property
    Public Property Phone3() As String
        Get
            Return _phone3
        End Get
        Set(ByVal value As String)
            _phone3 = Main.numericOnly(value)
        End Set
    End Property
    Public Property Fax() As String
        Get
            Return _fax
        End Get
        Set(ByVal value As String)
            _fax = Main.numericOnly(value)
        End Set
    End Property


    Public Sub createVendor(ByVal oVendor As Vendor)
        Dim eCon As New eConnectType
        Dim pmTrans As New taUpdateCreateVendorRcd

        Try
            With pmTrans

                .VENDORID = oVendor.VendorID
                .VENDNAME = oVendor.VendorName
                .ADDRESS1 = oVendor.Address1
                .ADDRESS2 = oVendor.Address2
                .ADDRESS3 = oVendor.Address3
                .CITY = oVendor.City
                .STATE = oVendor.State
                .ZIPCODE = oVendor.Zipcode
                'vendor purchase address code
                .VADCDPAD = oVendor.PurchaseAddCode
                'vendor remit to address code
                .VADCDTRO = oVendor.RemitToAddCode
                'vendor ship from address code
                .VADCDSFR = oVendor.ShipFromAddCode
                .VADDCDPR = oVendor.PrimaryAddCode
                .VNDCNTCT = oVendor.Contact
                .PHNUMBR1 = oVendor.Phone1
                .PHNUMBR2 = oVendor.Phone2
                .PHNUMBR3 = oVendor.Phone3
                .FAXNUMBR = oVendor.Fax
                .ACNMVNDR = oVendor.ACNMVNDR
                .TXIDNMBR = oVendor.TXIDNMBR
            End With

            Dim oPMVendorMasterType As New PMVendorMasterType
            Dim aoPMVendorMasterType(0) As PMVendorMasterType
            oPMVendorMasterType.taUpdateCreateVendorRcd = pmTrans
            aoPMVendorMasterType(0) = oPMVendorMasterType

            eCon.PMVendorMasterType = aoPMVendorMasterType
            Main.send(eCon, db)

        Catch ex As Exception
            Throw New Exception(ex.Message, ex.InnerException)

        End Try

    End Sub

End Class