11/22/2024 9:55:45 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss the use of .NET Extensions in SalesLogix version 7 and higher. View the code of conduct for posting guidelines.
|
|
|
|
MMS Update
Posted: 01 Mar 07 4:18 AM
|
fiogf49gjkf0d Hi There...
Wondering if anyone can help me out here...
Due to the fact that there is no current SalesLOGIX v7 to MMS 3.5 AIS link I have a need to write a 'Kind Of' Integration from SLX to MMS myself...
Best Practice dictates I use the Standard MMS Coding (Provided nicely in the SDK).. and so long as I use the correct assemblies then all should be fine...
It should be noted at this point that I am not a .NET programmer in any way.. my knowledge of it is pretty thin to say the least... however I have spoken to a .Net guy here who's coded up an example for me to use (see below)..
Now.. I've followed the excellent instructions on setting up a basic .NET "Hello World" message box as provided by Ryan and that works fine.. it's the next 'leap' I'm stuck on now...
How do I get arguments into the existing code.. and how do I get the newley created MMS Customer number backinto SalesLOGIX..
I apologise in advance for my 'blonde-ness'on this matter...If anyone can help or point me in the right direction then you would have my eternal gratitude!
As a footnote.. the .NET guy told me that whenever a class is instantiated the subroutine New is ALWAYS run which is why he put the connection details in there..
Here's the .NET Code
Imports System.windows.forms Imports Sage.SalesLogix.NetExtensions
Public Class Class1 Inherits Sage.SalesLogix.NetExtensions.BaseRunnable
' Declare the Application object used to connect. Dim oApplication As Sage.Accounting.Application = Nothing Dim oCustomer As Sage.Accounting.SalesLedger.Customer
' Connection Details / String Public Sub New() Try oApplication = New Sage.Accounting.Application
' Use the Connect method passing the username and password as strings) oApplication.Connect("testuser", "password") ' Must be a user within MMS
' IMPORTANT: select the company (database) - a connection will not be made ' unless this line is included. ' In this example an indexer is used to select the company. This ' is fine if there is only one company. If there are multiple companies a more ' appropriate solution would be to iterate the collection checking the Name property. oApplication.ActiveCompany = oApplication.Companies(0)
Dim oStringBuilder As System.Text.StringBuilder = New System.Text.StringBuilder
oStringBuilder.Append("Successfully logged on to " + oApplication.ActiveCompany.Name)
System.Windows.Forms.MessageBox.Show(oStringBuilder.ToString)
' The Connect method may throw the following exceptions: ' Ex9990Exception - User already logged in. ' Ex9991Exception - Maximum number of users logged in. Catch oException As System.Exception System.Windows.Forms.MessageBox.Show(oException.Message) Finally If Not (oApplication Is Nothing) Then oApplication.Disconnect() End If End Try
' Set Variables Dim oCustomers As Sage.Accounting.SalesLedger.Customers = oApplication.ActiveCompany.SalesModule.Customers oCustomer = CType(oCustomers.AddNew, Sage.Accounting.SalesLedger.Customer) End Sub
Private Sub CreateCustomer(ByVal AccountNo As String, ByVal strCustName As String, _ ByVal strAddr1 As String, ByVal strAddr2 As String, ByVal strAddr3 As String, _ ByVal strContact As String, ByVal Terms As Integer)
Try ' Create a new Customer Dim oCustomers As Sage.Accounting.SalesLedger.Customers = oApplication.ActiveCompany.SalesModule.Customers Dim oCustomer As Sage.Accounting.SalesLedger.Customer = CType(oCustomers.AddNew, Sage.Accounting.SalesLedger.Customer) ' Set some customer details oCustomer.Reference = AccountNo oCustomer.Name = strCustName
'oCustomer.PaymentTermsDays = CShort(Terms) oCustomer.MainAddress.AddressLine1 = strAddr1 oCustomer.MainAddress.AddressLine2 = strAddr2 oCustomer.MainAddress.AddressLine3 = strAddr3 oCustomer.CustomerAccount.Currency = oApplication.ActiveCompany.CompanyDetails.FinancialCurrencies.BaseCurrency
' Get the country code for GB Dim oCountryCodes As Sage.Accounting.SystemManager.CountryCodes = oApplication.ActiveCompany.CompanyDetails.CountryCodes oCountryCodes.Query.Filters.Add(New _ Sage.ObjectStore.Filter(Sage.Accounting.SystemManager.CountryCode.FIELD_CODE, "GB")) If Not (oCountryCodes.First Is Nothing) Then ' Set the country code oCustomer.CountryCode = oCountryCodes.First
' Get the tax code 1 Dim oTaxCodes As Sage.Accounting.TaxModule.TaxCodes = oApplication.TaxModule.TaxCodes
oTaxCodes.Query.Filters.Add(New Sage.ObjectStore.Filter( _ Sage.Accounting.TaxModule.TaxCode.FIELD_CODE, "1"))
If Not (oTaxCodes.First Is Nothing) Then ' Set the default tax code oCustomer.DefaultTaxCode = oTaxCodes.First
' Prepare the database information to be updated. ' This is not updated to the database until .Commit is called Dim oTransaction As New Sage.ObjectStore.PersistentObjectTransaction Try ' Update the changes oCustomer.Update() ' Update the database oTransaction.Commit() Finally oTransaction.Dispose() End Try Else System.Windows.Forms.MessageBox.Show("The specified tax code does not exist.") End If Else System.Windows.Forms.MessageBox.Show("The specified country code does not exist.") End If Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) Finally End Try End Sub
End Class |
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|