public static void Add(List <Note> list_note, Label label2, TextBox textBox1, TextBox textBox2, DataGrid dataGrid, CheckBox checkBox1, ComboBox comboBox1) { try { Note note = new Note(); DateTime dt; DateTime.TryParse(label2.Content + " " + textBox1.Text, out dt); note.date = dt; note.text = textBox2.Text; note.state = comboBox1.Text; note.login = AuthorizationWindow.user.name; note.notify = (bool)checkBox1.IsChecked; DataWorking.GetData(out list_note, "data.xml"); list_note.Add(note);//добавляет в список DataWorking.WriteData(list_note, "data.xml"); TableWorking.RefreshTable(label2, list_note, dataGrid); } catch (Exception ex) { MessageBox.Show(ex.Message); } }// добавляем заметку
private void toolStripMenuItem1_Click(object sender, EventArgs e) { DataWorking.GetData(out list_note, "data.xml"); this.Show(); Note note = new Note(); DateTime dt = note.date; DateTime.TryParse(DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":00", out dt); note.date = dt; note.text = message; note.notify = true; note.state = "В процессе"; note.login = AuthorizationWindow.user.name; list_note.Remove(note);// удаляем из списка note.state = "Завершено"; note.notify = false; list_note.Add(note); File.WriteAllText("data.xml", string.Empty);// очищаем файл DataWorking.WriteData(list_note, "data.xml"); TableWorking.RefreshTable(Date_label, list_note, dataGrid); }