private void btnAddMedicament_Click(object sender, EventArgs e) { if (libelleTextBox.Text.Equals("") || prixTextBox.Text.Equals("") || quantityTextBox.Text.Equals("") || familleComboBox.Text.Equals("") || stockComboBox.Text.Equals("")) { return; } Medicament m = frmMain.Instance.Medicament.AddMedicament( new Medicament { LibelleMedicament = libelleTextBox.Text, Prix = decimal.Parse(prixTextBox.Text), CodeFamille = frmMain.Instance.Famille.GetOneFamilleByDesignation(familleComboBox.Text).CodeFamille } , frmMain.Instance.Session); if (m != null) { StockMedi sm = frmMain.Instance.StockMedi.AddStockMedi( new StockMedi { CodeMedicament = m.CodeMedicament, NumStock = int.Parse(stockComboBox.Text), QuantiteMedicament = int.Parse(quantityTextBox.Text) }, frmMain.Instance.Session); if (sm != null) { MetroFramework.MetroMessageBox.Show(this, "Le medicament a ete ajouter", "Succes", MessageBoxButtons.OK, MessageBoxIcon.Information); OnAdd(); code++; codeTextBox.Text = code.ToString(); libelleTextBox.Clear(); prixTextBox.Clear(); quantityTextBox.Clear(); if (!frmMain.Instance.mainContainer.Controls.ContainsKey("ucMedicament")) { ucMedicament uc = new ucMedicament(); uc.Dock = DockStyle.Fill; frmMain.Instance.mainContainer.Controls.Add(uc); } frmMain.Instance.BtnBack.Visible = true; frmMain.Instance.mainContainer.Controls["ucMedicament"].BringToFront(); ucMedicament.Instance.Actualiser(); ucStock.Instance.Actualiser(); } else { MetroFramework.MetroMessageBox.Show(this, "Le medicament n'a pas ete ajouter", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public StockMedi DeleteStockMedi(StockMedi del) { try { context.StockMedis.Remove(del); context.SaveChanges(); return(null); } catch (Exception e) { logger.Error(e.Message); return(del); } }
public StockMedi AddStockMedi(StockMedi sm) { try { context.StockMedis.Add(sm); context.SaveChanges(); return(sm); } catch (Exception e) { logger.Error(e.Message); return(null); } }
public StockMedi EditStockMedi(StockMedi sm) { try { context.StockMedis.Attach(sm); context.Entry(sm).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(sm); } catch (Exception e) { logger.Error(e.Message); return(null); } }
public StockMedi EditStockMedi(StockMedi sm, User user) { if (sm != null) { if (StockDao.GetOneStockById(sm.NumStock) != null && MedicamentDao.GetOneMedicamentById(sm.CodeMedicament) != null) { StockMedi o = StockMediDao.AddStockMedi(sm); if (o != null) { logger.Info(user.Login + " a modifier le medicament " + MedicamentDao.GetOneMedicamentById(o.CodeMedicament).LibelleMedicament + " dans le stock " + o.NumStock); return(o); } } } return(null); }
public ActionResult Add(FormCollection collection) { if (Session["user"] == null) { return(RedirectToAction("Index", "Login")); } ViewBag.famille = InstanceResolver.Instance.Famille.GetAll().ToList(); ViewBag.stock = InstanceResolver.Instance.Stock.GetAll().ToList(); string libelle = Request["libelle"]; decimal prix = decimal.Parse(Request["prix"]); int famille = int.Parse(Request["famille"]); int quantite = int.Parse(Request["quantite"]); int stock = int.Parse(Request["stock"]); ViewBag.error = false; if (libelle.Equals("") || prix <= 0 || famille <= 0 || quantite <= 0 || stock <= 0) { ViewBag.message = "L'un des champs n'est pas valide"; ViewBag.error = true; return(View()); } Medicament m = InstanceResolver.Instance.Medicament.AddMedicament(new Medicament { LibelleMedicament = libelle, CodeFamille = famille, Prix = prix }, (User)Session["user"]); if (m != null) { StockMedi sm = InstanceResolver.Instance.StockMedi.AddStockMedi( new StockMedi { NumStock = stock, CodeMedicament = m.CodeMedicament, QuantiteMedicament = quantite } , (User)Session["user"]); return(RedirectToAction("Index", "Medicament")); } ViewBag.error = true; ViewBag.message = "L'un des objets est null"; return(View()); }
public StockMedi DeleteStockMedi(StockMedi del, User user) { throw new NotImplementedException(); }