private void btnModifierMedcin_Click(object sender, RoutedEventArgs e) { //Capter le medcin choisi pour ensuite faire les modification Medcin medcinSelectionee = lstMedcinAdmin.SelectedItem as Medcin; //Verifier si les champs sont pas vide if (txtNomMedcin.Text != "" & txtPrenomMedcin.Text != "") { medcinSelectionee.nom = txtNomMedcin.Text; medcinSelectionee.prenom = txtPrenomMedcin.Text; //On essaie la modification du medcin selectionne, si on rencontre une erreur on affiche le message d'erreur a l'utlisateur try { myBdd.SaveChanges(); lstMedcinAdmin.DataContext = myBdd.Medcins.ToList(); //On vide les champs apres l'operation txtNomMedcin.Text = ""; txtPrenomMedcin.Text = ""; lstMedcinAdmin.UnselectAll(); } catch (Exception) { MessageBox.Show("La modification n'a pas ete complete", "Erreur de modification"); } } else { MessageBox.Show("Tous les champs doivent etre rempli!", "Champs Vide!"); } }
private void lstMedcinAdmin_SelectionChanged(object sender, SelectionChangedEventArgs e) { //Capter le medcin choisi pour ensuite faire les modification Medcin medcinSelectionee = lstMedcinAdmin.SelectedItem as Medcin; //S'il y a un medcin selectionne remplir les champs avec les informations du medcin if (lstMedcinAdmin.SelectedItem != null) { txtNomMedcin.Text = medcinSelectionee.nom; txtPrenomMedcin.Text = medcinSelectionee.prenom; } }
//private static IServiceProvider _provider; //public AddMedcine(IServiceProvider serviceProvider) //{ // _provider = serviceProvider; //} public static async Task NewMedcine(Update update, TelegramBotClient Bot, IServiceProvider _provider) { using IServiceScope scope = _provider.CreateScope(); var _context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); var message = update.Message; var scenario = new Scenario() { Id = Guid.NewGuid(), Type = ScenarioType.AddMedcine, Finished = false, //QuestionTreeId = Guid.Parse("guid добавления лекарства"), StartDate = DateTimeOffset.Now, UserId = message.From.Id }; _context.Add(scenario); var medcine = new Medcin() { Id = Guid.NewGuid() }; _context.Add(medcine); var firstQuestion = _context.Questions .Include(c => c.QuestionTree) .Where(c => c.IsFirst == true) .Where(c => c.QuestionTree.Type == QuestionTreeType.AddMedcine) .FirstOrDefault(); await Bot.SendTextMessageAsync( chatId : message.Chat.Id, text : firstQuestion.Text ); var history = new QuestionTreeHistory() { Id = Guid.NewGuid(), CreateDate = DateTimeOffset.Now, QuestionId = firstQuestion.Id, //QuestionTreeId = scenario.QuestionTreeId, UserId = message.From.Id, MedcinId = medcine.Id, ScenarioId = scenario.Id }; _context.Add(history); _context.SaveChanges(); }
private void creeAdmission() { Lit lit = new Lit(); if (cmbNumLit.SelectedItem != null) { lit = cmbNumLit.SelectedItem as Lit; lit.Occupe = true; } //On retourne le medecin selectionne Medcin medcin = cmbMedecin.SelectedItem as Medcin; //On verifie si une admission actuel existe deja dans le system if ((from a in myBdd.Admissions where a.NSS == txtAdmissionNSS.Text & a.Numero_Lit != null select a).Any()) { MessageBox.Show("Une admission pour ce patient existe deja dans le systeme"); } else { Admission nouvelleAdmission = new Admission { Chirurgie_programme = (bool)chkChirurgieProg.IsChecked, Date_admission = DateTime.Now, Date_chirurgie = datePickChirurgie.SelectedDate, Televiseur = (bool)chkTeleviseur.IsChecked, NSS = txtAdmissionNSS.Text, Numero_Lit = lit.Numero_lit, ID_Medcin = medcin.ID_Medcin }; try { myBdd.Admissions.Add(nouvelleAdmission); myBdd.SaveChanges(); MessageBox.Show("Nouvelle admission ajouter avec succes"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void btnAjouterMedcin_Click(object sender, RoutedEventArgs e) { string nomMedcin = txtNomMedcin.Text; string prenomMedcin = txtPrenomMedcin.Text; //Validation si les champs ne sont pas vide if (nomMedcin != "" & prenomMedcin != "") { //On cree la nouvelle instance d'un Medcin et on rempli les parametres necessaires Medcin medcin = new Medcin { nom = nomMedcin, prenom = prenomMedcin }; //Validation de l'enregistrement au niveau de la bdd try { //Ajout du medcin dans la bdd myBdd.Medcins.Add(medcin); myBdd.SaveChanges(); //On refresh la liste avec les nouvelles donnee lstMedcinAdmin.DataContext = myBdd.Medcins.ToList(); //On vide les champs apres l'operation txtNomMedcin.Text = ""; txtPrenomMedcin.Text = ""; lstMedcinAdmin.UnselectAll(); } catch (Exception) { MessageBox.Show("Erreur d'entregistrement. L'ajout n'a pas pu etre apporter", "Erreur d'enregistrement!"); } } else { MessageBox.Show("Tous les champs doivent etre rempli!", "Champs Vide!"); } }
private void btnSuppMedcin_Click(object sender, RoutedEventArgs e) { //Capter le medcin choisi pour ensuite faire les modification Medcin medcinSelectionee = lstMedcinAdmin.SelectedItem as Medcin; //Essaie de supprimer le medcin, si on rencontre un erruer on affiche un message pour laisser savoir a l'utilisateur. try { myBdd.Medcins.Remove(medcinSelectionee); myBdd.SaveChanges(); lstMedcinAdmin.DataContext = myBdd.Medcins.ToList(); //On vide les champs apres l'operation txtNomMedcin.Text = ""; txtPrenomMedcin.Text = ""; lstMedcinAdmin.UnselectAll(); } catch (Exception) { MessageBox.Show("La supression n'a pas ete complete.", "Erreur de supression!"); } }