private void ImportExcelFile_Click(object sender, EventArgs e) { if (dt.Rows.Count > 0) { int addedRows = 0; foreach (DataRow dr in dt.Rows) { if (!StudentExist(dr[0].ToString())) { addedRows++; Etudiant etudiant = new Etudiant(); etudiant.cne = dr[0].ToString(); etudiant.nom = dr[1].ToString(); etudiant.prenom = dr[2].ToString(); etudiant.sexe = Convert.ToChar(dr[3]); etudiant.date_naissance = (DateTime)dr[4]; etudiant.adresse = dr[5].ToString(); etudiant.tele = dr[6].ToString(); etudiant.id_filiere = Convert.ToInt32(dr[7]); cl.Etudiant.InsertOnSubmit(etudiant); cl.SubmitChanges(); } } this.Hide(); MessageBox.Show(addedRows + " étudiant été ajouté(s) et " + dt.Rows.Count + " déjà existe"); } else { MessageBox.Show("Nothing To Import"); } }
private void listeCne_SelectedIndexChanged(object sender, EventArgs e) { Etudiant a = selectedEtudiant(); cne.Text = a.Cne.ToString(); Nom.Text = a.Nom; prenom.Text = a.Prenom; if (a.Sexe == 'F') { female.Checked = true; } else { male.Checked = true; } dateN.Text = a.DateNaissance; adresse.Text = a.Adresse; telephone.Text = a.Telephone; var fil = (from etd in db.etudiants join f in db.Filieres on etd.id_fil equals f.id_Filiere where etd.id_fil == a.Filiere select f); foreach (Filiere f in fil) { comboBox1.SelectedItem = f.nom_Filiere; break; } }
public Etudiant selectedEtudiant() { int cneSelected = Convert.ToInt32(listeCne.SelectedItem.ToString()); var etdSelected = (from etd in db.etudiants where etd.cne == cneSelected select etd).SingleOrDefault(); etudiant e1 = etdSelected as etudiant; Etudiant student = new Etudiant(e1.nom, e1.prenom, e1.date_naiss, e1.adresse, e1.telephone, e1.cne, Convert.ToInt32(e1.id_fil), Convert.ToChar(e1.sexe)); return(student); }
void FillTextBox_Etudiant(Etudiant e) { cne_textBox.Text = e.cne; nom_textbox.Text = e.nom; prenom_textbox.Text = e.prenom; adresse_textbox.Text = e.adresse; if (e.sexe == 'M') { male_radio.Checked = true; } else { female_radio.Checked = true; } tele_textbox.Text = e.tele; date_naissance.Value = (DateTime)e.date_naissance; choixFiliereCombo.Text = e.filiere.nom_filiere; }
private void Ajouter_Click(object sender, EventArgs e) { var cne = cne_textBox.Text; var x = from et in cl.Etudiant where et.cne == cne select et; if (x.Count() > 0) { MessageBox.Show("Le CNE existe déjà dans la base de données!"); return; } if (female_radio.Checked) { choix = "M"; } else { choix = "F"; } var etu = new Etudiant(); etu.cne = cne; etu.nom = nom_textbox.Text; etu.prenom = prenom_textbox.Text; etu.adresse = adresse_textbox.Text; etu.sexe = choix[0]; etu.date_naissance = date_naissance.Value; etu.tele = tele_textbox.Text; ComboBoxItem cnb = (ComboBoxItem)choixFiliereCombo.SelectedItem; etu.id_filiere = cnb.Value1; cl.Etudiant.InsertOnSubmit(etu); cl.SubmitChanges(); MessageBox.Show("L'étudiant a été ajouté avec succès."); dataGridView1.Refresh(); CleanTextBoxs(); }
public string AddStudent(string Cin, string Nom, string Prenom, string Email, string Tel, string NomFiliere) { var db = new SQLiteConnection(dbPath); var newEtudiant = new Etudiant(); newEtudiant.Cin = Cin; newEtudiant.Nom = Nom; newEtudiant.Prenom = Prenom; newEtudiant.Email = Email; newEtudiant.Tel = Tel; //adding filiere var f = db.Query <Filiere>("SELECT * FROM Filiere WHERE NomFiliere = ?", NomFiliere); if (f.Count() == 0) { return("Cette filière n'existe pas"); } else { newEtudiant.IdFiliere = f[0].IdFiliere; } //adding all infos in db var tables = db.Table <Etudiant>().FirstOrDefault(x => x.Cin == Cin); if (tables == null) { db.Insert(newEtudiant); return("Ajouté avec succès"); } else { return("Déjà ajouté"); } }
private void detach_Etudiant(Etudiant entity) { this.SendPropertyChanging(); entity.filiere = null; }
private void attach_Etudiant(Etudiant entity) { this.SendPropertyChanging(); entity.filiere = this; }
partial void DeleteEtudiant(Etudiant instance);
partial void UpdateEtudiant(Etudiant instance);
partial void InsertEtudiant(Etudiant instance);