Beispiel #1
0
        private void ch_st_Click(object sender, RoutedEventArgs e)
        {
            //if (studentsDataGrid.SelectedItems.Count < 1)
            //    return;
            //foreach (Students k in studentsDataGrid.SelectedItems)
            //{
            //    z = k.Id;
            //}
            //Students st = db.Student.Find(z);
            Page3 pag = new Page3();

            fr.Content = pag;
            //pag.name.Text = st.Name;
            //pag.age.Text = st.Age.ToString();
            //pag.sname.Text = st.S_name;
            //pag.lis.SelectedItem = st.Hostels;


            //st.Name = pag.name.Text;
            //st.Age = Convert.ToInt32(pag.age.Text);
            //st.S_name = pag.sname.Text;
            //foreach (Hostel item in pag.lis.SelectedItems)
            //{
            //    select.Add(item);
            //}
            //st.Hostels = select;
            //db.Entry(st).State = EntityState.Modified;
            //db.SaveChanges();
            //MessageBox.Show("Информация обновлена");
        }
        private void ch_st_Click(object sender, RoutedEventArgs e)
        {
            if (studentsDataGrid.SelectedItems.Count < 1)
            {
                return;
            }
            foreach (Students k in studentsDataGrid.SelectedItems)
            {
                z = k.Id;
            }
            Students st  = db.Student.Find(z);
            Page3    pag = new Page3();

            fr.Content           = pag;
            pag.name.Text        = st.Name;
            pag.age.Text         = st.Age.ToString();
            pag.sname.Text       = st.S_name;
            pag.lis.SelectedItem = st.Hostels;


            st.Name   = pag.name.Text;
            st.Age    = Convert.ToInt32(pag.age.Text);
            st.S_name = pag.sname.Text;
            foreach (Hostel item in pag.lis.SelectedItems)
            {
                select.Add(item);
            }
            st.Hostels         = select;
            db.Entry(st).State = EntityState.Modified;
            db.SaveChanges();
        }