private void Button_Click_1(object sender, RoutedEventArgs e) { bool name = true; bool email = true; try { MailAddress m = new MailAddress(textBox2.Text); if (textBox3.Password == textBox4.Password) { User user = new User(); user.email = textBox2.Text; user.name = textBox1.Text; user.password = Sha_512.GetHash(textBox3.Password); user.islocal = (bool)radioButton1.IsChecked; DataWorking.GetData(out user_list, "users.xml"); for (int i = 0; i < user_list.Count; i++) { if (user_list[i].name == user.name) { name = false; } if (user_list[i].email == user.email) { email = false; } } if (name == true && email == true) { user_list.Add(user); DataWorking.WriteData(user_list, "users.xml"); MessageBox.Show("Учетная запись была создана"); } if (name == false) { MessageBox.Show("Это имя уже занято"); } if (email == false) { MessageBox.Show("Этот email уже занят"); } } else { MessageBox.Show("Пароли не совпадают"); } } catch { MessageBox.Show("Некорректный email."); } }
}// добавляем заметку public static void Delete(List <Note> list_note, Label label2, DataGrid dataGridView1, Note Selected_Note) { Note note = new Note(); DateTime dt; DateTime.TryParse(Selected_Note.date.ToString(), out dt); note.date = dt; note.text = Selected_Note.text; DataWorking.GetData(out list_note, "data.xml"); list_note.Remove(note); // удаляем из списка File.WriteAllText("data.xml", string.Empty); // очищаем файл DataWorking.WriteData(list_note, "data.xml"); TableWorking.FillTable(label2, list_note, dataGridView1); } //удаляем заметку
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); }
public MainWindow() { InitializeComponent(); #region Calendar initialization FillCalendar(CurrentYear, CurrentMonth); ShowDayNames(Mo, Tu, We, Th, Fr, Sa, Su); ShowMonthNamesAndCurrentYear(CurrentMonth, CurrentYear, label3); int a = (DateTime.Now.Day + start2) % 8; int b = (DateTime.Now.Day + start2) / 8 + 1; dock[b, a].Background = Brushes.LightGray; #endregion #region Task tab's item initialization Date_label.Content = DateTime.Now.ToShortDateString(); DataWorking.GetData(out list_note, "data.xml"); for (int i = 0; i < list_note.Count; i++) { if ((list_note[i].date < DateTime.Now) && (list_note[i].state == "В процессе") && (list_note[i].login == AuthorizationWindow.user.name) && (list_note[i].notify == true)) { list_note[i].state = "Не выполнено"; DataWorking.WriteData(list_note, "data.xml"); } } TableWorking.FillTable(Date_label, list_note, dataGrid); State_comboBox.Items.Add("В процессе"); State_comboBox.Items.Add("Завершено"); #endregion #region Diary tab's item initialization InstalledFontCollection ifc = new InstalledFontCollection(); System.Drawing.FontFamily[] families = ifc.Families; for (int i = 0; i < families.Length; i++) { Label lb = new Label(); lb.Content = families[i].Name; lb.FontFamily = new FontFamily(families[i].Name); comboBox1.Items.Add(lb); } comboBox1.Text = "Times New Roman"; int[] FontSizes = { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }; for (int i = 0; i < FontSizes.Length; i++) { comboBox2.Items.Add(FontSizes[i]); } comboBox2.Text = "14"; comboBox3.ItemsSource = typeof(Colors).GetProperties(); try { Diary.Load(richTextBox, Date_label); } catch (Exception ex) { richTextBox.Document.Blocks.Clear(); } #endregion #region NotifyIcon initialization System.Drawing.Icon icon = new System.Drawing.Icon(@"G:\Orinizer_WPF_Project\Orginizer\Orginizer\Images\calendar.ico"); notifyIcon1.Icon = icon; notifyIcon1.Visible = true; notifyIcon1.BalloonTipClicked += new System.EventHandler(notifyIcon1_BalloonTipClicked); #endregion #region BackgroundWorker initialization backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(backgroundWorker1_DoWork); backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(backgroundWorker1_ProgressChanged); backgroundWorker1.RunWorkerAsync(); #endregion contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem1, toolStripMenuItem2 }); contextMenuStrip1.Visible = true; contextMenuStrip1.Size = new System.Drawing.Size(138, 48); toolStripMenuItem1.Text = "Завершено"; toolStripMenuItem1.Click += new System.EventHandler(toolStripMenuItem1_Click); contextMenuStrip1.Size = new System.Drawing.Size(138, 48); toolStripMenuItem2.Text = "Отложить"; toolStripMenuItem2.Click += new System.EventHandler(toolStripMenuItem2_Click); toolStripMenuItem2.Size = new System.Drawing.Size(137, 22); }