public static void ModifyEchographie(Echographie p) { DateTime da = DateTime.Today; SqlConnection c = Connexion.connect(); SqlCommand command; string q = "update echographie set date_echo='" + p.DateEchographie.Date + "',Description='" + p.DescriptionEchographie + "' where id=" + Convert.ToInt32(p.Id); try { c.Open(); command = new SqlCommand(q, c); command.ExecuteNonQuery(); command.Dispose(); q = "update dossier_patient set date_modification='" + da.Date + "' where id=" + Convert.ToInt32(p.IdDossier); command = new SqlCommand(q, c); command.ExecuteNonQuery(); command.Dispose(); c.Close(); MessageBox.Show("Modification avec succès"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static Echographie getEcho(string id) { Echographie p = new Echographie(); SqlConnection c = Connexion.connect(); SqlCommand command; SqlDataReader dataReader; string q = "Select * from echographie where id=" + Convert.ToInt32(id) + ""; try { c.Open(); command = new SqlCommand(q, c); dataReader = command.ExecuteReader(); while (dataReader.Read()) { if (dataReader.HasRows) { p.DateEchographie = (DateTime)dataReader["date_echo"]; p.DescriptionEchographie = dataReader["Description"].ToString(); } } dataReader.Close(); command.Dispose(); c.Close(); } catch (Exception) { } return(p); }
public static void persistEchographie(Echographie r) { SqlConnection c = Connexion.connect(); SqlCommand command; DateTime d = DateTime.Today; string tab = "echographie(id_dossier,date_echo,Description)"; string v = "values(" + Convert.ToInt32(r.IdDossier) + ",'" + r.DateEchographie.Date + "','" + r.DescriptionEchographie + "')"; string q = "insert into " + tab + " " + v; try { c.Open(); command = new SqlCommand(q, c); command.ExecuteNonQuery(); command.Dispose(); MessageBox.Show("Ajout d'échographie avec succès"); c.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }