private void m_btnSemaine_Click(object sender, System.EventArgs e) { if (m_modeAffichage != ModeAffichage.Semaine) { m_modeAffichage = ModeAffichage.Semaine; CreateControleAgenda(); } }
/// ///////////////////////////// private void m_btnModeMois_Click(object sender, System.EventArgs e) { if (m_modeAffichage != ModeAffichage.Mois) { m_modeAffichage = ModeAffichage.Mois; CreateControleAgenda(); } }
private void SaveOrUpdate() { //test libelle if (string.IsNullOrEmpty(txtLibelle.Text.Trim())) { MessageBox.Show(@"Vous devez entrer un libelle", @"Gestion des produits", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { if (_produit == null) { _produit = _produitService.Create(new Produit { Code = Convert.ToInt32(lblCode.Text), Libelle = txtLibelle.Text, Famille = _famille }); txtLibelle.Text = string.Empty; btnAnnuler.Visible = false; grbListeDesProduits.Visible = false; LoadAll(); grbListeDesProduits.Visible = true; _produit = null; _modeAffichage = forms.ModeAffichage.Insert; ModeAffichage(); } else //update { if (_produit.Libelle.ToUpper().CompareTo(txtLibelle.Text.ToUpper()) == 0 && _produit.Famille.Libelle.CompareTo(cmbFamille.Text) == 0) { MessageBox.Show(@"Vous devez faire au moins un changement", @"Gestion des produits", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } _produit.Code = Convert.ToInt32(lblCode.Text); _produit.Libelle = txtLibelle.Text; _produit.Famille = cmbFamille.SelectedItem as Famille; _produitService.Update(_produit); txtLibelle.Text = string.Empty; btnAnnuler.Visible = false; LoadAll(); } } catch (Exception exception) { GestionException.TraiterException(exception, @"Une erreur s'est produite lors de la sauvegarde des données", "Gestion des produits"); } }
private void Modify() { try { //_isAjoutMode = true; _modeAffichage = forms.ModeAffichage.Update; _produit = dgvProduits.SelectedRows[0].DataBoundItem as Produit; ModeAffichage(); } catch (Exception exception) { GestionException.TraiterException(exception, "Gestion des produits"); } }
private void lstfamille_SelectedIndexChanged(object sender, EventArgs e) { try { if (lstfamille.SelectedValue != null) { _famille = lstfamille.SelectedItem as Famille; //chargement des produits dgvProduits.DataSource = _produitService.GetByFamille(lstfamille.SelectedItem as Famille); if (dgvProduits.RowCount == 0) // pas de donnée { _produit = null; _modeAffichage = forms.ModeAffichage.Insert; ModeAffichage(); } else // on charge les produit et on met le premier dans la liste { dgvProduits.Rows[0].Selected = true; } } } catch (Exception exception) { GestionException.TraiterException(exception, "Gestion des produits"); } }
private void dgvProduits_SelectionChanged(object sender, EventArgs e) { try { if (dgvProduits.Rows.Count > 0) { if (dgvProduits.SelectedRows.Count > 0) { _produit = dgvProduits.SelectedRows[0].DataBoundItem as Produit; if (_isAjoutMode) _modeAffichage = forms.ModeAffichage.Insert; else _modeAffichage = forms.ModeAffichage.Browse; ModeAffichage(); } else { _produit = null; _modeAffichage = forms.ModeAffichage.Insert; ModeAffichage(); } } } catch (Exception exception) { GestionException.TraiterException(exception, "Gestion des produits"); } }
private void Cancel() { try { _isAjoutMode = false; txtLibelle.Text = string.Empty; btnAnnuler.Visible = false; _modeAffichage = forms.ModeAffichage.Browse; } catch (Exception exception) { GestionException.TraiterException(exception, "Gestion des produits"); } ModeAffichage(); }
private void Add() { _isAjoutMode = true; _produit = null; _modeAffichage = forms.ModeAffichage.Insert; ModeAffichage(); }