예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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;
            }
        }