protected void insertBtn_Click(object sender, EventArgs e) { if (nomTxt.Text != "" && ageInt.Text != "" && int.TryParse(ageInt.Text, out int age) && age >= 0) { String name = nomTxt.Text; Etudiant etudiant = db.Etudiant.SingleOrDefault(x => x.Nom == nomTxt.Text); if (etudiant == null) { etudiant = new Etudiant(); etudiant.Nom = name; etudiant.Age = age; db.Etudiant.InsertOnSubmit(etudiant); db.SubmitChanges(); effacer(); showData(); } else { effacer(); erreur.Text = "Error 404: " + name + " already exist !!!"; } } else { erreur.Text = "Error 404: the name is empty or the age is incorrect !"; } }
public string recherche(string name) { string result = ""; Etudiant etudiant = new Etudiant(); etudiant = db.Etudiant.FirstOrDefault(x => x.Nom == name); if (etudiant != null) { result += "Nom: " + etudiant.Nom + " Age: " + etudiant.Age + "."; } return(result); }
protected void deletebtn_Click(object sender, EventArgs e) { if (nomTxt.Text != "") { Etudiant etudiant = db.Etudiant.SingleOrDefault(x => x.Nom == nomTxt.Text); db.Etudiant.DeleteOnSubmit(etudiant); db.SubmitChanges(); effacer(); showData(); } else { erreur.Text = "Error 404: the name is empty !!!"; } }
protected void updatebtn_Click(object sender, EventArgs e) { if (nomTxt.Text != "" && ageInt.Text != "" && int.TryParse(ageInt.Text, out int age) && age >= 0) { String name = nomTxt.Text; Etudiant etudiant = db.Etudiant.SingleOrDefault(x => x.Nom == name); if (etudiant != null) { etudiant.Age = int.Parse(ageInt.Text); db.SubmitChanges(); showData(); effacer(); } else { effacer(); erreur.Text = "Error 404: " + name + " does not exist !!!"; } } else { erreur.Text = "Error 404: the name is empty or the age is incorrect !!!"; } }
partial void DeleteEtudiant(Etudiant instance);
partial void UpdateEtudiant(Etudiant instance);
partial void InsertEtudiant(Etudiant instance);