public Page(string u) { InitializeComponent(); this.user = u; this.hideAllGrids(); CPNNotification.Visibility = Visibility.Hidden; CPoNNotification.Visibility = Visibility.Hidden; Int32 rdv = RDVS.NombreTotalPatient(); TotalPatiente.Content = Convert.ToString(rdv); rdv = RDVS.NombreTotalPatientStatut("En attente"); PatienteEnAttente.Content = rdv.ToString(); rdv = RDVS.NombreTotalPatientStatut("Effectué"); ConsultationEffectuees.Content = rdv.ToString(); rdv = RDVS.NombreTotalPatientType("cpn"); Prenatale.Content = rdv.ToString(); rdv = RDVS.NombreTotalPatientType("cpon"); Postnatale.Content = rdv.ToString(); rdv = RDVS.NombreTotalPatientType("echo"); Echographie.Content = rdv.ToString(); AcceuilGrid.Visibility = Visibility.Visible; if (DateTime.Today.Day.ToString() == "1") { CPNNotification.Visibility = Visibility.Visible; CPoNNotification.Visibility = Visibility.Visible; RapportCPN.CreerRapport(); RapportCPoN.CreerRapport(); } }
public static void persistRDV(RDVS p) { SqlConnection c = Connexion.connect(); SqlCommand command; SqlDataReader dataReader; DateTime t = DateTime.Today.Date; if (p.Date.Date < t) { MessageBox.Show("Impossible de réserver dans le :" + p.Date.ToString()); throw new Exception(); } string tab = "rdv(id_patient,date,heure,duree,heure_fin,type_rdv,description,nom_patient,prenom_patient,statut)"; string v = "values(" + Convert.ToInt32(p.IdPatient) + ",'" + p.Date.Date + "','" + p.Heure + "','" + p.Duree + "','" + p.HeureFin + "','" + p.TypeRDV + "','" + p.Description + "','" + p.NomPatient + "','" + p.PrenomPatient + "','" + p.Statut + "')"; string q = "insert into " + tab + " " + v; try { c.Open(); command = new SqlCommand(q, c); dataReader = command.ExecuteReader(); dataReader.Close(); command.Dispose(); MessageBox.Show("RDV ajouté avec succès"); c.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//********************************************************************Acceuil private void AfficherRDVDuJour_Click(object sender, MouseButtonEventArgs e) { rdvDataGrid.ItemsSource = RDVS.AfficherRDVAujourdhui().DefaultView; this.hideAllGrids(); this.initialiserRDVChamp(); RemplirRDVGrid.Visibility = Visibility.Hidden; ChoisirPatientPourRDVGrid.Visibility = Visibility.Hidden; ListeRDV.Visibility = Visibility.Visible; RDVGrid.Visibility = Visibility.Visible; }
public static bool RDVIsFree(RDVS d, string idd) { RDVS p = new RDVS(); int t1, t2, t1comp, t2comp; string[] dd = d.Heure.Split(':'); t1 = (Convert.ToInt32(dd[0]) * 60) + Convert.ToInt32(dd[1]); string[] hh = d.HeureFin.Split(':'); t2 = (Convert.ToInt32(hh[0]) * 60) + Convert.ToInt32(hh[1]); SqlConnection c = Connexion.connect(); SqlCommand command; SqlDataReader dataReader; string q = "Select * from rdv where date='" + d.Date.Date + "' and statut='En attente' and id != " + Convert.ToInt32(idd); try { c.Open(); command = new SqlCommand(q, c); dataReader = command.ExecuteReader(); while (dataReader.Read()) { if (dataReader.HasRows) { p.Heure = dataReader["heure"].ToString(); p.HeureFin = dataReader["heure_fin"].ToString(); string[] dd1 = p.Heure.Split(':'); t1comp = (Convert.ToInt32(dd1[0]) * 60) + Convert.ToInt32(dd1[1]); string[] hh1 = p.HeureFin.Split(':'); t2comp = (Convert.ToInt32(hh1[0]) * 60) + Convert.ToInt32(hh1[1]); if ((t1 >= t1comp && t1 <= t2comp) || (t2 >= t1comp && t2 <= t2comp) || (t1 <= t1comp && t2 >= t2comp)) { MessageBox.Show("Rendez-vous déjà pris !! Veuillez choisir une autre heure"); return(false); } else if (t2 >= 930) { MessageBox.Show("Rendez-vous dépasse le temps réglementaire !! Veuillez choisir une autre heure"); return(false); } } } dataReader.Close(); command.Dispose(); c.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(true); }
private void AfficherRDVDuJourEcho_Click(object sender, MouseButtonEventArgs e) { try { rdvDataGrid.ItemsSource = RDVS.AfficherRDVAujourdhuiAvecType("echo").DefaultView; this.hideAllGrids(); this.initialiserRDVChamp(); RemplirRDVGrid.Visibility = Visibility.Hidden; ChoisirPatientPourRDVGrid.Visibility = Visibility.Hidden; ListeRDV.Visibility = Visibility.Visible; RDVGrid.Visibility = Visibility.Visible; } catch (Exception) { System.Windows.MessageBox.Show("Aucune échographie n'est prévue pour aujourd'hui"); } }
private void AfficherRDVDuJourEffectue_Click(object sender, MouseButtonEventArgs e) { try { rdvDataGrid.ItemsSource = RDVS.AfficherRDVAujourdhuiAvecStatut("Effectué").DefaultView; this.hideAllGrids(); this.initialiserRDVChamp(); RemplirRDVGrid.Visibility = Visibility.Hidden; ChoisirPatientPourRDVGrid.Visibility = Visibility.Hidden; ListeRDV.Visibility = Visibility.Visible; RDVGrid.Visibility = Visibility.Visible; } catch (Exception) { System.Windows.MessageBox.Show("Aucune consultation n'a été efféctuée"); } }
private void Accueil_Click(object sender, RoutedEventArgs e) { this.hideAllGrids(); Int32 rdv = RDVS.NombreTotalPatient(); TotalPatiente.Content = Convert.ToString(rdv); rdv = RDVS.NombreTotalPatientStatut("En attente"); PatienteEnAttente.Content = rdv.ToString(); rdv = RDVS.NombreTotalPatientStatut("Effectué"); ConsultationEffectuees.Content = rdv.ToString(); rdv = RDVS.NombreTotalPatientType("cpn"); Prenatale.Content = rdv.ToString(); rdv = RDVS.NombreTotalPatientType("cpon"); Postnatale.Content = rdv.ToString(); rdv = RDVS.NombreTotalPatientType("echo"); Echographie.Content = rdv.ToString(); AcceuilGrid.Visibility = Visibility.Visible; }
private void deleteRDV_Click(object sender, RoutedEventArgs e) { try { DataRowView dtr = (DataRowView)rdvDataGrid.SelectedItem; string message, caption; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; DataRowView row = (DataRowView)((System.Windows.Controls.Button)e.Source).DataContext; message = "Êtes-vous sûre de vouloir supprimer ce RDV ?"; caption = "Suppression de RDV"; result = System.Windows.Forms.MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { RDVS.deleteRDV(dtr["id"].ToString()); Int32 rdv = RDVS.NombreTotalPatient(); TotalPatiente.Content = Convert.ToString(rdv); this.PageWindow_Loaded(sender, e); } } catch (Exception) { } }
public static RDVS getRDV(string id) { RDVS p = new RDVS(); SqlConnection c = Connexion.connect(); SqlCommand command; SqlDataReader dataReader; string q = "Select * from rdv where id=" + Convert.ToInt32(id) + ""; try { c.Open(); command = new SqlCommand(q, c); dataReader = command.ExecuteReader(); while (dataReader.Read()) { if (dataReader.HasRows) { p.Id = dataReader["id"].ToString(); p.IdPatient = dataReader["id_patient"].ToString(); p.NomPatient = dataReader["nom_patient"].ToString(); p.PrenomPatient = dataReader["prenom_patient"].ToString(); p.Date = Convert.ToDateTime(dataReader["date"].ToString()); p.Heure = dataReader["heure"].ToString(); p.Description = dataReader["description"].ToString(); p.Statut = dataReader["statut"].ToString(); p.Duree = dataReader["duree"].ToString(); p.HeureFin = dataReader["heure_fin"].ToString(); p.TypeRDV = dataReader["type_rdv"].ToString(); } } dataReader.Close(); command.Dispose(); c.Close(); } catch (Exception) { } return(p); }
private void chercherRDV_click(object sender, RoutedEventArgs e) { string selectedItem = ""; switch (comboBoxRDV.SelectionBoxItem.ToString()) { case "Type de RDV": selectedItem = "type_rdv"; break; case "Nom de la patiente": selectedItem = "nom_patient"; break; case "Prénom de la patiente": selectedItem = "prenom_patient"; break; case "Statut du RDV": selectedItem = "statut"; break; } try { if (DatePickerRDV.SelectedDate.ToString().Equals("")) { rdvDataGrid.ItemsSource = RDVS.chercherRDV(selectedItem, RDVSearchText.Text.Replace("'", "''")).DefaultView; } else { rdvDataGrid.ItemsSource = RDVS.chercherRDVAvecDate(selectedItem, RDVSearchText.Text.Replace("'", "''"), (DateTime)DatePickerRDV.SelectedDate).DefaultView; } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } }
public static void ModifyRDV(RDVS p) { SqlConnection c = Connexion.connect(); SqlCommand command; SqlDataReader dataReader; DateTime d = p.Date; string q; q = "update rdv set id_patient=" + Convert.ToInt32(p.IdPatient) + ", nom_patient='" + p.NomPatient + "',prenom_patient='" + p.PrenomPatient + "',date='" + d.Date + "',heure='" + p.Heure + "',description='" + p.Description + "',statut='" + p.Statut + "',duree='" + p.Duree + "',heure_fin='" + p.HeureFin + "',type_rdv='" + p.TypeRDV + "' where id=" + Convert.ToInt32(p.Id); try { c.Open(); command = new SqlCommand(q, c); dataReader = command.ExecuteReader(); dataReader.Close(); command.Dispose(); c.Close(); MessageBox.Show("Modification avec succès"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ModifierRDV_Click(object sender, RoutedEventArgs e) { try { DataRowView dtr = (DataRowView)rdvDataGrid.SelectedItem; this.hideAllGrids(); this.initialiserRDVChamp(); this.type = "modifier"; RDVS r = RDVS.getRDV(dtr["id"].ToString()); this.id = r.Id; this.id_patient = r.IdPatient; if (r.TypeRDV.Trim(' ') == "CPN1") { cpn1.IsChecked = true; } else if (r.TypeRDV.Trim(' ') == "CPN2") { cpn2.IsChecked = true; } else if (r.TypeRDV.Trim(' ') == "CPN3") { cpn3.IsChecked = true; } else if (r.TypeRDV.Trim(' ') == "CPN4") { cpn4.IsChecked = true; } else if (r.TypeRDV.Trim(' ') == "Autre") { autreType.IsChecked = true; } else if (r.TypeRDV.Trim(' ') == "Echographie") { echographie.IsChecked = true; } else if (r.TypeRDV.Trim(' ') == "CPoN1") { cpon1.IsChecked = true; } else if (r.TypeRDV.Trim(' ') == "CPoN2") { cpon2.IsChecked = true; } if (r.Statut.Trim(' ') == "En attente") { enAttente.IsChecked = true; } else if (r.Statut.Trim(' ') == "Effectué") { effectue.IsChecked = true; } NomPatientRDV.Text = r.NomPatient; PrenomPatientRDV.Text = r.PrenomPatient; dateRDV.Text = r.Date.ToString(); string[] heure = r.Heure.Trim(' ').Split(':'); comboBoxHeureRDV.Text = heure[0]; comboBoxMinuteRDV.Text = heure[1]; string[] duree = r.Duree.Trim(' ').Split(':'); comboBoxDureeHeure.Text = duree[0]; comboBoxDureeMinute.Text = duree[1]; descriptionRDV.Text = r.Description; RDVGrid.Visibility = Visibility.Visible; RemplirRDVGrid.Visibility = Visibility.Visible; ListeRDV.Visibility = Visibility.Hidden; } catch (Exception) { } }
private void EnregistrerRDV_Click(object sender, RoutedEventArgs e) { RDVS r = new RDVS(); try { if (!((bool)cpn1.IsChecked) && !((bool)cpn2.IsChecked) && !((bool)cpn3.IsChecked) && !((bool)cpn4.IsChecked) && !((bool)autreType.IsChecked) && !((bool)cpon1.IsChecked) && !((bool)cpon2.IsChecked) && !((bool)echographie.IsChecked)) { System.Windows.MessageBox.Show("Veuillez choisir un type de CPN"); throw new Exception(); } else if (((bool)cpn1.IsChecked) && !((bool)cpn2.IsChecked) && !((bool)cpn3.IsChecked) && !((bool)cpn4.IsChecked) && !((bool)autreType.IsChecked) && !((bool)cpon1.IsChecked) && !((bool)cpon2.IsChecked) && !((bool)echographie.IsChecked)) { r.TypeRDV = "CPN1"; } else if (((bool)cpn2.IsChecked) && !((bool)cpn1.IsChecked) && !((bool)cpn3.IsChecked) && !((bool)cpn4.IsChecked) && !((bool)autreType.IsChecked) && !((bool)cpon1.IsChecked) && !((bool)cpon2.IsChecked) && !((bool)echographie.IsChecked)) { r.TypeRDV = "CPN2"; } else if (((bool)cpn3.IsChecked) && !((bool)cpn2.IsChecked) && !((bool)cpn1.IsChecked) && !((bool)cpn4.IsChecked) && !((bool)autreType.IsChecked) && !((bool)cpon1.IsChecked) && !((bool)cpon2.IsChecked) && !((bool)echographie.IsChecked)) { r.TypeRDV = "CPN3"; } else if (((bool)cpn4.IsChecked) && !((bool)cpn2.IsChecked) && !((bool)cpn3.IsChecked) && !((bool)cpn1.IsChecked) && !((bool)autreType.IsChecked) && !((bool)cpon1.IsChecked) && !((bool)cpon2.IsChecked) && !((bool)echographie.IsChecked)) { r.TypeRDV = "CPN4"; } else if (((bool)autreType.IsChecked) && !((bool)cpn2.IsChecked) && !((bool)cpn3.IsChecked) && !((bool)cpn4.IsChecked) && !((bool)cpn1.IsChecked) && !((bool)cpon1.IsChecked) && !((bool)cpon2.IsChecked) && !((bool)echographie.IsChecked)) { r.TypeRDV = "Autre"; } else if (((bool)cpon1.IsChecked) && !((bool)cpon2.IsChecked) && !((bool)cpn2.IsChecked) && !((bool)cpn3.IsChecked) && !((bool)cpn4.IsChecked) && !((bool)cpn1.IsChecked) && !((bool)autreType.IsChecked) && !((bool)echographie.IsChecked)) { r.TypeRDV = "CPoN1"; } else if (((bool)cpon2.IsChecked) && !((bool)cpon1.IsChecked) && !((bool)cpn2.IsChecked) && !((bool)cpn3.IsChecked) && !((bool)cpn4.IsChecked) && !((bool)cpn1.IsChecked) && !((bool)echographie.IsChecked) && !((bool)autreType.IsChecked)) { r.TypeRDV = "CPoN2"; } else if (((bool)echographie.IsChecked) && !((bool)cpn2.IsChecked) && !((bool)cpn3.IsChecked) && !((bool)cpn4.IsChecked) && !((bool)cpn1.IsChecked) && !((bool)cpon1.IsChecked) && !((bool)cpon2.IsChecked) && !((bool)autreType.IsChecked)) { r.TypeRDV = "Echographie"; } else { System.Windows.MessageBox.Show("Plusieurs champs sont séléctionner dans le type de CPN"); throw new Exception(); } r.NomPatient = NomPatientRDV.Text.Replace("'", "''"); r.PrenomPatient = PrenomPatientRDV.Text.Replace("'", "''"); r.Date = (DateTime)dateRDV.SelectedDate; r.Duree = comboBoxDureeHeure.SelectionBoxItem.ToString() + ":" + comboBoxDureeMinute.ToString(); if (!(bool)enAttente.IsChecked && !(bool)effectue.IsChecked) { System.Windows.MessageBox.Show("Veuillez choisir le statut du RDV"); throw new Exception(); } else if ((bool)enAttente.IsChecked && !(bool)effectue.IsChecked) { r.Statut = "En attente"; } else if (!(bool)enAttente.IsChecked && (bool)effectue.IsChecked) { r.Statut = "Effectué"; } else if ((bool)enAttente.IsChecked && (bool)effectue.IsChecked) { System.Windows.MessageBox.Show("Veuillez cocher un seul statut"); throw new Exception(); } if (comboBoxHeureRDV.Text.Trim(' ') == "") { System.Windows.MessageBox.Show("Veuillez saisir l'heure du RDV"); throw new Exception(); } else { r.Heure = comboBoxHeureRDV.SelectionBoxItem.ToString() + ":" + comboBoxMinuteRDV.SelectionBoxItem.ToString(); } if ((comboBoxDureeHeure.SelectionBoxItem.ToString().Trim(' ').Equals("00")) && (comboBoxDureeMinute.SelectionBoxItem.ToString().Trim(' ').Equals("00"))) { System.Windows.MessageBox.Show(comboBoxDureeHeure.SelectionBoxItem.ToString().Trim(' ') + ":" + comboBoxDureeMinute.SelectionBoxItem.ToString().Trim(' ')); System.Windows.MessageBox.Show("Veuillez saisir la durée du RDV"); throw new Exception(); } else { r.Duree = comboBoxDureeHeure.SelectionBoxItem.ToString() + ":" + comboBoxDureeMinute.SelectionBoxItem.ToString(); } int d = Convert.ToInt32(comboBoxDureeMinute.SelectionBoxItem) + Convert.ToInt32(comboBoxMinuteRDV.SelectionBoxItem); switch (d) { case 90: r.HeureFin = Convert.ToString(Convert.ToInt32(comboBoxDureeHeure.SelectionBoxItem) + Convert.ToInt32(comboBoxHeureRDV.SelectionBoxItem) + 1) + ":30"; break; case 75: r.HeureFin = Convert.ToString(Convert.ToInt32(comboBoxDureeHeure.SelectionBoxItem) + Convert.ToInt32(comboBoxHeureRDV.SelectionBoxItem) + 1) + ":15"; break; case 60: r.HeureFin = Convert.ToString(Convert.ToInt32(comboBoxDureeHeure.SelectionBoxItem) + Convert.ToInt32(comboBoxHeureRDV.SelectionBoxItem) + 1) + ":00"; break; default: string m = Convert.ToString(Convert.ToInt32(comboBoxDureeMinute.SelectionBoxItem) + Convert.ToInt32(comboBoxMinuteRDV.SelectionBoxItem)); r.HeureFin = Convert.ToString(Convert.ToInt32(comboBoxDureeHeure.SelectionBoxItem) + Convert.ToInt32(comboBoxHeureRDV.SelectionBoxItem)) + ":" + m; break; } r.Description = descriptionRDV.Text.Replace("'", "''"); if (this.type == "ajouter" && RDVS.RDVIsFree(r)) { if (NomPatientRDV.IsReadOnly) { r.IdPatient = this.id_patient; } else { System.Windows.MessageBox.Show("Veuillez choisir un patient"); throw new Exception(); } RDVS.persistRDV(r); RemplirRDVGrid.Visibility = Visibility.Hidden; this.PageWindow_Loaded(sender, e); ListeRDV.Visibility = Visibility.Visible; } else if (this.type == "modifier" && RDVS.RDVIsFree(r, this.id)) { if (NomPatientRDV.IsReadOnly) { r.IdPatient = this.id_patient; } else { System.Windows.MessageBox.Show("Veuillez choisir un patient"); throw new Exception(); } r.Id = this.id; RDVS.ModifyRDV(r); RemplirRDVGrid.Visibility = Visibility.Hidden; this.PageWindow_Loaded(sender, e); ListeRDV.Visibility = Visibility.Visible; } Int32 rdv = RDVS.NombreTotalPatient(); TotalPatiente.Content = Convert.ToString(rdv); } catch (Exception) { System.Windows.MessageBox.Show("Veuillez vérifier les champs du RDV"); } }