Exemplo n.º 1
0
        private void CmdModifier_Click(object sender, EventArgs e)
        {
            FrmDetailThemeFormation oFrmDetailThemeFormation;
            DialogResult            oResult;
            Theme oTheme;

            try
            {
                oTheme = (Theme)LstFormations.CurrentRow.DataBoundItem;

                if (oTheme != null)
                {
                    oFrmDetailThemeFormation = new FrmDetailThemeFormation(oTheme);
                    //oFrmDetailThemeFormation.TxtLibeller.Text = oTheme.Libelle;
                    oResult = oFrmDetailThemeFormation.ShowDialog();

                    if (oResult == DialogResult.OK)
                    {
                        oTheme.Libelle = oFrmDetailThemeFormation.TxtLibeller.Text;
                        this.ContexteDonnees.SaveChanges();

                        LstFormations.DataSource = this.ContexteDonnees.Theme.ToList();
                    }
                }
            }
            catch (Exception aEx)
            {
                MessageBox.Show(aEx.Message);
            }
        }
Exemplo n.º 2
0
        private void CmdAjouter_Click(object sender, EventArgs e)
        {
            FrmDetailThemeFormation oFrmDetailThemeFormation;
            DialogResult            oResult;
            Theme oTheme;

            try
            {
                oFrmDetailThemeFormation = new FrmDetailThemeFormation();
                oResult = oFrmDetailThemeFormation.ShowDialog();

                if (oResult == DialogResult.OK)
                {
                    oTheme = new Theme {
                        Libelle = oFrmDetailThemeFormation.TxtLibeller.Text
                    };

                    this.ContexteDonnees.Theme.Add(oTheme);
                    this.ContexteDonnees.SaveChanges();

                    LstFormations.DataSource = this.ContexteDonnees.Theme.ToList();
                }
            }
            catch (Exception aEx)
            {
                MessageBox.Show(aEx.Message);
            }
        }