using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorUi;
using System.Windows.Forms;
using System.Reflection;
namespace Main
{
public class Customizer : MercatorUi.ICustomizers.IExec
{
public void Main(MercatorUi.ICustomizers.ExecAction Action)
{
if (Action == MercatorUi.ICustomizers.ExecAction.DossierOpen)
{
Globals.Main.BaseFormCreating += new MercatorUi.Main.BaseFormCreatingEventHandler(Main_BaseFormCreating);
}
else if (Action == MercatorUi.ICustomizers.ExecAction.DossierClose)
{
Globals.Main.BaseFormCreating -= new MercatorUi.Main.BaseFormCreatingEventHandler(Main_BaseFormCreating);
}
}
void Main_BaseFormCreating(object sender, MercatorUi.Main.BaseFormCreatingEventArgs e)
{
if ((e.Form.GetType() == typeof(MercatorUi.Forms.Accounting.AccountingBankVirementForm))
&& (Globals.CurrentUser != null)
&& (Globals.CurrentUser["naam"].ToString() != "Guy")) // Als de gebruiker niet Guy is, gaan we de event invoeren. Anders doen we niets.
{
e.Form.Shown += new EventHandler(Form_Shown);
}
}
void Form_Shown(object sender, EventArgs e)
{
// De knop "Registreren" deactiveren
MercatorUi.Forms.Accounting.AccountingBankVirementForm accountingBankVirementForm = (MercatorUi.Forms.Accounting.AccountingBankVirementForm)sender;
accountingBankVirementForm.Shown -= new EventHandler(Form_Shown); // Het event uitschrijven
MercatorUi.BoutonsPro.BleuPro bleuPro1 = (MercatorUi.BoutonsPro.BleuPro)accountingBankVirementForm.Controls["bleuPro1"];
MercatorUi.BoutonsPro.ButtonXPro buttonXProSave = (MercatorUi.BoutonsPro.ButtonXPro)bleuPro1.Controls["buttonXProSave"];
buttonXProSave.Enabled = false;
// De subknop "Fiche" deactiveren
MercatorUi.BoutonsPro.ButtonXPro buttonBrowsePieceliees = (MercatorUi.BoutonsPro.ButtonXPro)bleuPro1.Controls["buttonBrowsePieceliees"];
buttonBrowsePieceliees.SubItems[0].Enabled = false;
// Het aanvinkvakje "Eigen rekening" verbergen
Control checkBoxProper = accountingBankVirementForm.Controls["checkBoxProper"];
checkBoxProper.Visible = false;
// De combobox voor het oproepen van een klanten-/leveranciers-/algemene rekening verbergen
Control comboAppelSig = accountingBankVirementForm.Controls["comboAppelSig"];
comboAppelSig.Visible = false;
// Alle controles in read-only zetten
// Om de eigenschap ReadOnly van iedere controle van dit form makkelijker te kunnen instellen op true, gaan we de Reflection gebruiken
foreach (Control c in accountingBankVirementForm.Controls)
{
PropertyInfo pi = c.GetType().GetProperty("ReadOnly");
if (pi != null) // Bestaat er een ReadOnly-eigenschap voor deze controle?
pi.SetValue(c, true, null);
}
MercatorUi.Dialogs.Stop("U bent niet gemachtigd om de gegevens van dit scherm te wijzigen!");
}
}
}