2.4. VOICI QUELS QUE CODES UTILISES DANS NOTRES
PROGRAMMATION
Pour partir de l'interface de démarrage au formulaire
de Sécurité (MDI) de notre application, nous avons donné
le code suivant au composant Timer1 :
3. privatevoid timer1_Tick(object sender, EventArgs e)
4. {
5. Securite paren = newSecurite();
6. Securite.Show ();
7. timer1.Enabled = false;
8. this.Hide();
9. }
Le code suivant appartient au formulaire
d'authentification :
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 aimery
{
publicpartialclassForm2 : Form
{
public Form2()
{
InitializeComponent();
}
privatevoid Form2_Load(object sender, EventArgs e)
{
}
privatevoid button1_Click(object sender, EventArgs e)
{
comboBox1.Text = "Choix de nom";
textBox1.Text = "bonis";
}
privatevoid button2_Click(object sender, EventArgs e)
{
if (comboBox1.Text == "Votre choix")
{
MessageBox.Show("Choisissez votre Identifiant!");
comboBox1.Text = "Choix de nom";
textBox1.Text = "";
textBox1.Focus();
}
elseif (comboBox1.Text == "aimery")
{
textBox1.Focus();
}
{
if (textBox1.Text == "aimery")
{
MessageBox.Show("Merci d'avoir choisi notre application!\n
cliquer sur OK pour continuer!");
Form Form = null;
Form Form3 = newForm3();
Form = Form3;
Form3.Show();
this.Hide();
}
else
{
MessageBox.Show("Impossible d'accéder à notre
application!\n Votre Clé de Sécurité est invalide\n
Inserer une bonne clé SVP:");
comboBox1.Text = "Choix du Nom";
textBox1.Focus();
textBox1.Text = "";
}
}
if (comboBox1.Text == "aime")
{
if (textBox1.Text == "aime")
{
MessageBox.Show("Merçi d'avoir choisi notre application!\n
cliquer sur OK pour continuer!");
Form Form = null;
Form Form3 = newForm3();
Form = Form3;
Form3.Show();
this.Hide();
}
else
{
MessageBox.Show("Impossible d'accéder à notre
application!\n Votre Clé de Sécurité est invalide\n
Inserer une bonne clé SVP:");
comboBox1.Text = "Choix du Nom";
}
}
}
privatevoid button3_Click(object sender, EventArgs e)
{
DialogResult res;
res = MessageBox.Show("Vous êtes sur le point
de quitter ce formulaire d'authentification, voulez-vous vraiement QUITTER?",
"Quitter le formulaire", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2);
if (res == DialogResult.Yes)
{
this.Close();
}
}
}
}
En plus, pour cette interface de mise à jour de la
table CLIENT, nous avons donné tout ce morceau de code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace aimery
{
publicpartialclassForm5 : Form
{
public Form5()
{
InitializeComponent();
}
privatevoid label7_Click(object sender, EventArgs e)
{
}
privatevoid button1_Click(object sender, EventArgs e)
{
CLIENT C = newCLIENT();
C.Cc = int.Parse(textBox1.Text);
C.Cp = int.Parse(textBox2.Text);
C.nc = textBox3.Text;
C.pst = textBox4.Text;
C.pr = textBox5.Text;
C.cat = comboBox1.Text;
C.dat = dateTimePicker1.Text;
C.etc = comboBox2.Text;
C.tél = int.Parse(textBox6.Text);
string chaine = @"provider=Microsoft.ACE.OLEDB.12.0; Data
Source=E:\UAC\aimery\aimery\clientaime.accdb";
OleDbConnection con = newOleDbConnection(chaine);
OleDbCommand requete = newOleDbCommand("insert into CLIENT
values('" + C.Cc + "','" + C.Cp + "','" + C.nc + "','" + C.pst + "','" + C.pr +
"','" + C.cat + "','" + C.dat + "','" + C.etc + "','" + C.tél + "')",
con);
con.Open();
requete.ExecuteNonQuery();
con.Close();
MessageBox.Show("Le Client" + textBox1.Text + " Enregistrer avec
succès!!!");
}
privatevoid button2_Click(object sender, EventArgs e)
{
string recherche = textBox1.Text;
string chaine = @"provider=Microsoft.ACE.OLEDB.12.0; Data
Source=E:\UAC\aimery\aimery\clientaime.accdb";
OleDbConnection con = newOleDbConnection(chaine);
OleDbCommand requete = newOleDbCommand("delete from CLIENT where
Ccl = '" + recherche + " ' ", con);
con.Open();
requete.ExecuteNonQuery();
con.Close();
MessageBox.Show("Le Client a été supprimé
avec succès!!!");
}
privatevoid button5_Click(object sender, EventArgs e)
{
string recherche = textBox1.Text;
string chaine = @"provider=Microsoft.ACE.OLEDB.12.0; Data
Source=E:\UAC\aimery\aimery\clientaime.accdb";
OleDbConnection con = newOleDbConnection(chaine);
OleDbCommand requete = newOleDbCommand("delete from CLIENT where
Ccl = '" + recherche + " ' ", con);
con.Open();
requete.ExecuteNonQuery();
con.Close();
MessageBox.Show("Le Client a été supprimé
avec succès!!!");
}
privatevoid button3_Click(object sender, EventArgs e)
{
MessageBox.Show("Etes-vous sure de Modifier ces
renseignements?");
string recherche = textBox1.Text;
string chaine = @"provider=Microsoft.ACE.OLEDB.12.0; Data
Source=E:\UAC\aimery\aimery\clientaime.accdb";
OleDbConnection con = newOleDbConnection(chaine);
OleDbCommand requete = newOleDbCommand("delete from CLIENT where
Ccl = '" + recherche + " ' ", con);
con.Open();
requete.ExecuteNonQuery();
con.Close();
MessageBox.Show("Le Client a été supprimé
avec succès!!!");
MessageBox.Show("Etes-vous sure de le remplacer?");
CLIENT C = newCLIENT();
C.Cc = int.Parse(textBox1.Text);
C.Cp = int.Parse(textBox2.Text);
C.nc = textBox3.Text;
C.pst = textBox4.Text;
C.pr = textBox5.Text;
C.cat = comboBox1.Text;
C.dat = dateTimePicker1.Text;
C.etc = comboBox2.Text;
C.tél = int.Parse(textBox6.Text);
string chaine1 = @"provider=Microsoft.ACE.OLEDB.12.0; Data
Source=E:\UAC\aimery\aimery\clientaime.accdb";
OleDbConnection co = newOleDbConnection(chaine1);
OleDbCommand requet = newOleDbCommand("insert into CLIENT
values('" + C.Cc + "','" + C.Cp + "','" + C.nc + "','" + C.pst + "','" + C.pr +
"','" + C.cat + "','" + C.dat + "','" + C.etc + "','" + C.tél + "')",
co);
co.Open();
requet.ExecuteNonQuery();
co.Close();
MessageBox.Show("Le Cient" + textBox1.Text + " Enregistrer avec
succès!!!");
}
privatevoid button7_Click(object sender, EventArgs e)
{
DialogResult res;
res = MessageBox.Show("Vous êtes sur le point
de quitter ce formulaire de Client, voulez-vous vraiement QUITTER?", "Quitter
le formulaire", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2);
if (res == DialogResult.Yes)
{
this.Close();
}
}
privatevoid button6_Click(object sender, EventArgs e)
{
Form Form = null;
Form Form3 = newForm3();
Form = Form3;
Form3.Show();
this.Hide();
}
privatevoid button4_Click(object sender, EventArgs e)
{
}
}
}
CLASSE CLIENT
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace aimery
{
classCLIENT
{
privateint Ccl;
privateint Crov;
privatestring Nomcl;
privatestring Postnomcl;
privatestring Prénomcl;
privatestring Catcl;
privateString Datentr;
privatestring Etcivcl;
privateint Télcl;
publicint Cc
{
get { return Ccl; }
set { Ccl = value; }
}
publicint Cp
{
get { return Crov; }
set { Crov = value; }
}
publicstring nc
{
get { return Nomcl; }
set { Nomcl = value; }
}
publicstring pst
{
get { return Postnomcl; }
set { Postnomcl = value; }
}
publicstring pr
{
get { return Prénomcl; }
set { Prénomcl = value; }
}
publicstring cat
{
get { return Catcl; }
set { Catcl = value; }
}
publicString dat
{
get { return Datentr; }
set { Datentr = value; }
}
publicstring etc
{
get { return Etcivcl; }
set { Etcivcl = value; }
}
publicint tél
{
get { return Télcl; }
set { Télcl = value; }
}
}
}
A présent nous voici au terme de notre application
réalisée et mise en place pour la gestion de clients de
l'entreprise Union Africaine de Commerce U.A.C en sigle et nous pensons que
même en dehors des utilisateurs de notre application, même nos
lecteurs ont eu aussi l'image de la manière dont fonctionne notre
logiciel de gestion des clients.
|