public WindowDetailedInfo(AchieveInfo aI) { InitializeComponent(); TBlAchName.Text = aI.Name; TBlDateName.Text = aI.Date.Date.ToShortDateString(); TBlPointsName.Text = aI.Points.ToString(); TBlThemeName.Text = aI.Theme.Name; TBlSubThemeName.Text = aI.Subtheme.Name; TBlUserName.Text = aI.Password.Name; TBlSummary.Text = aI.Subscribe; achI = aI; }
/// <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(); } }