private void btnEditMedicament_Click(object sender, EventArgs e) { if (libelleTextBox.Text.Equals("") || prixTextBox.Text.Equals("") || quantityTextBox.Text.Equals("") || familleComboBox.Text.Equals("") || stockComboBox.Text.Equals("")) { MessageBox.Show("champ(s) vide(s)"); return; } ucMedicament.Instance.Medicament.LibelleMedicament = libelleTextBox.Text; ucMedicament.Instance.Medicament.Prix = decimal.Parse(prixTextBox.Text); ucMedicament.Instance.Medicament.CodeFamille = frmMain.Instance.Famille.GetOneFamilleByDesignation(familleComboBox.Text).CodeFamille; if (frmMain.Instance.Medicament.EditMedicament(ucMedicament.Instance.Medicament, frmMain.Instance.Session) != null) { ucMedicament.Instance.Medicament = null; MessageBox.Show("Done"); 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(); } }
private void ucMedicament_Load(object sender, EventArgs e) { _instance = this; mEdit.Enabled = false; mChercher.Enabled = false; mDelete.Enabled = false; Actualiser(); }
private void btnBack_Click(object sender, EventArgs e) { 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(); }
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); } } }