private void btn_Adh_Valid_Click(object sender, EventArgs e) { Random coti = new Random(); string nom = txt_Nom_Adh.Text; string prenom = txt_Prenom_Adh.Text; try { DateTime naissance = DateTime.Parse(txt_naissance_adh.Text); string Cp = txt_Cp_Adh.Text; string Ville = txt_Ville_Adh.Text; string Adresse = txt_Adr_Adh.Text; if (nom.Length != 0 && prenom.Length != 0 && naissance.ToString().Length != 0 && Cp.Length != 0 && Ville.Length != 0 && Adresse.Length != 0) { adherent adhajouté = new adherent(nom, prenom, Cp, Adresse, Ville); adhajouté.DateNaissance = naissance; GesAdh.ajouter_Adherent(adhajouté); bADH.ajouterAdherent(adhajouté); MessageBox.Show("L'adhérent a bien été ajouté", "ajout réussi", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Veuillez remplir tous les champs !", "champ(s) manquant(s)", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { MessageBox.Show("Veuillez entrer une date valide !", "Date", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void SupprimerAdherent(adherent adhérents) { using (connection) { connection.Open(); string requete = "DELETE FROM `adherent` WHERE `adherent`.`A_id` = @id"; MySqlCommand cmd = new MySqlCommand(requete, connection); cmd.Parameters.AddWithValue("@id", adhérents.Id); cmd.ExecuteNonQuery(); } }
public void AjouterUnClub(club Unclub, adherent UnAdh) { using (connection) { connection.Open(); string requete = "UPDATE `adherent` SET `C_id` = @idC WHERE `adherent`.`A_id`= @idA"; MySqlCommand cmd = new MySqlCommand(requete, connection); cmd.Parameters.AddWithValue("@idA", UnAdh.Id); cmd.Parameters.AddWithValue("@idC", Unclub.id_club); cmd.ExecuteNonQuery(); } }
public async Task <ActionResult> Login(adherent adherent) { adherent currentUser = LRS.doLogin(adherent); //user currentUser = null; if (currentUser != null) { System.Web.HttpContext.Current.Session.Add("IUser", currentUser); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Email/Username/Password is/are incorrect"); return(View(adherent)); }
public void ajouterAdherent(adherent adhérents) { using (connection) { connection.Open(); string requete = "INSERT INTO `adherent` ('A_id', `A_licence`, `A_nom`, `A_prenom`, `A_datenaiss`, A_adresse`, `A_cp`, `A_ville`, `A_cotisation`, A_fk_evenement, A_fk_club) VALUES (NULL,@nom, @prenom, @sexe, @date, @Adresse, @codepostal, @ville,@cotisation, NULL, NULL);"; MySqlCommand cmd = new MySqlCommand(requete, connection); cmd.Parameters.AddWithValue("@nom", adhérents.Nom); cmd.Parameters.AddWithValue("@prenom", adhérents.Prenom); cmd.Parameters.AddWithValue("@date", adhérents.DateNaissance); cmd.Parameters.AddWithValue("@adresse", adhérents.Adresse); cmd.Parameters.AddWithValue("@codepostal", adhérents.CodePostal); cmd.Parameters.AddWithValue("@ville", adhérents.Ville); cmd.Parameters.AddWithValue("@cotisation", adhérents.Cotisation); cmd.ExecuteNonQuery(); } }
public void testnbradh() { type_club tc = new type_club(20, "tennis"); club club = new club("un club", "une url", "une adresse", "un CP", "une ville", "un mail", 012345679, tc); adherent adhtest = new adherent("Bertrand", "jean", "92130", "6 squares louis blé", "Issy-les-mx"); adherent adhtest1 = new adherent("Bertrand", "Paul", "92130", "6 squares louis blé", "Issy-les-mx"); adherent adhtest2 = new adherent("Bertrand", "Romain", "92130", "6 squares louis blé", "Issy-les-mx"); adhtest2.Id = 28; adherent adhtest3 = new adherent("Bertrand", "Romain", "92130", "6 squares louis blé", "Issy-les-mx"); adhtest3.Id = 28; club.AjouterClubAdh(adhtest); club.AjouterClubAdh(adhtest3); club.AjouterClubAdh(adhtest2); Assert.Equal(2, club.adherents.Count); }
public void ajouterAdherent(adherent adhérents) { using (connection) { connection.Open(); string requete = "INSERT INTO `adherent` (`id_adherent`, `numero_licence`, `Nom_adherent`, `Prenom_adherent`, `Date_naissance_adherent`, `Adresse_adherent`, `Code_Postal_adherent`, `Ville_adherent`, `cotisation_adherent`, `id_club`) VALUES (NULL,NULL, @nom, @prenom, @date, @Adresse, @codepostal, @ville,@cotisation, NULL);"; MySqlCommand cmd = new MySqlCommand(requete, connection); cmd.Parameters.AddWithValue("@nom", adhérents.Nom); cmd.Parameters.AddWithValue("@prenom", adhérents.Prenom); cmd.Parameters.AddWithValue("@date", adhérents.DateNaissance); cmd.Parameters.AddWithValue("@adresse", adhérents.Adresse); cmd.Parameters.AddWithValue("@codepostal", adhérents.CodePostal); cmd.Parameters.AddWithValue("@ville", adhérents.Ville); // cmd.Parameters.AddWithValue("@numero", adhérents.numero); cmd.Parameters.AddWithValue("@cotisation", adhérents.Cotisation); cmd.ExecuteNonQuery(); } }
public adherent doLogin(adherent adherent) { HttpClient Client = new HttpClient(); Client.BaseAddress = new Uri("http://localhost:8080"); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = Client.PostAsJsonAsync <adherent>("/otdav-4GLA-web/api/adherent", adherent).Result; if (response.IsSuccessStatusCode) { // AdherentLoggedin = response.Content.ReadAsAsync<adherent>().Result; return(response.Content.ReadAsAsync <adherent>().Result); } else { return(response.Content.ReadAsAsync <adherent>().Result); } }
public List <adherent> Readadherent() { List <adherent> liste = new List <adherent>(); adherent adhérents; club club; type_club type; using (connection) { connection.Open(); string requete = "select * from adherent left join club on adherent.id_club=club.id_club left join type_club on club.id_type_club = type_club.id_type_club order by adherent.id_adherent"; MySqlCommand cmd = new MySqlCommand(requete, connection); using (MySqlDataReader datareader = cmd.ExecuteReader()) { while (datareader.Read()) { adhérents = new adherent((string)datareader["Nom_adherent"], (string)datareader["Prenom_adherent"], (string)datareader["Code_Postal_adherent"], (string)datareader["Adresse_adherent"], (string)datareader["Ville_adherent"]); adhérents.DateNaissance = (DateTime)datareader["Date_naissance_adherent"]; adhérents.Id = (int)datareader["id_adherent"]; if (datareader["id_club"] != System.DBNull.Value && datareader["numero_licence"] != System.DBNull.Value) { type = new type_club(Convert.ToInt32(datareader["id_type_club"]), (string)datareader["libelle"]); club = new club((string)datareader["Titre_club"], (string)datareader["url_club"], (string)datareader["Adresse_club"], (string)datareader["Code_Postal_club"], (string)datareader["Ville_club"], (string)datareader["mail_club"], Convert.ToInt32(datareader["telephone_club"]), type); adhérents.numero_licence = Convert.ToInt32(datareader["numero_licence"]); adhérents.Cotisation = Convert.ToInt32(datareader["cotisation_adherent"]); adhérents.club = club; } liste.Add(adhérents); } } } return(liste); }
public void ModifierAdherent(adherent adhérents) { using (connection) { connection.Open(); string requete = "UPDATE `adherent` SET `A_nom` = @nom, `A_prenom` = @prenom, `A_datenaiss` = @date, `A_adresse` = @adresse, `A_cp` = @codepostal, `A_ville` = @ville, `A_licence` = @numero, `A_cotisation`=@coti WHERE `adherent`.`A_id` = @id"; MySqlCommand cmd = new MySqlCommand(requete, connection); cmd.Parameters.AddWithValue("@nom", adhérents.Nom); cmd.Parameters.AddWithValue("@prenom", adhérents.Prenom); cmd.Parameters.AddWithValue("@date", adhérents.DateNaissance); cmd.Parameters.AddWithValue("@adresse", adhérents.Adresse); cmd.Parameters.AddWithValue("@codepostal", adhérents.CodePostal); cmd.Parameters.AddWithValue("@ville", adhérents.Ville); cmd.Parameters.AddWithValue("@id", adhérents.Id); cmd.Parameters.AddWithValue("@numero", adhérents.numero_licence); cmd.Parameters.AddWithValue("@coti", adhérents.Cotisation); cmd.ExecuteNonQuery(); } }
public List <adherent> Readadherent() { List <adherent> liste = new List <adherent>(); adherent adhérents; club club; type_club type; //connexion_BDD connect = new connexion_BDD(); //connection = getConnection(); using (connection) { connection.Open(); string requete = "SELECT * FROM adherent LEFT JOIN club ON adherent.A_fk_club = club.C_id LEFT JOIN type_club ON club.C_fk_type = type_club.T_id ORDER BY adherent.A_id"; MySqlCommand cmd = new MySqlCommand(requete, connection); using (MySqlDataReader datareader = cmd.ExecuteReader()) { while (datareader.Read()) { adhérents = new adherent((string)datareader["A_nom"], (string)datareader["A_prenom"], (string)datareader["A_cp"], (string)datareader["A_adresse"], (string)datareader["A_ville"]); adhérents.DateNaissance = (DateTime)datareader["A_datenaiss"]; adhérents.Id = (int)datareader["A_id"]; if (datareader["A_fk_club"] != System.DBNull.Value && datareader["A_licence"] != System.DBNull.Value) { type = new type_club(Convert.ToInt32(datareader["T_id"]), (string)datareader["T_libelle"]); club = new club((string)datareader["C_nom"], (string)datareader["C_url"], (string)datareader["C_adresse"], (string)datareader["C_codepostal"], (string)datareader["C_ville"], (string)datareader["C_email"], Convert.ToInt32(datareader["C_tel"]), type); adhérents.numero_licence = Convert.ToInt32(datareader["A_licence"]); adhérents.Cotisation = Convert.ToInt32(datareader["A_cotisation"]); adhérents.club = club; } liste.Add(adhérents); } } } return(liste); }
public Modifer_Adh(DATA.adherent adherent, gestion_Clubs gClub) { InitializeComponent(); modadh = adherent; GestionC = gClub; }
public void testadherent() { adherent adhtest = new adherent("Bertrand", "jean", "92130", "6 squares louis blé", "Issy-les-mx"); Assert.Equal("Bertrand", adhtest.Nom); }