private void btnGrid_Click(object sender, RoutedEventArgs e) { if (DatagGrid.SelectedIndex != -1) { DataofExm dfg = (DataofExm)(DatagGrid.SelectedItem); for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; if (row[0].ToString() == dfg.numero.ToString()) { string path = row[4].ToString(); try { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = path; process.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } } } }
private void loadExm() { table = new DataTable(); DataGridTextColumn g0 = new DataGridTextColumn(); DataGridTextColumn g1 = new DataGridTextColumn(); DataGridTextColumn g2 = new DataGridTextColumn(); g0.Binding = new Binding("numero"); g0.Header = ""; g0.MaxWidth = 0; g1.Binding = new Binding("type"); g1.Header = "Type Examen"; g0.Width = 150; g2.Binding = new Binding("conclusion"); g2.Header = "Conclusion"; g2.MaxWidth = 300; g2.MinWidth = 300; DatagGrid.Columns.Add(g0); DatagGrid.Columns.Add(g1); DatagGrid.Columns.Add(g2); DatagGrid.Columns[0].DisplayIndex = 3; ConnexionBDD Datab = new ConnexionBDD(); Datab.connecter(); String Command = "SELECT * from Examen_Complementaire where Id_Dossier=" + IDDOSS; SqlCommand Macmd = new SqlCommand(Command, Datab.cnx); SqlDataReader dr = Macmd.ExecuteReader(); while (dr.Read()) { DataofExm ordodata = new DataofExm(); ordodata.numero = int.Parse(dr[0].ToString()); ordodata.type = dr[2].ToString(); ordodata.conclusion = dr[3].ToString(); DatagGrid.Items.Add(ordodata); } dr.Close(); SqlDataAdapter Daptr = new SqlDataAdapter(Macmd); Daptr.Fill(table); }
private void Supprimer_Click_1(object sender, RoutedEventArgs e) { if (DatagGrid.SelectedIndex >= 0) { DataofExm dataa = (DataofExm)(DatagGrid.SelectedItem); ConnexionBDD Datab = new ConnexionBDD(); Datab.connecter(); String Command = "DELETE FROM Examen_Complementaire where Id_Ex_Comp=" + dataa.numero; SqlCommand Macmd = new SqlCommand(Command, Datab.cnx); Macmd.ExecuteNonQuery(); Datab.deconnecter(); DatagGrid.Items.Remove(dataa); } }
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]; DataofExm ordodata = new DataofExm(); ordodata.numero = int.Parse(dr[0].ToString()); ordodata.type = dr[2].ToString(); ordodata.conclusion = dr[3].ToString(); DatagGrid.Items.Add(ordodata); } }
private void Enregistrer_Click(object sender, RoutedEventArgs e) { if (Type.Text != "" && Conclustion.Text != "") { Examen_Complémentaire exm = new Examen_Complémentaire(Type.Text, Conclustion.Text, FilePath.Text, IDDOSS); exm.Insert_Exm_Comp(); DataofExm ordodata = new DataofExm(); ordodata.numero = exm.Get_Id(); ordodata.type = Type.Text; ordodata.conclusion = Conclustion.Text; DatagGrid.Items.Add(ordodata); MessageBox.Show("Examen enregistré avec succès"); App.iff.support_fonction.NavigationService.Navigate(new Page_Examen_Comp(IDDOSS, IDMED, ADMIN, true, IDPAT)); this.AffichageStack.Visibility = Visibility.Hidden; this.Affichage2.Visibility = Visibility.Visible; this.DonnerExam.Visibility = Visibility.Hidden; this.vider(); } else { MessageBox.Show("Remplissez toutes les cases!"); } }