public List <RecompenseDal> GetAll() { List <RecompenseDal> lb = new List <RecompenseDal>(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "Select * from Recompense"; con.Open(); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { RecompenseDal b = new RecompenseDal(); b.recompenseId = (int)dataReader["recompenseId"]; b.biereId = (int?)dataReader["biereId"]; b.recompenseNom = (string)dataReader["recompenseNom"]; lb.Add(b); } } } } return(lb); }
public RecompenseDal GetOne(int id) { RecompenseDal b = new RecompenseDal(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "Select * from Recompense where recompenseId=@id"; command.Parameters.AddWithValue("id", id); con.Open(); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { b.recompenseId = (int)dataReader["recompenseId"]; b.biereId = (int?)dataReader["biereId"]; b.recompenseNom = (string)dataReader["recompenseNom"]; } } } } return(b); }
public List <RecompenseDal> GetAll(int id) { List <RecompenseDal> la = new List <RecompenseDal>(); using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "select * from Recompense where biereId=@id"; command.Parameters.AddWithValue("id", id); con.Open(); using (SqlDataReader read = command.ExecuteReader()) { while (read.Read()) { RecompenseDal a = new RecompenseDal(); a.recompenseId = (int)read["recompenseId"]; a.recompenseNom = (string)read["recompenseNom"]; a.biereId = (int)read["biereId"]; la.Add(a); } } } } return(la); }
public static RecompenseDal GetRecompenseDal(this RecompenseAPI api) { RecompenseDal dal = new RecompenseDal(); dal.biereId = api.biereId; dal.recompenseId = api.recompenseId; dal.recompenseNom = api.recompenseNom; return(dal); }
public static RecompenseAPI GetRecompenseAPI(this RecompenseDal dal) { RecompenseAPI api = new RecompenseAPI(); api.recompenseId = dal.recompenseId; api.recompenseNom = dal.recompenseNom; api.biereId = dal.biereId; return(api); }
public static RecompenseDal GetRecompenseDal(this RecompenseWPF wpf) { RecompenseDal dal = new RecompenseDal(); dal.biereId = wpf.biereId; dal.recompenseId = wpf.recompenseId; dal.recompenseNom = wpf.recompenseNom; return(dal); }
public static RecompenseWPF GetRecompenseWPF(this RecompenseDal dal) { RecompenseWPF wpf = new RecompenseWPF(); wpf.biereId = dal.biereId; wpf.recompenseId = dal.recompenseId; wpf.recompenseNom = dal.recompenseNom; return(wpf); }
public void Update(RecompenseDal parametre) { using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "EditRecompense"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue(nameof(parametre.recompenseId), parametre.recompenseId); command.Parameters.AddWithValue(nameof(parametre.recompenseNom), parametre.recompenseNom); command.Parameters.AddWithValue(nameof(parametre.biereId), parametre.biereId); con.Open(); command.ExecuteNonQuery(); } } }
public int Create(RecompenseDal parametre) { using (SqlConnection con = new SqlConnection()) { con.ConnectionString = connectionString; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "AddRecompenseBis"; SqlParameter pid = new SqlParameter(); pid.ParameterName = "ID"; pid.Value = 0; pid.Direction = System.Data.ParameterDirection.Output; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue(nameof(parametre.recompenseNom), parametre.recompenseNom); command.Parameters.AddWithValue(nameof(parametre.biereId), parametre.biereId); command.Parameters.Add(pid); con.Open(); command.ExecuteNonQuery(); int id = (int)command.Parameters["ID"].Value; return(id); } } }