private void Button_Click_1(object sender, RoutedEventArgs e) { if(PassBoxP.Password!=PassBoxPAg.Password) { MessageBox.Show("Пароли не совпадают!"); return; } MD5 md = new MD5CryptoServiceProvider(); byte[] bt = Encoding.UTF8.GetBytes(PassBoxP.Password); using (AchievmentsEntities ach = new AchievmentsEntities()) { if (ach.Passwords.Select(t => t.Name == TextBoxName.Text).FirstOrDefault()) { MessageBox.Show("Такое имя уже занято"); return; } Password p = new Password() { Name = TextBoxName.Text, Password1 = bt }; ach.Passwords.Add(p); ach.SaveChanges(); } this.Close(); }
/// <summary> /// Обновление ComboBox - подтем /// </summary> /// <param name="ach">Соединение с бд</param> void RefrefsSubTh(AchievmentsEntities ach) { ComboBoxSubtheme.Items.Clear(); Theme th=ach.Themes.Where(t=>t.Name==ComboBoxTheme.SelectedValue.ToString()).FirstOrDefault(); foreach (var item in ach.SubThemeRels) { if (item.Theme==th) { ComboBoxSubtheme.Items.Add(item.Subtheme.Name); } } if (ComboBoxSubtheme.Items.Count > 0) ComboBoxSubtheme.SelectedIndex = 0; }
/// <summary> /// Обновление ComboBox - тем и подтем /// </summary> void ComboBoxFill() { ComboBoxTheme.Items.Clear(); using (AchievmentsEntities ach = new AchievmentsEntities()) { foreach (var item in ach.Themes) { ComboBoxTheme.Items.Add(item.Name); } ComboBoxTheme.SelectedIndex = 0; } }
private void Button_Click(object sender, RoutedEventArgs e) { MD5 md = new MD5CryptoServiceProvider(); using (AchievmentsEntities ach = new AchievmentsEntities()) { Password p = ach.Passwords.Where(x => x.Name == TextBoxName.Text).FirstOrDefault(); byte[]b= Encoding.UTF8.GetBytes(PassBoxP.Password); if (p != null) if (b.SequenceEqual(p.Password1)) { App.curPnID = p.ID; MainWindow mw = new MainWindow(); mw.Show(); this.Close(); } else { MessageBox.Show("Неверный пароль"); } else MessageBox.Show("Такой пользователь не зарегистрирован"); } }
/// <summary> /// Получить все достижения для текущего пользователя /// </summary> /// <returns></returns> IQueryable<AchieveInfo> GetFullAchList() { AchievmentsEntities ach = new AchievmentsEntities(); var aa=ach.AchieveInfoes.Where(p=>p.Password.ID==App.curPnID); return aa; }
private void DGInfo_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { DataRowView dRowView = (DataRowView)DGInfo.SelectedItems[0]; DataRow dRow = dRowView.Row; string cellContent = dRow[2].ToString(); using (AchievmentsEntities ach = new AchievmentsEntities()) { AchieveInfo aI = GetFullAchList().Where(p => p.Name == cellContent).FirstOrDefault(); WindowDetailedInfo wdi = new WindowDetailedInfo(aI); detailedInfo = true; this.Close(); wdi.Show(); } } catch { } }
private void cbTheme_SelectionChanged(object sender, SelectionChangedEventArgs e) { using(AchievmentsEntities ach=new AchievmentsEntities()) { RefrefsSubTh(ach); } }
/// <summary> /// Заполнение стартовой информации (не таблицы) /// </summary> void FillingNP() { using (AchievmentsEntities ach = new AchievmentsEntities()) { Password p = ach.Passwords.Where(x => x.ID == App.curPnID).FirstOrDefault(); tblName.Text ="Пользователь: "+ p.Name; ComboBoxFill(); } }
/// <summary> /// Добавление нового достижения /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click_1(object sender, RoutedEventArgs e) { using (AchievmentsEntities ach = new AchievmentsEntities()) { Password p=ach.Passwords.Where(t=>t.ID==App.curPnID).FirstOrDefault(); Theme th = ach.Themes.Where(t => t.Name == ComboBoxTheme.SelectedValue.ToString()).FirstOrDefault(); Subtheme sth=new Subtheme(); try { sth= ach.Subthemes.Where(t => t.Name == ComboBoxSubtheme.SelectedValue.ToString()).FirstOrDefault(); } catch { } AchieveInfo achI = new AchieveInfo() { Date = TextBlockDate.SelectedDate.Value.Date, Points = (int)PointsSlider.Value, Name = TextBlockName.Text, Subscribe = TextBoxSubscr.Text, Password = p, Theme=th }; if (sth != null) achI.Subtheme = sth; ach.AchieveInfoes.Add(achI); ach.SaveChanges(); MainWindow mw = new MainWindow(); mw.Show(); this.Close(); } }
/// <summary> /// Изменение индекса CB темы - редактирование CB подтемы /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ComboBoxTheme_SelectionChanged(object sender, SelectionChangedEventArgs e) { if(ComboBoxTheme.SelectedIndex!=-1) using(AchievmentsEntities ach=new AchievmentsEntities()) { RefrefsSubTh(ach); } }