
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.Odbc;
namespace MINDONGO_FACTURATION_DEVIS
{
/// <summary>
/// Required designer variable.
/// </summary>
public class UTILISATEUR : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBoxloginut;
private System.Windows.Forms.Button bt_valider;
private System.Windows.Forms.Button bt_annuler;
private System.Windows.Forms.TextBox logine;
private System.Windows.Forms.TextBox pass;
private System.Windows.Forms.Label Login;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ListBox typeUser;
private System.Windows.Forms.GroupBox tt;
private System.Windows.Forms.RadioButton feminin;
private System.Windows.Forms.RadioButton Masculin;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_prenom;
private System.Windows.Forms.TextBox txt_nom;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label1;
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
public UTILISATEUR()
{
//
// Requis pour la prise en charge du Concepteur Windows Forms
//
InitializeComponent();
//
// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
//
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBoxloginut = new System.Windows.Forms.GroupBox();
this.bt_valider = new System.Windows.Forms.Button();
this.bt_annuler = new System.Windows.Forms.Button();
this.logine = new System.Windows.Forms.TextBox();
this.pass = new System.Windows.Forms.TextBox();
this.Login = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.typeUser = new System.Windows.Forms.ListBox();
this.tt = new System.Windows.Forms.GroupBox();
this.feminin = new System.Windows.Forms.RadioButton();
this.Masculin = new System.Windows.Forms.RadioButton();
this.label5 = new System.Windows.Forms.Label();
this.txt_prenom = new System.Windows.Forms.TextBox();
this.txt_nom = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.groupBoxloginut.SuspendLayout();
this.tt.SuspendLayout();
this.SuspendLayout();
//
// groupBoxloginut
//
this.groupBoxloginut.Controls.Add(this.bt_valider);
this.groupBoxloginut.Controls.Add(this.bt_annuler);
this.groupBoxloginut.Controls.Add(this.logine);
this.groupBoxloginut.Controls.Add(this.pass);
this.groupBoxloginut.Controls.Add(this.Login);
this.groupBoxloginut.Controls.Add(this.label2);
this.groupBoxloginut.Controls.Add(this.label3);
this.groupBoxloginut.Controls.Add(this.typeUser);
this.groupBoxloginut.Controls.Add(this.tt);
this.groupBoxloginut.Location = new System.Drawing.Point(79, 55);
this.groupBoxloginut.Name = "groupBoxloginut";
this.groupBoxloginut.Size = new System.Drawing.Size(359, 343);
this.groupBoxloginut.TabIndex = 1;
this.groupBoxloginut.TabStop = false;
//
// bt_valider
//
this.bt_valider.BackColor = System.Drawing.Color.Transparent;
this.bt_valider.Location = new System.Drawing.Point(155, 303);
this.bt_valider.Name = "bt_valider";
this.bt_valider.Size = new System.Drawing.Size(86, 23);
this.bt_valider.TabIndex = 7;
this.bt_valider.Text = "Connexion";
this.bt_valider.UseVisualStyleBackColor = false;
this.bt_valider.Click += new System.EventHandler(this.bt_valider_Click);
//
// bt_annuler
//
this.bt_annuler.BackColor = System.Drawing.Color.Transparent;
this.bt_annuler.Location = new System.Drawing.Point(266, 304);
this.bt_annuler.Name = "bt_annuler";
this.bt_annuler.Size = new System.Drawing.Size(83, 23);
this.bt_annuler.TabIndex = 8;
this.bt_annuler.Text = "Annuler";
this.bt_annuler.UseVisualStyleBackColor = false;
this.bt_annuler.Click += new System.EventHandler(this.bt_annuler_Click);
//
// logine
//
this.logine.Location = new System.Drawing.Point(136, 31);
this.logine.Name = "logine";
this.logine.Size = new System.Drawing.Size(100, 20);
this.logine.TabIndex = 1;
//
// pass
//
this.pass.Location = new System.Drawing.Point(135, 64);
this.pass.Name = "pass";
this.pass.PasswordChar = '*';
this.pass.Size = new System.Drawing.Size(100, 20);
this.pass.TabIndex = 2;
//
// Login
//
this.Login.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Login.ForeColor = System.Drawing.Color.Red;
this.Login.Location = new System.Drawing.Point(26, 30);
this.Login.Name = "Login";
this.Login.Size = new System.Drawing.Size(100, 23);
this.Login.TabIndex = 0;
this.Login.Text = "Nom utilisateur";
//
// label2
//
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.Color.Red;
this.label2.Location = new System.Drawing.Point(26, 61);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 23);
this.label2.TabIndex = 2;
this.label2.Text = "Mot de passe";
//
// label3
//
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.ForeColor = System.Drawing.Color.Red;
this.label3.Location = new System.Drawing.Point(29, 265);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(100, 14);
this.label3.TabIndex = 4;
this.label3.Text = "Type User";
//
// typeUser
//
this.typeUser.Items.AddRange(new object[] {
"Administrateur",
"utilisateur"});
this.typeUser.Location = new System.Drawing.Point(134, 267);
this.typeUser.Name = "typeUser";
this.typeUser.Size = new System.Drawing.Size(97, 17);
this.typeUser.TabIndex = 6;
//
// tt
//
this.tt.Controls.Add(this.feminin);
this.tt.Controls.Add(this.Masculin);
this.tt.Controls.Add(this.label5);
this.tt.Controls.Add(this.txt_prenom);
this.tt.Controls.Add(this.txt_nom);
this.tt.Controls.Add(this.label4);
this.tt.Controls.Add(this.label1);
this.tt.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tt.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.tt.Location = new System.Drawing.Point(12, 97);
this.tt.Name = "tt";
this.tt.Size = new System.Drawing.Size(339, 143);
this.tt.TabIndex = 3;
this.tt.TabStop = false;
this.tt.Text = "information personnel";
//
// feminin
//
this.feminin.Location = new System.Drawing.Point(227, 101);
this.feminin.Name = "feminin";
this.feminin.Size = new System.Drawing.Size(77, 24);
this.feminin.TabIndex = 14;
this.feminin.Text = "Feminin";
//
// Masculin
//
this.Masculin.Location = new System.Drawing.Point(123, 99);
this.Masculin.Name = "Masculin";
this.Masculin.Size = new System.Drawing.Size(83, 24);
this.Masculin.TabIndex = 13;
this.Masculin.Text = "Masculin";
//
// label5
//
this.label5.Location = new System.Drawing.Point(21, 105);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(36, 14);
this.label5.TabIndex = 12;
this.label5.Text = "Sexe :";
//
// txt_prenom
//
this.txt_prenom.Location = new System.Drawing.Point(124, 70);
this.txt_prenom.Name = "txt_prenom";
this.txt_prenom.Size = new System.Drawing.Size(100, 20);
this.txt_prenom.TabIndex = 5;
//
// txt_nom
//
this.txt_nom.Location = new System.Drawing.Point(124, 37);
this.txt_nom.Name = "txt_nom";
this.txt_nom.Size = new System.Drawing.Size(100, 20);
this.txt_nom.TabIndex = 4;
//
// label4
//
this.label4.Location = new System.Drawing.Point(19, 37);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(100, 16);
this.label4.TabIndex = 10;
this.label4.Text = "Nom";
//
// label1
//
this.label1.Location = new System.Drawing.Point(19, 70);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 14);
this.label1.TabIndex = 8;
this.label1.Text = "Prénom";
//
// UTILISATEUR
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.ClientSize = new System.Drawing.Size(516, 452);
this.Controls.Add(this.groupBoxloginut);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "UTILISATEUR";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "UTILISATEUR";
this.groupBoxloginut.ResumeLayout(false);
this.groupBoxloginut.PerformLayout();
this.tt.ResumeLayout(false);
this.tt.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private void bt_valider_Click(object sender, System.EventArgs e)
{
OdbcConnection cnx = new OdbcConnection("DSN=KINGMINDONGO");
int KING;
try
{
cnx.Open();
}
catch
{
MessageBox.Show("Erreure de la Connexion");
}
finally
{
OdbcCommand comdKING;
comdKING=new OdbcCommand("select * from utilisateur where login=?",cnx);
comdKING.Parameters.Add("login",logine.Text);
comdKING.Connection=cnx;
OdbcDataReader dtr;
try
{
dtr=comdKING.ExecuteReader();
if (dtr.Read())
{
MessageBox.Show(this, "Login Existant", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (logine.Text != "" && pass.Text != "" && typeUser.SelectedItem.ToString() != "" && txt_prenom.Text != "" && txt_nom.Text != "" && (Masculin.Checked == true || feminin.Checked == true))
{
dtr.Close();
OdbcCommand cmdRex = new OdbcCommand("insert into utilisateur values(?,?,?,?,?,?)", cnx);
cmdRex.Parameters.Add("login", logine.Text);
cmdRex.Parameters.Add("mot_de_passe", pass.Text);
if (typeUser.SelectedItem.ToString() == "")
cmdRex.Parameters.Add("type", "u");
if (typeUser.SelectedItem.ToString() == "Administrateur")
cmdRex.Parameters.Add("type", "a");
if (typeUser.SelectedItem.ToString() == "utilisateur")
cmdRex.Parameters.Add("type", "u");
cmdRex.Parameters.Add("prenom", txt_prenom.Text.ToLower());
cmdRex.Parameters.Add("nom", txt_nom.Text.ToUpper());
if (Masculin.Checked == true)
cmdRex.Parameters.Add("sexe", "Monsieur");
if (feminin.Checked == true)
cmdRex.Parameters.Add("sexe", "Madame/Mademoiselle");
KING = cmdRex.ExecuteNonQuery();
MessageBox.Show(this, "Utilisateur ajouté", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
logine.Text = "";
pass.Text = "";
}
else
MessageBox.Show(this, "Veuiller remplir tous les champs", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch
{
MessageBox.Show(this,"Erreure du System","",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
cnx.Close();
}
private void bt_annuler_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.Odbc;
namespace MINDONGO_FACTURATION_DEVIS
{
public class UPDATE_USER : System.Windows.Forms.Form
{
OdbcDataReader dtr;
int KINGrowCount = 0;
private System.Windows.Forms.GroupBox groupBoxupd;
private System.Windows.Forms.GroupBox groupBoxyasika;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox pass_new;
private System.Windows.Forms.TextBox login_new;
private System.Windows.Forms.Label labeltypuser;
private System.Windows.Forms.ListBox typeUpd;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button bt_valider;
private System.Windows.Forms.Button bt_annuler;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox pass;
private System.Windows.Forms.ComboBox LOGID;
private Button buttonsup;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
public UPDATE_USER()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBoxupd = new System.Windows.Forms.GroupBox();
this.LOGID = new System.Windows.Forms.ComboBox();
this.groupBoxyasika = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.pass_new = new System.Windows.Forms.TextBox();
this.login_new = new System.Windows.Forms.TextBox();
this.labeltypuser = new System.Windows.Forms.Label();
this.typeUpd = new System.Windows.Forms.ListBox();
this.label4 = new System.Windows.Forms.Label();
this.bt_valider = new System.Windows.Forms.Button();
this.bt_annuler = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.pass = new System.Windows.Forms.TextBox();
this.buttonsup = new System.Windows.Forms.Button();
this.groupBoxupd.SuspendLayout();
this.groupBoxyasika.SuspendLayout();
this.SuspendLayout();
//
// groupBoxupd
//
this.groupBoxupd.BackColor = System.Drawing.Color.Transparent;
this.groupBoxupd.Controls.Add(this.LOGID);
this.groupBoxupd.Controls.Add(this.groupBoxyasika);
this.groupBoxupd.Controls.Add(this.label2);
this.groupBoxupd.Controls.Add(this.label1);
this.groupBoxupd.Controls.Add(this.pass);
this.groupBoxupd.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.groupBoxupd.ForeColor = System.Drawing.Color.Blue;
this.groupBoxupd.Location = new System.Drawing.Point(57, 50);
this.groupBoxupd.Name = "groupBoxupd";
this.groupBoxupd.Size = new System.Drawing.Size(304, 328);
this.groupBoxupd.TabIndex = 1;
this.groupBoxupd.TabStop = false;
this.groupBoxupd.Text = "Utilisateur";
//
// LOGID
//
this.LOGID.FormattingEnabled = true;
this.LOGID.Location = new System.Drawing.Point(144, 37);
this.LOGID.Name = "LOGID";
this.LOGID.Size = new System.Drawing.Size(109, 21);
this.LOGID.TabIndex = 9;
//
// groupBoxyasika
//
this.groupBoxyasika.Controls.Add(this.buttonsup);
this.groupBoxyasika.Controls.Add(this.label5);
this.groupBoxyasika.Controls.Add(this.pass_new);
this.groupBoxyasika.Controls.Add(this.login_new);
this.groupBoxyasika.Controls.Add(this.labeltypuser);
this.groupBoxyasika.Controls.Add(this.typeUpd);
this.groupBoxyasika.Controls.Add(this.label4);
this.groupBoxyasika.Controls.Add(this.bt_valider);
this.groupBoxyasika.Controls.Add(this.bt_annuler);
this.groupBoxyasika.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.groupBoxyasika.Location = new System.Drawing.Point(8, 128);
this.groupBoxyasika.Name = "groupBoxyasika";
this.groupBoxyasika.Size = new System.Drawing.Size(288, 192);
this.groupBoxyasika.TabIndex = 8;
this.groupBoxyasika.TabStop = false;
this.groupBoxyasika.Text = "nouvelle donnée";
//
// label5
//
this.label5.Location = new System.Drawing.Point(24, 32);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(100, 23);
this.label5.TabIndex = 11;
this.label5.Text = "Login";
//
// pass_new
//
this.pass_new.Location = new System.Drawing.Point(128, 72);
this.pass_new.Name = "pass_new";
this.pass_new.PasswordChar = '*';
this.pass_new.Size = new System.Drawing.Size(100, 20);
this.pass_new.TabIndex = 9;
//
// login_new
//
this.login_new.Location = new System.Drawing.Point(128, 32);
this.login_new.Name = "login_new";
this.login_new.Size = new System.Drawing.Size(100, 20);
this.login_new.TabIndex = 14;
//
// labeltypuser
//
this.labeltypuser.Location = new System.Drawing.Point(24, 112);
this.labeltypuser.Name = "labeltypuser";
this.labeltypuser.Size = new System.Drawing.Size(100, 23);
this.labeltypuser.TabIndex = 13;
this.labeltypuser.Text = "Type User";
//
// typeUpd
//
this.typeUpd.Items.AddRange(new object[] {
"Administrateur",
"Utilisateur"});
this.typeUpd.Location = new System.Drawing.Point(128, 112);
this.typeUpd.Name = "typeUpd";
this.typeUpd.Size = new System.Drawing.Size(104, 17);
this.typeUpd.TabIndex = 10;
//
// label4
//
this.label4.Location = new System.Drawing.Point(24, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(100, 23);
this.label4.TabIndex = 12;
this.label4.Text = "Mot de passe";
//
// bt_valider
//
this.bt_valider.BackColor = System.Drawing.Color.Transparent;
this.bt_valider.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.bt_valider.Location = new System.Drawing.Point(24, 152);
this.bt_valider.Name = "bt_valider";
this.bt_valider.Size = new System.Drawing.Size(70, 23);
this.bt_valider.TabIndex = 3;
this.bt_valider.Text = "Valider";
this.bt_valider.UseVisualStyleBackColor = false;
this.bt_valider.Click += new System.EventHandler(this.bt_valider_Click);
//
// bt_annuler
//
this.bt_annuler.BackColor = System.Drawing.Color.Transparent;
this.bt_annuler.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.bt_annuler.Location = new System.Drawing.Point(100, 152);
this.bt_annuler.Name = "bt_annuler";
this.bt_annuler.Size = new System.Drawing.Size(73, 23);
this.bt_annuler.TabIndex = 2;
this.bt_annuler.Text = "Annuler";
this.bt_annuler.UseVisualStyleBackColor = false;
this.bt_annuler.Click += new System.EventHandler(this.bt_annuler_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(40, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 23);
this.label2.TabIndex = 5;
this.label2.Text = "Mot de passe";
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 23);
this.label1.TabIndex = 4;
this.label1.Text = "Login";
//
// pass
//
this.pass.Location = new System.Drawing.Point(144, 80);
this.pass.Name = "pass";
this.pass.PasswordChar = '*';
this.pass.Size = new System.Drawing.Size(100, 20);
this.pass.TabIndex = 2;
//
// buttonsup
//
this.buttonsup.Location = new System.Drawing.Point(180, 152);
this.buttonsup.Name = "buttonsup";
this.buttonsup.Size = new System.Drawing.Size(80, 22);
this.buttonsup.TabIndex = 15;
this.buttonsup.Text = "Supprimer";
this.buttonsup.UseVisualStyleBackColor = true;
this.buttonsup.Click += new System.EventHandler(this.buttonsup_Click);
//
// UPDATE_USER
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.ClientSize = new System.Drawing.Size(419, 429);
this.Controls.Add(this.groupBoxupd);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "UPDATE_USER";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "UPDATE_USER";
this.Load += new System.EventHandler(this.UPDATE_USER_Load);
this.groupBoxupd.ResumeLayout(false);
this.groupBoxupd.PerformLayout();
this.groupBoxyasika.ResumeLayout(false);
this.groupBoxyasika.PerformLayout();
this.ResumeLayout(false);
}
#endregion
void connexion()
{
OdbcConnection cnx = new OdbcConnection("DSN=KINGMINDONGO");
int KING;
try
{
cnx.Open();
}
catch
{
MessageBox.Show("Erreure de la Connexion");
}
finally
{
OdbcCommand comdKING;
comdKING = new OdbcCommand("select * from utilisateur where login=?", cnx);
comdKING.Parameters.Add("login", LOGID.Text);
OdbcDataReader dtr;
try
{
dtr = comdKING.ExecuteReader();
if (dtr.Read())
{
if (dtr.GetString(1) == pass.Text)
{
dtr.Close();
OdbcCommand cmdKING = new OdbcCommand("update utilisateur set login=?,mot_de_passe=?,niveau=? where login=?", cnx);
cmdKING.Parameters.Add("login", login_new.Text);
cmdKING.Parameters.Add("mot_de_passe", pass_new.Text);
if (typeUpd.SelectedItem.ToString() == "Administrateur")
cmdKING.Parameters.Add("niveau", "a");
if (typeUpd.SelectedItem.ToString() == "utilisateur")
cmdKING.Parameters.Add("niveau", "u");
cmdKING.Parameters.Add("", LOGID.Text);
KING = cmdKING.ExecuteNonQuery();
MessageBox.Show(this, "Utilisateur Modifié ", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
LOGID.Text = "";
login_new.Text = "";
pass_new.Text = "";
}
else
MessageBox.Show(this, "Ancien mot de passe invalid ", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show(this, "Utilisateur inexistant ", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception KINGREX)
{
MessageBox.Show(this, "Erreure du System", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
LOGID.Text = KINGREX.ToString();
}
}
cnx.Close();
}
private void bt_annuler_Click(object sender, System.EventArgs e)
{
this.Close();
}
// c'est à partir d'ici que nous avons mis à jour les utilisateurs (suppression,modification)
void lecture()
{
//pour mettre en jour La base de données et le combobox après une exécussion quelconque
OdbcConnection cnx = new OdbcConnection("DSN=KINGMINDONGO");
LOGID.Items.Clear();
try
{
cnx.Open();
}
catch
{
MessageBox.Show("Failed to connect to data source");
}
finally
{
OdbcDataAdapter adpt;
OdbcCommand cmd;
cmd = new OdbcCommand("select * from utilisateur", cnx);
adpt = new OdbcDataAdapter(cmd);
DataSet dh = new DataSet();
adpt.Fill(dh, "utilisateur");
OdbcDataReader dtr ;
cnx.Close();
}
}
private void remplir()
{
//remplire le combobox (LOGID)
OdbcConnection cnx = new OdbcConnection("DSN=KINGMINDONGO");
LOGID.Items.Clear();
try
{
cnx.Open();
}
catch
{
MessageBox.Show("Failed to connect to data source");
}
finally
{
OdbcCommand comm;
comm = new OdbcCommand("select * from utilisateur");
comm.Connection = cnx;
OdbcDataReader dtr;
dtr = comm.ExecuteReader();
while (dtr.Read())
LOGID.Items.Add(dtr["login"].ToString());
dtr.Close();
}
}
private void bt_valider_Click(object sender,System.EventArgs e)
{
connexion();
}
private void UPDATE_USER_Load(object sender, System.EventArgs e)
{
lecture();
remplir();
}
private void buttonsup_Click(object sender, System.EventArgs e)
{
OdbcConnection cnx = new OdbcConnection("DSN=KINGMINDONGO");
try
{
cnx.Open();
//vérification de l'existance d'un utilisateur selectionné dans le combobox LOGIN
OdbcCommand cmd = new OdbcCommand(("SELECT COUNT(*) FROM utilisateur WHERE login='" + LOGID.Text + "'"),cnx );
OdbcDataAdapter adpt = new OdbcDataAdapter(cmd);
int temp = System.Convert.ToInt32(cmd.ExecuteScalar().ToString());
if (temp == 1)
{
//suppression
cmd = new OdbcCommand("DELETE * FROM utilisateur WHERE login='" + LOGID.Text + "'", cnx);
cmd.ExecuteReader();
MessageBox.Show("l'utilisateur Supprimé");
LOGID.Text = "";
remplir();
}
else
{
//en cas d'echec lors de la suppression
MessageBox.Show("l'utilisateur n'existe pas");
}
}
catch (Exception REX)
{
MessageBox.Show(REX.Message);
}
cnx.Close();
}
}
}