private void inscription_Click(object sender, EventArgs e) { Animaux an = new Animaux(); an.Nom = textBox1.Text; an.Poids = (int)numericUpDown1.Value; an.Caractéristiques = richTextBox1.Text; an.DateNaissance = dateTimePicker1.Value; if (client != null) { an.Clients_idClients = client.idClients; } if (femelle.Checked) { an.Sexe = "F"; } else { an.Sexe = "M"; } if (animal == null) { _db.Animaux.Add(an); } else { animal.Nom = an.Nom; animal.DateNaissance = an.DateNaissance; animal.Sexe = an.Sexe; animal.Poids = an.Poids; animal.Caractéristiques = an.Caractéristiques; } _db.SaveChanges(); var animaux = _db.Animaux; int max = 0; foreach (Animaux ani in animaux) { max = ani.idAnimaux; } List <Race> mesRaces = new List <Race>(); mesRaces.Add(raceSelected); Animaux animal2 = _db.Animaux.Find(max); animal2.Race = mesRaces; _db.SaveChanges(); inscriptionGood(an); }
private void validateRappel_Click(object sender, EventArgs e) { if (description.Text.Equals("")) { MessageBox.Show("Veuillez entrer une description."); } else { Rappel rappel = new Rappel(); rappel.Description = description.Text; rappel.Date = datePicker.Value; rappel.Animaux_idAnimaux = animal.idAnimaux; animal.Rappel.Add(rappel); _db.Rappel.Add(rappel); _db.SaveChanges(); string message = "Le rappel a été ajouté avec succès. Voulez-vous ajouté un nouveau rappel ?"; string caption = "Rappel ajouté"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.No) { this.Close(); } if (result == System.Windows.Forms.DialogResult.Yes) { description.Clear(); datePicker.Value = DateTime.Now; } } }
public static void removeAnimal(int id, DB_ENTITIES _db) { Animaux myAnimal = _db.Animaux.Find(id); var rappels = _db.Rappel; foreach (Rappel rappel in rappels) { if (rappel.Animaux_idAnimaux == myAnimal.idAnimaux) { Utils.removeRappel(rappel.idRappel, _db); } } var ordonnances = _db.Ordonnance; foreach (Ordonnance ordonnance in ordonnances) { if (ordonnance.Animaux_idAnimaux == myAnimal.idAnimaux) { Utils.removeOrdonnance(ordonnance.idOrdonnance, _db); } } myAnimal.Soins = null; myAnimal.Race = null; _db.Animaux.Remove(myAnimal); _db.SaveChanges(); }
public static void removeClient(int id, DB_ENTITIES _db) { Clients selectedClient = _db.Clients.Find(id); var rdv = _db.RendezVous; foreach (RendezVous myRdv in rdv) { if (myRdv.Clients_idClients == selectedClient.idClients) { Utils.removeRdv(myRdv.idRendezVous, _db); } } var animals = _db.Animaux; foreach (Animaux animal in animals) { if (animal.Clients_idClients == selectedClient.idClients) { Utils.removeAnimal(animal.idAnimaux, _db); } } var ordonnances = _db.Ordonnance; foreach (Ordonnance ordonnance in ordonnances) { if (ordonnance.Clients_idClients == selectedClient.idClients) { Utils.removeOrdonnance(ordonnance.idOrdonnance, _db); } } _db.Clients.Remove(selectedClient); _db.SaveChanges(); }
public static void removeSoin(int id, DB_ENTITIES _db) { var factures = _db.Factures; foreach (Factures facture in factures) { Utils.removefacture(facture.idFactures, _db); } _db.Soins.Remove(_db.Soins.Find(id)); _db.SaveChanges(); }
private void button1_Click(object sender, EventArgs e) { if (description.Text != null && nameDesease != null) { String name = nameDesease.Text; String descriptionMaladie = description.Text; Maladies maMaladie = new Maladies(); maMaladie.Nom = name; maMaladie.Description = descriptionMaladie; _db.Maladies.Add(maMaladie); _db.SaveChanges(); MessageBox.Show("Ajout de la maladie"); nameDesease.Text = ""; description.Text = ""; completeMaladie(); } else { MessageBox.Show("Merci de completer les champs de nom et de description"); } }
private void insert_Click(object sender, EventArgs e) { DateTime d; if (!pAcq.Text.Equals("") && !pVente.Text.Equals("") && !dAcq.Text.Equals("") && !re.Text.Equals("") && !des.Text.Equals("") && !pNom.Text.Equals("") && DateTime.TryParse(dAcq.Text, out d)) { if (p == null) { int i; if (!this.qtt.Text.Equals("") && int.TryParse(this.qtt.Text, out i)) { for (int j = 0; j < i; j++) { p = new Produits(); p.Nom = pNom.Text; p.refProduits = re.Text; p.Description = des.Text; p.PrixAcquisition = Convert.ToInt32(pAcq.Text); p.PrixVente = Convert.ToInt32(pVente.Text); p.DateAcquisition = DateTime.Parse(dAcq.Text); _db.Produits.Add(p); } } } else { String old = p.Nom; p.Nom = pNom.Text; p.refProduits = re.Text; p.Description = des.Text; p.PrixAcquisition = Convert.ToInt32(pAcq.Text); p.PrixVente = Convert.ToInt32(pVente.Text); p.DateAcquisition = DateTime.Parse(dAcq.Text); foreach (Produits pr in _db.Produits) { if (pr.Nom == old) { pr.Nom = pNom.Text; pr.refProduits = re.Text; pr.Description = des.Text; pr.PrixAcquisition = Convert.ToInt32(pAcq.Text); pr.PrixVente = Convert.ToInt32(pVente.Text); pr.DateAcquisition = DateTime.Parse(dAcq.Text); } } } _db.SaveChanges(); s.initialiseProduits(""); this.Close(); } }
private void supprimerToolStripMenuItem_Click(object sender, EventArgs e) { if (listRdv.SelectedItem == null) { MessageBox.Show("Sélectionnez un rendez-vous."); } else { RendezVous selectedRdv = rdvs[listRdv.SelectedIndex]; Utils.removeRdv(selectedRdv.idRendezVous, _db); _db.SaveChanges(); this.Close(); } }
public static void removeRdv(int id, DB_ENTITIES _db) { RendezVous myRdv = _db.RendezVous.Find(id); var factures = _db.Factures; foreach (Factures facture in factures) { if (facture.RendezVousId == myRdv.idRendezVous) { Utils.removefacture(facture.RendezVousId, _db); } } _db.RendezVous.Remove(_db.RendezVous.Find(id)); _db.SaveChanges(); }
private void button3_Click(object sender, EventArgs e) { var produits = _db.Produits; int i = 0; foreach (Produits p in produits) { if (p.Nom.Equals(produit.Nom)) { if (i < Convert.ToInt32(this.label1.Text)) { _db.Produits.Remove(p); i++; } } } _db.SaveChanges(); generateFacture(); s.initialiseProduits(""); this.Close(); }
private void validateButton_Click(object sender, EventArgs e) { if (rdvValid()) { RendezVous rdvToAdd = new RendezVous();; if (rdvId != -1) { Utils.removeRdv(_db.RendezVous.Find(rdvId).idRendezVous, _db); } DateTime rdvDate = new DateTime(datePicker.Value.Year, datePicker.Value.Month, datePicker.Value.Day, timePicker.Value.Hour, timePicker.Value.Minute, timePicker.Value.Second); int idClient = int.Parse(((String)clientList.SelectedItem.ToString()).Substring(0, ((String)clientList.SelectedItem.ToString()).IndexOf('.', 0))); rdvToAdd.Clients_idClients = idClient; rdvToAdd.Date = rdvDate; rdvToAdd.Description = description.Text; _db.RendezVous.Add(rdvToAdd); _db.SaveChanges(); string message = "Le rendez-vous a été ajouté avec succès. Voulez-vous ajouté un nouveau rendez-vous ?"; string caption = "Rendez-vous ajouté"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.No) { this.Close(); } if (result == System.Windows.Forms.DialogResult.Yes) { description.Clear(); clientList.ClearSelected(); } } else { MessageBox.Show("Le rendez-vous entré n'est pas valide."); } }
private void LogingIn_Click(object sender, EventArgs e) { String login = ""; var utilisateurs = _db.Utilisateurs; foreach (Utilisateurs u in utilisateurs) { if (u.Login.Equals(this.login.Text) && u.MotDePasse.Equals(this.pass.Text)) { login = u.Login; Logs l = new Logs(); l.Action = "Connexion de " + u.Login; l.Date = DateTime.Now; _db.Logs.Add(l); } } _db.SaveChanges(); if (login != "") { Globalinterface g = new Globalinterface(login); g.Show(); this.Hide(); } }
public static void removeOrdonnance(int id, DB_ENTITIES _db) { _db.Ordonnance.Remove(_db.Ordonnance.Find(id)); _db.SaveChanges(); }
public static void removeRappel(int id, DB_ENTITIES _db) { _db.Rappel.Remove(_db.Rappel.Find(id)); _db.SaveChanges(); }
private static void removefacture(int idFactures, DB_ENTITIES _db) { _db.Factures.Remove(_db.Factures.Find(idFactures)); _db.SaveChanges(); }
private void validateButton_Click(object sender, EventArgs e) { if (allInformationComplete()) { Clients toInsert = new Clients(); toInsert.Nom = nameTextBox.Text; toInsert.Prenom = prenomTextBox.Text; toInsert.Adresse = adressTextBox.Text; try { var eMailValidator = new System.Net.Mail.MailAddress(emailTextBox.Text); toInsert.Email = emailTextBox.Text; toInsert.DateNaissance = SelectedDate; if (womanRadioButton.Checked) { toInsert.Sexe = "F"; } else { toInsert.Sexe = "M"; } if (telTextBox.Text == "") { MessageBox.Show("numéro null"); } try { toInsert.Téléphone = Int32.Parse(telTextBox.Text); if (client == null) { _db.Clients.Add(toInsert); } else { client.Nom = toInsert.Nom; client.Prenom = toInsert.Prenom; client.Adresse = toInsert.Adresse; client.Email = toInsert.Email; client.DateNaissance = toInsert.DateNaissance; client.Sexe = toInsert.Sexe; client.Téléphone = toInsert.Téléphone; } _db.SaveChanges(); inscriptionGood(toInsert); } catch (FormatException ex) { MessageBox.Show("numéro incorrect (format incorrect)"); } catch (OverflowException ex) { MessageBox.Show("numéro incorrect (trop long) "); } } catch (FormatException ex) { emailTextBox.ResetText(); MessageBox.Show("Email incorrect"); } } }