public FormInventaire(MDIParent mDIParent, String uidInventaire) { this.mDIParent = mDIParent; this.uidInventaire = uidInventaire; InitializeComponent(); //change the dimensions of button itself toolStrip1.AutoSize = false; toolStrip1.Height = 50; toolStripButton1.AutoSize = false; toolStripButton1.Width = 50; //resize the image of the button to the int sourceWidth = toolStripButton1.Image.Width; int sourceHeight = toolStripButton1.Image.Height; Bitmap b = new Bitmap(40, 40); Graphics g = Graphics.FromImage((Image)b); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.DrawImage(toolStripButton1.Image, 0, 0, 40, 40); g.Dispose(); Image myResizedImg = (Image)b; //put the resized image back to the button and change toolstrip's toolStripButton1.Image = myResizedImg; toolStrip1.ImageScalingSize = new Size(35, 35); gestion_utilisateur.privilege privi = new gestion_utilisateur.privilege(); privi.forminventaire(mDIParent.priv, this); //privi.forminventaire(mDIParent.priv, this); }
public void connexion() { try { string requete = "select * from utilisateur where pseudo='" + login.Text.Trim() + "' and motDePasse='" + mot_pass.Text.Trim()+"'"; DataSet conn = MaConnexion.ExecuteSelect(connectionString, requete); if (conn.Tables[0].Rows.Count == 0) { MessageBox.Show("Pseudo et mot de passe erroné"); } else { this.Close(); string requete_privilege = "select attribuer.*,droit.doit from attribuer join droit on attribuer.id_droit=droit.id_droit and id_utilisateur=" + conn.Tables[0].Rows[0][0].ToString().ToLower(); parent.priv= MaConnexion.ExecuteSelect(connectionString, requete_privilege); recupe_privilege = MaConnexion.ExecuteSelect(connectionString, requete_privilege); parent.menuStrip.Enabled = true; parent.toolStrip.Enabled = true; parent.toolStripLabel_utilisateur.Text = login.Text.Trim(); parent.Administrateur = conn.Tables[0].Rows[0][2].ToString().ToLower(); parent.idUtilisateur = conn.Tables[0].Rows[0][0].ToString().ToLower(); parent.toolStripStatusLabel.Text = "Utilisateur : " + login.Text.Trim(); OuvrirInventaire ouvre = new OuvrirInventaire(parent); ouvre.MdiParent = parent; ouvre.Show(); /* if (parent.priv != null) { foreach (DataRow row in parent.priv.Tables[0].Rows) { MessageBox.Show("privilege " + row[3].ToString().Trim() + " \\ " + row[2]); if ((row[3].ToString().Trim()=="Inventaire") && (row[2].ToString().Trim()=="consultation")) { parent.tSBNouvelInventaire.Visible = false; parent.toolStripSeparator2.Visible = false; } } }*/ privilege privi = new privilege(); privi.ouvrirInventaire(parent.priv, parent); } } catch (Exception ex) //La base de données existe déja { MessageBox.Show("L'installation de la base à échoué" + "\n" + ex.ToString(), "Erruer", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// validation de l'euthentification private void bvalider_Click(object sender, EventArgs e) { string requete = "select idUtilisateur, motDePasse, Administrateur from Utilisateur where pseudo = '" + tBPseudo.Text.Trim() + "' and motDePasse='" + tBMotDePasse.Text.Trim()+ "' and etat='Valide'"; dSUtilisateur = MaConnexion.ExecuteSelect(connectionString, requete); // si l'utilisateur n'existe pas if (dSUtilisateur.Tables[0].Rows.Count == 0) { panel1.Visible = true; DateTime t = DateTime.Now; Random r = new Random((int)(t.Ticks)); while (DateTime.Now.Second < t.Second + 1) { this.DesktopLocation = new Point(this.Location.X + r.Next(-2, 3), this.Location.Y + r.Next(-2, 3)); this.StartPosition = FormStartPosition.CenterScreen; } } else { attribuer_privilaige(); charger_inv(); privilege privi = new privilege(); privi.ouvrirInventaire(parent.priv, parent); } }