private void button1_Click(object sender, EventArgs e) { try { sessions = sessionController.Shows(FileWorker.pathToSession); for (int j = 0; j < sessions.Count; j++) { var s = JsonConvert.DeserializeObject <SessionModel>(sessions[j]); if ((bool)dataGridView1.Rows[j].Cells[1].Value) { var a = s.timeSession.ToString(); newSessions.Add(a); continue; } } int err = 0; foreach (Control c in Controls) { if (c is TextBox) { if (string.IsNullOrEmpty((c as TextBox).Text)) { err++; } } } if (err > 0) { MessageBox.Show($"Неправильно заполнены поля ({err})"); } else { filmController.Add(textBox1.Text, comboBox2.Text, textBox4.Text, textBox3.Text, textBox2.Text, newSessions, path); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void initializeCombo() { comboBox2.Items.Clear(); films = filmController.Shows(FileWorker.pathToDesktopFilms); sessions = sessionController.Shows(FileWorker.pathToSession); for (int i = 0; i < films.Count; i++) { var s = JsonConvert.DeserializeObject <FilmModel>(films[i]); comboBox2.Items.Add(s.Name); } if (comboBox2.Items.Count < 0) { comboBox2.Text = comboBox2.Items[0].ToString(); pictureBox1.ImageLocation = JsonConvert.DeserializeObject <FilmModel>(films[0]).PathToPoster; } }