MercatorWebService20.MercatorWebService client = new MercatorWebService20.MercatorWebService();
MercatorWebService20.SecurityInfo si = new MercatorWebService20.SecurityInfo();
si.SecureKey = ... ;
client.SecurityInfoValue = si;
MercatorWebService20.StringMws s = client.BillingEngineInitNew(MercatorWebService20.TypeVAEnum.V, 1, "Factu");
if (!string.IsNullOrEmpty(s.LastError))
{
MessageBox.Show("BillingEngineInitNew : " + s.LastError);
return;
}
// à partir d'ici, il est obligatoire d'appeler la méthode BillingEngineClose
string uniqueId = s.Value;
MercatorWebService20.BooleanMws b = client.BillingEngineApplyCustomerSupplier(uniqueId, "INEO52209");
if (!string.IsNullOrEmpty(b.LastError))
{
MessageBox.Show("ApplyCustomerSupplier : " + b.LastError);
}
else
{
MercatorWebService20.Int32Mws i = client.BillingEngineAppendLine(uniqueId);
if (!string.IsNullOrEmpty(i.LastError))
{
MessageBox.Show("BillingEngineAppendLine : " + i.LastError);
}
else
{
b = client.BillingEngineInsertItem2(uniqueId, "03102001", i.Value, 5); // q = 5
if (!string.IsNullOrEmpty(b.LastError))
{
MessageBox.Show("InsertItem : " + b.LastError);
}
else
{
b = client.BillingEngineUpdateAmounts(uniqueId);
if (!string.IsNullOrEmpty(b.LastError))
{
MessageBox.Show("BillingEngineUpdateAmounts : " + b.LastError);
}
else
{
b = client.BillingEngineSave(uniqueId);
if (!string.IsNullOrEmpty(b.LastError))
{
MessageBox.Show("BillingEngineSave : " + b.LastError);
}
else
{
MercatorWebService20.Int64Mws p = client.BillingEngineSavedNumber(uniqueId);
if (!string.IsNullOrEmpty(p.LastError))
MessageBox.Show("BillingEngineSavedNumber : " + p.LastError);
else
MessageBox.Show(string.Format("La vente {0} {1} a été créée !", "Factu", p.Value));
}
}
}
}
}
MercatorWebService20.VoidMws v = client.BillingEngineClose(uniqueId); // toujours terminer par BillingEngineClose() après un InitNew fructueux
if (!string.IsNullOrEmpty(v.LastError))
MessageBox.Show("BillingEngineClose : " + v.LastError);