private void btnValider_Click(object sender, EventArgs e) { string refe = tbReference.Text; string codeVis = cbVisiteur.Text; string codeMed = cbMedecin.Text; DateTime dateVisite = dtpDateVisite.Value.Date; Visite laVisite = new Visite(refe, dateVisite, codeMed, codeVis); PasserelleOracle.verifVisite() }
public static int verifVisite(Visite uneVisite) {//retourne 1 si aucune visite de ce type existe, s'il y en a une, retourne 1 int resultat = 1; OracleDataReader dr = selectionner("SELECT * FROM VISITE where reference='" + uneVisite.Reference + "',date=" + uneVisite.Date); if (dr.HasRows) { resultat = 0; } dr.Close(); conn.Dispose(); return(resultat); }
public static void creerVisite(Visite uneVisite) { string oradb = "Data Source= localhost;User Id=GSB;Password=password;"; OracleConnection conn = new OracleConnection(oradb); conn.Open(); OracleCommand cmd = new OracleCommand(); cmd.Connection = conn; // OracleDataReader dr = selectionner("INSERT INTO VISITE VALUES ('" + uneVisite.Reference + "'," + uneVisite.Date + ",'" + uneVisite.Commentaire + "','" + uneVisite.UnMedecin.CodeMed + "','" + uneVisite.UnVisiteur.Matricule + "');"); // Perform insert using parameters (bind variables) cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (:1, :2, :3, :4, :5)"; // Here's one way to use parameters aka bind variables: // Create parameters to hold values from front-end cmd.Parameters.Add(new OracleParameter("1", OracleDbType.Varchar2, uneVisite.Reference, ParameterDirection.Input)); cmd.Parameters.Add(new OracleParameter("2", OracleDbType.Date, uneVisite.Date, ParameterDirection.Input)); cmd.Parameters.Add(new OracleParameter("3", OracleDbType.Varchar2, uneVisite.Commentaire, ParameterDirection.Input)); cmd.Parameters.Add(new OracleParameter("4", OracleDbType.Varchar2, uneVisite.UnMedecin.CodeMed, ParameterDirection.Input)); cmd.Parameters.Add(new OracleParameter("5", OracleDbType.Varchar2, uneVisite.UnVisiteur.Matricule, ParameterDirection.Input)); int rowsUpdated = cmd.ExecuteNonQuery(); if (rowsUpdated == 0) { MessageBox.Show("Record not inserted"); } else { MessageBox.Show("Success!"); } conn.Dispose(); }
public static List <Visite> retournerListVisite() { List <Visite> lstVis = new List <Visite>(); OracleDataReader dr = selectionner("Select * from visite"); if (dr.HasRows) { while (dr.Read()) { String reference = dr.GetString(0); DateTime date = dr.GetDateTime(1); String com = dr.GetString(2); Visiteur vis = retournerVisiteur(dr.GetString(3)); Medecin med = retournerMedecin(dr.GetString(4)); Visite uneVisite = new Visite(reference, date, com, med, vis); lstVis.Add(uneVisite); } } dr.Close(); conn.Dispose(); return(lstVis); }