Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        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;
            }
        }