public void AddOuvrage(Ouvrage e)
 {
     if (liste.Contains(e) == false)
     {
         liste.Add(e);
     }
 }
Ejemplo n.º 2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int     code = int.Parse(comboBox1.GetItemText(this.comboBox1.SelectedItem));
            Ouvrage ouv  = MenuForm.listOuvrages.Recherche(code);

            textBox1.Text = ouv.Titre;
        }
 public bool DelOuvrage(Ouvrage e)
 {
     if (liste.Contains(e) == true)
     {
         liste.Remove(e);
         return(true);
     }
     return(false);
 }
 public Ouvrage Recherche(String titre)
 {
     foreach (var x in liste)
     {
         Ouvrage e = x as Ouvrage;
         if (e.Titre == titre)
         {
             return(e);
         }
     }
     return(null);
 }
 public Ouvrage Recherche(int code)
 {
     foreach (var x in liste)
     {
         Ouvrage e = x as Ouvrage;
         if (e.Code == code)
         {
             return(e);
         }
     }
     return(null);
 }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string titre = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
         dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);
         Ouvrage ouvrage = MenuForm.listOuvrages.Recherche(titre);
         MenuForm.listOuvrages.DelOuvrage(ouvrage.Code);
     }
     catch (Exception)
     {
     }
 }
        private void button2_Click(object sender, EventArgs e)
        {
            int year, month, day;

            try
            {
                year  = int.Parse(textBox2.Text);
                month = int.Parse(textBox3.Text);
                day   = int.Parse(textBox4.Text);
            }
            catch (Exception)
            {
                month = 0;
                day   = 0;
                year  = 0;
            }


            if (month > 0 && month < 13 && day > 0 && day < 32 && year < 3000)
            {
                int code = int.Parse(comboBox1.GetItemText(this.comboBox1.SelectedItem));
                MenuForm.listOuvrages.ModifyOuvrage(code, textBox1.Text, new DateTime(year, month, day));
                Ouvrage ouvrage = MenuForm.listOuvrages.Recherche(code);
                ouvrage.Auteurs.Clear();
                foreach (string x in listBox1.Items)
                {
                    ouvrage.AddAuteur(x);
                    MenuForm.ouvrage.AddAuteur(x);
                }

                label7.Text = "";
                MessageBox.Show("Modification avec succés");
                this.Close();
            }
            else
            {
                textBox2.Text = "";
                textBox5.Text = "";
                textBox4.Text = "";
                label7.Text   = "verifié la date ";
            }
        }
Ejemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            int year, month, day;

            try
            {
                year  = int.Parse(textBox2.Text);
                month = int.Parse(textBox4.Text);
                day   = int.Parse(textBox5.Text);
            }
            catch (Exception)
            {
                month = 0;
                day   = 0;
                year  = 0;
            }


            if (month > 0 && month < 13 && day > 0 && day < 32 && year < 3000)
            {
                Ouvrage ouvrage = new Ouvrage(textBox1.Text, new DateTime(year, month, day));
                foreach (string x in listBox1.Items)
                {
                    ouvrage.AddAuteur(x);
                    MenuForm.ouvrage.AddAuteur(x);
                }
                MenuForm.listOuvrages.Liste.Add(ouvrage);
                MessageBox.Show("Ajouter avec succés");
                this.Close();
                label7.Text = "";
            }
            else
            {
                textBox2.Text = "";
                textBox5.Text = "";
                textBox4.Text = "";
                label7.Text   = "verifié la date ";
            }
        }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            ListeOuvrages listOuvrage = new ListeOuvrages();

            try
            {
                foreach (string x in checkedListBox1.CheckedItems)
                {
                    Ouvrage ouv = MenuForm.listOuvrages.Recherche(x);
                    listOuvrage.AddOuvrage(ouv);
                    MenuForm.listOuvrages.DelOuvrage(ouv);
                    MenuForm.tempListOuvrages.AddOuvrage(ouv);
                }

                int        code = int.Parse(comboBox1.GetItemText(this.comboBox1.SelectedItem));
                Emprunteur emp  = MenuForm.gestionEmprunts.Emprunteurs.Recherche(code);
                MenuForm.gestionEmprunts.Add(emp, listOuvrage);
            }
            catch (Exception)
            {
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         listBox1.Items.Clear();
         int     code = int.Parse(comboBox1.GetItemText(this.comboBox1.SelectedItem));
         Ouvrage ouv  = MenuForm.listOuvrages.Recherche(code);
         textBox1.Text = ouv.Titre;
         textBox2.Text = ouv.Edition.Year.ToString();
         textBox3.Text = ouv.Edition.Month.ToString();
         textBox4.Text = ouv.Edition.Day.ToString();
         foreach (string x in ouv.Auteurs)
         {
             listBox1.Items.Add(x);
         }
         label4.Text = "";
     }
     catch (Exception)
     {
         label4.Text = "Select code";
     }
 }