public static fsg_gpao.Acteurs.Vente GetVente(int id) { Vente V = new Vente(); try { Connexion con = new Connexion(); con.OpenConnection(); string req = " SELECT id, idarticle, nbex, prix, remise FROM vente WHERE id =" + id; MySqlCommand cmd = new MySqlCommand(req, con.connexion); MySqlDataReader dt = cmd.ExecuteReader(); while (dt.Read()) { V.ID = dt.GetInt16(0); V.IDARTICLE = dt.GetInt16(1); V.NBEX = dt.GetInt16(2); V.PRIX = dt.GetInt16(3); V.REMISE = dt.GetInt16(4); } con.CloseConnection(); return(V); } catch (Exception e) { MessageBox.Show(e.Message); return(null); } }
public void RegistreAchat(Vente vente) { string again; int choixProduit; do { Console.WriteLine("Que souhaitez-vous acheter ?"); Produit.GetAllProduits(); Produit produitChoisi; Int32.TryParse(Console.ReadLine(), out choixProduit); produitChoisi = Produit.GetProduitById(choixProduit); if (produitChoisi != null) { vente.SaveVenteProduit(vente.Id, choixProduit); vente.Total += produitChoisi.Prix; if (vente.Update()) { Console.WriteLine("Total modifé"); } } else { Console.WriteLine("Produit Introuvable"); } Console.WriteLine("Voulez vous autre chose ? oui/non"); again = Console.ReadLine(); } while (again == "oui"); Console.WriteLine("Registre de vente mis à jour"); }
public async Task <IActionResult> Edit(int id, [Bind("ID,visiteID,articleID,articlePositionID,montant")] Vente vente) { if (id != vente.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vente); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VenteExists(vente.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["articleID"] = new SelectList(_context.Articles, "ID", "ID", vente.articleID); ViewData["articlePositionID"] = new SelectList(_context.ArticlePositions, "ID", "ID", vente.articlePositionID); ViewData["visiteID"] = new SelectList(_context.Visites, "ID", "ID", vente.visiteID); return(View(vente)); }
public IHttpActionResult PostVente(Vente vente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Vente.Add(vente); try { db.SaveChanges(); } catch (DbUpdateException) { if (VenteExists(vente.venteID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = vente.venteID }, vente)); }
public IHttpActionResult PutVente(int id, Vente vente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != vente.venteID) { return(BadRequest()); } db.Entry(vente).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!VenteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> Edit(long id, [Bind("VenteId,ProduitId,AchatId,Quantite")] Vente vente) { if (id != vente.VenteId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vente); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VenteExists(vente.VenteId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AchatId"] = new SelectList(_context.Achat, "AchatId", "AchatId", vente.AchatId); ViewData["ProduitId"] = new SelectList(_context.Produit, "ProduitId", "ProduitName", vente.ProduitId); return(View(vente)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { dico = new Dictionary <string, List <Commercial> >(); List <Commercial> comNord = new List <Commercial>(); List <Commercial> comSud = new List <Commercial>(); List <Commercial> comOuest = new List <Commercial>(); Commercial com1 = new Commercial("Jean"); Commercial com2 = new Commercial("Isa"); Commercial com3 = new Commercial("Steph"); Vente v1 = new Vente("AAA", 100); Vente v2 = new Vente("BBB", 200); Vente v3 = new Vente("CCC", 300); Vente v4 = new Vente("DDD", 400); Vente v5 = new Vente("EEE", 500); com1.AjouterVente(v1); com1.AjouterVente(v2); com2.AjouterVente(v3); com2.AjouterVente(v4); com3.AjouterVente(v5); comNord.Add(com1); comSud.Add(com2); comOuest.Add(com3); dico.Add("Nord", comNord); dico.Add("Sud", comSud); dico.Add("Ouest", comOuest); lstSecteurs.ItemsSource = dico.Keys; }
private Vente creerVenteFromView() { Vente vente = null; if (typePaiement_comboBox != null && typePaiement_comboBox.SelectedIndex >= 0) { List <Prestation> listPrestation = new List <Prestation>(); List <Produit> listProduit = new List <Produit>(); Client client = null; Vendeur vendeur = null; if (comboBox_client.SelectedIndex != -1 && comboBox_vendeur.SelectedIndex != -1) { client = listClients[comboBox_client.SelectedIndex]; vendeur = listVendeurs[comboBox_vendeur.SelectedIndex]; } foreach (Element elem in dataGrid_Element.Items) { if (elem is Prestation) { listPrestation.Add((Prestation)elem); } else if (elem is Produit) { listProduit.Add((Produit)elem); } } float prixTotal; if (float.TryParse(textBox_prixTotal.Text, out prixTotal)) { if (client != null && vendeur != null) { string typePaiement = ""; string test = ((ComboBoxItem)typePaiement_comboBox.SelectedItem).Content.ToString(); if (test == "Carte bancaire") { typePaiement = "cb"; } else if (test == "Espèces") { typePaiement = "especes"; } else if (test == "Chèque") { typePaiement = "cheque"; } if (typePaiement != "") { vente = new Vente(prixTotal, client, vendeur, listProduit, listPrestation, typePaiement, DateTime.Now); } } } if (utiliserFideliteCheckBox.IsChecked == true) { controller.viderFidelite(client); } } return(vente); }
private void Load() { ListeVentes = new ObservableCollection <Vente>(_ctx.Ventes); if (CurrentVente == null) { CurrentVente = new Vente(); } }
public ActionResult DeleteConfirmed(int id) { Vente vente = db.Vente.Find(id); db.Vente.Remove(vente); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult ReglementConfirmed(Guid id, double mtRegle, string reglement) { Vente vente = (Vente)db.Operations.Find(id); new CaisseManager(db).reglerVente(mtRegle, vente, "Paiement de vente", reglement); db.SaveChanges(); return(RedirectToAction("Index")); }
private void GetVenteDetailWindow() { Vente v = SelectedVente; VenteDetailWindow win = new VenteDetailWindow(SelectedVente); win.Owner = Application.Current.MainWindow; win.ShowDialog(); }
protected void btnAjouter_Click(object sender, EventArgs e) { Vente p = new Vente(); p.idClient = int.Parse(txtIdClient.Text); p.dateV = DateTime.Now; db.Vente.Add(p); db.SaveChanges(); }
private void btnInserer_Click(object sender, RoutedEventArgs e) { if (txtNomSecteur.Text == "") { MessageBox.Show("Veiuller insérer un secteur", "Erreur de sélection", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (txtNomCommercial.Text == "") { MessageBox.Show("Veiuller insérer un commercial ", "Erreur d'insertion", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (txtNomClient.Text == "") { MessageBox.Show("Veiuller insérer le nom du client ", "Erreur d'insertion", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (txtNbMontant.Text == "") { MessageBox.Show("Veiuller insérer le montant ", "Erreur d'insertion", MessageBoxButton.OK, MessageBoxImage.Error); } else { Vente v = new Vente(txtNomClient.Text, Convert.ToInt32(txtNbMontant.Text)); if (dico.ContainsKey(txtNomSecteur.Text) == false) { List <Commercial> comEst = new List <Commercial>(); dico.Add(txtNomSecteur.Text, comEst); Commercial com = new Commercial(txtNomCommercial.Text); comEst.Add(com); com.AjouterVente(v); lstSecteurs.Items.Refresh(); } else { if (dico[txtNomSecteur.Text].Exists(com => com.NomCommercial == txtNomCommercial.Text)) { dico[txtNomSecteur.Text].Find(com => com.NomCommercial == txtNomCommercial.Text).AjouterVente(v); } else { Commercial com = new Commercial(txtNomCommercial.Text); com.AjouterVente(v); dico[txtNomSecteur.Text].Add(com); } lstSecteurs.Items.Refresh(); lstCommerciaux.Items.Refresh(); lstVentes.Items.Refresh(); } } } } } }
public ActionResult Add(FormCollection collection) { ViewBag.error = false; if (Session["user"] == null) { return(RedirectToAction("Index", "Login")); } Medicament m = InstanceResolver.Instance.Medicament.GetOneMedicamentById(int.Parse(Request["medicament"])); Stock s = InstanceResolver.Instance.Stock.GetOneStockById(int.Parse(Request["stock"])); int quantity = int.Parse(Request["quantite"]); decimal montant = quantity * m.Prix; if (m == null || s == null) { ViewBag.message = "Stock ou Medicament null"; ViewBag.error = true; return(View()); } if (InstanceResolver.Instance.StockMedi.GetOneStockMediById(s.NumStock, m.CodeMedicament) == null) { ViewBag.message = "Pas de medicament dans ce stock"; ViewBag.error = true; return(View()); } if (InstanceResolver.Instance.StockMedi.GetOneStockMediById(s.NumStock, m.CodeMedicament).QuantiteMedicament < quantity) { ViewBag.message = "Quantite n'est pas valide"; ViewBag.error = true; return(View()); } Vente v = InstanceResolver.Instance.Vente.AddVente( new Vente { MontantVente = montant, DateVente = DateTime.Now }, (User)Session["user"]); if (v != null) { VenteMedi vm = InstanceResolver.Instance.VenteMedi.AddVenteMedi( new VenteMedi { NumVente = v.NumVente, CodeMedicament = m.CodeMedicament, QuantiteMedicament = quantity }, s, (User)Session["user"]); if (vm != null) { return(RedirectToAction("Index", "Vente")); } } ViewBag.error = true; ViewBag.message = "L'un des objets est null"; return(View()); }
public int Modifier(Vente model) { try { return(Gestion.Modifier(model.Id, model.IdStock, model.Prix, model.Quantite, model.IdCommande)); } catch (Exception e) { throw new Exception($"Impossible de modifier la vente {model.Id} : \n" + e.Message); } }
public Vente AddVente(Vente v, User user) { Vente o = VenteDao.AddVente(v); if (o != null) { logger.Info(user.Login + " a ajouter le Stock {" + o.NumVente + "," + o.MontantVente + "}"); return(o); } return(null); }
public Vente EditVente(Vente v, User user) { Vente o = VenteDao.EditVente(v); if (o != null) { logger.Info(user.Login + " a modifie le Stock de {" + v.NumVente + "," + v.MontantVente + "," + v.DateVente + "} a {" + o.NumVente + "," + o.MontantVente + "," + o.DateVente + "}"); return(o); } return(null); }
//Initialiser la vente public static void InitialiserVente(NouvelleVente frm) { Utilisateur user = frm.Session["utilisateur"] as Utilisateur; Vente vente = new Vente(); vente.numFiliale = user.numFiliale; vente.nomUtilisateur = user.nomUtilisateur; frm.Session["vente"] = vente; }
public ActionResult Edit(VenteVM vente, Guid clientId, string reglement) { if (ModelState.IsValid) { StockManager stockManager = new StockManager(db); Vente oldVente = db.Ventes.Where(v => v.Id == vente.Id).Include(v => v.Details.Select(d => d.Produit)).First(); //Restitution du stock foreach (var detail in oldVente.Details) { stockManager.AddStock(detail.ProduitID, detail.QuantiteVendue, OperationType.Vente); } //Annulation des reglements var caisseManager = new CaisseManager(db); caisseManager.AnnulerReglementsVente(oldVente, "suppression"); //Suppression des anciens details oldVente.Montant = 0; oldVente.MontantRegle = 0; oldVente.MontantRestant = 0; for (int i = 0; i < oldVente.Details.Count; i++) { db.DetailsVente.Remove(oldVente.Details[i]); } db.SaveChanges(); //Enregistrement des nouveaux details commande double total = 0; foreach (var detail in vente.Details) { if (detail.Quantite > 0) { oldVente.Details.Add(new DetailVente() { Produit = db.Produits.Find(detail.ProduitId), QuantiteVendue = detail.Quantite, ProduitID = detail.ProduitId, ID = Guid.NewGuid() }); } //Sortie de stock stockManager.RemoveStock(detail.ProduitId, detail.Quantite, OperationType.Vente); total += detail.Quantite * db.Produits.Find(detail.ProduitId).PrixVente; } //Reglements oldVente.Montant = total; oldVente.MontantRestant = total; db.SaveChanges(); caisseManager.reglerVente(vente.MontantPaye, oldVente, "Paiement de vente", reglement); return(RedirectToAction("Confirmer", new { id = oldVente.Id })); } ViewBag.ClientId = new SelectList(db.Clients, "ID", "Nom", vente.ClientId); return(View(vente)); }
public IHttpActionResult GetVente(int id) { Vente vente = db.Vente.Find(id); if (vente == null) { return(NotFound()); } return(Ok(vente)); }
public int Ajouter(Vente model) { try { return(Gestion.Ajouter(model.IdStock, model.Prix, model.Quantite, model.IdCommande)); } catch (Exception e) { throw new Exception("Impossible d'ajouter la vente : \n" + e.Message); } }
private void btnAddVente_Click(object sender, EventArgs e) { if (Stock == null) { return; } Vente v = new Vente { MontantVente = decimal.Parse(PrixTextBox.Text), DateVente = DateTime.Now }; if ((v = frmMain.Instance.Vente.AddVente(v, frmMain.Instance.Session)) != null) { Medicament m = frmMain.Instance.Medicament.GetMedicamentByLibelle(medicamentComboBox.Text); if (m != null) { VenteMedi vm = new VenteMedi { NumVente = v.NumVente, CodeMedicament = m.CodeMedicament, QuantiteMedicament = quantityTrackBar.Value }; if ((vm = frmMain.Instance.VenteMedi.AddVenteMedi(vm, Stock, frmMain.Instance.Session)) != null) { MetroFramework.MetroMessageBox.Show(this, "La vente a ete ajouter", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); if (!frmMain.Instance.mainContainer.Controls.ContainsKey("ucVente")) { ucVente uc = new ucVente(); uc.Dock = DockStyle.Fill; frmMain.Instance.mainContainer.Controls.Add(uc); } medicamentComboBox.Items.Clear(); stockComboBox.Items.Clear(); quantityTrackBar.Value = 1; quantityTrackBar.Enabled = false; btnAddVente.Enabled = false; PrixTextBox.Enabled = false; frmMain.Instance.BtnBack.Visible = true; frmMain.Instance.mainContainer.Controls["ucVente"].BringToFront(); ucVente.Instance.Actualiser(frmMain.Instance.VenteMedi.GetAll().ToList()); LoadData(frmMain.Instance.Medicament.GetAll().ToList()); OnAdd(); } } } else { MetroFramework.MetroMessageBox.Show(this, "Vente null", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Ajouter une ligne vente dans la vente encours public static void Ajouter(NouvelleVente frm) { try { int numArticle = int.Parse(frm.TxtNumArticle.Text); int quantite = int.Parse(frm.TxtQuantite.Text); double prixVente = double.Parse(frm.TxtPrixVente.Text); Utilisateur user = frm.Session["utilisateur"] as Utilisateur; Vente vente = frm.Session["vente"] as Vente; int qteStock = GetQuantiteEnStock(numArticle, user.numFiliale); if (qteStock > 0 && qteStock >= quantite) { //Récuperer une ligne vente encours LigneVente ligne = RechercherLigneVente(numArticle, vente.LigneVentes); if (ligne == null) { vente.LigneVentes.Add( new LigneVente { numArticle = numArticle, quantite = quantite, prix = prixVente } ); vente.montant += prixVente * quantite; frm.TxtMontant.Text = vente.montant.ToString(); } else { ligne.quantite += quantite; vente.montant += prixVente * quantite; frm.TxtMontant.Text = vente.montant.ToString(); } frm.GridLigneVente.DataSource = vente.LigneVentes; frm.GridLigneVente.DataBind(); frm.LblTxtQuantite.Text = "Ajout avec succes!"; } else { //Message : Qte en stock frm.LblTxtQuantite.Text = "Quantité en stock insufisante!"; } } catch (Exception) { frm.LblTxtQuantite.Text = "En numérique obligatoire!"; } }
public static void Populate(Vente vente) { // liste des ventes qui on beusoin de se faire peupler (leurs liste utilisateurs) if (!VenteAlreadyInDictionary(vente.IdVente)) { GetVenteById(vente.IdVente); } vente.LotVente = _ventesDictionary[vente.IdVente].LotVente; vente.AdresseVente = _ventesDictionary[vente.IdVente].AdresseVente; }
public ActionResult Edit([Bind(Include = "IDVente,Date_vente,Prix_vente,IDClient,IDVelo")] Vente vente) { if (ModelState.IsValid) { db.Entry(vente).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDClient = new SelectList(db.Client, "IDClient", "Nom", vente.IDClient); ViewBag.IDVelo = new SelectList(db.Velo, "IDVelo", "Marque", vente.IDVelo); return(View(vente)); }
public async Task <IActionResult> Create([Bind("VenteId,ProduitId,AchatId,Quantite")] Vente vente) { if (ModelState.IsValid) { _context.Add(vente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AchatId"] = new SelectList(_context.Achat, "AchatId", "AchatId", vente.AchatId); ViewData["ProduitId"] = new SelectList(_context.Produit, "ProduitId", "ProduitName", vente.ProduitId); return(View(vente)); }
public IHttpActionResult DeleteVente(int id) { Vente vente = db.Vente.Find(id); if (vente == null) { return(NotFound()); } db.Vente.Remove(vente); db.SaveChanges(); return(Ok(vente)); }
public async Task <IActionResult> Create([Bind("ID,visiteID,articleID,articlePositionID,montant")] Vente vente) { if (ModelState.IsValid) { _context.Add(vente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["articleID"] = new SelectList(_context.Articles, "ID", "ID", vente.articleID); ViewData["articlePositionID"] = new SelectList(_context.ArticlePositions, "ID", "ID", vente.articlePositionID); ViewData["visiteID"] = new SelectList(_context.Visites, "ID", "ID", vente.visiteID); return(View(vente)); }
public Vente DeleteVente(Vente del) { try { context.Ventes.Remove(del); context.SaveChanges(); return(null); } catch (Exception e) { logger.Error(e.Message); return(del); } }