As part of our Dynamics CRM to MYOB Connector we have created a .NET
Library for MYOB. It allows you to connect to MYOB just like you
connect to SQL or any other database, we also ship a tool that can be
used to generate proxy classes for MYOB tables.
Here is an example of inserting an Invoice into MYOB.
using (MyobConnection connection = new MyobConnection(
new MyobConnectionString
{ ExeFilePath = ConfigurationManager.AppSettings["myobExe"],
DataFilePath = ConfigurationManager.AppSettings["myobFile"],
KeyFilePath = ConfigurationManager.AppSettings["myobKeyFile"],
UserName = ConfigurationManager.AppSettings["myobLogin"],
Password = ConfigurationManager.AppSettings["myobPassword"]
}))
{ // class created automatically by our code-generator
ImportMiscellaneousSale sale = new ImportMiscellaneousSale
{ RecordID = 1234,
AccountNumber = 41000,
InvoiceNumber = "20723YLL",
SaleDate = "01/01/2008",
Inclusive = "Y",
Description = "example description here",
ExTaxAmount = 100,
IncTaxAmount = 112.5d,
TaxCode = "S",
GSTAmount = 1.125d,
SaleStatus = "I",
Memo = "INV-2072-3YLL"
};
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
IDbCommand command = connection.CreateCommand();
command.Transaction = transaction;
// GetInsertString() automatically generated by the code-generator
command.CommandText = sale.GetInsertString();
try
{ command.ExecuteNonQuery();
transaction.Commit();
}
catch
{ transaction.Rollback();
}
finally
{ command.Dispose();
transaction.Dispose();
}
}