using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorController;
using MercatorUi;
// <CompileWithRoslyn />
namespace Mercator.Ribbon.ButtonsCodes
{
public static class Script
{
public static void Exec(DevComponents.DotNetBar.ButtonItem clickedButtonItem)
{
// enter your customized code here
string qrCode = MercatorUi.Dialogs.AskString("Code QR ?", "");
if (string.IsNullOrEmpty(qrCode))
return;
if (qrCode.Length != 27)
{
MercatorUi.Dialogs.Stop("Le code QR n'a pas la longueur attendue !");
return;
}
if (!Int64.TryParse(qrCode.Substring(16, 10).TrimStart(), out Int64 piece))
{
MercatorUi.Dialogs.Stop("Le code QR n'a pas le format attendu ! (piece)");
return;
}
if (!int.TryParse(Api.Right(qrCode, 1), out int type))
{
MercatorUi.Dialogs.Stop("Le code QR n'a pas le format attendu ! (type)");
return;
}
string id = qrCode.Substring(1, 10);
string journal = qrCode.Substring(11, 5);
MercatorUi.Globals.Main.ShowBillingExisting("V", type, id, journal, piece);
}
}
}