Deze programmatie toont hoe je het uitwissen van een document afhankelijk kan maken van het niveau van de gebruiker.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using MercatorApi;
using MercatorUi;
using MercatorExtensions;
using MercatorDatabase;
namespace Billing
{
public class Customizer :
MercatorUi.ICustomizers.IFormLoadCustomizer,
MercatorUi.ICustomizers.IFormClosedCustomizer
{
public void FormLoadCustomize(System.Windows.Forms.Form WindowsForm)
{
MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)WindowsForm;
MercatorUi.GridPro.DataGridViewXPro grid = ((MercatorUi.Forms.Billing.BillingObjects.LinesEditor)billingForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Billing.BillingObjects.LinesEditor))[0]).Grid;
billingForm.FormClosable = false;
billingForm.FormClosing += new System.Windows.Forms.FormClosingEventHandler(billingForm_FormClosing);
MercatorUi.BoutonsPro.BleuPro bleuPro1 = (MercatorUi.BoutonsPro.BleuPro)billingForm.Controls["BleuPro1"];
foreach (Control c in bleuPro1.Controls)
{
if (c.Name == "valider")
{
MercatorUi.BoutonsPro.ButtonXPro btn = (MercatorUi.BoutonsPro.ButtonXPro)c;
foreach (MercatorUi.BoutonsPro.ButtonItemPro c1 in btn.SubItems)
if (c1.Name == "saveonly")
c1.Enabled = false;
}
if ((c.Name == "annuler") && Convert.ToInt32(Globals.CurrentUser["niveau"]) < 90)
c.Enabled = false;
}
}
public void FormClosedCustomize(System.Windows.Forms.Form WindowsForm)
{
MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)WindowsForm;
MercatorUi.GridPro.DataGridViewXPro grid = ((MercatorUi.Forms.Billing.BillingObjects.LinesEditor)billingForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Billing.BillingObjects.LinesEditor))[0]).Grid;
billingForm.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(billingForm_FormClosing);
}
void billingForm_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
{
MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)sender;
billingForm.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(billingForm_FormClosing);
if ((billingForm.BillingEngine.LIGNES.Rows.Count == 0) || (billingForm.Saved))
billingForm.FormClosable = true;
}
}
}
Zie ook:
In een verkoop vermijden dat een artikellijn gewijzigd/verwijderd kan worden.