1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
| using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DIAGOLY
{
public partial class FormFamille : Form
{
public FormFamille()
{
InitializeComponent();
}
private void txtRecherche_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
if(string.IsNullOrEmpty(txtRecherche.Text))
dataGridView.DataSource = familleProduitBindingSource;
else
{
var query= from o in this.appData.FamilleProduit
where o.Reffamille.Contains(txtRecherche.Text) || o.Nomfamille.Contains(txtRecherche.Text)
select o;
dataGridView.DataSource = query.ToList();
}
}
}
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
if (MessageBox.Show("Voulez Vous vraiment supprimer cette ligne ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
familleProduitBindingSource.RemoveCurrent();
}
}
private void btn_Nouveau_Click(object sender, EventArgs e)
{
try
{
panel.Enabled = true;
txtReffamille.Focus();
this.appData.FamilleProduit.AddFamilleProduitRow(this.appData.FamilleProduit.NewFamilleProduitRow());
familleProduitBindingSource.MoveLast();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
familleProduitBindingSource.ResetBindings(false);
}
}
private void btn_Modifier_Click(object sender, EventArgs e)
{
panel.Enabled = true;
txtReffamille.Focus();
}
private void btn_Annuler_Click(object sender, EventArgs e)
{
panel.Enabled = false;
familleProduitBindingSource.ResetBindings(false);
}
private void btn_Supprimer_Click(object sender, EventArgs e)
{
}
private void btn_Enregistrer_Click(object sender, EventArgs e)
{
try
{
familleProduitBindingSource.EndEdit();
familleProduitTableAdapter.Update(this.appData.FamilleProduit);
panel.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
familleProduitBindingSource.ResetBindings(false);
}
}
private void btn_Fermer_Click(object sender, EventArgs e)
{
this.Close();
}
private void FormFamille_Load(object sender, EventArgs e)
{
// TODO: cette ligne de code charge les données dans la table 'appData.FamilleProduit'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
this.familleProduitTableAdapter.Fill(this.appData.FamilleProduit);
using System;
}
}
} |
Partager