Exemplo n.º 1
0
        private void btnAltSubmit_Click(object sender, RoutedEventArgs e)
        {
            var allotment = new SEATALLOT
            {
                room_number = txtAltRoomNo.Text,
                hostel_id   = int.Parse(txtAltHostelId.Text),
                seat_number = txtAltSeatNo.Text,
                std_id      = int.Parse(txtAltStdId.Text)
            };

            context.SEATALLOTS.Add(allotment);
            context.SaveChanges();

            tableAlocatedSeat.ItemsSource = tableVctSeat.ItemsSource = context.SEATVACANTS.Select(x => new { x.HOSTEL.hostel_name, x.room_number, x.seat_number }).ToList();
        }
Exemplo n.º 2
0
 private void btnVctSubmit_Click(object sender, RoutedEventArgs e)
 {
     if (context.SEATALLOTS.Any(x => x.hostel_id == int.Parse(txtVctHostelId.Text) && x.room_number == txtVctRoomNo.Text && x.seat_number == txtVctSeatNo.Text && x.std_id == int.Parse(txtVctStdId.Text)))
     {
         var vs = context.SEATALLOTS.First(x => x.room_number == txtVctRoomNo.Text && x.seat_number == txtVctSeatNo.Text);
         try
         {
             var record = new SEATALLOT {
                 id = vs.id
             };
             context.SEATALLOTS.Attach(record);
             context.SEATALLOTS.Remove(record);
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             lbladdroom.Content = "Please fill the field correctly";
         }
     }
     tableVctSeat.ItemsSource = context.SEATVACANTS.ToList();
 }