void itemclk() { abc.IsReadOnly = false; deleteButton.Visibility = Visibility; saveButton.Visibility = Visibility; var k = qwe.SelectedItem.ToString(); using (DelaContext ncon = new DelaContext()) { var delo = (from dela in ncon.Delas where dela.Title.Equals(k) select dela.Delo ).FirstOrDefault().ToString(); abc.Text = delo; var title = (from dela in ncon.Delas where dela.Title.Equals(k) select dela.Title).FirstOrDefault().ToString(); titleTblock.Text = title; var date = (from dela in ncon.Delas where dela.Title.Equals(k) select dela.DateTime).FirstOrDefault().ToString(); dateTblock.Text = date; } }
private void Item_Click(object sender, MouseButtonEventArgs e) { string pass; using (DelaContext ncon = new DelaContext()) { pass = (from dela in ncon.Delas where dela.Title.Equals(qwe.SelectedItem.ToString()) select dela.Password ).FirstOrDefault().ToString(); } if (string.IsNullOrWhiteSpace(pass) || pass == "") { itemclk(); } else { PassWindow pw = new PassWindow(); if (pw.ShowDialog() == true) { if (pw.Password == pass) { itemclk(); } else { MessageBox.Show("Неверный пароль"); } } } }
private void Send_Click(object sender, RoutedEventArgs e) { using (DelaContext ncon = new DelaContext()) { try { if (!string.IsNullOrWhiteSpace(AddNameTBox.Text)) { var zametka = new Delas() { Title = AddNameTBox.Text, Delo = mainTbox.Text, DateTime = DateTime.Now.ToString("G"), Password = AddPassTBox.Text }; ncon.Delas.Add(zametka); ncon.SaveChanges(); ListUpdate(); Tab2Clear(); myTabContrl.SelectedIndex = 0; } else { MessageBox.Show("Дайте заметке название"); } } catch { MessageBox.Show("Название должно быть уникальным"); } } }
private void Delete_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Вы действительно хотите удалить заметку?", "Удаление заметки", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { using (DelaContext ncon = new DelaContext()) { var zxc = (from o in ncon.Delas where o.Title == titleTblock.Text select o).FirstOrDefault(); ncon.Delas.Remove(zxc); ncon.SaveChanges(); } ListUpdate(); abc.Text = "Выберете заметку"; abc.IsReadOnly = true; titleTblock.Text = ""; dateTblock.Text = ""; deleteButton.Visibility = Visibility.Hidden; saveButton.Visibility = Visibility.Hidden; } else { // Пользователь отменил действие. } }
void ListUpdate() { using (DelaContext ncon = new DelaContext()) { var name = (from dela in ncon.Delas select dela.Title).ToList(); qwe.ItemsSource = name; } }
private void Save_Click(object sender, RoutedEventArgs e) { try { using (DelaContext ncon = new DelaContext()) { var zxc = (from o in ncon.Delas where o.Title == titleTblock.Text select o).First <Delas>(); zxc.Delo = abc.Text; ncon.SaveChangesAsync(); } ListUpdate(); } catch (Exception) { MessageBox.Show("Нечего сохранять"); } }