private void btnSupplier_Click(object sender, System.EventArgs e)
{
object objDescription = (object)"Account_Ref";
string strDescription = "";
try
{
switch(getSelectedSageVersion())
{
case SAGE_VERSION.SAGE_V5:
SageDataObject50.PurchaseRecord srSupplier50 = (SageDataObject50.PurchaseRecord)ws50.CreateObject("PurchaseRecord");
srSupplier50.MoveFirst();
while(!srSupplier50.IsEOF())
{
strDescription = srSupplier50.Fields.Item(ref objDescription).Value.ToString();
this.lvSuppliers.Items.Add(strDescription);
srSupplier50.MoveNext();
}
break;
case SAGE_VERSION.SAGE_V9:
SageDataObject90.PurchaseRecord srSupplier90 = (SageDataObject90.PurchaseRecord)ws90.CreateObject("PurchaseRecord");
srSupplier90.MoveFirst();
while(!srSupplier90.IsEOF())
{
strDescription = srSupplier90.Fields.Item(ref objDescription).Value.ToString();
this.lvSuppliers.Items.Add(strDescription);
srSupplier90.MoveNext();
}
break;
case SAGE_VERSION.SAGE_V10:
SageDataObject100.PurchaseRecord srSupplier100 = (SageDataObject100.PurchaseRecord)ws100.CreateObject("PurchaseRecord");
srSupplier100.MoveFirst();
while(!srSupplier100.IsEOF())
{
strDescription = srSupplier100.Fields.Item(ref objDescription).Value.ToString();
this.lvSuppliers.Items.Add(strDescription);
srSupplier100.MoveNext();
}
break;
case SAGE_VERSION.SAGE_V11:
SageDataObject111.PurchaseRecord srSupplier111 = (SageDataObject111.PurchaseRecord)ws111.CreateObject("PurchaseRecord");
srSupplier111.MoveFirst();
while(!srSupplier111.IsEOF())
{
strDescription = srSupplier111.Fields.Item(ref objDescription).Value.ToString();
this.lvSuppliers.Items.Add(strDescription);
srSupplier111.MoveNext();
}
break;
}
}
catch(Exception ex)
{
MessageBox.Show("Could not connect to Sage.\n" + ex.Message.ToString());
return;
}
}