Example #1
0
        //Supprimer
        private void button3_Click(object sender, EventArgs e)
        {
            string matricule_recherché = textBox1.Text;
            bool   trouve = false;

            DialogResult réponse = MessageBox.Show("Êtes-vous sûre de vouloir supprimer le personnel " + matricule_recherché, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (réponse == DialogResult.Yes)
            {
                for (int i = 0; i < Personnel.NbrPersonnels; i++)
                {
                    try
                    {
                        Personnel p = Personnel.Deserialisation("personnels\\" + i.ToString() + ".txt");

                        if (p.Matricule == matricule_recherché)
                        {
                            trouve = true;
                            if (File.Exists(@"personnels\" + i.ToString() + ".txt"))
                            {
                                File.Delete(@"personnels\" + i.ToString() + ".txt");
                                //Personnel.NbrPersonnels--;
                                MessageBox.Show("Le personnel a été supprimé");
                                vider();
                            }
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }

                if (trouve == false)
                {
                    MessageBox.Show("Personnel introuvable");
                }
            }
        }
Example #2
0
        //Rechercher
        private void button2_Click(object sender, EventArgs e)
        {
            string matricule_recherché = textBox1.Text;
            bool   trouve = false;

            for (int i = 0; i < Personnel.NbrPersonnels; i++)
            {
                try
                {
                    Personnel p = Personnel.Deserialisation("personnels\\" + i.ToString() + ".txt");

                    if (p.Matricule == matricule_recherché)
                    {
                        trouve          = true;
                        p.Matricule     = textBox1.Text;
                        p.Nom           = textBox3.Text;
                        p.Prenom        = textBox4.Text;
                        p.Datenaissance = dateTimePicker1.Value;
                        p.Discipline    = comboBox1.Text;
                        p.Serialisation(@"personnels\" + i + ".txt");
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                catch (Exception)
                {
                    continue;
                }
            }

            if (trouve == false)
            {
                MessageBox.Show("Personnel introuvable");
            }
        }
Example #3
0
        private void LoadData()
        {
            Thread.AllocateDataSlot();

            if (Client.NbrClients > 0)
            {
                for (int i = 0; i < Client.NbrClients; i++)
                {
                    try
                    {
                        Client c = Client.Deserialisation(@"clients\" + i + ".xml");
                        dataGridView1.Rows.Add(c.Numeroinscription, c.Nom, c.Prenom, c.Cin);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }

            if (Personnel.NbrPersonnels > 0)
            {
                for (int i = 0; i < Personnel.NbrPersonnels; i++)
                {
                    try
                    {
                        Personnel p = Personnel.Deserialisation(@"personnels\" + i + ".txt");
                        dataGridView2.Rows.Add(p.Matricule, p.Nom, p.Prenom, p.Discipline);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
        }