public void ajouterAbonne() { #region Ajouter un abonné à la base if (tousChampsRemplis()) { if (LoginUnique(textBoxLogin.Text)) { Abonné a = new Abonné(); a.Nom_Abonné = textBoxNom.Text; a.Prénom_Abonné = textBoxPrenom.Text; a.Login = textBoxLogin.Text; a.Password = textBoxMDP.Text; a.Code_Pays = comboBoxPays.SelectedItem.GetHashCode(); musiqueSQL.Abonné.Add(a); musiqueSQL.SaveChanges(); labelMessage.Text = "Inscription confirmée"; } } else { labelMessage.Text = "Veuillez remplir tous les champs"; labelMessage.ForeColor = Color.Red; } #endregion }
public MesEmprunts() { InitializeComponent(); abn = new Abonné(); musiqueSQL = new MusiqueSQLEntities(); buttonProlonger.Enabled = checkBoxEmprunt.Checked && listAlbums.SelectedItem != null; buttonPrologerAll.Enabled = checkBoxEmprunt.Checked; checkBoxEmprunt.Enabled = abn == null; }
private string prenomAbonné(Abonné a) { string nom = "Sans prénom"; if (a.Prénom_Abonné != null) { string[] v = System.Text.RegularExpressions.Regex.Split(a.Prénom_Abonné, " "); nom = v[0]; } return(nom); }
private void checkBoxEmprunt_CheckedChanged(object sender, EventArgs e) { listAlbums.Items.Clear(); if (LoginBox.Text != null && PassBox.Text != null) { var abo = (from a in musiqueSQL.Abonné where a.Login == LoginBox.Text && a.Password == PassBox.Text select a).ToList(); abn = abo.First(); } buttonProlonger.Enabled = checkBoxEmprunt.Checked && listAlbums.SelectedItem != null; buttonPrologerAll.Enabled = checkBoxEmprunt.Checked; chargerListeAlbum(); }
private void listAbo_SelectedIndexChanged(object sender, EventArgs e) { #region affichage des informations sur l'abonné choisi Abonné a = (Abonné)listAbo.SelectedItem; textBoxLogin.Text = a.Login; listRetards.Items.Clear(); foreach (Emprunter emp in emprunts) { if (emp.Code_Abonné == a.Code_Abonné) { listRetards.Items.Add(emp.Album); } } #endregion }
private void buttonConnexion_Click(object sender, EventArgs e) { try { if (LoginBox.Text != null && PassBox.Text != null) { var abo = (from a in musiqueSQL.Abonné where a.Login == LoginBox.Text && a.Password == PassBox.Text select a).ToList(); abn = abo.First(); } chargerListeAlbum(); checkBoxEmprunt.Enabled = abn != null; } catch { labelMessage.Text = "Erreur ! Login ou Mot de Passe invalide"; labelMessage.ForeColor = Color.Red; } }
private void button1_Click(object sender, EventArgs e) { #region Récuperation de l'album et l'abonné Abonné abn = new Abonné(); abn.Login = "******"; bool emprunter = false; labelMessage.Text = ""; label5.Text = ""; Album AlbSelection = new Album(); try { if (listBox1.SelectedItem != null && !titreAlbum.Text.Contains("INDISPONIBLE")) { AlbSelection = (Album)listBox1.SelectedItem; } else { emprunter = true; label5.Text = "Cet album est indisponible"; label5.ForeColor = Color.Red; } } catch { labelMessage.Text = "Veuillez choisir un autre album et cliquez sur emprunter "; } var abonnés = (from a in musique.Abonné orderby a.Login select a).ToList(); // Remplir la listbox foreach (Abonné a in abonnés) { if (Login.Text == a.Login) { var abonné = (from ab in musique.Abonné where ab.Login == Login.Text select ab).ToList(); abn = abonné.First(); } else { label5.Text = "Entrez un login valide"; label5.ForeColor = Color.Red; } } // Verifier que l'album est disponible if (!emprunter) { var albemprunte = (from ab in musique.Emprunter where ab.Date_Retour == null select ab).ToList(); foreach (Emprunter em in albemprunte) { if (em.Code_Album == AlbSelection.Code_Album) { //emprunter = true; label5.Text = "Cet album est indisponible"; label5.ForeColor = Color.Red; } } } // Création d'emprunt if (listBox1.SelectedItem != null && abn.Login != "temp" && !emprunter) { Emprunter E = new Emprunter() { Code_Abonné = abn.Code_Abonné, Code_Album = AlbSelection.Code_Album, Date_Emprunt = DateTime.Now }; musique.Emprunter.Add(E); try { musique.SaveChanges(); Login.Clear(); label5.Text = "Emprunt OK"; label5.ForeColor = Color.Red; labelDate.Text = "Album emprunté le " + DateTime.Now; labelDate.ForeColor = Color.Blue; } catch { label5.Text = "Erreur !!"; label5.ForeColor = Color.Red; } } #endregion }