private void btnAddLit_Click(object sender, RoutedEventArgs e) { if (dgChambres.SelectedItem != null) { Lit lit = new Lit(); lit.Occupe = false; lit.ChambreID = (dgChambres.SelectedItem as Chambre).ID; mgr.BDD.Lits.Add(lit); mgr.SaveChanges(); actualiserLits(); } }
private void dgSejours_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (dgSejours.SelectedItem != null) { SejMedView viewItem = dgSejours.SelectedItem as SejMedView; Patient patient = mgr.BDD.Patients.Where(x => x.ID == viewItem.PatientID).SingleOrDefault(); MessageBoxResult result = MessageBox.Show( "Voulez vous donner congé a " + patient.Prenom + " " + patient.Nom, "Congé?", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { Sejour sejour = mgr.BDD.Sejours.Where(x => x.ID == viewItem.ID).SingleOrDefault(); sejour.DateFin = DateTime.Now; Lit lit = mgr.BDD.Lits.Where(x => x.ID == viewItem.LitID).SingleOrDefault(); lit.Occupe = false; mgr.BDD.SaveChanges(); actualiser(); } } }
private void autoSelectBed() { predispo = 0; List <Chambre> initChambres = mgr.BDD.Chambres.Where(x => x.DepMedID == depMed.ID && x.Type == "Standard").ToList(); Lit initLit = null; foreach (Chambre chambre in initChambres) { initLit = mgr.BDD.Lits.Where(x => x.Occupe == false && x.ChambreID == chambre.ID).FirstOrDefault(); if (initLit != null) { break; } } if (initLit == null) { predispo++; } if (predispo == 1) { initChambres = mgr.BDD.Chambres.Where(x => x.DepMedID == depMed.ID && x.Type == "SemiPrivé").ToList(); foreach (Chambre chambre in initChambres) { initLit = mgr.BDD.Lits.Where(x => x.Occupe == false && x.ChambreID == chambre.ID).FirstOrDefault(); if (initLit != null) { break; } } if (initLit == null) { predispo++; } } if (predispo == 2) { initChambres = mgr.BDD.Chambres.Where(x => x.DepMedID == depMed.ID && x.Type == "Privé").ToList(); foreach (Chambre chambre in initChambres) { initLit = mgr.BDD.Lits.Where(x => x.Occupe == false && x.ChambreID == chambre.ID).FirstOrDefault(); if (initLit != null) { break; } } } if (initLit == null) { txtBoxPredispo.Text = "Aucun lit est disponible :("; } else { switch (predispo) { case 0: txtBoxPredispo.Text = "• Choix Normal de chambre et lit"; break; case 1: txtBoxPredispo.Text = "• Chambre/Lit Standard non disponible\n Choix Gratuit de chambre et lit semi-privé"; break; case 2: txtBoxPredispo.Text = "• Chambre/Lit Standard/Semi-Privé non disponible\nChoix Gratuit de chambre et lit privé"; break; default: txtBoxErreur.Text += "Erreur lors de la selection automatique d'un lit.\n"; break; } lit = initLit; } }