public static void update(Entreprise uneEntreprise) { try { open("App"); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conn; cmd.CommandText = "UPDATE entreprise SET numeroSiret=@numeroSiret,nomEntreprise=@nomEntreprise,adresse=@adresse,codePostal=@codePostal,ville=@ville,commentaire=@commentaire WHERE idEntreprise=@idEntreprise"; cmd.Prepare(); cmd.Parameters.AddWithValue("@numeroSiret", uneEntreprise.NumeroSiret); cmd.Parameters.AddWithValue("@nomEntreprise", uneEntreprise.NomEntreprise); cmd.Parameters.AddWithValue("@adresse", uneEntreprise.Adresse); cmd.Parameters.AddWithValue("@codePostal", uneEntreprise.CodePostal); cmd.Parameters.AddWithValue("@ville", uneEntreprise.Ville); cmd.Parameters.AddWithValue("@commentaire", uneEntreprise.Commentaire); cmd.Parameters.AddWithValue("@idEntreprise", uneEntreprise.IdEntreprise); cmd.ExecuteNonQuery(); close(); } catch (MySqlException ex) { Console.WriteLine("Error: {0}", ex.ToString()); } }
public IHttpActionResult PutEntreprise(int id, Entreprise entreprise) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != entreprise.id_entreprise) { return(BadRequest()); } db.Entry(entreprise).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EntrepriseExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
static void Main(string[] args) { Random randSalaire = new Random(); Entreprise<Employe> entreprise = new Entreprise<Employe>(); for (int i = 0; i < 10; i++) { Employe e = new Employe(i + "emp"); e.Salaire = randSalaire.Next(2000, 5000); entreprise.add(e, e.NomPrenom); } Console.Write("Entre le nom et prenom tout attaché : "); string line = Console.ReadLine(); Employe emp = entreprise.getEmpoye(line); Console.WriteLine("L'employée {0} gagne {1}", emp.NomPrenom, emp.Salaire ); List<Employe> emps = new List<Employe>(); emps = entreprise.GetEmployeesList(); foreach (var e in emps) { Console.WriteLine("Nom et Prénom : {0} - Salaire : {1} CHF", e.NomPrenom, e.Salaire); } }
// // GET: /Bilan/ public ActionResult Index() { Entreprise ent = new Entreprise(); var model = ent.getList(); return(View(model)); }
public List <Entreprise> GetAllEntreprises() { Requete = "Select * from ENTREPRISE order by NOM_ENTREPRISE"; SqlCommand objSelectCommand = new SqlCommand(Requete); DataTable objDataTable = objSingleton.ExecuteDataTable(objSelectCommand); foreach (DataRow row in objDataTable.Rows) { Entreprise entreprise = new Entreprise(); entreprise.IDEntreprise = Convert.ToInt32(row["ID_ENTREPRISE"]); entreprise.NomEntreprise = row["NOM_ENTREPRISE"].ToString(); if (row.IsNull("CONTACT_ENTREPRISE")) { entreprise.ContactEntreprise = "Non renseigné"; } else { entreprise.ContactEntreprise = row["CONTACT_ENTREPRISE"].ToString(); } if (row.IsNull("TELEPHONE_CONTACT")) { entreprise.NumeroEntreprise = 0; } else { entreprise.NumeroEntreprise = Convert.ToInt32(row["TELEPHONE_CONTACT"]); } Liste.Add(entreprise); } return(Liste); }
public int UpdateEntreprise(int numero, string nom) { SqlCommand objSelectCommand = new SqlCommand(); objSingleton.Open(); objSelectCommand.CommandText = "dbo.UpdateEntreprise"; objSelectCommand.CommandType = CommandType.StoredProcedure; objSelectCommand.Parameters.AddWithValue("@ID_ENTREPRISE", numero); objSelectCommand.Parameters.AddWithValue("@CONTACT_ENTREPRISE", nom); int nbLignes = objSingleton.ExecuteNonQuery(objSelectCommand); DataTable objDataTable = new DataTable(); SqlDataAdapter objDataAdapter = new SqlDataAdapter(objSelectCommand); objDataAdapter.Fill(objDataTable); foreach (DataRow row in objDataTable.Rows) { Entreprise entreprise = new Entreprise(); entreprise.IDEntreprise = Convert.ToInt32(row["ID_ENTREPRISE"]); entreprise.NomEntreprise = row["NOM_ENTREPRISE"].ToString(); entreprise.ContactEntreprise = row["CONTACT_ENTREPRISE"].ToString(); entreprise.NumeroEntreprise = Convert.ToInt32(row["TELEPHONE_CONTACT"]); Liste.Add(entreprise); } objSingleton.Close(); return(nbLignes); }
//Modifier Entreprise static public bool modifierEntreprise(Entreprise Entreprise, List <int> idsFormationsRecherchees, List <int> idsInteretsRecherches, List <int> idsTechnologiesRecherchees) { bool modifie = RequeteEntreprise.modifierEntreprise(Entreprise); if (modifie) { RequeteEntreprise.deleteDomaineRecherche(Entreprise.Id); if (idsInteretsRecherches != null) { foreach (int i in idsInteretsRecherches) { RequeteEntreprise.ajouterInteretRecherche(Entreprise.Id, i); } } if (idsFormationsRecherchees != null) { foreach (int i in idsFormationsRecherchees) { RequeteEntreprise.ajouterFormationRecherchee(Entreprise.Id, i); } } if (idsTechnologiesRecherchees != null) { foreach (int i in idsTechnologiesRecherchees) { RequeteEntreprise.ajouterTechnologieRecherche(Entreprise.Id, i); } } } return(modifie); }
//Ajouter Entreprise //Ajouter Entreprise static public bool ajouterEntreprise(Entreprise Entreprise, List <int> idsFormationsRecherchees, List <int> idsInteretsRecherches, List <int> idsTechnologiesRecherchees) { bool cree = false; cree = RequeteEntreprise.ajouterEntreprise(Entreprise); //ajouter les domaines recherche if (cree) { if (idsInteretsRecherches != null) { foreach (int id in idsInteretsRecherches) { RequeteEntreprise.ajouterInteretRecherche(Entreprise.Id, id); } } if (idsFormationsRecherchees != null) { foreach (int i in idsFormationsRecherchees) { RequeteEntreprise.ajouterFormationRecherchee(Entreprise.Id, i); } } if (idsTechnologiesRecherchees != null) { foreach (int i in idsTechnologiesRecherchees) { RequeteEntreprise.ajouterTechnologieRecherche(Entreprise.Id, i); } } } return(cree); }
public async Task <IActionResult> Delete(int id) { if (ModelState.IsValid) { try { Entreprise _entreprise = _unitOfWork.Entreprise.GetSingleOrDefault(e => e.Id == id); if (_entreprise != null) { _unitOfWork.Entreprise.Remove(_entreprise); await _unitOfWork.SaveChangesAsync(); return(Ok("OK")); } else { return(BadRequest()); } } catch (Exception ex) { return(BadRequest(ex.Data)); } } else { return(BadRequest(ModelState)); } }
public EntrepriseModel Get(long id) { return(Entreprise.toModel(_ctx.Entreprise .Include(e => e.Entities) .Include(e => e.Contracts) .FirstOrDefault(e => e.EntrepriseId == id))); }
public async Task <IActionResult> PutEntreprise(Guid id, Entreprise entreprise) { if (id != entreprise.Id) { return(BadRequest()); } _context.Entry(entreprise).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EntrepriseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult getListNomEnt() { Entreprise entreprise = new Entreprise(); var model = entreprise.getList(); return(View(model)); }
//Modifier Entreprise info protected void ModifierEnt_ServerClick(object sender, EventArgs e) { int id = int.Parse(Session["idUser"].ToString()); Entreprise En = db.Entreprise.SingleOrDefault(x => x.idEntreprise == id); if (logoUp.PostedFile != null) { string strPath = Path.GetExtension(logoUp.PostedFile.FileName); strPath = strPath.ToLower(); if (strPath != ".jpg" && strPath != ".jpeg" && strPath != ".gif" && strPath != ".png") { ClientScript.RegisterStartupScript(this.GetType(), "erreurAlert", "loginalert()", true); Response.Write("only image"); } else { string filup = Path.GetFileName(logoUp.PostedFile.FileName); logoUp.SaveAs(Server.MapPath("~/Logo_Entreprise/") + filup); En.logo = filup; } } En.nom = txtNomEnt.Text; En.ville = txtVilleEnt.Text; En.adresse = txtadresseEnt.Text; En.anneeCreation = DateTime.Parse(txtDateEnt.Text).Date; En.description = txtDescription.Text; db.SubmitChanges(); Response.Redirect("~/Home.aspx"); }
public ActionResult EnregistrerLesModifications() { if (!EstCeQueLaRequeteEstValidePourEnregistrerLesModifications()) { this.AddToastMessage("Confirmation", "l'opération ne s'est pas effectué avec succes", ToastType.Error, true); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var entreprise = new Entreprise { IdEntreprise = Convert.ToInt32(Request.Form["id"]), Pays = Request.Form["pays"], Province = Request.Form["province"], Ville = Request.Form["ville"], Rue = Request.Form["rue"], NumeroCivique = Convert.ToInt32(Request.Form["numeroCivique"]), CodePostal = Request.Form["codePostal"], Nom = Request.Form["nom"] }; this.AddToastMessage("Confirmation", "l'opération c'est effectué avec succes", ToastType.Success, true); _db.Entreprise.AddOrUpdate(entreprise); _db.SaveChanges(); return(RedirectToAction("Index")); }
static void Main(string[] args) { Services service1 = new Services(1, "Production"); Services service2 = new Services(2, "Comptabilité"); Services service3 = new Services(3, "Direction"); Employe p1 = new Employe(1, "DUPONT", "Charles", Personnel.Gender.male, new DateTime(1998, 04, 12), 1500, service1, 14); Employe p2 = new Employe(2, "KERBAN", "Henry", Personnel.Gender.female, new DateTime(1981, 09, 24), 1500, service1, 7); Employe p3 = new Employe(3, "CHAMPOT", "Paul", Personnel.Gender.male, new DateTime(1981, 03, 17), 1500, service1, 6); Cadre p4 = new Cadre(4, "JOULIE", "Alexandre", Personnel.Gender.female, new DateTime(1987, 11, 21), 2100, service2, 100); Cadre p5 = new Cadre(5, "MITAUT", "Marcel", Personnel.Gender.female, new DateTime(1972, 10, 06), 6000, service3, 2000); List <Personnel> listPersonne = new List <Personnel>(); listPersonne.AddRange(new Personnel[] { p1, p2, p3, p4, p5 }); List <Services> listService = new List <Services>(); listService.AddRange(new Services[] { service1, service2, service3 }); Entreprise entreprise = new Entreprise(listPersonne, listService); Console.WriteLine(p1.Identite); Console.WriteLine(p2.Identite); Console.WriteLine(p3.Identite); Console.WriteLine(p4.Identite); Console.WriteLine(p5.Identite); }
public IHttpActionResult PostEntreprise(Entreprise entreprise) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Entreprise.Add(entreprise); try { db.SaveChanges(); } catch (DbUpdateException) { if (EntrepriseExists(entreprise.id_entreprise)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = entreprise.id_entreprise }, entreprise)); }
public PageAjouterEntreprise(Entreprise a) { InitializeComponent(); WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; txt_Nom.Text = a.nomEntreprise; using (var db = new MarcassinEntities1()) { cmb_Ville.ItemsSource = db.Villes.ToList(); cmb_Ville.DisplayMemberPath = "nomVille"; cmb_Ville.SelectedValuePath = "id_Ville"; int index = 0; for (int i = 0; i < cmb_Ville.Items.Count; i++) { List <Ville> parts = db.Villes.ToList(); if (parts[i].nomVille == a.Ville.nomVille) { index = i; } } this.cmb_Ville.SelectedIndex = index; } Id = a.id_Entreprise; Action = "update"; Btn_ajouter.Content = "Modifier"; Btn_ajouter.Background = new SolidColorBrush(Color.FromRgb(255, 200, 0)); }
public ActionResult EnregistrerLesModifications( int?idContact, string nom, string courriel, string telephone, Entreprise entreprise ) { if (idContact == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var contact = _db.Contact.Find(idContact); if (contact == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } contact.Courriel = courriel; contact.Nom = nom; contact.Telephone = telephone; contact.Entreprise_IdEntreprise = entreprise.IdEntreprise; _db.SaveChanges(); return(RedirectToAction("Index", "Contact")); }
public ActionResult Edit([Bind(Include = "EntrepriseID,Name,Address,City,Email,Password,Cellphone,Website")] Entreprise entreprise, HttpPostedFileBase Logo) { if (ModelState.IsValid) { db.Entry(entreprise).State = EntityState.Modified; if (Logo != null && Logo.ContentLength > 0) { var fileName = Path.GetFileName(Logo.FileName); var path = Path.Combine(Server.MapPath("~/Uploads/"), fileName); Logo.SaveAs(path); entreprise.Logo = fileName; } else { db.Entry(entreprise).Property(m => m.Logo).IsModified = false; } ModelState.Clear(); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(entreprise)); }
static void Main(string[] args) { string path = Directory.GetCurrentDirectory() + @"\Document\TestConvention.docx"; if (!File.Exists(path)) { string pathCopy = Directory.GetCurrentDirectory() + @"\Document\Copy.docx"; File.Copy(path, pathCopy); //using (WordprocessingDocument doc = WordprocessingDocument.Open(path, true)) //{ //} if (!File.Exists(pathCopy)) { return; } using (WordprocessingDocument doc = WordprocessingDocument.Open(pathCopy, true)) { IEnumerable <FieldCode> docWorld = OpenXmlWordHelpers.GetMergeFields(doc); Entreprise ent = Program._context.Entreprises.First(); foreach (FieldCode item in docWorld) { if (item.InnerXml.Contains("Nom_Entreprise")) { item.ReplaceWithText(ent.RaisonSociale); } if (item.InnerXml.Contains("Adresse_entreprise")) { item.ReplaceWithText(ent.NumeroNomVoieEntreprise); } //if (item.InnerXml.Contains("Adresse_entreprise_suite")) //{ // if (ent.ComplementAdresseEntreprise == string.Empty) // item.ReplaceWithText("0"); // else // item.ReplaceWithText(ent.ComplementAdresseEntreprise); //} if (item.InnerXml.Contains("Code_postal_entreprise")) { item.ReplaceWithText(ent.CodePostalEntreprise); } if (item.InnerXml.Contains("Ville_entreprise")) { item.ReplaceWithText(ent.VilleEntreprise); } if (item.InnerXml.Contains("Téléphone_entreprise")) { item.ReplaceWithText(""); } } } } string toto = HashPassword("toto"); }
public static void create(Entreprise uneEntreprise, string connect) { try { open(connect); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conn; cmd.CommandText = "INSERT INTO entreprise (numeroSiret,nomEntreprise,adresse,codePostal,ville,commentaire,entrepriseCreer) VALUES (@numeroSiret,@nomEntreprise,@adresse,@codePostal,@ville,@commentaire,@entrepriseCreer)"; cmd.Prepare(); cmd.Parameters.AddWithValue("@numeroSiret", uneEntreprise.NumeroSiret); cmd.Parameters.AddWithValue("@nomEntreprise", uneEntreprise.NomEntreprise); cmd.Parameters.AddWithValue("@adresse", uneEntreprise.Adresse); cmd.Parameters.AddWithValue("@codePostal", uneEntreprise.CodePostal); cmd.Parameters.AddWithValue("@ville", uneEntreprise.Ville); cmd.Parameters.AddWithValue("@commentaire", uneEntreprise.Commentaire); cmd.Parameters.AddWithValue("@entrepriseCreer", uneEntreprise.EntrepriseCreer); cmd.ExecuteNonQuery(); close(); } catch (MySqlException ex) { Console.WriteLine("Error: {0}", ex.ToString()); } }
public async Task <ActionResult <Entreprise> > PostEntreprise(Entreprise entreprise) { _context.Entreprise.Add(entreprise); await _context.SaveChangesAsync(); return(CreatedAtAction("GetEntreprise", new { id = entreprise.Id }, entreprise)); }
public ActionResult ajoutEntreprise() { Entreprise ent = new Entreprise(); ent.Design = Convert.ToString(Request.Form["Design"]); ent.raisonSociale = Convert.ToString(Request.Form["raisonSociale"]); ent.addresse = Convert.ToString(Request.Form["addresse"]); ent.enregistEntreprise(ent); string sql = "SELECT * from entreprise order by id desc"; conn = new MySqlConnection(Connexion_param); cmd = new MySqlCommand(sql, conn); conn.Open(); reader = cmd.ExecuteReader(); var model = new List <Entreprise>(); while (reader.Read()) { var entreprise = new Entreprise(); entreprise.Design = reader["Design"].ToString(); entreprise.raisonSociale = reader["raisonSociale"].ToString(); entreprise.addresse = reader["addresse"].ToString(); entreprise.id = reader["id"].ToString(); entreprise.numEntreprise = reader["numEntreprise"].ToString(); model.Add(entreprise); } conn.Close(); return(View(model)); }
private static void AffectParamCde(Entreprise ent, SqlCommand sqlCde) { sqlCde.CommandType = CommandType.StoredProcedure; sqlCde.Parameters.Clear(); // affectation des parametres communs sqlCde.Parameters.Add(new SqlParameter("@idActivite", SqlDbType.TinyInt)).Value = ent.SecteurActivite.IdActivite; if (ent.PoleRattachement != null) { sqlCde.Parameters.Add(new SqlParameter("@idPole", SqlDbType.Int)).Value = ent.PoleRattachement.IdPole; } sqlCde.Parameters.Add(new SqlParameter("@raisonsociale", SqlDbType.VarChar, 50)).Value = ent.RaisonSociale; sqlCde.Parameters.Add(new SqlParameter("@adr1", SqlDbType.VarChar, 30)).Value = ent.Adresse1Ent; sqlCde.Parameters.Add(new SqlParameter("@adr2", SqlDbType.VarChar, 30)).Value = ent.Adresse2Ent; sqlCde.Parameters.Add(new SqlParameter("@cpent", SqlDbType.VarChar, 5)).Value = ent.CpEnt; sqlCde.Parameters.Add(new SqlParameter("@villeEnt", SqlDbType.VarChar, 30)).Value = ent.VilleEnt; sqlCde.Parameters.Add(new SqlParameter("@cliente", SqlDbType.Bit)).Value = ent.Cliente; if (ent.Contact != null) { sqlCde.Parameters.Add(new SqlParameter("@nomCorresp", SqlDbType.VarChar, 50)).Value = ent.Contact; } if (ent.TelContact != null) { sqlCde.Parameters.Add(new SqlParameter("@tel", SqlDbType.VarChar, 20)).Value = ent.TelContact; } if (ent.MailContact != null) { sqlCde.Parameters.Add(new SqlParameter("@mail", SqlDbType.VarChar, 30)).Value = ent.MailContact; } sqlCde.Parameters.Add(new SqlParameter("@datecreation", SqlDbType.Date)).Value = ent.DateCreation; }
public void SupprEnt(Entreprise a) { using (var db = new MarcassinEntities1()) { Entreprise b = db.Entreprises.Find(a.id_Entreprise); db.Entreprises.Remove(b); db.SaveChanges(); } }
public EntrepriseModel Add(EntrepriseModel entreprise) { Entreprise entity = Entreprise.formModel(entreprise); _ctx.Entreprise.Add(entity); _ctx.SaveChanges(); return(Entreprise.toModel(entity)); }
public IActionResult Enregistrementbd(Entreprise Entreprise) { Entreprise.Id = null; var resultat = _maBd.Entreprise.Add(Entreprise); _maBd.SaveChanges(); return(new OkObjectResult(Entreprise)); }
public void TestEntreprise_uneEntrepriseValideEstValide() { Entreprise entreprise = new Entreprise(); IEntrepriseMessage message = TEST.MESSAGE_ENTREPRISE_VALIDE; entreprise.modifier(message); Assert.IsTrue(entreprise.estValide()); Assert.AreEqual(0, entreprise.donnerLesMessagesDeValidation().Count()); }
public ActionResult DeleteConfirmed(int id) { Entreprise entreprise = db.Entreprises.Find(id); db.Entreprises.Remove(entreprise); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public void modifier(IClientEntrepriseMessage message) { Civilité = (Civilite)message.Civilité; Nom = new Nom(message.Nom); Prénom = new Prenom(message.Prénom); AdresseEmail = new AdresseEmail(message.AdresseEmail); Téléphone = new NumeroTelephone(message.Téléphone); Entreprise = Entreprise.charger(message.IdEntreprise); }
private void ajoutBtn_Click(object sender, EventArgs e) { Entreprise ent = new Entreprise(siretBox.Text, entBox.Text, adresseBox.Text, cpBox.Text, villeBox.Text, tbxCommentaire.Text, false); AdoEntreprise.create(ent, "App"); Accueil accueil = new Accueil(); accueil.Show(); this.Close(); }
private void RecupererEntreprise(object sender, RoutedEventArgs e) { Button b = (Button)sender; entreprise = (Entreprise)b.DataContext; ImgEntreprise.Source = new BitmapImage(new Uri(@"" + entreprise.ImageLogo, UriKind.RelativeOrAbsolute)); NomEntrepriseVue.Content = entreprise.Nom; LeStage.IdEntreprise = entreprise.Id; }
public ActionResult suppEntreprise() { String id = Convert.ToString(Request.Form["id"]); Entreprise ent = new Entreprise(); ent.suppEnt(id); var model = ent.getList(); return(View(model)); }
public void TestEntreprise_uneEntrepriseVideEstInvalide() { Entreprise entreprise = new Entreprise(); entreprise.modifier(TEST.MESSAGE_ENTREPRISE_VIDE); Assert.IsFalse(entreprise.estValide()); ListeMessagesValidation erreurs = entreprise.donnerLesMessagesDeValidation(); Assert.AreEqual(5, erreurs.Count()); Assert.IsTrue(erreurs.Any(x => x == VALIDATION.REQUIS_NUMERO_SIRET)); Assert.IsTrue(erreurs.Any(x => x == VALIDATION.REQUIS_DENOMINATION)); Assert.IsTrue(erreurs.Any(x => x == VALIDATION.REQUIS_VOIE)); Assert.IsTrue(erreurs.Any(x => x == VALIDATION.REQUIS_CODE_POSTAL)); Assert.IsTrue(erreurs.Any(x => x == VALIDATION.REQUIS_COMMUNE)); }
public void TestEntreprise_uneEntrepriseAvecUnNuméroSIRETDéjàPrisEstInvalide() { Entreprise entrepriseEnregistrée = new Entreprise(); IEntrepriseMessage message = TEST.MESSAGE_ENTREPRISE_VALIDE; entrepriseEnregistrée.modifier(TEST.MESSAGE_ENTREPRISE_VALIDE); entrepriseEnregistrée.enregistrer(); Entreprise entreprise = new Entreprise(); entreprise.modifier(message); Assert.IsFalse(entreprise.estValide()); ListeMessagesValidation erreurs = entreprise.donnerLesMessagesDeValidation(); Assert.AreEqual(1, erreurs.Count()); Assert.IsTrue(erreurs.Any(x => x == VALIDATION.INDISPONIBLE_NUMERO_SIRET)); }
public DevisChoixContactWindow(Entreprise _entreprise) { InitializeComponent(); //Mise en place des droits sur les boutons et tabs Securite securite = new Securite(); if (!securite.VerificationDroitActionsCRUD("SitaffRibbon.UserControls.ListeContactsControl", "Add")) { this.NewContact.Visibility = Visibility.Collapsed; } if (!securite.VerificationDroitActionsCRUD("SitaffRibbon.UserControls.ListeContactsControl", "Look")) { this.LookContact.Visibility = Visibility.Collapsed; } this.entreprise = _entreprise; }
public List<Entreprise> SelectEntrepriseHabiliterPourUnTypeControle(int idTypeControle) { SqlConnection objConnexion = AccesBD.GetInstance().GetSqlConnexion(); List<Entreprise> maListe = new List<Entreprise>(); SqlCommand maCommande = new SqlCommand("sp_SelectEntrepriseHabiliterPourUnTypeControle", objConnexion); maCommande.CommandType = CommandType.StoredProcedure; maCommande.Parameters.Add("idTypeControle", SqlDbType.Int); maCommande.Parameters[0].Value = idTypeControle; objConnexion.Open(); SqlDataReader lecteur = maCommande.ExecuteReader(); while (lecteur.Read()) { Entreprise uneEntreprise = new Entreprise((int)lecteur["ID_ENTREPRISE"], (string)lecteur["NOM_ENTREPRISE"]); maListe.Add(uneEntreprise); } AccesBD.GetInstance().CloseConnexion(); return maListe; }
public List<Entreprise> GetEntreprise(int idEntreprise) { SqlConnection objConnexion = AccesBD.GetInstance().GetSqlConnexion(); SqlCommand maCommande = new SqlCommand("sp_AficherLesEntreprises", objConnexion); List<Entreprise> maListe = new List<Entreprise>(); maCommande.CommandType = System.Data.CommandType.StoredProcedure; maCommande.Parameters.Add("idEntrprise", SqlDbType.Int); maCommande.Parameters[0].Value = idEntreprise; SqlDataReader monLecteur; objConnexion.Open(); monLecteur = maCommande.ExecuteReader(); while (monLecteur.Read()) { Entreprise uneEntreprise = new Entreprise((int)monLecteur["ID_ENTREPRISE"], (string)monLecteur["NOM_ENTREPRISE"]); maListe.Add(uneEntreprise); } AccesBD.GetInstance().CloseConnexion(); return maListe; }
/// <summary> /// Ouvre l'entreprise séléctionnée en lecture seule à l'aide d'une nouvelle fenêtre /// </summary> public Entreprise Look(Entreprise entreprise) { if (this._DataGridMain.SelectedItem != null || entreprise != null) { if (this._DataGridMain.SelectedItems.Count == 1 || entreprise != null) { //Affichage du message "affichage en cours" ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true; ((App)App.Current)._theMainWindow.changementTexteStatusBar("Affichage d'une entreprise en cours ..."); //Création de la fenêtre EntrepriseWindow entrepriseWindow = new EntrepriseWindow(); //Initialisation du Datacontext en entreprise et association à la entreprise sélectionnée entrepriseWindow.DataContext = new Entreprise(); if (entreprise != null) { entrepriseWindow.DataContext = entreprise; } else { entrepriseWindow.DataContext = this._DataGridMain.SelectedItem; } //Je positionne la lecture seule sur la fenêtre entrepriseWindow.creation = false; entrepriseWindow.SoloLecture = true; entrepriseWindow.lectureSeule(); //J'affiche la fenêtre bool? dialogResult = entrepriseWindow.ShowDialog(); //Affichage du message "affichage en cours" ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false; ((App)App.Current)._theMainWindow.changementTexteStatusBar("Affichage d'une entreprise terminé : " + this.Entreprises.Count() + " / " + this.max); //Renvoi null return null; } else { MessageBox.Show("Vous ne devez sélectionner qu'une seule entreprise.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } } else { MessageBox.Show("Vous devez sélectionner une entreprise.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } }
/// <summary> /// Met à jour l'état en bas pour l'utilisateur /// </summary> /// <param name="typeEtat">texte : "Filtrage", "Ajout", "Modification", "Suppression", "Look", "" ("" = Chargement)</param> /// <param name="dao">un objet Commande_Fournisseur soit pour l'ajouter au listing, soit pour afficher qui a été modifié ou supprimé</param> public void MiseAJourEtat(string typeEtat, Entreprise ent) { //Je racalcul le nombre max d'élements this.recalculMax(); //En fonction de l'action, j'affiche le message if (typeEtat == "Filtrage") { ((App)App.Current)._theMainWindow.changementTexteStatusBar("filtrage des entreprises terminée : " + this.Entreprises.Count() + " / " + this.max); } else if (typeEtat == "Ajout") { //J'ajoute la commande_fournisseur dans le linsting this.Entreprises.Add(ent); //Je racalcul le nombre max d'élements après l'ajout this.recalculMax(); ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une entreprise '" + ent.Libelle + "' effectué avec succès. Nombre d'élements : " + this.Entreprises.Count() + " / " + this.max); try { this._DataGridMain.SelectedItem = ent; } catch (Exception) { } } else if (typeEtat == "Modification") { //Je raffraichis mon datagrid this._DataGridMain.Items.Refresh(); ((App)App.Current)._theMainWindow.changementTexteStatusBar("Modification de l'entreprise : '" + ent.Libelle + "' effectuée avec succès. Nombre d'élements : " + this.Entreprises.Count() + " / " + this.max); } else if (typeEtat == "Suppression") { //Je supprime de mon listing l'élément supprimé this.Entreprises.Remove(ent); //Je racalcul le nombre max d'élements après la suppression this.recalculMax(); ((App)App.Current)._theMainWindow.changementTexteStatusBar("Suppression de l'entreprise : '" + ent.Libelle + "' effectuée avec succès. Nombre d'élements : " + this.Entreprises.Count() + " / " + this.max); } else if (typeEtat == "Look") { } else { ((App)App.Current)._theMainWindow.changementTexteStatusBar("Chargement des entreprises terminé : " + this.Entreprises.Count() + " / " + this.max); } //Je retri les données dans le sens par défaut this.triDatas(); //J'arrete la progressbar ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false; }
private void NewEntreprise_Click(object sender, RoutedEventArgs e) { EntrepriseWindow entrepriseWindow = new EntrepriseWindow(); Entreprise tmp = new Entreprise(); tmp.Adresse1 = new Adresse(); tmp.Adresse2 = new Adresse(); tmp.Client = new Client(); tmp.Is_Client = false; tmp.Fournisseur = new Fournisseur(); entrepriseWindow.DataContext = tmp; entrepriseWindow.creation = true; //booléen nullable vrai ou faux ou null bool? dialogResult = entrepriseWindow.ShowDialog(); Entreprise entreprise = (Entreprise)entrepriseWindow.DataContext; if (dialogResult.HasValue && dialogResult.Value == true) { ((App)App.Current).mySitaffEntities.Attach(entreprise); if (_checkBoxEntAtelier.IsChecked == true) { this.miseAutoEntrepriseLivraison(); } if (_checkBoxEntAutre.IsChecked == true) { this.TouteEntreprise(); } if (_checkBoxEntChantier.IsChecked == true) { this.TriEntreprise(); } this._comboBoxEntLivraison.SelectedItem = entreprise; } else { //Entreprise non validée (on détache tout !) // On enlève tous les Commande_Fournisseur associés foreach (Commande_Fournisseur item in entreprise.Commande_Fournisseur1) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Commande_Fournisseur1.Remove(item); } catch (Exception) { entreprise.Commande_Fournisseur1.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Commande_Fournisseur associés foreach (Commande_Fournisseur item in entreprise.Commande_Fournisseur2) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Commande_Fournisseur1.Remove(item); } catch (Exception) { entreprise.Commande_Fournisseur1.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Entreprise_Activite associés foreach (Entreprise_Activite item in entreprise.Entreprise_Activite) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Entreprise_Activite.Remove(item); } catch (Exception) { entreprise.Entreprise_Activite.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Entreprise_Litige associés foreach (Entreprise_Litige item in entreprise.Entreprise_Litige) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Entreprise_Litige.Remove(item); } catch (Exception) { entreprise.Entreprise_Litige.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Entreprise_Mere associés foreach (Entreprise_Mere item in entreprise.Entreprise_Mere) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Entreprise_Mere.Remove(item); } catch (Exception) { entreprise.Entreprise_Mere.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Numero_Tva_Intraco associés foreach (Numero_Tva_Intraco item in entreprise.Numero_Tva_Intraco) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Numero_Tva_Intraco.Remove(item); } catch (Exception) { entreprise.Numero_Tva_Intraco.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les NumeroTvaIntracommunautaire associés foreach (NumeroTvaIntracommunautaire item in entreprise.NumeroTvaIntracommunautaire) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.NumeroTvaIntracommunautaire.Remove(item); } catch (Exception) { entreprise.NumeroTvaIntracommunautaire.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Personne associés foreach (Personne item in entreprise.Personne) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Personne.Remove(item); } catch (Exception) { entreprise.Personne.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } try { ((App)App.Current).mySitaffEntities.Detach(entreprise.Fournisseur); entreprise.Fournisseur = null; } catch (Exception) { try { entreprise.Fournisseur = null; ((App)App.Current).mySitaffEntities.Detach(entreprise.Fournisseur); } catch (Exception) { } } try { ((App)App.Current).mySitaffEntities.Detach(entreprise.Client); entreprise.Client = null; } catch (Exception) { try { entreprise.Client = null; ((App)App.Current).mySitaffEntities.Detach(entreprise.Client); } catch (Exception) { } } try { ((App)App.Current).mySitaffEntities.Detach(entreprise); } catch (Exception) { try { ((App)App.Current).mySitaffEntities.Entreprise.DeleteObject(entreprise); } catch (Exception) { } } } ListeEntreprisesControl listeEntrepriseControl = new ListeEntreprisesControl(); if (entreprise != null) { //this.listFournisseurs = new ObservableCollection<Fournisseur>(((App)App.Current).mySitaffEntities.Fournisseur.OrderBy(ent => ent.Entreprise.Libelle)); } else { this._comboBoxFournisseur.SelectedItem = null; } }
private void _comboBoxEntFacturation_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.Verif_comboBoxEntFacturation(); Entreprise E = new Entreprise(); E = (Entreprise)this._comboBoxEntFacturation.SelectedItem; if (E != null) { this._comboBoxEntFacturation.SelectedItem = E; this._textBoxAddEntFacturation.Text = E.Adresse1.Rue + " " + E.Adresse1.Complement_Adresse; this._textBoxCpEntFacturation.Text = E.Adresse1.Ville1.Code_Postal; this._textBoxVilleEntFacturation.Text = E.Adresse1.Ville1.Libelle; this._textBoxPaysEntFacturation.Text = E.Adresse1.Ville1.Pays1.Libelle; } else { this._comboBoxEntFacturation.SelectedItem = null; this._textBoxAddEntFacturation.Text = null; this._textBoxCpEntFacturation.Text = null; this._textBoxVilleEntFacturation.Text = null; this._textBoxPaysEntFacturation.Text = null; } }
public ClientEntreprise() : base() { Entreprise = new Entreprise(); }
/// <summary> /// Ajoute une nouvelle entreprise à la liste à l'aide d'une nouvelle fenêtre /// </summary> public Entreprise Add() { //Affichage du message "ajout en cours" ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true; ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une entreprise en cours ..."); //Initialisation de la fenêtre EntrepriseWindow entrepriseWindow = new EntrepriseWindow(); //Création de l'objet temporaire Entreprise tmp = new Entreprise(); tmp.Adresse1 = new Adresse(); tmp.Adresse2 = new Adresse(); tmp.Client = new Client(); tmp.Is_Client = false; tmp.Fournisseur = new Fournisseur(); tmp.Is_Fournisseur = false; //Mise de l'objet temporaire dans le datacontext entrepriseWindow.DataContext = tmp; entrepriseWindow.creation = true; //booléen nullable vrai ou faux ou null bool? dialogResult = entrepriseWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { //Si j'appuie sur le bouton Ok, je renvoi l'objet commande se trouvant dans le datacontext de la fenêtre return (Entreprise)entrepriseWindow.DataContext; } else { try { try { ObservableCollection<Entreprise_Activite> toRemove = new ObservableCollection<Entreprise_Activite>(); foreach (Entreprise_Activite item in ((Entreprise)entrepriseWindow.DataContext).Entreprise_Activite) { toRemove.Add(item); } foreach (Entreprise_Activite item in toRemove) { ((App)App.Current).mySitaffEntities.Detach(item); } } catch (Exception) { } try { ObservableCollection<Entreprise_Litige> toRemove2 = new ObservableCollection<Entreprise_Litige>(); foreach (Entreprise_Litige item in ((Entreprise)entrepriseWindow.DataContext).Entreprise_Litige) { toRemove2.Add(item); } foreach (Entreprise_Litige item in toRemove2) { ((App)App.Current).mySitaffEntities.Detach(item); } } catch (Exception) { } try { ObservableCollection<Entreprise_RIB> toRemove3 = new ObservableCollection<Entreprise_RIB>(); foreach (Entreprise_RIB item in ((Entreprise)entrepriseWindow.DataContext).Entreprise_RIB) { toRemove3.Add(item); } foreach (Entreprise_RIB item in toRemove3) { ((App)App.Current).mySitaffEntities.Detach(item); } } catch (Exception) { } try { ObservableCollection<Numero_Tva_Intraco> toRemove4 = new ObservableCollection<Numero_Tva_Intraco>(); foreach (Numero_Tva_Intraco item in ((Entreprise)entrepriseWindow.DataContext).Numero_Tva_Intraco) { toRemove4.Add(item); } foreach (Numero_Tva_Intraco item in toRemove4) { ((App)App.Current).mySitaffEntities.Detach(item); } } catch (Exception) { } try { ObservableCollection<Fournisseur_Cle_Comptable> toRemove4 = new ObservableCollection<Fournisseur_Cle_Comptable>(); foreach (Fournisseur_Cle_Comptable item in ((Entreprise)entrepriseWindow.DataContext).Fournisseur.Fournisseur_Cle_Comptable) { toRemove4.Add(item); } foreach (Fournisseur_Cle_Comptable item in toRemove4) { ((App)App.Current).mySitaffEntities.Detach(item); } } catch (Exception) { } try { ObservableCollection<Fournisseur_Condition_Reglement> toRemove4 = new ObservableCollection<Fournisseur_Condition_Reglement>(); foreach (Fournisseur_Condition_Reglement item in ((Entreprise)entrepriseWindow.DataContext).Fournisseur.Fournisseur_Condition_Reglement) { toRemove4.Add(item); } foreach (Fournisseur_Condition_Reglement item in toRemove4) { ((App)App.Current).mySitaffEntities.Detach(item); } } catch (Exception) { } try { ObservableCollection<Client_Condition_Reglement> toRemove4 = new ObservableCollection<Client_Condition_Reglement>(); foreach (Client_Condition_Reglement item in ((Entreprise)entrepriseWindow.DataContext).Client.Client_Condition_Reglement) { toRemove4.Add(item); } foreach (Client_Condition_Reglement item in toRemove4) { ((App)App.Current).mySitaffEntities.Detach(item); } } catch (Exception) { } try { ObservableCollection<Client_Cle_Comptable> toRemove4 = new ObservableCollection<Client_Cle_Comptable>(); foreach (Client_Cle_Comptable item in ((Entreprise)entrepriseWindow.DataContext).Client.Client_Cle_Comptable) { toRemove4.Add(item); } foreach (Client_Cle_Comptable item in toRemove4) { ((App)App.Current).mySitaffEntities.Detach(item); } } catch (Exception) { } try { try { ((App)App.Current).mySitaffEntities.Detach(((Entreprise)entrepriseWindow.DataContext).Fournisseur.Agence_Interimaire); } catch (Exception) { } try { ((App)App.Current).mySitaffEntities.Detach(((Entreprise)entrepriseWindow.DataContext).Fournisseur.Sous_Traitant); } catch (Exception) { } ((App)App.Current).mySitaffEntities.Detach(((Entreprise)entrepriseWindow.DataContext).Fournisseur); } catch (Exception) { } try { ((App)App.Current).mySitaffEntities.Detach(((Entreprise)entrepriseWindow.DataContext).Client); } catch (Exception) { } ((App)App.Current).mySitaffEntities.Detach((Entreprise)entrepriseWindow.DataContext); } catch (Exception) { } //Si j'appuie sur le bouton annuler, je préviens que j'annule mon ajout ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false; this.recalculMax(); ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une entreprise annulé : " + this.Entreprises.Count() + " / " + this.max); return null; } }
private void _buttonIntNouvelleEntreprise_Click(object sender, RoutedEventArgs e) { EntrepriseWindow entrepriseWindow = new EntrepriseWindow(); Entreprise tmp = new Entreprise(); tmp.Adresse1 = new Adresse(); tmp.Client = new Client(); tmp.Is_Client = false; tmp.Fournisseur = new Fournisseur(); //tmp.Is_Fournisseur = true; entrepriseWindow.DataContext = tmp; entrepriseWindow.creation = true; //booléen nullable vrai ou faux ou null bool? dialogResult = entrepriseWindow.ShowDialog(); Entreprise entreprise = (Entreprise)entrepriseWindow.DataContext; if (dialogResult.HasValue && dialogResult.Value == true) { if (entreprise.Fournisseur != null) { this.listFournisseur.Add(entreprise); this._comboBoxIntEntreprise.SelectedItem = entreprise; } else { MessageBox.Show("L'entreprise que vous avez ajouté n'a pas été définie en tant que 'fournisseur', vous ne pourrez donc pas la sélectionner", "Entreprise non fournisseur", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { //Entreprise non validée (on détache tout !) // On enlève tous les Commande_Fournisseur associés foreach (Commande_Fournisseur item in entreprise.Commande_Fournisseur1) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Commande_Fournisseur1.Remove(item); } catch (Exception) { entreprise.Commande_Fournisseur1.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Commande_Fournisseur associés foreach (Commande_Fournisseur item in entreprise.Commande_Fournisseur2) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Commande_Fournisseur1.Remove(item); } catch (Exception) { entreprise.Commande_Fournisseur1.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Entreprise_Activite associés foreach (Entreprise_Activite item in entreprise.Entreprise_Activite) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Entreprise_Activite.Remove(item); } catch (Exception) { entreprise.Entreprise_Activite.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Entreprise_Litige associés foreach (Entreprise_Litige item in entreprise.Entreprise_Litige) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Entreprise_Litige.Remove(item); } catch (Exception) { entreprise.Entreprise_Litige.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Entreprise_Mere associés foreach (Entreprise_Mere item in entreprise.Entreprise_Mere) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Entreprise_Mere.Remove(item); } catch (Exception) { entreprise.Entreprise_Mere.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Numero_Tva_Intraco associés foreach (Numero_Tva_Intraco item in entreprise.Numero_Tva_Intraco) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Numero_Tva_Intraco.Remove(item); } catch (Exception) { entreprise.Numero_Tva_Intraco.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les NumeroTvaIntracommunautaire associés foreach (NumeroTvaIntracommunautaire item in entreprise.NumeroTvaIntracommunautaire) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.NumeroTvaIntracommunautaire.Remove(item); } catch (Exception) { entreprise.NumeroTvaIntracommunautaire.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Personne associés foreach (Personne item in entreprise.Personne) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Personne.Remove(item); } catch (Exception) { entreprise.Personne.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } try { ((App)App.Current).mySitaffEntities.Detach(entreprise.Fournisseur); entreprise.Fournisseur = null; } catch (Exception) { try { entreprise.Fournisseur = null; ((App)App.Current).mySitaffEntities.Detach(entreprise.Fournisseur); } catch (Exception) { } } try { ((App)App.Current).mySitaffEntities.Detach(entreprise.Client); entreprise.Client = null; } catch (Exception) { try { entreprise.Client = null; ((App)App.Current).mySitaffEntities.Detach(entreprise.Client); } catch (Exception) { } } try { ((App)App.Current).mySitaffEntities.Detach(entreprise); } catch (Exception) { try { ((App)App.Current).mySitaffEntities.Entreprise.DeleteObject(entreprise); } catch (Exception) { } } } }
private Distance_Ville GetDistance_Ville(Entreprise e, Salarie s) { Distance_Ville dist_ville = null; if (e.Adresse1 != null && s.Personne != null && s.Personne.Adresse1 != null) { if (e.Adresse1.Ville1 != null && s.Personne.Adresse1.Ville1 != null) { ObservableCollection<Distance_Ville> list = new ObservableCollection<Distance_Ville>(((App)App.Current).mySitaffEntities.Distance_Ville); foreach (Distance_Ville item in ((App)App.Current).mySitaffEntities.Distance_Ville.Where(vil => vil.Ville.Identifiant == e.Adresse1.Ville1.Identifiant && vil.Ville3.Identifiant == s.Personne.Adresse1.Ville1.Identifiant)) { dist_ville = item; } if (dist_ville == null) { foreach (Distance_Ville item in ((App)App.Current).mySitaffEntities.Distance_Ville.Where(vil => vil.Ville.Identifiant == s.Personne.Adresse1.Ville1.Identifiant && vil.Ville3.Identifiant == e.Adresse1.Ville1.Identifiant)) { dist_ville = item; } } } } return dist_ville; }
public void EntrepriseAdd(Entreprise e) { ListEntrep.Add(e); }
private void NewEntreprise_Click(object sender, RoutedEventArgs e) { EntrepriseWindow entrepriseWindow = new EntrepriseWindow(); Entreprise tmp = new Entreprise(); tmp.Adresse1 = new Adresse(); tmp.Adresse2 = new Adresse(); tmp.Client = new Client(); tmp.Is_Client = true; tmp.Fournisseur = new Fournisseur(); entrepriseWindow.DataContext = tmp; entrepriseWindow.creation = true; //booléen nullable vrai ou faux ou null bool? dialogResult = entrepriseWindow.ShowDialog(); Entreprise entreprise = (Entreprise)entrepriseWindow.DataContext; if (dialogResult.HasValue && dialogResult.Value == true) { ((App)App.Current).mySitaffEntities.AddToEntreprise(entreprise); if (entreprise.Client != null && entreprise.Is_Client == true) { this.listClient = new ObservableCollection<Entreprise>(((App)App.Current).mySitaffEntities.Entreprise.Where(civ => civ.Client != null && civ.Is_Client == true).OrderBy(civ => civ.Libelle)); this.listClient.Add(entreprise); this.listClient = new ObservableCollection<Entreprise>(this.listClient.OrderBy(tc => tc.Libelle)); this._comboBoxClient.SelectedItem = entreprise; } } else { //Entreprise non validée (on détache tout !) // On enlève tous les Commande_Fournisseur associés foreach (Commande_Fournisseur item in entreprise.Commande_Fournisseur1) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Commande_Fournisseur1.Remove(item); } catch (Exception) { entreprise.Commande_Fournisseur1.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Commande_Fournisseur associés foreach (Commande_Fournisseur item in entreprise.Commande_Fournisseur2) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Commande_Fournisseur1.Remove(item); } catch (Exception) { entreprise.Commande_Fournisseur1.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Entreprise_Activite associés foreach (Entreprise_Activite item in entreprise.Entreprise_Activite) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Entreprise_Activite.Remove(item); } catch (Exception) { entreprise.Entreprise_Activite.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Entreprise_Litige associés foreach (Entreprise_Litige item in entreprise.Entreprise_Litige) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Entreprise_Litige.Remove(item); } catch (Exception) { entreprise.Entreprise_Litige.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Entreprise_Mere associés foreach (Entreprise_Mere item in entreprise.Entreprise_Mere) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Entreprise_Mere.Remove(item); } catch (Exception) { entreprise.Entreprise_Mere.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Numero_Tva_Intraco associés foreach (Numero_Tva_Intraco item in entreprise.Numero_Tva_Intraco) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Numero_Tva_Intraco.Remove(item); } catch (Exception) { entreprise.Numero_Tva_Intraco.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les NumeroTvaIntracommunautaire associés foreach (NumeroTvaIntracommunautaire item in entreprise.NumeroTvaIntracommunautaire) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.NumeroTvaIntracommunautaire.Remove(item); } catch (Exception) { entreprise.NumeroTvaIntracommunautaire.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } // On enlève tous les Personne associés foreach (Personne item in entreprise.Personne) { try { ((App)App.Current).mySitaffEntities.Detach(item); entreprise.Personne.Remove(item); } catch (Exception) { entreprise.Personne.Remove(item); ((App)App.Current).mySitaffEntities.Detach(item); } } try { ((App)App.Current).mySitaffEntities.Detach(entreprise.Fournisseur); entreprise.Fournisseur = null; } catch (Exception) { try { entreprise.Fournisseur = null; ((App)App.Current).mySitaffEntities.Detach(entreprise.Fournisseur); } catch (Exception) { } } try { ((App)App.Current).mySitaffEntities.Detach(entreprise.Client); entreprise.Client = null; } catch (Exception) { try { entreprise.Client = null; ((App)App.Current).mySitaffEntities.Detach(entreprise.Client); } catch (Exception) { } } try { ((App)App.Current).mySitaffEntities.Detach(entreprise); } catch (Exception) { try { ((App)App.Current).mySitaffEntities.Entreprise.DeleteObject(entreprise); } catch (Exception) { } } } }
public void initialiser() { _entreprise = Entreprise.créer(TEST.MESSAGE_ENTREPRISE_VALIDE); _entreprise.enregistrer(); }