public List <EvenementDal> GetAll() { List <EvenementDal> la = new List <EvenementDal>(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "select * from VueEvenment"; con.Open(); using (SqlDataReader read = command.ExecuteReader()) { while (read.Read()) { EvenementDal a = new EvenementDal(); a.eventId = (int)read["eventId"]; a.eventDescription = (string)read["eventDescription"]; a.eventDateDebut = (DateTime)read["eventDateDebut"]; a.eventDateFin = (DateTime)read["eventDateFin"]; //a.clientPwd = (string)read["biereImage"]; a.brasserieId = (int)read["brasserieId"]; la.Add(a); } } } } return(la); }
public EvenementDal GetOne(int id) { EvenementDal b = new EvenementDal(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "Select * from Evenement where eventId=@id"; command.Parameters.AddWithValue("id", id); con.Open(); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { b.eventId = (int)dataReader["eventId"]; b.brasserieId = (int?)dataReader["brasserieId"]; b.eventDateDebut = (DateTime)dataReader["eventDateDebut"]; b.eventDateFin = (DateTime)dataReader["eventDateFin"]; b.eventDescription = (string)dataReader["eventDescription"]; } } } } return(b); }
public List <EvenementDal> GetAll() { List <EvenementDal> lb = new List <EvenementDal>(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "Select * from Evenement"; con.Open(); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { EvenementDal b = new EvenementDal(); b.eventId = (int)dataReader["eventId"]; b.brasserieId = (int?)dataReader["brasserieId"]; b.eventDateDebut = (DateTime)dataReader["eventDateDebut"]; b.eventDateFin = (DateTime)dataReader["eventDateFin"]; b.eventDescription = (string)dataReader["eventDescription"]; lb.Add(b); } } } } return(lb); }
public static EvenementDal GetEvenementDal(this EvenementAPI evenementAPI) { EvenementDal evenementDal = new EvenementDal(); evenementDal.brasserieId = evenementAPI.brasserieId; evenementDal.eventDateDebut = evenementAPI.eventDateDebut; evenementDal.eventDateFin = evenementAPI.eventDateFin; evenementDal.eventDescription = evenementAPI.eventDescription; evenementDal.eventId = evenementAPI.eventId; return(evenementDal); }
public static EvenementDal GetEvenementDal(this EvenementWPF wpf) { EvenementDal dal = new EvenementDal(); dal.brasserieId = wpf.brasserieId; dal.eventDateDebut = wpf.eventDateDebut; dal.eventDateFin = wpf.eventDateFin; dal.eventDescription = wpf.eventDescription; dal.eventId = wpf.eventId; return(dal); }
public static EvenementWPF GetEvenementWPF(this EvenementDal dal) { EvenementWPF wpf = new EvenementWPF(); wpf.brasserieId = dal.brasserieId; wpf.eventDateDebut = dal.eventDateDebut; wpf.eventDateFin = dal.eventDateFin; wpf.eventDescription = dal.eventDescription; wpf.eventId = dal.eventId; return(wpf); }
public void Update(EvenementDal parametre) { using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "EditEvenement"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue(nameof(parametre.eventId), parametre.eventId); command.Parameters.AddWithValue(nameof(parametre.eventDateDebut), parametre.eventDateDebut); command.Parameters.AddWithValue(nameof(parametre.eventDateFin), parametre.eventDateFin); command.Parameters.AddWithValue(nameof(parametre.eventDescription), parametre.eventDescription); con.Open(); command.ExecuteNonQuery(); } } }
public int Create(EvenementDal parametre) { using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "AddEvenementBis"; command.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter pid = new SqlParameter(); pid.ParameterName = "ID"; pid.Value = 0; pid.Direction = System.Data.ParameterDirection.Output; command.Parameters.AddWithValue(nameof(parametre.eventDateDebut), parametre.eventDateDebut); command.Parameters.AddWithValue(nameof(parametre.eventDateFin), parametre.eventDateFin); command.Parameters.AddWithValue(nameof(parametre.eventDescription), parametre.eventDescription); command.Parameters.Add(pid); con.Open(); command.ExecuteNonQuery(); int id = (int)command.Parameters["ID"].Value; return(id); } } }