public IHttpActionResult GetPosteSearch(string type, string country, string destination, string dateDebut, string dateFin) { var pvm = new PosteViewModel(); Poste poste = db.Postes.Find(type, country, destination, dateDebut, dateFin); if (poste == null) { return(NotFound()); } else { pvm.ID = poste.ID; pvm.CategorieID = poste.CategorieID; pvm.ClientID2 = poste.ClientID2; pvm.Poste_title = poste.Poste_title; pvm.Poste_image = poste.Poste_image; pvm.Poste_description = poste.Poste_description; pvm.Date_debut = poste.Date_debut; pvm.Date_fin = poste.Date_fin; pvm.Etat = poste.Etat; } return(Ok(pvm)); }
public frmYellow(Offre offre) { InitializeComponent(); _RegionManager = new RegionManager(); _PosteManager = new PosteManager(); _ContratManager = new ContratManager(); _OldOffre = offre; _NewOffre = offre; this.DialogResult = DialogResult.Cancel; this.FillFormulaire(_OldOffre); this.FillingAllComboBox(); buttonUpdate.Enabled = EnabledUpdate(); regionNew = _DefaultRegion; contratNew = _DefaultContrat; posteNew = _DefaultPoste; labelTitre.Text = $"Modification de l'offre N°{_OldOffre.Id}"; labelResultat.Text = String.Empty; }
public FiltersOffreRequest(Region region, Contrat contrat, Poste poste, Intervalle intervalle) { this.region = region; this.contrat = contrat; this.poste = poste; this.intervalle = intervalle; }
public ActionResult GetPosteById(long IdPoste) { Poste poste = UnitOfWork.PosteRepository.Get(p => p.IdPoste == IdPoste && p.DataExclusao == null, includeProperties: "Cidade").FirstOrDefault(); FotoPoste foto = UnitOfWork.FotoPosteRepository.Get(f => f.IdPoste == IdPoste && f.DataExclusao == null).FirstOrDefault(); PosteView posteview = new MetodosPosteView().PostetoPosteView(poste); LatLon LatLong = new ConverterUtmToLatLon(poste.Cidade.Datum, poste.Cidade.NorteOuSul, poste.Cidade.Zona).Convert(poste.X, poste.Y); //Object poste_return = new //{ // IdPoste = poste.IdPoste, // Latitude = LatLong.Lat, // Longitude = LatLong.Lon, // //Img = poste.Finalizado == true ? "03" : "08", // Img = poste.Finalizado == true ? "10" : "08", // IdCidade = poste.IdCidade, // CodGeo = poste.CodigoGeo, // Altura = poste.Altura, // TipoPoste = poste.TipoPoste, // Esforco = poste.Esforco, // Descricao = poste.Descricao //}; return(Json(posteview, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Méthode retournant la liste des postes /// </summary> /// <returns></returns> public List <Poste> listePoste() { SqlConnection cn = new SqlConnection(); cn.ConnectionString = ConfigurationManager.ConnectionStrings["SQL"].ConnectionString; cn.Open(); SqlCommand objSelect = new SqlCommand(); objSelect.Connection = cn; objSelect.CommandText = "dbo.GetPoste"; objSelect.CommandType = CommandType.StoredProcedure; List <Poste> ListePoste = new List <Poste>(); DataTable objDataset = new DataTable(); SqlDataAdapter objDataAdapter = new SqlDataAdapter(objSelect); objDataAdapter.Fill(objDataset); foreach (DataRow poste in objDataset.Rows) { Poste Poste2 = new Poste(); Poste2.Idposte = Convert.ToInt32(poste["IDPOSTE"]); Poste2.TypePoste = poste["TYPEPOSTE"].ToString(); ListePoste.Add(Poste2); } return(ListePoste); }
public List <Poste> RetrieveAllPostes(string textItem) { List <Poste> postes = new List <Poste>(); PosteDataAccess dataAccess = new PosteDataAccess(); DataTable schemaTable = dataAccess.SelectAll(); foreach (DataRow row in schemaTable.Rows) { Poste poste = new Poste { Id = Convert.ToInt32(row["ID_POSTE"]), Nom = row["TYPE_POSTE"].ToString() }; postes.Add(poste); } Poste posteItem = new Poste { Id = 0, Nom = textItem }; postes.Insert(0, posteItem); return(postes); }
public HttpResponseMessage Deletar(PosteEditAPI poste) { Poste PostesDB = UnitOfWork.PosteRepository.Get(p => p.IdPoste == poste.IdPoste && p.DataExclusao == null, includeProperties: "Cidade").FirstOrDefault(); if (PostesDB != null) { // Salvando a posição do Mobile no momento da exclusao do poste UTM posicaoAtualizacao = new ConverterLatLonToUtm(PostesDB.Cidade.Datum, PostesDB.Cidade.NorteOuSul, PostesDB.Cidade.Zona).Convert(poste.LatAtualizacao, poste.LonAtualizacao); PostesDB.XAtualizacao = posicaoAtualizacao.X; PostesDB.YAtualizacao = posicaoAtualizacao.Y; UnitOfWork.PosteRepository.Update(PostesDB); UnitOfWork.PosteRepository.SetDataExclusao(PostesDB); UnitOfWork.Save(); return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi() { Status = Status.OK, Message = Resources.Messages.Save_OK })); } else { return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi() { Status = Status.NOK, Message = Resources.Messages.Not_Register_Data_Base })); } }
/// <summary> /// Récupère une Poste à partir d'un identifiant de client /// </summary> /// <param name="Identifiant">Identifant de Poste</param> /// <returns>Un Poste </returns> public static Poste Get(Int32 identifiant) { //Connection SqlConnection connection = DataBase.connection; //Commande String requete = @"SELECT Identifiant, Libelle, Fonction FROM Poste WHERE Identifiant = @Identifiant"; SqlCommand commande = new SqlCommand(requete, connection); //Paramètres commande.Parameters.AddWithValue("Identifiant", identifiant); //Execution connection.Open(); SqlDataReader dataReader = commande.ExecuteReader(); dataReader.Read(); //1 - Création du Poste Poste poste = new Poste(); poste.Identifiant = dataReader.GetInt32(0); poste.Libelle = dataReader.GetString(1); poste.Fonction = dataReader.GetString(2); dataReader.Close(); connection.Close(); return poste; }
public async Task GetAllNecessites() { lesNecessites = new List <Necessites>(); //http://localhost/recru_eatgood_api/getAllNecessites.php var reponse = await hc.GetStringAsync("http://localhost/recru_eatgood_api/getAllNecessites.php"); var donnees = JsonConvert.DeserializeObject <dynamic>(reponse); var list = donnees["results"]["necessiter"]; if (list != null) { foreach (var item in list) { Restaurant leResto = GetUnRestoById(Convert.ToInt32(item["codeRestaurant"].Value.ToString())); Poste lePoste = GetUnPosteById(Convert.ToInt32(item["codePoste"].Value.ToString())); // codePoste codeRestaurant quantite Necessites uneNecessite = new Necessites() { LePoste = lePoste, LeResto = leResto, LaQuantite = Convert.ToInt32(item["quantite"].Value.ToString()) }; lesNecessites.Add(uneNecessite); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nom")] Poste poste) { if (id != poste.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(poste); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PosteExists(poste.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(poste)); }
static void Main(string[] args) { Comentario c1 = new Comentario("Have a nice trip"); Comentario c2 = new Comentario("Wow That's awesome!"); Poste p1 = new Poste( DateTime.Parse("21/06/2018 13:05:44"), "Traveling to New Zealand", "I'm going to visit this wonderful country", 12); p1.AddComentarios(c1); p1.AddComentarios(c2); Comentario c3 = new Comentario("Good night"); Comentario c4 = new Comentario("May the Force be with you"); Poste p2 = new Poste( DateTime.Parse("28/07/2018 23:14:19"), "Good night guys", "See you tomorrow", 5); p2.AddComentarios(c3); p2.AddComentarios(c4); Console.WriteLine(p1); Console.WriteLine(p2); }
public HttpResponseMessage Post(Poste entity) { try { entity.UserID = usuario.UsuarioID; entity.EmpresaID = usuario.EmpresaID; entity.Fecha = DateTime.Now; var result = this._InsertPoste(entity); return(Request.CreateResponse <Poste>(HttpStatusCode.Created, result)); } catch (SqlException ex) { HttpError err = new HttpError("No se pudo actualizar."); if (ex.Message.Contains("UNIQUE KEY")) { return(Request.CreateResponse(HttpStatusCode.Conflict, err)); } //throw new HttpResponseException(HttpStatusCode.Conflict); err = new HttpError("Error no controlado."); return(Request.CreateResponse(HttpStatusCode.Conflict, err)); } catch (Exception ex) { HttpError err = new HttpError(ex.Message); return(Request.CreateResponse(HttpStatusCode.Conflict, err)); } }
/// <summary> /// Fonction appelé pour sauvegarder le nom du volontaire qui a fait la modification de l'état du poste. /// </summary> /// <param name="p">Le poste qui a été ciblé par la modification</param> private void SauvegarderVolontaireModification(Poste p) { if (p != null) { var taskSave = PosteHelper.UpdateModificateurtAsync(p.Numero, LocalSelectionne.Numero, p.DernierModificateur.NomUtilisateur); } }
public List <Utilisateur> GetUtilisateurValidation(string etat) { List <Utilisateur> reponse = new List <Utilisateur>(); Connexion connexion = new Connexion(); string sql = "select * from utilisateur where etat='" + etat + "'"; MySqlCommand command = new MySqlCommand(sql, connexion.GetConnection()); MySqlDataReader dataReader; connexion.GetConnection().Open(); dataReader = command.ExecuteReader(); PosteDAO posteDAO = new PosteDAO(); try { while (dataReader.Read()) { Poste poste = posteDAO.GetPosteById(dataReader["ID_POSTE"].ToString()); reponse.Add(new Utilisateur(dataReader["ID_UTILISATEUR"].ToString(), poste, dataReader["NOM_UTILISATEUR"].ToString(), dataReader["PRENOMS"].ToString(), dataReader["IDENTIFIANTS"].ToString(), dataReader["MDP"].ToString())); } return(reponse); } catch (Exception exception) { throw exception; } finally { connexion.CloseAll(command, null, connexion.GetConnection()); } }
public static void Hydrate(Poste p, DataRow dr) { //Poste p.CodePoste = (int)dr["CodePoste"]; p.Name = dr["libPoste"].ToString(); p.Salaire = double.Parse(dr["SalaireBase"].ToString()); }
public async void ActionAjoutMethode() { Salarie LeSalarie = new Salarie(); Poste LePoste = new Poste(); LeSalarie.LesPostes = new List <Poste>(); LePoste.LesSalaries = new List <Salarie>(); LeSalarie.Nom = "nom"; LePoste.Libelle = "fghjg"; LeSalarie.LesPostes.Add(LePoste); LePoste.LesSalaries.Add(LeSalarie); await App.Database.SaveItemAsync(LeSalarie); await App.Database.SaveItemAsyncEvent(LePoste); await App.Database.MiseAJourRelationSalariePoste(LeSalarie); await App.Database.MiseAJourRelationPosteSalarie(LePoste); var SalarieStored = App.Database.GetRelationSalariePoste(LeSalarie); var PosteStored = App.Database.GetRelationPosteSalarie(LePoste); string x = SalarieStored.Result.Nom; MaListe = await App.Database.GetItemsAsync(); //TodoItem eventStored2 = await App.Database.TOTO2(MaListe[3]); }
public static Poste GetPoste(int code_poste) { Poste d = new Poste(); Connecteur ct = new Connecteur(); try { SqlDataAdapter dae = new SqlDataAdapter(StatutCarriereDAL.selectPoste, ct.Connection); dae.SelectCommand.Parameters.AddWithValue("@CodePoste", code_poste); DataTable dt = new DataTable("Poste"); ct.Connection.Open(); dae.Fill(dt); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; StatutCarriereDAL.Hydrate(d, dr); } return(d); } catch (SqlException ex) { throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)"); } finally { ct.Connection.Close(); } }
public static Poste getOneById(int id) { Poste bean = new Poste(); NpgsqlConnection connect = new Connexion().Connection(); try { string query = "select * from yvs_grh_poste_de_travail where id =" + id + ";"; NpgsqlCommand Lcmd = new NpgsqlCommand(query, connect); NpgsqlDataReader lect = Lcmd.ExecuteReader(); if (lect.HasRows) { while (lect.Read()) { bean = Return(lect); } } return(bean); } catch (Exception ex) { Messages.Exception("PosteDAO (getOneById) ", ex); return(bean); } finally { Connexion.Close(connect); } }
public List <Offre> GetAllOffres(FiltersOffreRequest filtre) { List <Offre> offres = new List <Offre>(); string query = "SELECT * FROM OFFRE"; var parameters = new List <SqlParameter>(); query = AddFilterQuery <int?>(query, "REG_ID", "@REG_ID", "=", filtre.region?.Id, parameters); query = AddFilterQuery(query, "CON_ID", "@CON_ID", "=", filtre.contrat?.Id, parameters); query = AddFilterQuery(query, "POS_ID", "@POS_ID", "=", filtre.poste?.Id, parameters); query = AddFilterQuery(query, "CREATION", "@CREATIONSTART", ">=", filtre.intervalle?.Start, parameters); query = AddFilterQuery(query, "CREATION", "@CREATIONDEND", "<=", filtre.intervalle?.End, parameters); DataSet dataSet = SQLManager.ExcecuteQuery(query, parameters); foreach (DataRow row in dataSet.Tables[0].Rows) { Region r = Configuration.ConfigDAL.regionDAO.FindRegionByID((int)row["REG_ID"]); Contrat c = Configuration.ConfigDAL.contratDAO.FindContratByID((int)row["CON_ID"]); Poste p = Configuration.ConfigDAL.posteDAO.FindPosteByID((int)row["POS_ID"]); Offre off = new Offre(row, p, c, r); offres.Add(off); } return(offres); }
public ActionResult NewPoste(PosteView requestData) { Cidade cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == requestData.IdCidade).FirstOrDefault(); if (cidade != null) { ConverterLatLonToUtm converter = new ConverterLatLonToUtm(cidade.Datum, cidade.NorteOuSul, cidade.Zona); UTM utm = converter.Convert(requestData.Latitude, requestData.Longitude); OrdemDeServico ordemDeServico = UnitOfWork.OrdemDeServicoRepository.Get(or => or.NumeroOS == requestData.IdOrdemServicoTexto).FirstOrDefault(); Poste p = new Poste { X = utm.X, Y = utm.Y, Cidade = cidade, DataCadastro = DateTime.Now, IdOrdemDeServico = ordemDeServico.IdOrdemDeServico, CodigoGeo = -1 }; UnitOfWork.PosteRepository.Insert(p); UnitOfWork.Save(); Poste pst = UnitOfWork.PosteRepository.Get(pt => pt.X == p.X && pt.Y == p.Y, includeProperties: "Cidade").FirstOrDefault(); PosteView posteview = new MetodosPosteView().PostetoPosteView(pst); return(Json(new ResponseView() { Status = Status.Found, Result = posteview }, JsonRequestBehavior.AllowGet)); } else { return(Json(new ResponseView() { Status = Status.NotFound, Result = Resources.Messages.Cidade_Not_Found }, JsonRequestBehavior.AllowGet)); } }
public Utilisateur GetUtilisateurByLogin(LoginUsers loginUsers) { Utilisateur reponse = new Utilisateur(); Connexion connexion = new Connexion(); string sql = "select * from utilisateur where IDENTIFIANTS='" + loginUsers.Identifiant + "' and MDP = '" + loginUsers.Mdp + "' and ETAT='1'"; MySqlCommand command = new MySqlCommand(sql, connexion.GetConnection()); MySqlDataReader dataReader; connexion.GetConnection().Open(); dataReader = command.ExecuteReader(); PosteDAO posteDAO = new PosteDAO(); try { if (dataReader.Read().ToString() == "True") { Poste poste = posteDAO.GetPosteById(dataReader["ID_POSTE"].ToString()); reponse = new Utilisateur(dataReader["ID_UTILISATEUR"].ToString(), poste, dataReader["NOM_UTILISATEUR"].ToString(), dataReader["PRENOMS"].ToString(), dataReader["IDENTIFIANTS"].ToString(), dataReader["MDP"].ToString()); reponse.EtatMdp = dataReader["etatmdp"].ToString(); } else { throw new Exception("Identifiants / mot de passe invalide"); } return(reponse); } catch (Exception exception) { throw exception; } finally { connexion.CloseAll(command, null, connexion.GetConnection()); } }
public ActionResult CancelfinalizarPoste(long IdPoste) { Poste poste = UnitOfWork.PosteRepository.Get(p => p.IdPoste == IdPoste && p.DataExclusao == null).FirstOrDefault(); if (poste != null) { poste.Finalizado = false; poste.DataFinalizado = null; UnitOfWork.PosteRepository.Update(poste); UnitOfWork.Save(); return(Json(new ResponseView() { Status = Status.OK, Result = Resources.Messages.Save_OK }, JsonRequestBehavior.AllowGet)); } else { return(Json(new ResponseView() { Status = Status.NotFound, Result = Resources.Messages.Poste_Not_Found }, JsonRequestBehavior.AllowGet)); } }
public Utilisateur GetMagasinier(string mdp) { Utilisateur reponse = new Utilisateur(); Connexion connexion = new Connexion(); string sql = "select * from utilisateur where MDP = '" + mdp + "' and id_poste='2'"; MySqlCommand command = new MySqlCommand(sql, connexion.GetConnection()); MySqlDataReader dataReader; connexion.GetConnection().Open(); dataReader = command.ExecuteReader(); PosteDAO posteDAO = new PosteDAO(); try { while (dataReader.Read()) { Poste poste = posteDAO.GetPosteById(dataReader["ID_POSTE"].ToString()); reponse = new Utilisateur(dataReader["ID_UTILISATEUR"].ToString(), poste, dataReader["NOM_UTILISATEUR"].ToString(), dataReader["PRENOMS"].ToString(), dataReader["IDENTIFIANTS"].ToString(), dataReader["MDP"].ToString()); } return(reponse); } catch (Exception exception) { throw exception; } finally { connexion.CloseAll(command, null, connexion.GetConnection()); } }
public frmGreen() { InitializeComponent(); _RegionNew = _DefaultRegion; _ContratNew = _DefaultContrat; _PosteNew = _DefaultPoste; _SocieteNew = _DefaultSociete; _SocieteManager = new SocieteManager(); _RegionManager = new RegionManager(); _PosteManager = new PosteManager(); _ContratManager = new ContratManager(); this.DialogResult = DialogResult.Cancel; _NewOffre = new Offre(); this.FillingAllComboBox(); this.FillFormulaire(); buttonInsert.Visible = this.EnabledInsertion(); labelTitre.Text = "Création d'une nouvelle Offre"; labelInsert.Text = "Veuillez remplir les champs obligatoires"; labelInsert.ForeColor = Color.DarkRed; }
public Utilisateur GetUtilisateurByIdentifiant(string identifiants) { Utilisateur reponse = new Utilisateur(); Connexion connexion = new Connexion(); string sql = "select * from utilisateur where IDENTIFIANTS='" + identifiants + "'"; MySqlCommand command = new MySqlCommand(sql, connexion.GetConnection()); MySqlDataReader dataReader; connexion.GetConnection().Open(); dataReader = command.ExecuteReader(); PosteDAO posteDAO = new PosteDAO(); try { if (dataReader.Read().ToString() == "True") { Poste poste = posteDAO.GetPosteById(dataReader["ID_POSTE"].ToString()); reponse = new Utilisateur(dataReader["ID_UTILISATEUR"].ToString(), poste, dataReader["NOM_UTILISATEUR"].ToString(), dataReader["PRENOMS"].ToString(), dataReader["IDENTIFIANTS"].ToString(), dataReader["MDP"].ToString()); } return(reponse); } catch (Exception exception) { throw exception; } finally { connexion.CloseAll(command, null, connexion.GetConnection()); } }
public PosteManager() { Consultation = new Poste(); Request = new RestRequest("RetrieveAllPostes/{textItem}"); //Id = "ID_POSTE"; //Nom = "TYPE_POSTE"; }
public IHttpActionResult PutPoste(int id, Poste poste) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != poste.ID) { return(BadRequest()); } db.Entry(poste).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PosteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public Poste _InsertPoste(Poste entity) { db.Postes.InsertOnSubmit(entity); db.SubmitChanges(); return(entity); //return db.VW_Planillas.SingleOrDefault(p => p.PlanillaID == entity.PlanillaID); }
public String IdentificaCorPosteNaSa(Poste poste) { String resultado = ""; foreach (FotoPoste ft in poste.Fotos) { if (ft.NumeroFoto == "NA") { resultado = "NA"; } else if (ft.NumeroFoto == "SA") { resultado = "SA"; } } switch (resultado) { case "NA": return("17"); case "SA": return("19"); default: return("13"); } }
public static Poste ConstructeurPoste(Poste poste) { using (var db = new DBAirAtlantiqueContext()) { if (poste.ListeFormationMini.Count() == 0) { var formations = from pf in db.PosteFormation where pf.PosteConcerne.PosteID == poste.PosteID select pf; foreach (PosteFormation pf in formations) { var requeteFormation = from f in db.Formations where f.FormationID == pf.FormationConcerne.FormationID select f; pf.FormationConcerne = requeteFormation.First(); poste.ListeFormationMini.Add(pf); } } if (poste.ListeEmployee.Count() == 0) { var employees = from e in db.Employees where e.PosteAttribuer.PosteID == poste.PosteID select e; foreach (Employee pf in employees) { poste.ListeEmployee.Add(pf); } } } return(poste); }
public ActionResult SalvarEdicaoIP(int _IdPosteAssociado, int _IdIp, string _TipoBraco, string _TipoLuminaria, string _TipoLampada, int _QtdLuminaria, double _Potencia, string _Acionamento, string _LampadaAcesa, string _Fase, int _QtdLampada) { if (_IdIp == -1) { Poste poste = UnitOfWork.PosteRepository.Get(p => p.IdPoste == _IdPosteAssociado && p.DataExclusao == null).FirstOrDefault(); UnitOfWork.IPRepository.Insert(new IP() { Poste = poste, TipoBraco = _TipoBraco, TipoLuminaria = _TipoLuminaria, QtdLuminaria = _QtdLuminaria, TipoLampada = _TipoLampada, Potencia = _Potencia, CodigoGeoBD = -1, Acionamento = _Acionamento, LampadaAcesa = _LampadaAcesa, Fase = _Fase, QtdLampada = _QtdLampada }); UnitOfWork.Save(); } else { IP Ip = UnitOfWork.IPRepository.Get(i => i.IdIp == _IdIp && i.DataExclusao == null).FirstOrDefault(); Ip.IdPoste = _IdPosteAssociado; Ip.TipoBraco = _TipoBraco; Ip.TipoLuminaria = _TipoLuminaria; Ip.TipoLampada = _TipoLampada; Ip.QtdLuminaria = _QtdLuminaria; Ip.Potencia = _Potencia; Ip.Acionamento = _Acionamento; Ip.Fase = _Fase; Ip.LampadaAcesa = _LampadaAcesa; Ip.QtdLampada = _QtdLampada; UnitOfWork.IPRepository.Update(Ip); UnitOfWork.Save(); } return(Json(new ResponseView() { Status = Status.OK, Result = Resources.Messages.Save_OK }, JsonRequestBehavior.AllowGet)); }
public static void Insert(Poste Poste) { //Connection SqlConnection connection = DataBase.connection; //Commande String requete = @"INSERT INTO Poste (Libelle, Fonction) VALUES (@Libelle, @Fonction)SELECT SCOPE_IDENTITY() "; SqlCommand commande = new SqlCommand(requete, connection); //Paramètres commande.Parameters.AddWithValue("Libelle", Poste.Libelle); commande.Parameters.AddWithValue("Fonction", Poste.Fonction); //Execution connection.Open(); commande.ExecuteNonQuery(); connection.Close(); }
/// <summary> /// Constructeur d'un joueur acceptant 6 arguments /// </summary> /// <param name="identifiant">Identifiant du joueur</param> /// <param name="prenom">Prénom du joueur</param> /// <param name="nom">Nom du joueur</param> /// <param name="dateDeNaissance">Date de naissance du joueur</param> /// <param name="isCapitaine">Si le joueur est capitaine</param> /// <param name="poste">Poste du joueur</param> /// <param name="scoreCoupe">Score du joueur durant la coupe</param> /// <param name="nombreDeSelection">Nombre de sélection du joueur</param> public Joueur(int identifiant, string prenom, string nom, DateTime dateDeNaissance, bool isCapitaine, Poste poste, int nombreDeSelection) : base(identifiant, prenom, nom, dateDeNaissance) { Capitaine = isCapitaine; Poste = poste; NombreDeSelection = nombreDeSelection; }
public static void Update(Poste Poste) { //Connection SqlConnection connection = DataBase.connection; //Commande String requete = @"UPDATE Poste SET Libelle = @Libelle, Fonction = @Fonction WHERE Identifiant = @Identifiant"; SqlCommand commande = new SqlCommand(requete, connection); //Paramètres commande.Parameters.AddWithValue("Libelle", Poste.Libelle); commande.Parameters.AddWithValue("Fonction", Poste.Fonction); commande.Parameters.AddWithValue("Identifiant", Poste); //Execution connection.Open(); commande.ExecuteNonQuery(); connection.Close(); }
/// <summary> /// Récupère une liste de Poste à partir de la base de données /// </summary> /// <returns>Une liste de client</returns> public static List<Poste> List() { //Récupération de la chaine de connexion //Connection SqlConnection connection = DataBase.connection; //Commande String requete = "SELECT Identifiant, Libelle, Fonction FROM Poste"; connection.Open(); SqlCommand commande = new SqlCommand(requete, connection); //execution SqlDataReader dataReader = commande.ExecuteReader(); List<Poste> list = new List<Poste>(); while (dataReader.Read()) { //1 - Créer un Poste à partir des donner de la ligne du dataReader Poste poste = new Poste(); poste.Identifiant = dataReader.GetInt32(0); poste.Libelle = dataReader.GetString(1); poste.Fonction = dataReader.GetString(2); //2 - Ajouter ce Poste à la list de client list.Add(poste); } dataReader.Close(); connection.Close(); return list; }