public async Task <IActionResult> Edit(int id, [Bind("id,nom,prenom,cin,adress,email,password")] etudiant etudiant) { if (id != etudiant.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(etudiant); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!etudiantExists(etudiant.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(etudiant)); }
// ajoute un etudiant private static etudiant ajouterEtudiant() { etudiant et = new etudiant(); string idEtudiant; string nomEtudiant; string prenomEtudiant; string noteEtudiant; int valNote; Console.Clear(); Console.WriteLine("Exercise Etudiant"); Console.WriteLine("ID de l'etudiant :"); idEtudiant = Console.ReadLine().ToUpper(); Console.WriteLine("Nom de l'etudiant :"); nomEtudiant = Console.ReadLine().ToUpper(); Console.WriteLine("Prénom de l'etudiant :"); prenomEtudiant = Console.ReadLine().ToUpper(); Console.WriteLine("Note de l'etudiant :"); noteEtudiant = Console.ReadLine().ToUpper(); bool noteValid = Int32.TryParse(noteEtudiant, out valNote); if (!noteValid) { Console.WriteLine("conversion de '{0}' a échouer.", noteEtudiant); } et = new etudiant(idEtudiant, nomEtudiant, prenomEtudiant, valNote); return et; }
public ActionResult Create(etudiant et) { if (ModelState.IsValid) { rep.CreateNewEtudiant(et); return(RedirectToAction("Index")); } return(View("Create")); }
public void TestCreateForRedirect() { EtudiantController contro = new EtudiantController(_stubMock); etudiant et = new etudiant(); var result = contro.Create(et) as RedirectToRouteResult; Assert.AreEqual("Index", result.RouteValues["Action"]); }
public void TestCreateIsCalled() { EtudiantController contro = new EtudiantController(_stubMock); etudiant et = new etudiant(); var result = contro.Create(et); _stubMock.Received().CreateNewEtudiant(et);// tester si Getdonnee a ete appele }
public async Task <IActionResult> Create([Bind("id,nom,prenom,cin,adress,email,password")] etudiant etudiant) { if (ModelState.IsValid) { _context.Add(etudiant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details))); } return(View(etudiant)); }
private void pictureBox1_Click_1(object sender, EventArgs e) { try { var Login = new TwitterLogin("RKlFn8Fo0xFxM1xgcaWAg22lK", "6sIGj7PN6DqPM8a7mQ2InpCIl4syZNLImwknedenN3xpfMJkP1", true, true); Login.ShowDialog(); MessageBox.Show(Login.IsSuccessfully.ToString()); if (Login.IsSuccessfully) { try { db = new EtudiantLoginDataContext(); etudiant en = new etudiant(); en.nom = Login.UserInfo.UserName; var query = from enseignant in db.etudiants where enseignant.nom == en.nom select enseignant; List <etudiant> listeEns = query.ToList <etudiant>(); if (listeEns.Count == 0) { MessageBox.Show("aucun compte n'est lié à ce twitter !"); } else { etudiant enss = listeEns[0]; ValidatedEns.cin = enss.cin; ValidatedEns.mots_de_passe = enss.mots_de_passe; ValidatedEns.nom = enss.nom; ValidatedEns.prenom = enss.prenom; ValidatedEns.mail = enss.mail; ValidatedEns.photo = enss.photo; ValidatedEns.code_a_bar = enss.code_a_bar; ValidatedEns.NiveauEtud = enss.NiveauEtud; ValidatedEns.Année = enss.Année; Accueil_Etudiant ac = new Accueil_Etudiant(); ac.Show(); } } catch (SqlException ex) { MessageBox.Show("Erreur de connection BD " + ex.Message); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult Inscription(Etudiant e) { string id = ""; string pass = ""; Random r = new Random(); for (int i = 0; i < 8; i++) { id += r.Next(0, 9); } for (int i = 0; i < 16; i++) { pass += (char)r.Next(33, 125); } e.Id = e.Nom.Substring(0, 3) + e.Prenom.Substring(0, 3) + id; using (DataClasses1DataContext db = new DataClasses1DataContext()) { etudiant etud = new etudiant { Id = e.Id, nom = e.Nom, prenom = e.Prenom, email = e.Email, education = e.Education }; connection con = new connection { Idetudiant = e.Id, user = e.Id, password = pass }; db.etudiants.InsertOnSubmit(etud); db.connections.InsertOnSubmit(con); db.SubmitChanges(); } if (!sendMail(e.Email, e.Id, pass)) { ViewBag.email = "erreur veuillez contacter l'administration"; } return(View("Index")); }
private void pictureBox2_Click(object sender, EventArgs e) { var login = new FacebookLogin("1435890426686808", "c6057dfae399beee9e8dc46a4182e8fd", true, true); login.ShowDialog(); if (login.IsSuccessfully) { try { db = new EtudiantLoginDataContext(); etudiant en = new etudiant(); en.mail = login.UserInfo.Email; var query = from enseignant in db.etudiants where enseignant.mail == en.mail select enseignant; List <etudiant> listeEns = query.ToList <etudiant>(); if (listeEns.Count == 0) { MessageBox.Show("aucun compte n'est lié à ce compte facebook !"); } else { etudiant enss = listeEns[0]; ValidatedEns.cin = enss.cin; ValidatedEns.mots_de_passe = enss.mots_de_passe; ValidatedEns.nom = enss.nom; ValidatedEns.prenom = enss.prenom; ValidatedEns.mail = enss.mail; ValidatedEns.photo = enss.photo; ValidatedEns.code_a_bar = enss.code_a_bar; ValidatedEns.NiveauEtud = enss.NiveauEtud; ValidatedEns.Année = enss.Année; Accueil_Etudiant ac = new Accueil_Etudiant(); ac.Show(); } } catch (SqlException exx) { MessageBox.Show(exx.Message); } } }
public ActionResult Index(String s) { String password = Request.Form["passet"]; String username = Request.Form["emailet"]; projet1aspEntities dbd = new projet1aspEntities(); var etud = dbd.etudiants.SingleOrDefault(x => x.Nom.Equals(username) && x.password.Equals(password)); String passwordp = Request.Form["passp"]; String emailp = Request.Form["emailp"]; var prof = dbd.professeurs.SingleOrDefault(x => x.Nom.Equals(emailp) && x.password.Equals(passwordp)); if (etud != null) { etudiant e = (etudiant)etud; return(View("etudiant", e)); } else if (prof != null) { professeur e = (professeur)prof; return(View("professeur", e)); } return(View()); }
private void bunifuFlatButton1_Click_1(object sender, EventArgs e) { allgood = true; foreach (Control c in panel1.Controls) { if (c is TextBox) { if (c.Text.Length == 0) { MessageBox.Show("veuillez remplir tout les champs !"); c.Focus(); allgood = false; break; } else if (c == textBox1 && textBox1.Text.Length < 8) { MessageBox.Show("cin doit être composé de 8 chiffres !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); allgood = false; } } } if (allgood) { bool emailverif = true; try { var m = new System.Net.Mail.MailAddress(textBox5.Text); } catch (System.FormatException f) { MessageBox.Show("email incorrect !"); emailverif = false; } if (picturechanged == false && pictureBox1.Image == null) { MessageBox.Show("insérer votre image et votre QR code svp !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (picturechanged == false) { MessageBox.Show("insérer votre image svp !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (pictureBox1.Image == null) { MessageBox.Show("générer votre QR code svp !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { db = new EtudiantLoginDataContext(); etudiant ens = new etudiant(); ens.cin = textBox1.Text; var query = from enseignant in db.etudiants where enseignant.cin == ens.cin select enseignant; List <etudiant> listeEns = query.ToList <etudiant>(); if (listeEns.Count != 0) { MessageBox.Show("vous êtes déjà inscrit !"); } else { ens.mail = textBox5.Text; ens.mots_de_passe = textBox4.Text; ens.nom = textBox2.Text; ens.prenom = textBox3.Text; ens.Année = Int32.Parse(textBox7.Text); ens.NiveauEtud = Int32.Parse(textBox6.Text); MemoryStream ms = new MemoryStream(); photo.Image.Save(ms, ImageFormat.Jpeg); byte[] pic_array = new byte[ms.Length]; ms.Position = 0; ms.Read(pic_array, 0, pic_array.Length); ens.photo = pic_array; MemoryStream mss = new MemoryStream(); pictureBox1.Image.Save(mss, ImageFormat.Bmp); byte[] qr_array = new byte[mss.Length]; mss.Position = 0; mss.Read(qr_array, 0, qr_array.Length); ens.code_a_bar = qr_array; db.etudiants.InsertOnSubmit(ens); db.SubmitChanges(); // len = ens.photo.ToString().Length; MessageBox.Show("inscription réussite !"); } } catch (Exception exx) { MessageBox.Show(text: "erreur d'insertion " + exx.Message, caption: "Erreur", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error); } } //MessageBox.Show(len.ToString()); /* * var optionss = new ZXing.Common.EncodingOptions * { * PureBarcode = true, * Height = 30, * Width = 100, * }; * * var writerr = new BarcodeWriter(); * writerr.Format = BarcodeFormat.CODE_128; * writerr.Options = optionss; * var qrr = new BarcodeWriter(); * qrr.Options = optionss; * qrr.Format = ZXing.BarcodeFormat.CODE_128; * var resultt = new Bitmap(qrr.Write(textBox1.Text.Trim())); * pictureBox2.Image = resultt; * * var reader = new BarcodeReader(); * var x=reader.Decode(resultt); * textBox6.Text= x.ToString(); */ } }
private void bunifuFlatButton1_Click(object sender, EventArgs e) { if (cin_tb.Text == "") { MessageBox.Show("Veuillez remplir cin"); } else if (cin_tb.Text.Length > 8) { MessageBox.Show("la longueur de cin dépasse les 8 chiffres veuillez vérifier !"); } else if (mdp_tb.Text == "") { MessageBox.Show("Veuillez remplir mot de passe !"); } else { try { db = new EtudiantLoginDataContext(); etudiant en = new etudiant(); en.cin = cin_tb.Text.ToString(); en.mots_de_passe = mdp_tb.Text.ToString(); var query = from enseignant in db.etudiants where enseignant.cin == en.cin select enseignant; List <etudiant> listeEns = query.ToList <etudiant>(); if (listeEns.Count == 0) { MessageBox.Show("cin introuvable veuillez vérifier !"); } else { etudiant enss = listeEns[0]; if (enss.mots_de_passe != en.mots_de_passe) { MessageBox.Show("mot de passe incorrect"); } else { ValidatedEns.cin = enss.cin; ValidatedEns.mots_de_passe = enss.mots_de_passe; ValidatedEns.nom = enss.nom; ValidatedEns.prenom = enss.prenom; ValidatedEns.mail = enss.mail; ValidatedEns.photo = enss.photo; ValidatedEns.code_a_bar = enss.code_a_bar; ValidatedEns.NiveauEtud = enss.NiveauEtud; ValidatedEns.Année = enss.Année; Accueil_Etudiant ac = new Accueil_Etudiant(); ac.Show(); Hide(); } } } catch (SqlException ex) { MessageBox.Show("Erreur de connection BD " + ex.Message); } } }
private void Form1_Load(object sender, EventArgs e) { ValidatedEns = new etudiant(); }
static void Main(string[] args) { etudiant et = new etudiant(); //donnée test et = new etudiant("ABC01", "Cooke", "André", 60); etudiantListe.Add(et); et = new etudiant("ABC02", "Asselin", "Maxime"); etudiantListe.Add(et); int valeurChoix = 0; while (valeurChoix != 8) { valeurChoix = menu(); if (valeurChoix == 5) return; //Prendre action / loadé le module correspondant if (valeurChoix == 1) // Option 1 - Ajouter Etudiant { etudiantListe.Add(ajouterEtudiant()); } else if (valeurChoix == 2) // Option 2 - Afficher un Étudiant { afficherEtudiant(); } else if (valeurChoix == 3) // Option 3 Modifier un Étudiant { Console.WriteLine("Afficher Modifier un Étudiant"); Console.ReadKey(); } else if (valeurChoix == 4) // Option 4 - Afficher tous les Étudiants { afficherTousLesEtudiant(); } else if (valeurChoix == 5) // Option 5 - Sortir du programme { Console.WriteLine("Quitter"); } } //Console.WriteLine(etudiantListe[0].); //Console.WriteLine(etudiantListe[1].ToString()); //Console.WriteLine(etudiantListe[2].ToString()); }
public void DeleteEtudiant(etudiant etudiant) { etudiantRepo.Remove(etudiant); }
public void CreateNewEtudiant(etudiant etud) { db.etudiants.Add(etud); db.SaveChanges(); }