Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            ManipulationBD.ConnectionDataBase();

            listView1.Items.Clear();

            MySqlCommand cmd = new MySqlCommand(" Select * from tarification", ManipulationBD.Cnn);

            using (MySqlDataReader read = cmd.ExecuteReader())
            {
                while (read.Read())
                {
                    string ID  = read["Id_tarif"].ToString();
                    string Cat = read["categorie"].ToString();
                    string TC  = read["tarif_chauff"].ToString();
                    string TL  = read["tarif_loc_jr"].ToString();
                    string TH  = read["tarif_loc_jr"].ToString();
                    string TKm = read["tarif_km_parc"].ToString();
                    string DT  = read["date_tarif"].ToString();

                    listView1.Items.Add(new ListViewItem(new[] { ID, Cat, TC, TL, TH, TKm, DT }));
                }
            }

            ManipulationBD.DecoonectionDataBase();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            RadioButton rb1 = null;

            for (int i = 0; i < groupBox1.Controls.Count; i++)
            {
                rb1 = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                if (rb1.Checked)
                {
                    break;
                }
            }

            string       Insertion1 = "insert into tarification values ('" + numtarif.Text + "',' " + rb1.Text + " ' ,' " + T_chauff.Text + " ','" + T_Loc.Text + "','" + T_heure.Text + "','" + T_km.Text + "','" + Date_T.Text + "')";
            MySqlCommand cmd1       = new MySqlCommand(Insertion1, ManipulationBD.Cnn);

            try
            {
                ManipulationBD.ConnectionDataBase();
                cmd1.ExecuteNonQuery();
                MessageBox.Show("Ajout effectuez");
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                    if (rb.Checked)
                    {
                        break;
                    }
                }

                string Insertion = "insert into compte values (?,?,?,?,?,?,?)";

                MySqlCommand cmd = new MySqlCommand(Insertion, ManipulationBD.Cnn);

                MySqlParameter p1 = new MySqlParameter("id_cmp", Id.Text);
                cmd.Parameters.Add(p1);
                MySqlParameter p2 = new MySqlParameter("nom_cmp", nom.Text);
                cmd.Parameters.Add(p2);
                MySqlParameter p3 = new MySqlParameter("prenom", Prenom.Text);
                cmd.Parameters.Add(p3);
                MySqlParameter p5 = new MySqlParameter("tel_cmp", Tel.Text);
                cmd.Parameters.Add(p5);
                MySqlParameter p6 = new MySqlParameter("User_name", Username.Text);
                cmd.Parameters.Add(p6);
                MySqlParameter p7 = new MySqlParameter("Pwd", Pwd.Text);
                cmd.Parameters.Add(p7);
                MySqlParameter p4 = new MySqlParameter("type", rb.Text);
                cmd.Parameters.Add(p4);

                cmd.ExecuteNonQuery();

                if (rb.Text == "Administrateur")
                {
                    Administrateur.Administrateur a = new Administrateur.Administrateur();
                    this.Hide();
                    a.Show();
                }
                else
                {
                    Agent.Agent a = new Agent.Agent();
                    this.Hide();
                    a.Show();
                }
                //MessageBox.Show(rb.Text);
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                    if (rb.Checked)
                    {
                        break;
                    }
                }
                string       Insertion = "insert into compte values ('" + Id.Text + "','" + Nom.Text + "','" + Prenom.Text + "','" + Tel.Text + "','" + UserName.Text + "','" + Pwd.Text + "','" + rb.Text + "')";
                MySqlCommand cmd       = new MySqlCommand(Insertion, ManipulationBD.Cnn);

                cmd.ExecuteNonQuery();
                MessageBox.Show("Ajout effectuez");
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            RadioButton rb = null;

            for (int i = 0; i < groupBox1.Controls.Count; i++)
            {
                rb = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                if (rb.Checked)
                {
                    break;
                }
            }
            string       Insertion = "update compte set id_cmp='" + ID.Text + "',nom_cmp='" + Nom.Text + "',prenom_cmp='" + Prenom.Text + "',tel_cmp='" + Tel.Text + "',User_name='" + Username.Text + "',Pwd='" + Pwd.Text + "',type_cmp='" + rb.Text + "' " + "where Pwd='" + Pwd_modif.Text + "'";
            MySqlCommand cmd       = new MySqlCommand(Insertion, ManipulationBD.Cnn);

            try
            {
                Administrateur admin = new Administrateur();

                ManipulationBD.ConnectionDataBase();
                cmd.ExecuteNonQuery();
                admin.Show();
                this.Hide();
                MessageBox.Show("Modification effectuez");
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                    if (rb.Checked)
                        break;
                }
                
                    string Insertion1 = "insert into contrat values (?,?,?,?,?,?,?,?,?,?)";
                    string strverif = "select count(*) from contrat where num_contrat=?";

                    MySqlCommand cmd1 = new MySqlCommand(Insertion1, ManipulationBD.Cnn);
                    MySqlParameter p1 = new MySqlParameter("p1", textBox1.Text);
                    cmd1.Parameters.Add(p1);
                    MySqlParameter p2 = new MySqlParameter("p2", textBox3.Text);
                    cmd1.Parameters.Add(p2);
                    MySqlParameter p3 = new MySqlParameter("p3", textBox4.Text);
                    cmd1.Parameters.Add(p3);
                    MySqlParameter p4 = new MySqlParameter("p4", textBox2.Text);
                    cmd1.Parameters.Add(p4);
                    MySqlParameter p5 = new MySqlParameter("p5", textBox5.Text);
                    cmd1.Parameters.Add(p5);
                    MySqlParameter p6 = new MySqlParameter("p6", dateTimePicker1.Text);
                    cmd1.Parameters.Add(p6);
                    MySqlParameter p7 = new MySqlParameter("p7", dateTimePicker2.Text);
                    cmd1.Parameters.Add(p7);
                    MySqlParameter p8 = new MySqlParameter("p8", rb.Text);
                    cmd1.Parameters.Add(p8);
                    MySqlParameter p9 = new MySqlParameter("p9", textBox6.Text);
                    cmd1.Parameters.Add(p9);
                    MySqlParameter p10 = new MySqlParameter("p10", textBox7.Text);
                    cmd1.Parameters.Add(p10);

                    MySqlCommand verif = new MySqlCommand(strverif, ManipulationBD.Cnn);
                    MySqlParameter p16 = new MySqlParameter("p16", textBox1.Text);
                    verif.Parameters.Add(p16);

                    long n = (long)verif.ExecuteScalar();
                    if (n == 0)
                    {
                        cmd1.ExecuteNonQuery();
                        MessageBox.Show("Ajout effectuez");
                    }
                    else
                    {
                        MessageBox.Show("Ajout Impossible car Risque de Doublon");
                    }
                }
            }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                if (textBox1.Text == "")
                {
                    MessageBox.Show(" Champ vide !!");
                }
                else if (textBox2.Text == "")
                {
                    MessageBox.Show(" Champ vide !! ");
                }
                else if (textBox3.Text == "")
                {
                    MessageBox.Show(" Champ vide !! ");
                }
                else
                {
                    string Insertion1 = "delete from contrat where Numero_Contrat=?";
                    string strverif   = "select count(*) from contrat where Numero_Contrat=?";

                    MySqlCommand   cmd1 = new MySqlCommand(Insertion1, ManipulationBD.Cnn);
                    MySqlParameter p1   = new MySqlParameter("Contrat", textBox1.Text);
                    cmd1.Parameters.Add(p1);

                    MySqlCommand   verif = new MySqlCommand(strverif, ManipulationBD.Cnn);
                    MySqlParameter p16   = new MySqlParameter("p16", textBox1.Text);
                    verif.Parameters.Add(p16);

                    long n = (long)verif.ExecuteScalar();
                    if (n == 1)
                    {
                        cmd1.ExecuteNonQuery();
                        MessageBox.Show("Suppression effectuez");
                    }
                    else
                    {
                        MessageBox.Show("Suppression Impossible Car le Contrat N'existe pas");
                    }
                }
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 8
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb1 = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb1 = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                    if (rb1.Checked)
                    {
                        break;
                    }
                }


                string update = "select * from contrat where Numero_Contrat=?";

                MySqlCommand   cmd = new MySqlCommand(update, ManipulationBD.Cnn);
                MySqlParameter p   = new MySqlParameter("p", textBox7.Text);
                cmd.Parameters.Add(p);

                MySqlDataReader dr = cmd.ExecuteReader();
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        rb1.Text             = (string)dr[7];
                        dateTimePicker1.Text = ((DateTime)dr[6]).ToString();
                        dateTimePicker2.Text = ((DateTime)dr[5]).ToString();
                        textBox1.Text        = ((int)dr[0]).ToString();
                        textBox5.Text        = ((int)dr[3]).ToString();
                        textBox4.Text        = ((int)dr[1]).ToString();
                        textBox2.Text        = ((int)dr[2]).ToString();
                        textBox3.Text        = ((int)dr[4]).ToString();
                        textBox6.Text        = ((int)dr[8]).ToString();
                        textBox8.Text        = ((int)dr[9]).ToString();
                    }
                }
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 9
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                string UserName = user.Text;
                string Password = pwd.Text;
                User_name = user.Text;

                MySqlCommand   cmd = new MySqlCommand(" Select * from compte where User_name = ? And Pwd = ? ", ManipulationBD.Cnn);
                MySqlParameter P1  = new MySqlParameter("P1", user.Text);
                cmd.Parameters.Add(P1);
                MySqlParameter P2 = new MySqlParameter("P2", pwd.Text);
                cmd.Parameters.Add(P2);

                MySqlDataReader dr = cmd.ExecuteReader();


                if (dr != null)
                {
                    while (dr.Read())
                    {
                        if ((string)dr["type_cmp"] == "Administrateur")
                        {
                            Administrateur.Administrateur a = new Administrateur.Administrateur();
                            a.Show();
                            this.Hide();
                        }
                        else
                        {
                            Agent.Agent a = new Agent.Agent();
                            this.Hide();
                            a.Show();
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            RadioButton rb1 = null;

            for (int i = 0; i < Cat.Controls.Count; i++)
            {
                rb1 = (RadioButton)Cat.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                if (rb1.Checked)
                {
                    break;
                }
            }

            RadioButton rb3 = null;

            for (int i = 0; i < Etat.Controls.Count; i++)
            {
                rb3 = (RadioButton)Etat.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                if (rb3.Checked)
                {
                    break;
                }
            }

            string       Insertion1 = "update vehicule set num_ch = ' " + NumCh.Text + " ',categorie = ' " + rb1.Text + " ',marque = ' " + Marque.Text + " ',nbr_km = ' " + NbrKm.Text + " ',nbr_hr = ' " + NbrHr.Text + " ', etat = ' " + rb3.Text + " ' where num_ch ='" + NewNum.Text + " ' ";
            MySqlCommand cmd1       = new MySqlCommand(Insertion1, ManipulationBD.Cnn);

            try
            {
                ManipulationBD.ConnectionDataBase();
                cmd1.ExecuteNonQuery();
                MessageBox.Show("Modification effectuez");
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            string         Insertion1 = "delete from compte where Pwd=?";
            MySqlCommand   cmd1       = new MySqlCommand(Insertion1, ManipulationBD.Cnn);
            MySqlParameter p1         = new MySqlParameter("Pwd", Pwd.Text);

            cmd1.Parameters.Add(p1);
            try
            {
                Administrateur admin = new Administrateur();
                ManipulationBD.ConnectionDataBase();
                cmd1.ExecuteNonQuery();
                MessageBox.Show("Suppression effectuez");
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            string         Insertion1 = "delete from tarification where Id_tarif =?";
            MySqlCommand   cmd1       = new MySqlCommand(Insertion1, ManipulationBD.Cnn);
            MySqlParameter p1         = new MySqlParameter("Id_tarif", textBox6.Text);

            cmd1.Parameters.Add(p1);
            try
            {
                ManipulationBD.ConnectionDataBase();
                cmd1.ExecuteNonQuery();
                cmd1.Parameters.Clear();
                MessageBox.Show("Suppression effectuez");
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 13
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            RadioButton rb1 = null;

            for (int i = 0; i < groupBox1.Controls.Count; i++)
            {
                rb1 = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                if (rb1.Checked)
                {
                    break;
                }
            }

            string       Insertion1 = "update tarification set Id_tarif = ' " + numtarif.Text + " ', categorie = ' " + rb1.Text + " ',tarif_chauff=' " + T_chauff.Text + "',tarif_loc_jr='" + T_Loc.Text + "',tarif_hr_trv='" + T_heure.Text + "',tarif_km_parc='" + T_km.Text + "',date_tarif='" + Date_T.Text + " ' " + "where Id_tarif='" + numTarif_modif.Text + "'";
            MySqlCommand cmd1       = new MySqlCommand(Insertion1, ManipulationBD.Cnn);

            try
            {
                //Administrateur admin = new Administrateur();
                ManipulationBD.ConnectionDataBase();
                cmd1.ExecuteNonQuery();
                cmd1.Parameters.Clear();
                new Administrateur().Show();
                this.Hide();

                MessageBox.Show("Modification effectuez");
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 14
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                    if (rb.Checked)
                    {
                        break;
                    }
                }

                string Insertion1 = "update facturation set Numero_Fact=?,Numero_Contrat=?,Numero_Chassis=?,Categorie=?,Nbr_Km_Parc=?,Tarif_Km_Parc=?, Nombre_Jour_Loc=?,Tarif_Jour=?,Tarif_Jour_Chauff=?,Montant_Globale=?,Montant_TVA=?,Montant_Hors_Taxe=?,Montant_Net=?,Nombre_Heure_fct=?,Tarif_Heure=? where Numero_Fact=?";
                string strverif   = "select count(*) from facturation where Numero_Fact=?";

                MySqlCommand   cmd1 = new MySqlCommand(Insertion1, ManipulationBD.Cnn);
                MySqlParameter p1   = new MySqlParameter("p1", textBox5.Text);
                cmd1.Parameters.Add(p1);
                MySqlParameter p2 = new MySqlParameter("p2", textBox3.Text);
                cmd1.Parameters.Add(p2);
                MySqlParameter p3 = new MySqlParameter("p3", textBox4.Text);
                cmd1.Parameters.Add(p3);
                MySqlParameter p4 = new MySqlParameter("p4", rb.Text);
                cmd1.Parameters.Add(p4);
                MySqlParameter p5 = new MySqlParameter("p5", textBox6.Text);
                cmd1.Parameters.Add(p5);
                MySqlParameter p6 = new MySqlParameter("p6", textBox8.Text);
                cmd1.Parameters.Add(p6);
                MySqlParameter p7 = new MySqlParameter("p7", textBox1.Text);
                cmd1.Parameters.Add(p7);
                MySqlParameter p8 = new MySqlParameter("p8", textBox9.Text);
                cmd1.Parameters.Add(p8);
                MySqlParameter p9 = new MySqlParameter("p9", textBox10.Text);
                cmd1.Parameters.Add(p9);
                MySqlParameter p10 = new MySqlParameter("p10", textBox11.Text);
                cmd1.Parameters.Add(p10);
                MySqlParameter p11 = new MySqlParameter("p11", textBox12.Text);
                cmd1.Parameters.Add(p11);
                MySqlParameter p12 = new MySqlParameter("p12", textBox13.Text);
                cmd1.Parameters.Add(p12);
                MySqlParameter p13 = new MySqlParameter("p13", textBox14.Text);
                cmd1.Parameters.Add(p13);
                MySqlParameter p14 = new MySqlParameter("p14", textBox2.Text);
                cmd1.Parameters.Add(p14);
                MySqlParameter p15 = new MySqlParameter("p15", textBox7.Text);
                cmd1.Parameters.Add(p15);
                MySqlParameter par = new MySqlParameter("par", textBox15.Text);
                cmd1.Parameters.Add(par);

                MySqlCommand   verif = new MySqlCommand(strverif, ManipulationBD.Cnn);
                MySqlParameter p16   = new MySqlParameter("p16", textBox5.Text);
                verif.Parameters.Add(p16);

                long n = (long)verif.ExecuteScalar();
                if (n == 1)
                {
                    cmd1.ExecuteNonQuery();
                    MessageBox.Show("Modidication effectuez");
                }
                else
                {
                    MessageBox.Show("Impossible car ce contrat n'existe pas");
                }
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 15
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Agent.Acteur    = Connection.Login.User_name;
            Agent.Operation = " a ajouter un nouveau client ";

            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb = (RadioButton)groupBox1.Controls[i];
                    if (rb.Checked)
                    {
                        break;
                    }
                }

                string Tunisien   = "insert into client values (@code_client,@adr_client,@tel_client,null,@cin,null,null,@nom,@prenom,null,null)";
                string Etranger   = "insert into client values (@code_client,@adr_client,@tel_client,@nationalite,null,@num_passport,@pays_org,@nom,@prenom,null,null)";
                string Entreprise = "insert into client values (@code_client,@adr_client,@tel_client,null,null,null,null,null,null,@code_fisc,@rais_soc)";
                string Historique = "insert into historique values(null, @Operation,@Acteur)";
                string strverif   = "select count(*) from client where Code_Client=?";

                MySqlCommand cmd1 = new MySqlCommand(Tunisien, ManipulationBD.Cnn);
                cmd1.Parameters.AddWithValue("@code_client", Cd_client.Text);
                cmd1.Parameters.AddWithValue("@adr_client", Adr_client.Text);
                cmd1.Parameters.AddWithValue("@tel_client", Tel.Text);
                cmd1.Parameters.AddWithValue("@cin", Cin.Text);
                cmd1.Parameters.AddWithValue("@nom", Nom.Text);
                cmd1.Parameters.AddWithValue("@prenom", Prenom.Text);

                MySqlCommand cmd2 = new MySqlCommand(Etranger, ManipulationBD.Cnn);
                cmd2.Parameters.AddWithValue("@code_client", Cd_client.Text);
                cmd2.Parameters.AddWithValue("@adr_client", Adr_client.Text);
                cmd2.Parameters.AddWithValue("@tel_client", Tel.Text);
                cmd2.Parameters.AddWithValue("@nationalite", Nat.Text);
                cmd2.Parameters.AddWithValue("@num_passport", NumPass.Text);
                cmd2.Parameters.AddWithValue("@pays_org", P_Org.Text);
                cmd2.Parameters.AddWithValue("@nom", Nom.Text);
                cmd2.Parameters.AddWithValue("@prenom", Prenom.Text);

                MySqlCommand cmd3 = new MySqlCommand(Entreprise, ManipulationBD.Cnn);
                cmd3.Parameters.AddWithValue("@code_client", Cd_client.Text);
                cmd3.Parameters.AddWithValue("@adr_client", Adr_client.Text);
                cmd3.Parameters.AddWithValue("@tel_client", Tel.Text);
                cmd3.Parameters.AddWithValue("@code_fisc", Cd_fisc.Text);
                cmd3.Parameters.AddWithValue("@rais_soc", R_soc.Text);

                MySqlCommand Cmd = new MySqlCommand(Historique, ManipulationBD.Cnn);
                Cmd.Parameters.AddWithValue("@Operation", (string)Agent.Operation);
                Cmd.Parameters.AddWithValue("@Acteur", (string)Agent.Acteur);

                MySqlCommand   verif = new MySqlCommand(strverif, ManipulationBD.Cnn);
                MySqlParameter p16   = new MySqlParameter("p16", Cd_client.Text);
                verif.Parameters.Add(p16);

                long n = (long)verif.ExecuteScalar();

                if (n == 0)
                {
                    if (rb.Text == "Tunisien")
                    {
                        cmd1.ExecuteNonQuery();
                        Cmd.ExecuteNonQuery();
                        agent.Show();
                        this.Hide();
                        MessageBox.Show("Ajout effectuez");
                    }
                    else if (rb.Text == "Etranger")
                    {
                        cmd2.ExecuteNonQuery();
                        Cmd.ExecuteNonQuery();
                        agent.Show();
                        this.Hide();
                        MessageBox.Show("Ajout effectuez");
                    }
                    else
                    {
                        cmd3.ExecuteNonQuery();
                        Cmd.ExecuteNonQuery();
                        new Agent().Show();
                        this.Hide();
                        MessageBox.Show("Ajout effectuez");
                    }
                }
                else
                {
                    MessageBox.Show("Ajout Impossible car Risque de Doublon");
                }
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 16
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                    if (rb.Checked)
                    {
                        break;
                    }
                }

                string Client     = "select * from client where code_client = ?";
                string Tunisien   = "select * from client where code_client=?";
                string Etranger   = "select * from client where code_client=?";
                string Entreprise = "select * from client where code_client=?";

                MySqlCommand   client = new MySqlCommand(Client, ManipulationBD.Cnn);
                MySqlParameter par    = new MySqlParameter("par", cd_client.Text);
                client.Parameters.Add(par);

                MySqlCommand   tunisien = new MySqlCommand(Tunisien, ManipulationBD.Cnn);
                MySqlParameter pmt1     = new MySqlParameter("pmt1", cd_client.Text);
                tunisien.Parameters.Add(pmt1);


                MySqlCommand   etranger = new MySqlCommand(Etranger, ManipulationBD.Cnn);
                MySqlParameter pmt2     = new MySqlParameter("pmt2", cd_client.Text);
                etranger.Parameters.Add(pmt2);

                MySqlCommand   entreprise = new MySqlCommand(Entreprise, ManipulationBD.Cnn);
                MySqlParameter pmt3       = new MySqlParameter("pmt3", cd_client.Text);
                etranger.Parameters.Add(pmt3);

                MySqlDataReader dr = client.ExecuteReader();
                if (dr != null)
                {
                    /*while (dr.Read())
                     * {
                     *  // textBox1.Text = ((int)dr[0]).ToString();
                     *  textBox1.Text = dr.GetInt32(0).ToString();
                     *  textBox5.Text = (string)dr[1];
                     *  textBox4.Text = dr.GetInt32(2).ToString();
                     * }
                     * dr.Close();*/

                    if (rb.Text == "Tunisien")
                    {
                        while (dr.Read())
                        {
                            cd_client.Text  = dr.GetInt32(0).ToString();
                            adr_client.Text = (string)dr[1];
                            Tel.Text        = dr.GetInt32(2).ToString();
                        }
                        dr.Close();

                        MySqlDataReader dr1 = tunisien.ExecuteReader();

                        if (dr1 != null)
                        {
                            while (dr1.Read())
                            {
                                cin.Text    = ((int)dr[4]).ToString();
                                Nom.Text    = (string)dr1[7];
                                Prenom.Text = (string)dr1[8];
                            }
                            dr1.Close();
                        }
                    }
                    else if (rb.Text == "Etranger")
                    {
                        while (dr.Read())
                        {
                            cd_client.Text  = dr.GetInt32(0).ToString();
                            adr_client.Text = (string)dr[1];
                            Tel.Text        = (string)dr[2];
                        }
                        dr.Close();

                        MySqlDataReader dr1 = etranger.ExecuteReader();
                        if (dr1 != null)
                        {
                            while (dr1.Read())
                            {
                                Nat.Text     = (string)dr1[3];
                                numPass.Text = (string)dr[5];
                                P_org.Text   = (string)dr1[6];
                                Nom.Text     = (string)dr1[7];
                                Prenom.Text  = (string)dr1[8];
                            }
                            dr1.Close();
                        }
                    }
                    else
                    {
                        while (dr.Read())
                        {
                            cd_client.Text  = dr.GetInt32(0).ToString();
                            adr_client.Text = (string)dr[1];
                            Tel.Text        = dr.GetInt32(2).ToString();
                        }
                        dr.Close();

                        MySqlDataReader dr1 = entreprise.ExecuteReader();
                        if (dr1 != null)
                        {
                            while (dr1.Read())
                            {
                                R_soc.Text   = ((int)dr1[9]).ToString();
                                Cd_fisc.Text = (string)dr1[10];
                            }
                            dr1.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Modification Impossible car Il n'existe pas !");
                }
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 17
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                    if (rb.Checked)
                    {
                        break;
                    }
                }

                string Tunisien   = "update client set code_client = ?, adr_client=?, tel_client=?, cin=?, nom=?, prenom=? where code_client=?";
                string Etranger   = "update client set code_client=?,adr_client=?,tel_client=?,nationalite=? , num_passport=?, pays_org=?, nom=?, prenom=? where Code_Client =?";
                string Entreprise = "update client set code_client=?,adr_client=?,tel_client=?,code_fisc=?,rais_soc=? where code_client =?";


                MySqlCommand   cmd1 = new MySqlCommand(Tunisien, ManipulationBD.Cnn);
                MySqlParameter p1   = new MySqlParameter("p1", cd_client.Text);
                cmd1.Parameters.Add(p1);
                MySqlParameter p2 = new MySqlParameter("p2", adr_client.Text);
                cmd1.Parameters.Add(p2);
                MySqlParameter p3 = new MySqlParameter("p3", Tel.Text);
                cmd1.Parameters.Add(p3);
                MySqlParameter p4 = new MySqlParameter("p4", cin.Text);
                cmd1.Parameters.Add(p4);
                MySqlParameter p5 = new MySqlParameter("p5", Nom.Text);
                cmd1.Parameters.Add(p5);
                MySqlParameter p6 = new MySqlParameter("p6", Prenom.Text);
                cmd1.Parameters.Add(p6);
                MySqlParameter par1 = new MySqlParameter("par1", Cd_mod.Text);
                cmd1.Parameters.Add(par1);


                MySqlCommand   cmd2 = new MySqlCommand(Etranger, ManipulationBD.Cnn);
                MySqlParameter e1   = new MySqlParameter("e1", cd_client.Text);
                cmd2.Parameters.Add(e1);
                MySqlParameter e2 = new MySqlParameter("e2", adr_client.Text);
                cmd2.Parameters.Add(e2);
                MySqlParameter e3 = new MySqlParameter("e3", Tel.Text);
                cmd2.Parameters.Add(e3);
                MySqlParameter e4 = new MySqlParameter("e4", Nat.Text);
                cmd2.Parameters.Add(e4);
                MySqlParameter e5 = new MySqlParameter("e5", numPass.Text);
                cmd2.Parameters.Add(e5);
                MySqlParameter e6 = new MySqlParameter("e6", P_org.Text);
                cmd2.Parameters.Add(e6);
                MySqlParameter e7 = new MySqlParameter("e7", Nom.Text);
                cmd2.Parameters.Add(e7);
                MySqlParameter e8 = new MySqlParameter("e8", Prenom.Text);
                cmd2.Parameters.Add(e8);
                MySqlParameter par2 = new MySqlParameter("par2", Cd_mod.Text);
                cmd2.Parameters.Add(par2);

                MySqlCommand   cmd3 = new MySqlCommand(Entreprise, ManipulationBD.Cnn);
                MySqlParameter p8   = new MySqlParameter("p8", cd_client.Text);
                cmd3.Parameters.Add(p8);
                MySqlParameter p9 = new MySqlParameter("p9", adr_client.Text);
                cmd3.Parameters.Add(p9);
                MySqlParameter p10 = new MySqlParameter("p10", Tel.Text);
                cmd3.Parameters.Add(p10);
                MySqlParameter p11 = new MySqlParameter("p11", Cd_fisc.Text);
                cmd3.Parameters.Add(p11);
                MySqlParameter p12 = new MySqlParameter("p12", R_soc.Text);
                cmd3.Parameters.Add(p12);
                MySqlParameter par3 = new MySqlParameter("par3", Cd_mod.Text);
                cmd3.Parameters.Add(par3);


                //cmd1.ExecuteNonQuery();
                //MessageBox.Show("Modification effectuez");

                if (rb.Text == "Tunisien")
                {
                    cmd1.ExecuteNonQuery();
                    MessageBox.Show("Modification effectuez");
                }
                else if (rb.Text == "Etranger")
                {
                    cmd2.ExecuteNonQuery();
                    agent.Show();
                    this.Hide();
                    MessageBox.Show("Modification effectuez");
                }
                else
                {
                    cmd3.ExecuteNonQuery();
                    agent.Show();
                    this.Hide();
                    MessageBox.Show("Modification effectuez");
                }
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                    if (rb.Checked)
                    {
                        break;
                    }
                }

                string Tunisien   = "delete from client where code_client=?";
                string Etranger   = "delete from client where code_client=?";
                string Entreprise = "delete from client where code_client=?";
                string strverif   = "select count(*) from client where code_client=?";

                MySqlCommand   cmd1 = new MySqlCommand(Tunisien, ManipulationBD.Cnn);
                MySqlParameter p1   = new MySqlParameter("code_client", cd_client.Text);
                cmd1.Parameters.Add(p1);

                MySqlCommand   cmd2 = new MySqlCommand(Etranger, ManipulationBD.Cnn);
                MySqlParameter p2   = new MySqlParameter("code_client", cd_client.Text);
                cmd2.Parameters.Add(p2);

                MySqlCommand   cmd3 = new MySqlCommand(Entreprise, ManipulationBD.Cnn);
                MySqlParameter p3   = new MySqlParameter("code_client", cd_client.Text);
                cmd3.Parameters.Add(p3);

                MySqlCommand   verif = new MySqlCommand(strverif, ManipulationBD.Cnn);
                MySqlParameter par   = new MySqlParameter("par", cd_client.Text);
                verif.Parameters.Add(par);

                long n = (long)verif.ExecuteScalar();

                if (n > 0)
                {
                    if (rb.Text == "Tunisien")
                    {
                        cmd1.ExecuteNonQuery();
                        MessageBox.Show("Suppression effectuez");
                    }
                    else if (rb.Text == "Etranger")
                    {
                        cmd2.ExecuteNonQuery();
                        MessageBox.Show("Suppression effectuez");
                    }
                    else
                    {
                        cmd3.ExecuteNonQuery();
                        MessageBox.Show("Suppression effectuez");
                    }
                }
                else
                {
                    MessageBox.Show("Suppression Impossible car Il n'existe pas !");
                }
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }
Exemplo n.º 19
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManipulationBD.ConnectionDataBase();

                RadioButton rb = null;
                for (int i = 0; i < groupBox1.Controls.Count; i++)
                {
                    rb = (RadioButton)groupBox1.Controls[i];    // On sort dès qu'on trouve le bouton sélectionné
                    if (rb.Checked)
                    {
                        break;
                    }
                }

                if (textBox1.Text == "")
                {
                    MessageBox.Show(" Champ vide !!");
                }
                else if (textBox2.Text == "")
                {
                    MessageBox.Show(" Champ vide !! ");
                }
                else if (textBox3.Text == "")
                {
                    MessageBox.Show(" Champ vide !! ");
                }
                else if (textBox4.Text == "")
                {
                    MessageBox.Show(" Champ vide !! ");
                }
                else if (textBox5.Text == "")
                {
                    MessageBox.Show(" Champ vide !! ");
                }
                else if (textBox6.Text == "")
                {
                    MessageBox.Show(" Champ vide !! ");
                }
                else if (textBox7.Text == "")
                {
                    MessageBox.Show(" Champ vide !! ");
                }
                else if (textBox8.Text == "")
                {
                    MessageBox.Show(" Champ vide !! ");
                }
                else
                {
                    string Insertion1 = "update contrat set Numero_Contrat=?,Numero_Chassis=?,Numero=?,Code_Client=?,Montant_Avance=?,Date_Debut_Loc=?,Date_Retour_prev=?,Chauffeur=?,Valeur_Compteur_Km=?,Valeur_Compteur_Heure=? where Numero_Contrat=?";
                    string strverif   = "select count(*) from contrat where Numero_Contrat=?";

                    MySqlCommand   cmd1 = new MySqlCommand(Insertion1, ManipulationBD.Cnn);
                    MySqlParameter p1   = new MySqlParameter("p1", textBox1.Text);
                    cmd1.Parameters.Add(p1);
                    MySqlParameter p2 = new MySqlParameter("p2", textBox4.Text);
                    cmd1.Parameters.Add(p2);
                    MySqlParameter p3 = new MySqlParameter("p3", textBox2.Text);
                    cmd1.Parameters.Add(p3);
                    MySqlParameter p4 = new MySqlParameter("p4", textBox5.Text);
                    cmd1.Parameters.Add(p4);
                    MySqlParameter p5 = new MySqlParameter("p5", textBox3.Text);
                    cmd1.Parameters.Add(p5);
                    MySqlParameter p6 = new MySqlParameter("p6", dateTimePicker1.Text);
                    cmd1.Parameters.Add(p6);
                    MySqlParameter p7 = new MySqlParameter("p7", dateTimePicker2.Text);
                    cmd1.Parameters.Add(p7);
                    MySqlParameter p8 = new MySqlParameter("p8", rb.Text);
                    cmd1.Parameters.Add(p8);
                    MySqlParameter p9 = new MySqlParameter("p9", textBox6.Text);
                    cmd1.Parameters.Add(p9);
                    MySqlParameter p10 = new MySqlParameter("p10", textBox8.Text);
                    cmd1.Parameters.Add(p10);
                    MySqlParameter p11 = new MySqlParameter("p11", textBox7.Text);
                    cmd1.Parameters.Add(p11);

                    MySqlCommand   verif = new MySqlCommand(strverif, ManipulationBD.Cnn);
                    MySqlParameter p16   = new MySqlParameter("p16", textBox1.Text);
                    verif.Parameters.Add(p16);

                    long n = (long)verif.ExecuteScalar();
                    if (n == 1)
                    {
                        cmd1.ExecuteNonQuery();
                        MessageBox.Show("Modification effectuez");
                    }
                    else
                    {
                        MessageBox.Show("Modification Impossible car cet Contrat n'existe pas");
                    }
                }
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            finally
            {
                ManipulationBD.DecoonectionDataBase();
            }
        }