public async Task <IActionResult> Edit(int id, [Bind("ID,libelleTypeArticle")] TypeArticle typeArticle) { if (id != typeArticle.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(typeArticle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeArticleExists(typeArticle.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(typeArticle)); }
public Article(string nom, double prix, int quantite, TypeArticle type) { Nom = nom; Prix = prix; Quantite = quantite; Type = type; }
public Article(string nom, int prix, int quantite, TypeArticle type) { this.nom = nom; this.prix = prix; this.quantite = quantite; this.type = type; }
//Update un type d'article public static int updateType(TypeArticle type) { try { //connection à la base de données MySqlCommand cmd = new MySqlCommand(Bdd.updateType, Bdd.connexion()); //ajout des parametres cmd.Parameters.AddWithValue("id", type.id); cmd.Parameters.AddWithValue("nom", type.nom); cmd.Parameters.AddWithValue("encombrement", type.encombrement); cmd.Parameters.AddWithValue("tva", type.TVA); cmd.Parameters.AddWithValue("ttc", type.TTC); cmd.Parameters.AddWithValue("dep_id", type.departement.id); cmd.Parameters.AddWithValue("idT", type.id); //Execute la commande int retour = cmd.ExecuteNonQuery(); Bdd.deconnexion(); return(retour); } catch (Exception Ex) { //LogDAO.insertLog(new Log(DateTime.Now, "ERREUR BDD : Erreur dans l'insertion d'un type dans la base de données.")); Bdd.deconnexion(); return(0); } }
public Article(string designation, int prix, TypeArticle typeArticle, int quantite) { this.typeArticle = typeArticle; this.designation = designation; this.prix = prix; this.quantite = quantite; }
private void initializeFieldsModif() { Txb_adminArt_modifTypeNom = null; Txb_adminArt_modifTypeTTC = 0; Txb_adminArt_modifTypeTVA = 0; Txb_adminArt_modifTypeEncombrement = 0; typeModif = null; }
public async Task <IActionResult> Create([Bind("ID,libelleTypeArticle")] TypeArticle typeArticle) { if (ModelState.IsValid) { _context.Add(typeArticle); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(typeArticle)); }
public AdministrationArticlesDepartementsVM() { ListeDepartementChoix = comboDepart.ListeDep(); ListeDepartementChoixDelete = comboDepart.ListeDep(); typeArticle = new TypeArticle(); Txb_adminArt_modifTypeEncombrement = new float(); Txb_adminArt_modifTypeTVA = new float(); Txb_adminArt_modifTypeTTC = new float(); }
private void modifArticle() { //Departement dep = new Departement(S.cbbDepId, Selected_adminArt_ChoixDepart.NameDepart); if (typeModif != null) { TypeArticle TArtModif = new TypeArticle(typeModif.id, Txb_adminArt_modifTypeNom, Txb_adminArt_modifTypeEncombrement, Txb_adminArt_modifTypeTVA, Txb_adminArt_modifTypeTTC, typeModif.departement); int index = TypeArticleDAO.updateType(TArtModif); if (index != 0) { MessageBox.Show("Modification " + TArtModif.nom + " reussie"); initializeFieldsModif(); } } }
private void addArticles() { Departement dep = new Departement(Selected_adminArt_ChoixDepart.cbbDepId, Selected_adminArt_ChoixDepart.NameDepart); TypeArticle TArt = new TypeArticle(typeArticle.nom, typeArticle.encombrement, typeArticle.TVA, typeArticle.TTC, dep); //MessageBox.Show(TArt.nom); int index = TypeArticleDAO.insertType(TArt); if (index != 0) { MessageBox.Show("Enregistrement " + TArt.nom + " reussi"); initializeFieldsAdd(); } }
//Selectionner les types d'articles pour un département public static List <TypeArticle> selectTypeByDepId(int dep_id) { try { List <TypeArticle> retour = new List <TypeArticle>(); //connection à la base de données MySqlCommand cmd = new MySqlCommand(Bdd.selectTypeByDepId, Bdd.connexion()); //ajout des parametres cmd.Parameters.AddWithValue("typ_dep_id", dep_id); //Execute la commande MySqlDataReader msdr = cmd.ExecuteReader(); TypeArticle type; while (msdr.Read()) { type = new TypeArticle( Int32.Parse(msdr["typ_id"].ToString()), msdr["typ_nom"].ToString(), float.Parse(msdr["typ_encombrement"].ToString()), float.Parse(msdr["typ_TVA"].ToString()), float.Parse(msdr["typ_TTC"].ToString()), new Departement(Int32.Parse(msdr["typ_dep_id"].ToString()), null)); retour.Add(type); } msdr.Dispose(); Bdd.deconnexion(); #region ajout des départements foreach (TypeArticle typ in retour) { typ.departement = DepartementDAO.selectDepartementById(typ.departement.id); } #endregion return(retour); } catch (Exception Ex) { //LogDAO.insertLog(new Log(DateTime.Now, "ERREUR BDD : Erreur dans la selection d'un département dans la base de données.")); Bdd.deconnexion(); return(null); } }
private void ExecuteModifArticle(AdministrationArticlesDepartementsVM obj) { if (obj.Selected_adminArt_ChoixArticlesDelete != null & obj.Selected_adminArt_ChoixArticlesDelete.cbbDepId == obj.Selected_adminArt_ChoixDepartDetele.cbbDepId) { typeModif = TypeArticleDAO.selectTypesById(obj.Selected_adminArt_ChoixArticlesDelete.cbbArtId); if (typeModif != null) { Txb_adminArt_modifTypeNom = typeModif.nom; Txb_adminArt_modifTypeTTC = typeModif.TTC; Txb_adminArt_modifTypeTVA = typeModif.TVA; Txb_adminArt_modifTypeEncombrement = typeModif.encombrement; } } else { MessageBox.Show("Choissez un departement ou un article de ce departement"); } }
private void ExecuteDeleteArticles(AdministrationArticlesDepartementsVM obj) { if (obj.Selected_adminArt_ChoixArticlesDelete != null & obj.Selected_adminArt_ChoixArticlesDelete.cbbDepId == obj.Selected_adminArt_ChoixDepartDetele.cbbDepId) { //MessageBox.Show(obj.Selected_adminArt_ChoixArticlesDelete.NameArticles); TypeArticle artType = TypeArticleDAO.selectTypesById(obj.Selected_adminArt_ChoixArticlesDelete.cbbArtId); if (artType != null) { int ind = TypeArticleDAO.deleteType(artType); if (ind != 0) { MessageBox.Show("l'article " + obj.Selected_adminArt_ChoixArticlesDelete.NameArticles + " est supprimé"); initializeFieldsDelete(); } } } else { MessageBox.Show("Choissez un departement ou un article de ce departement"); } }
public Video(string designation, int prix, int duree, TypeArticle typeArticle, int quantite) : base(designation, prix, typeArticle, quantite) { this.duree = duree; }
public void AjouterArticles(object button) { if (ClasseGlobale._contentDetailCommande != null) { Button clickedbutton = button as Button; if (clickedbutton != null) { typeArticleDTO = (TypeArticle)TypeArticleDAO.selectTypesById(Int32.Parse(clickedbutton.Tag.ToString())); PlaceConvoyeur place = new PlaceConvoyeur(); place = null; if (typeArticleDTO.encombrement == 0 || typeArticleDTO.encombrement > 3) { //Cet article ne va pas dans le convoyeur //MessageBox.Show("Cet article ne va pas dans le convoyeur."); } else { //Je parcours la liste pour trouver une place convoyeur pouvant accueillir l'article int finDeListe = ClasseGlobale.PlacesLibres.getList().Count(); float encombrement_occupe_pour_cette_place; float encombrement_maximum = 3 - typeArticleDTO.encombrement; for (int i = 0; i < finDeListe; i++) { //si l'encombrement du convoyeur est permet de recevoir l'article encombrement_occupe_pour_cette_place = ClasseGlobale.PlacesLibres.getList()[i].encombrement; if (encombrement_occupe_pour_cette_place <= encombrement_maximum) { //Je modifie l'encombrement de la place convoyeur ClasseGlobale.PlacesLibres[i].encombrement += typeArticleDTO.encombrement; //Je récupère la place convoyeur concernée place = ClasseGlobale.PlacesLibres.getList()[i]; break; } if (i == finDeListe - 1) { MessageBox.Show("Cet article ne trouve pas sa place dans le convoyeur.\n" + "Peut-être n'y a t-il plus de place ou cet article est trop volumineux pour les emplacements restants."); } } } //On construit un nouvel ArticlesVM ArticlesVM articleVmAAjouter = new ArticlesVM() { typeArticle = typeArticleDTO, ArticlesName = typeArticleDTO.nom, PlaceConvoyeur = place }; ClasseGlobale._contentDetailCommande.Add(articleVmAAjouter); Label_NouvelleCommande_prixTotal = 0; decimal tampon = 0; foreach (ArticlesVM artVm in ClasseGlobale._contentDetailCommande) { //MessageBox.Show("ajout de " + artVm.typeArticle.TTC); //Label_NouvelleCommande_prixTotal += (artVm.typeArticle.TTC); tampon += (decimal)(artVm.typeArticle.TTC); } //MessageBox.Show(tampon.ToString()); Label_NouvelleCommande_prixTotal = (float)tampon;//(float)Math.Round(tampon, 2, MidpointRounding.AwayFromZero);// } } }
public Broche(string designation, int prix, string isbn, int nbPages, TypeArticle typeArticle, int quantite) : base(designation, prix, isbn, nbPages, typeArticle, quantite) { }
/* Selectionner l'ensemble des articles d'une commande dans la base de données * @param cmd_id : id d'une commande */ public static List <Article> selectArticleByIdCmd(int cmd_id) { try { List <Article> retour = new List <Article>(); //connection à la base de données MySqlCommand cmd = new MySqlCommand(Bdd.selectArticleByIdCmd, Bdd.connexion()); //ajout des parametres cmd.Parameters.AddWithValue("id", cmd_id); //Execute la commande MySqlDataReader msdr = cmd.ExecuteReader(); int art_id; String art_photo; String art_commentaire; bool art_rendu; float art_TVA; float art_TTC; TypeArticle typeArticle; PlaceConvoyeur placeConv; int art_cmd_id; int conv_id; while (msdr.Read()) { art_id = Int32.Parse(msdr["art_id"].ToString()); art_photo = msdr["art_photo"].ToString(); art_commentaire = msdr["art_commentaire"].ToString(); art_rendu = bool.Parse(msdr["art_rendu"].ToString()); art_TVA = float.Parse(msdr["art_TVA"].ToString()); art_TTC = float.Parse(msdr["art_TTC"].ToString()); typeArticle = new TypeArticle(Int32.Parse(msdr["art_typ_id"].ToString()), null, 0, 0, 0, null); //conv_id = Int32.Parse(msdr["art_conv_id"].ToString()); String test = msdr["art_conv_id"].ToString(); if (test == null || test == "") { conv_id = 0; } else { conv_id = Int32.Parse(msdr["art_conv_id"].ToString()); } placeConv = new PlaceConvoyeur(conv_id, 0, 0); art_cmd_id = Int32.Parse(msdr["art_cmd_id"].ToString()); Article article = new Article( art_id, art_photo, art_commentaire, art_rendu, art_TVA, art_TTC, typeArticle, placeConv, art_cmd_id); if (msdr["art_date_rendu"].ToString().Equals(null)) { article.date_rendu = DateTime.Parse(msdr["art_date_rendu"].ToString()); } retour.Add(article); } msdr.Dispose(); Bdd.deconnexion(); #region ajout des types, des departements et des places convoyeurs foreach (Article art in retour) { art.type = TypeArticleDAO.selectTypesById(art.type.id); art.convoyeur = PlaceConvoyeurDAO.selectConvoyeurById(art.convoyeur.id); } #endregion return(retour); } catch (Exception Ex) { MessageBox.Show("ERREUR BDD : SelectArticleByIdCmd"); Bdd.deconnexion(); return(null); } }
protected void SetTypeArticle(TypeArticle value) { this.type = value; }
public static void Initialize(OpticAppContext context) { if (context.Clients.Any()) { return; // DB has been seeded } var clients = new Client[] { new Client { nom = "nom1", prenom = "prenom1" }, new Client { nom = "nom2", prenom = "prenom2" }, new Client { nom = "nom3", prenom = "prenom3" }, new Client { nom = "nom4", prenom = "prenom4" }, new Client { nom = "nom5", prenom = "prenom5" }, }; foreach (Client c in clients) { context.Clients.Add(c); } context.SaveChanges(); var typePayements = new TypePaiement[] { new TypePaiement { libelleTypePaiement = "Espèce" }, new TypePaiement { libelleTypePaiement = "TPE" }, new TypePaiement { libelleTypePaiement = "Chèque" }, }; foreach (TypePaiement tp in typePayements) { context.TypePaiements.Add(tp); } context.SaveChanges(); var typeArticles = new TypeArticle[] { new TypeArticle { libelleTypeArticle = "Verre" }, new TypeArticle { libelleTypeArticle = "Monture" }, new TypeArticle { libelleTypeArticle = "Lentille" }, }; foreach (TypeArticle ta in typeArticles) { context.TypeArticles.Add(ta); } context.SaveChanges(); var fournisseurs = new Fournisseur[] { new Fournisseur { nomFournisseur = "Fournisseur1" }, new Fournisseur { nomFournisseur = "Fournisseur2" }, new Fournisseur { nomFournisseur = "Fournisseur3" }, }; foreach (Fournisseur f in fournisseurs) { context.Fournisseurs.Add(f); } context.SaveChanges(); var articles = new Article[] { new Article { code = "Code1", fournisseurID = 1, libelleArticle = "Article1", prixAchat = 100, prixVenteHT = 150, typeArticleID = 1, stock = 10 }, new Article { code = "Code2", fournisseurID = 2, libelleArticle = "Article2", prixAchat = 200, prixVenteHT = 250, typeArticleID = 1, stock = 10 }, new Article { code = "Code3", fournisseurID = 3, libelleArticle = "Article3", prixAchat = 300, prixVenteHT = 350, typeArticleID = 2, stock = 10 }, }; foreach (Article a in articles) { context.Articles.Add(a); } context.SaveChanges(); var visites = new Visite[] { new Visite { clientID = 1, DateLivraison = DateTime.Now.AddDays(5), etatVisiteID = 2 }, }; foreach (Visite v in visites) { context.Visites.Add(v); } context.SaveChanges(); var paiements = new Paiement[] { new Paiement { visiteID = 1, typePaiementID = 1, datePaiement = DateTime.Now, montant = 200 }, new Paiement { visiteID = 1, typePaiementID = 1, datePaiement = DateTime.Now, montant = 300 }, new Paiement { visiteID = 1, typePaiementID = 1, datePaiement = DateTime.Now, montant = 500 }, }; foreach (Paiement p in paiements) { context.Paiements.Add(p); } context.SaveChanges(); var articlePositions = new ArticlePosition[] { new ArticlePosition { Libelle = "Loin_verre_OG" }, new ArticlePosition { Libelle = "Loin_verre_OD" }, new ArticlePosition { Libelle = "Loin_monture" }, new ArticlePosition { Libelle = "pres_verre_OG" }, new ArticlePosition { Libelle = "pres_verre_OD" }, new ArticlePosition { Libelle = "pres_monture" }, new ArticlePosition { Libelle = "accessoire" }, }; foreach (ArticlePosition ap in articlePositions) { context.ArticlePositions.Add(ap); } context.SaveChanges(); var ventes = new Vente[] { new Vente { articleID = 1, articlePositionID = 1, visiteID = 1, montant = 500 }, new Vente { articleID = 2, articlePositionID = 2, visiteID = 1, montant = 800 }, new Vente { articleID = 3, articlePositionID = 3, visiteID = 1, montant = 1500 }, }; foreach (Vente v in ventes) { context.Ventes.Add(v); } context.SaveChanges(); }
static void Main(string[] args) { //Instanciation Article produitAuchan = new Article("t-shirt nike", 49, 253, TArticle.TypeArticle.habillement); Article produitCarrefour = new Article("Playstation 5", 499, 58, TArticle.TypeArticle.loisir); //Affichage Console.WriteLine("Affichage de tous les produits créés"); produitAuchan.afficher(); produitCarrefour.afficher(); Console.WriteLine("Entrez un nom de produit :"); string articleName = Console.ReadLine(); Console.WriteLine("Entrez le prix du produit :"); int articlePrice = int.Parse(Console.ReadLine()); Console.WriteLine("Entrez la quantité de produit :"); int articleQuantity = int.Parse(Console.ReadLine()); Console.WriteLine("Entrez le type de produit parmis les choix disponibles : Alimentaire, Droguerie, Habillement, Loisir ou autre;"); string TypeArticle = Console.ReadLine(); TypeArticle enumTypeArticle = TArticle.TypeArticle.autre; switch (TypeArticle.ToLower()) { case "alimentaire": enumTypeArticle = TArticle.TypeArticle.alimentaire; break; case "droguerie": enumTypeArticle = TArticle.TypeArticle.droguerie; break; case "habillement": enumTypeArticle = TArticle.TypeArticle.habillement; break; case "loisir": enumTypeArticle = TArticle.TypeArticle.loisir; break; // le type d'article autre est déjà assigné lors de l'instanciation inutile de répété, tout autre texte entré sera considéré comme type autre default: break; } //instanciation du produit créé par l'utilisateur Article userArticle = new Article(articleName, articlePrice, articleQuantity, enumTypeArticle); //affichage userArticle.afficher(); Console.WriteLine("Voulez-vous ajouter une quantité ou en retirer? (A/R) :"); string choice = Console.ReadLine(); while (choice.ToUpper() != "A" && choice.ToUpper() != "R") { Console.WriteLine("Veuillez respecter les seules réponses disponibles : celle qui sont entre parenthèses !"); Console.WriteLine("Voulez-vous ajouter une quantité ou en retirer? (A/R) :"); choice = Console.ReadLine(); } if (choice.ToUpper() == "A") { Console.WriteLine("Quel est la quantité que vous souhaitez ajouter ?"); int quantityToAdd = int.Parse(Console.ReadLine()); userArticle.ajouter(quantityToAdd); userArticle.afficher(); } else { Console.WriteLine("Quel est la quantité que vous souhaitez retirer ?"); int quantityToRemove = int.Parse(Console.ReadLine()); userArticle.retirer(quantityToRemove); userArticle.afficher(); } }
public Disque(string designation, int prix, string label, TypeArticle typeArticle, int quantite) : base(designation, prix, typeArticle, quantite) { this.label = label; }
public Poche(string designation, int prix, string isbn, int nbPages, string categorie, TypeArticle typeArticle, int quantite) : base(designation, prix, isbn, nbPages, typeArticle, quantite) { this.categorie = categorie; }
public Livre(string designation, int prix, string isbn, int nbPages, TypeArticle typeArticle, int quantite) : base(designation, prix, typeArticle, quantite) { this.isbn = isbn; this.nbPages = nbPages; }