private void Button_Click(object sender, RoutedEventArgs e) { Hostel hostel = new Hostel(); hostel.Name = name_h.Text; db.Hostels.Add(hostel); db.SaveChanges(); MessageBox.Show("Общежитие добавлено!"); onLoad(); }
private void Button_Click(object sender, RoutedEventArgs e) { Hostel hostel = new Hostel(); hostel.Name = name_h.Text; hostel.Student = new List <Students>(); db.Hostels.Add(hostel); db.SaveChanges(); MessageBox.Show("Team added"); onLoad(); }
private void del_host_Click(object sender, RoutedEventArgs e) { if (hostelDataGrid.SelectedItems.Count < 1) { return; } foreach (Hostel k in hostelDataGrid.SelectedItems) { p = k.Id; } Hostel st = db.Hostels.Find(p); db.Hostels.Remove(st); db.SaveChanges(); MessageBox.Show("Hostel deleted"); studentsDataGrid.DataContext = db.Student.ToList(); hostelDataGrid.DataContext = db.Hostels.ToList(); }
private void ch_host_Click(object sender, RoutedEventArgs e) { if (hostelDataGrid.SelectedItems.Count < 1) { return; } foreach (Hostel k in hostelDataGrid.SelectedItems) { z = k.Id; } Hostel host = db.Hostels.Find(z); Page4 pag = new Page4(); fr.Content = pag; pag.name.Text = host.Name; host.Name = pag.name.Text; db.Entry(host).State = EntityState.Modified; db.SaveChanges(); }
public Page4() { InitializeComponent(); db = new Model1(); onHostRequest(); int count = 0; bool IsGoodJob = true; while (MyHost == null) { count++; if (count == 100) { IsGoodJob = false; break; } } if (IsGoodJob) { hostels = MyHost; MyHost = null; name.Text = hostels.Name; } }