private void btnConger_Click(object sender, RoutedEventArgs e) { var queryDoss = from p in Singleton.Instance.hopitalBDD.Patients join d in Singleton.Instance.hopitalBDD.DossierAdmissions on p.nss equals d.nss join l in Singleton.Instance.hopitalBDD.Lits on d.numLit equals l.numLit join m in Singleton.Instance.hopitalBDD.Medecins on d.idMedecin equals m.idMedecin select new { d.nss, l.numLit, l.occupe, d.idAdmission, p.nom, p.prenom, d.dateConge, d.dateAdmission, Medecin = m.prenom + " " + m.nom }; dossierFact = (DossierAdmission)cbadmission.SelectedItem; if (cbadmission.SelectedItem != null) { if (!String.IsNullOrEmpty(dateConge.Text)) { DossierAdmission patientConge = (DossierAdmission)cbadmission.SelectedItem; var query = Singleton.Instance.hopitalBDD.Lits.Where(l => l.numLit == patientConge.numLit).ToList(); foreach (var item in query) { item.occupe = false; } patientConge.dateConge = dateConge.SelectedDate; Singleton.Instance.hopitalBDD.SaveChanges(); MessageBox.Show("Le patient est en congé"); if (dossierFact.prixCh + dossierFact.prixTel + dossierFact.prixTv == 0) { MessageBox.Show("Pas de facture a payé !"); } else { Facture facture = new Facture(); facture.ShowDialog(); } } else { MessageBox.Show("Entrer une date de congé !"); } cbadmission.DataContext = cbadmission.DataContext = Singleton.Instance.hopitalBDD.DossierAdmissions.Where(dos => dos.dateConge == null).ToList(); dgAdmission.DataContext = queryDoss.Where(dos => dos.dateConge == null).ToList(); dateConge.Text = string.Empty; } else { MessageBox.Show("Pas d'admission !"); } }
private void cbadmission_SelectionChanged(object sender, SelectionChangedEventArgs e) { DossierAdmission dossAdmi = (DossierAdmission)cbadmission.SelectedItem; Patient patient = new Patient(); if (cbadmission.SelectedItem != null) { txtNss.Text = dossAdmi.nss; txtLit.Text = dossAdmi.numLit; dateAdmission.SelectedDate = dossAdmi.dateAdmission; var query = Singleton.Instance.hopitalBDD.Patients.Where(p => p.nss == dossAdmi.nss).ToList(); foreach (var item in query) { txtNom.Text = item.nom; txtPrenom.Text = item.prenom; } } else { txtNss.Text = ""; txtLit.Text = ""; } }
private void btnAjoutAdmiss_Click(object sender, RoutedEventArgs e) { DossierAdmission admission = new DossierAdmission(); if (txtNumAdmiss.Text != string.Empty && txtNss.Text != string.Empty && cbLit.Text != string.Empty && cbMedecin.Text != string.Empty && DateAdmission.Text != string.Empty) { if (ValidationAdmi("ADMI_" + txtNumAdmiss.Text)) { MessageBox.Show("L'ID d'admission existe déjà. Veuillez ressayer !"); } else { if (!ValidationPatient("NSS_" + txtNss.Text)) { MessageBox.Show("L'ID Patient (NSS) n'existe pas. Veuillez l'ajouter !"); } else { if (rbPublic.IsChecked == false && rbPrive.IsChecked == false) { MessageBox.Show("Veuillez choisir un type d'assurance.", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (rbOui.IsChecked == false && rbNon.IsChecked == false) { MessageBox.Show("Veuillez selectionner si la chirurgie est programme ou non !", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (rbPublic.IsChecked == true) { if (cekTv.IsChecked == true) { admission.prixTv = 42.50; prixTotal += 42.50; } else { admission.prixTv = 0; } if (cekTel.IsChecked == true) { admission.prixTel = 7.50; prixTotal += 7.50; } else { admission.prixTel = 0; } } else { admission.prixTv = 0; admission.prixTel = 0; } if (rbOui.IsChecked == true) { if (DateChirurgie.Text != string.Empty) { admission.chirurgieProgramme = true; admission.dateChirurgie = DateChirurgie.SelectedDate; admission.idAdmission = ("ADMI_" + txtNumAdmiss.Text); admission.nss = ("NSS_" + txtNss.Text); admission.dateAdmission = (DateAdmission.SelectedDate); admission.numLit = ((Lit)cbLit.SelectedItem).numLit; ((Lit)cbLit.SelectedItem).occupe = true; admission.idMedecin = ((Medecin)cbMedecin.SelectedItem).idMedecin; admission.prixCh = prixChambre; try { Singleton.Instance.hopitalBDD.DossierAdmissions.Add(admission); Singleton.Instance.hopitalBDD.SaveChanges(); MessageBox.Show("Admission ajouter avec succées"); initAdmission(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Veuillez saisir la date de chirurgie ! "); } } else { admission.chirurgieProgramme = false; admission.idAdmission = ("ADMI_" + txtNumAdmiss.Text); admission.nss = ("NSS_" + txtNss.Text); admission.dateAdmission = (DateAdmission.SelectedDate); admission.numLit = ((Lit)cbLit.SelectedItem).numLit; ((Lit)cbLit.SelectedItem).occupe = true; admission.idMedecin = ((Medecin)cbMedecin.SelectedItem).idMedecin; admission.prixCh = prixChambre; try { Singleton.Instance.hopitalBDD.DossierAdmissions.Add(admission); Singleton.Instance.hopitalBDD.SaveChanges(); MessageBox.Show("Admission ajouter avec succées"); initAdmission(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } } } } else { MessageBox.Show("Veuillez remplir tous les champs.", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } var query = from p in Singleton.Instance.hopitalBDD.Patients join d in Singleton.Instance.hopitalBDD.DossierAdmissions on p.nss equals d.nss join m in Singleton.Instance.hopitalBDD.Medecins on d.idMedecin equals m.idMedecin join s in Singleton.Instance.hopitalBDD.Specialites on m.idSpecialite equals s.idSpecialite select new { d.idAdmission, p.nss, p.nom, p.prenom, m.idMedecin, s.descSpecialite, Medecin = m.prenom + " " + m.nom, d.dateConge, d.dateAdmission }; gvAdmission.DataContext = query.ToList(); }