Bonjour chers amis, je suis entrain de concevoir un logiciel à présent et je souhaiterais que chaque d'utilisateur bénéficie des privilèges en fonction des du type (mode admin, mode normal...), mais cela ne marche pas je suis bloqué au niveau du code du bouton enregistré

Voici tout le code du formulaire de connexion:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
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;
using System.Net.Mail;
using System.Runtime.InteropServices;
 
namespace MyApp.PL
{
    public partial class FRM_Connexion : Form
    {
        [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
        private static extern IntPtr CreateRoundRectRgn
           (
               int nLeftRect,     // x-coordinate of upper-left corner
               int nTopRect,      // y-coordinate of upper-left corner
               int nRightRect,    // x-coordinate of lower-right corner
               int nBottomRect,   // y-coordinate of lower-right corner
               int nWidthEllipse, // height of ellipse
               int nHeightEllipse // width of ellipse
           );
        private DbStockContext db;
        private Form frmmenu;
        BL.CLS_Connexion C = new BL.CLS_Connexion();
        public FRM_Connexion(Form Menu)
        {
            InitializeComponent();
            this.frmmenu = Menu;
            db = new DbStockContext();
            //Afficher Categorie dans combocategorie
            combogestion.DataSource = db.Gestions.ToList();
            //Afficher uniqùt Nom cat
            combogestion.DisplayMember = "Nom_Gestion";
            combogestion.ValueMember = "ID_GESTION";
 
            this.FormBorderStyle = FormBorderStyle.None;
            Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 40, 40));
        }
 
        private void BtnSuprimer_Click(object sender, EventArgs e)
        {
            Close();
        }
 
        //champs obligatoires
        string textobligatoire()
        {
            if (txtEmailPro.Text == "" || txtEmailPro.Text == "Email")
            {
                return "Entrer l'adresse Email de l'utilisateur";
            }
 
            if (txtMotDePassePro.Text == "" || txtMotDePassePro.Text == "Mot De Passe")
            {
                return "Entrer Mot De Passe utilisateur";
            }
 
            if (combogestion.Text == "" || combogestion.Text == "")
            {
                return "Entrer la catégorie d'utilisateur";
            }
 
            //Email valide ou non
            if (txtEmailPro.Text != "" || txtEmailPro.Text != "Email Utilisateur")
            {
                try
                {
                    new MailAddress(txtEmailPro.Text);
                }
                catch (Exception)
                {
                    return "Email Invalide";
                }
            }
            return null;
        }
 
        private void TxtEmailPro_Enter(object sender, EventArgs e)
        {
            if (txtEmailPro.Text == "Email Utilisateur")
            {
                txtEmailPro.Text = "";
                txtEmailPro.ForeColor = Color.Black;
            }
        }
 
        private void TxtMotDePassePro_Enter(object sender, EventArgs e)
        {
            if (txtMotDePassePro.Text == "Mot De Passe")
            {
                txtMotDePassePro.Text = "";
                txtMotDePassePro.UseSystemPasswordChar = false;
                txtMotDePassePro.PasswordChar = '*';
                txtMotDePassePro.ForeColor = Color.Black;
            }
 
        }
 
        private void TxtEmailPro_Leave(object sender, EventArgs e)
        {
            if (txtEmailPro.Text == "")
            {
                txtEmailPro.Text = "Email Utilisateur";
                txtEmailPro.ForeColor = Color.Black;
            }
        }
 
        private void TxtMotDePassePro_Leave(object sender, EventArgs e)
        {
            if (txtMotDePassePro.Text == "")
            {
                txtMotDePassePro.Text = "Mot De Passe";
                txtMotDePassePro.UseSystemPasswordChar = true; //désactiver passwordchar
                txtMotDePassePro.ForeColor = Color.Black;
            }
        }
 
        private void Btntion_Click(object sender, EventArgs e)
        {
            if (textobligatoire() == null)
 
            {
                if (C.ConnexionValide(db, txtEmailPro.Text, txtMotDePassePro.Text, Convert.ToInt32(combogestion.SelectedValue)) == true && (combogestion.DisplayMember != "ADMIN"))//utilisateur existe
                {
                    MessageBox.Show("Connexion a réussi", "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    (frmmenu as FRM_Menu).adminform();
                    this.Close(); //quitter formulaire
                }
                else//si l'utilisateur n'existe pas
                {
                    MessageBox.Show("Echec Connexion", "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
 
                //User normal
 
               if (C.ConnexionValide(db, txtEmailPro.Text, txtMotDePassePro.Text, Convert.ToInt32(combogestion.SelectedValue)) == true && (combogestion.DisplayMember != "NORMAL"))//utilisateur existe
                {
                    MessageBox.Show("Connexion a réussi", "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    (frmmenu as FRM_Menu).activerform();
                    this.Close(); //quitter formulaire
                }
                else//si l'utilisateur n'existe pas
                {
                    MessageBox.Show("Echec Connexion", "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
 
            }
            else
            {
                MessageBox.Show(textobligatoire(), "Obligatoire", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
 
 
        }
 
        private void BtnSuprimer_Click_1(object sender, EventArgs e)
            {
                Close();
            }
    }
}


et aussi celui du formulaire menu




Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
public void desactiverForm()
        {
            btnclient.Enabled = false;
            btnproduit.Enabled = false;
            btncommande.Enabled = false;
            btncategorie.Enabled = false;
            pnlBut.Enabled = false;
            BTNDCT.Enabled = false;
            btncaisse.Enabled = false;
            btnmenu.Enabled = false;
            btnad.Enabled = false;
            btnAccueil.Enabled = false;
            //btnnotification.Enabled = false;
            //ACTIVER BOUTON
            BTNCNT.Enabled = true;
        }
 
        public void adminform()
        {
            btnclient.Enabled = true;
            btnproduit.Enabled = true;
            btncommande.Enabled = true;
            btncategorie.Enabled = true;
            BTNDCT.Enabled = true;
            pnlBut.Enabled = true;
            btncaisse.Enabled = true;
            btnmenu.Enabled = true;
            btnad.Enabled = true;
            btnAccueil.Enabled = true;
            //btnnotification.Enabled = true;
            //DESACTIVER BOUTON
            BTNCNT.Enabled = false;
        }
 
        //Activer le formulaire
       public void activerform()
        {
            btnclient.Enabled = true;
            btnproduit.Enabled = true;
            btncommande.Enabled = true;
            btncategorie.Enabled = true;
            BTNDCT.Enabled = true;
            pnlBut.Enabled = true;
            btncaisse.Enabled = true;
            btnmenu.Enabled = true;
            btnAccueil.Enabled = true;
            //btnnotification.Enabled = true;
            //DESACTIVER BOUTON
            BTNCNT.Enabled = false;
            btnad.Enabled = false;
        }
S'il vous plait aidez-moi !