MercatorWebService40.MercatorWebServiceSoapClient client = new MercatorWebService40.MercatorWebServiceSoapClient();
MercatorWebService40.SecurityInfo si = new MercatorWebService40.SecurityInfo();
si.SecureKey = ... ;
MercatorWebService40.StringMws s = client.BillingEngineInitNew(si, MercatorWebService40.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;
MercatorWebService40.BooleanMws b = client.BillingEngineApplyCustomerSupplier(uniqueId, "INEO52209");
if (!string.IsNullOrEmpty(b.LastError))
{
MessageBox.Show("ApplyCustomerSupplier : " + b.LastError);
}
else
{
MercatorWebService40.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
{
MercatorWebService40.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));
}
}
}
}
}
MercatorWebService40.VoidMws v = client.BillingEngineClose(uniqueId); // toujours terminer par BillingEngineClose() après un InitNew fructueux
if (!string.IsNullOrEmpty(v.LastError))
MessageBox.Show("BillingEngineClose : " + v.LastError);