Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TPMenus
{
public partial class Menu : Form
{
public Menu()
{
InitializeComponent();
}

private void Menu_Load(object sender, EventArgs e)


{

private void MenuSeConnecté_Click(object sender, EventArgs e)


{
if (MenuSeConnecté.Text == "&Se Connecté")
{
Authenfification frm = new Authenfification();

frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{

switch (frm.Privillege)
{
case "admin":
{
MenuStock.Enabled = true;
MenuProduit.Enabled = true;
MenuParametre.Enabled = true;
MenuSeConnecté.Text = "&Se Déconnecté"; break;
}
case "user":
{
MenuStock.Enabled = false;
MenuProduit.Enabled = true;
MenuParametre.Enabled = false;
MenuSeConnecté.Text = "&Se Déconnecté"; break;
}
}

}
}
else
{
MenuStock.Enabled = false;
MenuProduit.Enabled = false;
MenuParametre.Enabled = false;
MenuSeConnecté.Text = "&Se Connecté";
}

}
private void fermerToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TPMenus
{
public partial class Authenfification : Form
{
public String Privillege;
public Authenfification()
{
InitializeComponent();
}

private void Authenfification_Load(object sender, EventArgs e)


{

private void btValider_Click(object sender, EventArgs e)


{
if (txtLogin.Text == "admin" && txtMp.Text == "123")
{
Privillege = "admin";
this.DialogResult= DialogResult .OK;
}

if (txtLogin.Text == "badri" && txtMp.Text == "123")


{
Privillege = "user";
this.DialogResult= DialogResult .OK;
}

}
}
}

You might also like