private void patientGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (DatagGrid.SelectedIndex > -1) { DataofPatient dofpatient = (DataofPatient)(DatagGrid.SelectedItem); this.idpatient = dofpatient.numero; buttonConsulter.IsEnabled = true; buttonDelpat.IsEnabled = true; this.Afficher.IsEnabled = true; } }
public void addtoDatagGrid(string nom, string prenom, DateTime date, string adresse, string grp, string numt, int id) { DataofPatient dofpatient = new DataofPatient(); dofpatient.nom = nom; dofpatient.prenom = prenom; dofpatient.date = date; dofpatient.adr = adresse; dofpatient.grp = grp; dofpatient.num = numt; dofpatient.numero = id; DatagGrid.Items.Add(dofpatient); ConnexionBDD Datab = new ConnexionBDD(); Datab.connecter(); String Command = @"select Nom,Prenom,Date_de_naissance,Adresse,Groupe_sanguin,Num_Tel"; Command += @",Id_Patient from Patient LEFT OUTER JOIN Person on Person.Id_Person=Patient.Id_Person order by Nom"; SqlCommand Macmd = new SqlCommand(Command, Datab.cnx); SqlDataAdapter DAPTR = new SqlDataAdapter(Macmd); DATBL = new DataTable(); DAPTR.Fill(DATBL); Datab.deconnecter(); }
private void Rempliravec(DataTable tmp) { for (int i = DatagGrid.Items.Count - 1; i >= 0; i--) { DatagGrid.Items.RemoveAt(i); } for (int i = tmp.Rows.Count - 1; i >= 0; i--) { DataRow dr = tmp.Rows[i]; DataofPatient dofpatient = new DataofPatient(); dofpatient.nom = dr[0].ToString(); dofpatient.prenom = dr[1].ToString(); dofpatient.date = DateTime.Parse(dr[2].ToString()); dofpatient.adr = dr[3].ToString(); dofpatient.grp = dr[4].ToString(); dofpatient.num = dr[5].ToString(); dofpatient.numero = int.Parse(dr[6].ToString()); DatagGrid.Items.Add(dofpatient); } }
//************************************************************************** private void patientGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { //DataGrid Dg = sender as DataGrid; //DataRowView Drv = Dg.SelectedItem as DataRowView; //if (Drv != null) //{ // this.idpatient = int.Parse(Drv[4].ToString()); // this.nom_p = Drv[0].ToString(); // this.prenom_p = Drv[1].ToString(); // buttonSélèctioner.IsEnabled = true; //} if (patientGrid.SelectedIndex > -1) { DataofPatient datardv = (DataofPatient)(patientGrid.SelectedItem); this.idpatient = datardv.numero; this.nom_p = datardv.nom; this.prenom_p = datardv.prenom; buttonSélèctioner.IsEnabled = true; } }
private void Loadpatient() { //ConnexionBDD Datab = new ConnexionBDD(); //Datab.connecter(); //String Command = @"select Nom,Prenom,Date_de_naissance,Adresse"; //Command = Command + @",Id_Patient as [Référence Patient] from Patient LEFT OUTER JOIN Person on Person.Id_Person=Patient.Id_Person order by Nom"; //SqlCommand Macmd = new SqlCommand(Command, Datab.cnx); //SqlDataAdapter DAPTR = new SqlDataAdapter(Macmd); //DATB = new DataTable(); //DAPTR.Fill(DATB); //patientGrid.ItemsSource = DATB.DefaultView; DataGridTextColumn g0 = new DataGridTextColumn(); g0.Binding = new Binding("nom"); g0.Header = "Nom"; DataGridTextColumn g1 = new DataGridTextColumn(); g1.Binding = new Binding("prenom"); g1.Header = "Prenom"; DataGridTextColumn g2 = new DataGridTextColumn(); g2.Binding = new Binding("date"); g2.Header = "Date de naissance"; g2.MaxWidth = 150; DataGridTextColumn g3 = new DataGridTextColumn(); g3.Binding = new Binding("adr"); g3.Header = "Adresse"; g3.MaxWidth = 150; DataGridTextColumn g6 = new DataGridTextColumn(); g6.Binding = new Binding("numero"); g6.Header = "Référence Patient"; patientGrid.Columns.Add(g0); patientGrid.Columns.Add(g1); patientGrid.Columns.Add(g2); patientGrid.Columns.Add(g3); patientGrid.Columns.Add(g6); g2.ClipboardContentBinding.StringFormat = "d"; ConnexionBDD Datab = new ConnexionBDD(); Datab.connecter(); String Command = @"select Nom,Prenom,Date_de_naissance,Adresse"; Command += @",Id_Patient from Patient LEFT OUTER JOIN Person on Person.Id_Person=Patient.Id_Person order by Nom"; SqlCommand Macmd = new SqlCommand(Command, Datab.cnx); SqlDataReader dr = Macmd.ExecuteReader(); while (dr.Read()) { DataofPatient dofpatient = new DataofPatient(); dofpatient.nom = dr[0].ToString(); dofpatient.prenom = dr[1].ToString(); dofpatient.date = DateTime.Parse(dr[2].ToString()); dofpatient.adr = dr[3].ToString(); dofpatient.numero = int.Parse(dr[4].ToString()); patientGrid.Items.Add(dofpatient); } dr.Close(); }
private void Loadpatient() { DATBL = new DataTable(); DataGridTextColumn g0 = new DataGridTextColumn(); g0.Binding = new Binding("nom"); g0.Header = "Nom"; DataGridTextColumn g1 = new DataGridTextColumn(); g1.Binding = new Binding("prenom"); g1.Header = "Prenom"; DataGridTextColumn g2 = new DataGridTextColumn(); g2.Binding = new Binding("date"); g2.Header = "Date de naissance"; g2.MaxWidth = 150; DataGridTextColumn g3 = new DataGridTextColumn(); g3.Binding = new Binding("adr"); g3.Header = "Adresse"; g3.MaxWidth = 150; DataGridTextColumn g4 = new DataGridTextColumn(); g4.Binding = new Binding("grp"); g4.Header = "Groupe sanguin"; DataGridTextColumn g5 = new DataGridTextColumn(); g5.Binding = new Binding("num"); g5.Header = "Numero Telephone"; DataGridTextColumn g6 = new DataGridTextColumn(); g6.Binding = new Binding("numero"); g6.Header = "Référence Patient"; g6.MaxWidth = 0; DatagGrid.Columns.Add(g0); DatagGrid.Columns.Add(g1); DatagGrid.Columns.Add(g2); DatagGrid.Columns.Add(g3); DatagGrid.Columns.Add(g4); DatagGrid.Columns.Add(g5); DatagGrid.Columns.Add(g6); g2.ClipboardContentBinding.StringFormat = "d"; ConnexionBDD Datab = new ConnexionBDD(); Datab.connecter(); String Command = @"select Nom,Prenom,Date_de_naissance,Adresse,Groupe_sanguin,Num_Tel"; Command += @",Id_Patient from Patient LEFT OUTER JOIN Person on Person.Id_Person=Patient.Id_Person order by Nom"; SqlCommand Macmd = new SqlCommand(Command, Datab.cnx); SqlDataReader dr = Macmd.ExecuteReader(); while (dr.Read()) { DataofPatient dofpatient = new DataofPatient(); dofpatient.nom = dr[0].ToString(); dofpatient.prenom = dr[1].ToString(); dofpatient.date = DateTime.Parse(dr[2].ToString()); dofpatient.adr = dr[3].ToString(); dofpatient.grp = dr[4].ToString(); dofpatient.num = dr[5].ToString(); dofpatient.numero = int.Parse(dr[6].ToString()); DatagGrid.Items.Add(dofpatient); } dr.Close(); SqlDataAdapter DAPTR = new SqlDataAdapter(Macmd); DATBL = new DataTable(); DAPTR.Fill(DATBL); Datab.deconnecter(); }
private void buttouisupp_Click(object sender, RoutedEventArgs e) { int id_doss = -1, id_prs = -1; ConnexionBDD Datab = new ConnexionBDD(); Datab.connecter(); String command = "SELECT Id_Dossier FROM Dossier_medical WHERE Id_Patient=" + idpatient; SqlCommand Macmd = new SqlCommand(command, Datab.cnx); SqlDataReader dr = Macmd.ExecuteReader(); if (dr.Read()) { id_doss = (int)dr["Id_Dossier"]; } dr.Close(); command = "SELECT Id_Person FROM Patient WHERE Id_patient=" + idpatient; Macmd = new SqlCommand(command, Datab.cnx); dr = Macmd.ExecuteReader(); if (dr.Read()) { id_prs = (int)dr["Id_Person"]; } dr.Close(); command = "DELETE FROM Certeficat_medical WHERE Id_FC in (SELECT Id_FC FROM Contient WHERE Id_DM =" + id_doss + ")"; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Prescrire WHERE Id_Ordonnance in (SELECT Id_Ordonnance FROM Ordonnance WHERE Id_FC in (SELECT Id_FC FROM Contient WHERE Id_DM =" + id_doss + "))"; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Ordonnance WHERE Id_FC in (SELECT Id_FC FROM Contient WHERE Id_DM =" + id_doss + ")"; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Contient WHERE Id_DM=" + id_doss; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Fiche_Consultation WHERE Id_Fiche_Consultation not in (SELECT Contient.Id_FC FROM Contient)"; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Lettre WHERE Id_DM =" + id_doss; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Examine_Comp WHERE Id_DM =" + id_doss; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Examen_Complementaire WHERE Id_Ex_Comp not in (SELECT Id_DM From Examine_Comp)"; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Avoir_RDV WHERE Id_RDV in(SELECT Id_RDV FROM [Rendez-vous] WHERE Id_Patient=" + idpatient + ")"; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM [Rendez-vous] WHERE Id_Patient=" + idpatient; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Dossier_medical WHERE Id_Patient=" + idpatient; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Patient WHERE Id_Patient=" + idpatient; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); command = "DELETE FROM Person WHERE Id_Person=" + id_prs; Macmd = new SqlCommand(command, Datab.cnx); Macmd.ExecuteNonQuery(); bool del = false; int i = 0; while (!del && i < DatagGrid.Items.Count) { DataofPatient da = (DataofPatient)(DatagGrid.Items[i]); if (da.numero == this.idpatient) { DatagGrid.Items.RemoveAt(i); del = true; } i++; } Stackconfirmsupp.Visibility = System.Windows.Visibility.Hidden; RecStackconfirmsupp.Visibility = System.Windows.Visibility.Hidden; grdpatt.IsEnabled = true; }