private void buttonSalva_Click(object sender, EventArgs e)
        {
            string nome         = textBoxNome.Text;
            string genereString = comboBoxGeneri.Text;


            if (nome == null)
            {
                System.Windows.Forms.MessageBox.Show("Il nome non può essere nullo");
            }
            else if (genereString == null)
            {
                System.Windows.Forms.MessageBox.Show("Selezionare un genere");
            }
            else
            {
                genere gen;
                Enum.TryParse <genere>(genereString, out gen);
                Lista listaNew = new Lista
                {
                    Nome       = nome,
                    Gen        = gen,
                    IsVisibile = _lista.IsVisibile,
                    Username   = _lista.Username,
                    Id         = _lista.Id
                };
                List <Libro> listaLibriNew = new List <Libro>();
                foreach (Libro l in _lista.ListaLibri)
                {
                    foreach (Libro daEliminare in _libriDaEliminare)
                    {
                        if (!l.Titolo.Equals(daEliminare.Titolo) && !l.Autore.Equals(daEliminare.Autore))
                        {
                            listaLibriNew.Add(l);
                        }
                    }
                }
                listaNew.ListaLibri = listaLibriNew.ToArray();
                _leMieListe.ModificaListaPersonale(listaNew);

                new LaMiaLibreriaView(_addr, _username).Show();
                this.Hide();
            }
        }
예제 #2
0
        private void dataGridViewListe_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridViewListe.CurrentCell.ColumnIndex.Equals(0) && e.RowIndex != -1)
            {
                if (dataGridViewListe.CurrentCell != null && dataGridViewListe.CurrentCell.Value != null)
                {
                    Lista        list       = (Lista)dataGridViewListe.Rows[e.RowIndex].Cells[3].Value;
                    List <Libro> listaLibri = list.ListaLibri.ToList <Libro>();
                    listaLibri.Add(_libro);
                    list.ListaLibri = listaLibri.ToArray <Libro>();
                    _leMieListe.ModificaListaPersonale(list);

                    System.Windows.Forms.MessageBox.Show("Libro aggiunto alla lista!");

                    new SchedaLibroView(_addr, _username, _libro).Show();
                    this.Hide();
                }
            }

            else
            {
            }
        }