/// <summary> /// Charger la liste des familles et choisir la dernière famille sélectionné. /// </summary> public void LoadAll() { try { var i = lstfamille.SelectedIndex; if (lstfamille.Items.Count == 0) { lstfamille.DataSource = _familleService.ListAll(); } if (lstfamille.Items.Count > 0) { if (_modeAffichage == forms.ModeAffichage.Update) { if (lstfamille.SelectedIndex == cmbFamille.SelectedIndex) lstfamille_SelectedIndexChanged(null, null); else lstfamille.SelectedIndex = cmbFamille.SelectedIndex; } else { if (lstfamille.SelectedIndex == i) { lstfamille_SelectedIndexChanged(null, null); } else { lstfamille.SelectedIndex = i > 0 ? i : 0; } } } else // pas de famille il faut en ajouter au moins une avant de continuer. { _famille = null; if (MessageBox.Show(@"Il n'existe acune famille. Voulez-vous ajouter une nouvelle famille?", @"Gestion des familles", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { _formFamilleGestion = new FormFamilleGestion(); _formFamilleGestion.CloseGestionFamilleForm += new FormFamilleGestion.CloseFormHandler(CloseGestionFamilleForm); _formFamilleGestion.LoadAll(); _formFamilleGestion.ShowDialog(); } else { OnCloseForm(); } } } catch (Exception exception) { GestionException.TraiterException(exception, "Gestion des produits"); } }
private void OpenGestionFamille() { _formFamilleGestion = new FormFamilleGestion(); _formFamilleGestion.CloseGestionFamilleForm += CloseGestionFamilleForm; _formFamilleGestion.LoadAll(); _formFamilleGestion.ShowDialog(); }